Pedegodgical example of all the things in an OpenNURBS 3dm archive. The openNURBS examples use ONX_Model to store the information read from 3dm archives. Please study example_read.cpp for details. More...

#include <opennurbs_extensions.h>

Public Member Functions

 ONX_Model ()
 
virtual ~ONX_Model ()
 
unsigned int ActiveAndDeletedComponentCount (ON_ModelComponent::Type component_type) const
 
unsigned int ActiveComponentCount (ON_ModelComponent::Type component_type) const
 
int AddDefaultDimensionStyle (const wchar_t *dimension_style_name, ON::LengthUnitSystem length_unit_system, double model_tolerance)
 Easy way to add a default dimension style to the model. More...
 
int AddDefaultLayer (const wchar_t *layer_name, ON_Color layer_color)
 Easy way to add a default layer to the model. Properties: layer_name - [in] can be nullptr or empty. layer_color - [in] can be ON_Color::UnsetColor More...
 
int AddLayer (const wchar_t *layer_name, ON_Color layer_color)
 Easy way to add a layer to the model. More...
 
ON_ModelComponentReference AddManagedModelComponent (class ON_ModelComponent *managed_model_component, bool bResolveIdAndNameConflicts)
 Add a managed model component (ON_Layer, ON_DimStyle, ...) to this model. More...
 
ON_ModelComponentReference AddManagedModelComponent (class ON_ModelComponent *managed_model_component)
 
ON_ModelComponentReference AddManagedModelGeometryComponent (class ON_Object *managed_geometry_object, class ON_3dmObjectAttributes *managed_attributes, bool bResolveIdAndNameConflicts)
 Add an copy of the model_geometry and attrbutes to this model. More...
 
ON_ModelComponentReference AddManagedModelGeometryComponent (class ON_Object *managed_geometry_object, class ON_3dmObjectAttributes *managed_attributes)
 
ON_ModelComponentReference AddModelComponent (const class ON_ModelComponent &model_component, bool bResolveIdAndNameConflicts)
 Add an copy of a model_compoent to this model. model_component - [in] A copy of model_component is added to this model. The index, id, and name of the copied component are set the the model values (Manifest() "Manifest" index, name, and id). More...
 
ON_ModelComponentReference AddModelComponent (const class ON_ModelComponent &model_component)
 
ON_ModelComponentReference AddModelComponentForExperts (class ON_ModelComponent *model_component, bool bManagedComponent, bool bResolveIdAndNameConflicts, bool bUpdateComponentIdentification)
 Add a model component to this model and control how the model_component instance is managed. More...
 
ON_ModelComponentReference AddModelGeometryComponent (const class ON_Object *geometry_object, const class ON_3dmObjectAttributes *attributes, bool bResolveIdAndNameConflicts)
 Add an copy of the model_geometry and attrbutes to this model. More...
 
ON_ModelComponentReference AddModelGeometryComponent (const class ON_Object *geometry_object, const class ON_3dmObjectAttributes *attributes)
 
ON_ModelComponentReference AddModelGeometryComponentForExperts (bool bManageGeometry, class ON_Object *geometry_object, bool bManageAttributes, class ON_3dmObjectAttributes *attributes, bool bResolveIdAndNameConflicts)
 Add geometry and attibutes to this model and control how the instances are managed. More...
 
ON_ModelComponentReference ComponentFromId (ON_ModelComponent::Type component_type, ON_UUID component_model_id) const
 
ON_ModelComponentReference ComponentFromIndex (ON_ModelComponent::Type component_type, int component_model_index) const
 
ON_ModelComponentReference ComponentFromName (ON_ModelComponent::Type component_type, ON_UUID component_parent_id, const wchar_t *component_model_name) const
 
ON_ModelComponentReference ComponentFromNameHash (ON_ModelComponent::Type component_type, const ON_NameHash &component_model_name_hash) const
 
ON_ModelComponentReference ComponentFromUnsignedIndex (ON_ModelComponent::Type component_type, unsigned int component_model_index) const
 
unsigned int ComponentIndexLimit (ON_ModelComponent::Type component_type) const
 
ON_SHA1_Hash ContentHash () const
 
ON_ModelComponentReference CurrentDimensionStyle () const
 
ON_UUID CurrentDimensionStyleId () const
 
ON_ModelComponentReference DefaultDimensionStyle () const
 
unsigned int DeletedComponentCount (ON_ModelComponent::Type component_type) const
 
ON_ModelComponentReference DimensionStyleFromId (ON_UUID dimension_styleid) const
 
ON_ModelComponentReference DimensionStyleFromIndex (int dimension_style_index) const
 Get a dimension style from its model index. More...
 
ON_ModelComponentReference DimensionStyleFromName (const wchar_t *dimension_style_name) const
 
ON_ModelComponentReference DimensionStyleFromNameHash (ON_NameHash dimension_style_name_hash) const
 
ON_ModelComponentReference DimensionStyleWithFontCharacteristics (const ON_Font &font_characteristics, double model_space_text_scale)
 Find or create a dimension style with the specified font characteristics. More...
 
void Dump (ON_TextLog &) const
 text dump of entire model More...
 
void DumpComponentList (ON_ModelComponent::Type component_type, ON_TextLog &text_log) const
 
void DumpComponentLists (ON_TextLog &text_log) const
 
void DumpSummary (ON_TextLog &) const
 text dump of model properties and settings More...
 
void DumpUserDataTable (ON_TextLog &) const
 text dump of user data table More...
 
ON_ModelComponentReference FirstDimensionStyleFromFont (const ON_Font *font, double model_space_text_scale, bool bIgnoreSystemDimStyles) const
 
ON_ModelComponentReference FirstDimensionStyleFromManagedFontSerialNumber (unsigned int managed_font_serial_number, double model_space_text_scale, bool bIgnoreSystemDimStyles) const
 
bool GetDocumentUserString (const wchar_t *key, ON_wString &string_value) const
 Get user string from the document. More...
 
int GetDocumentUserStrings (ON_ClassArray< ON_UserString > &user_strings) const
 Get a list of all user strings in the document. More...
 
ON_ModelComponentReference ImageFromFileContent (const ON_ContentHash &image_file_content_hash) const
 
ON_ModelComponentReference ImageFromFileFullPath (const wchar_t *image_file_full_path_name) const
 
ON_ModelComponentReference ImageFromFileReference (const ON_FileReference &file_reference) const
 
ON_ModelComponentReference ImageFromId (ON_UUID image_id) const
 
ON_ModelComponentReference ImageFromIndex (int image_model_index) const
 Get an image from its model index. More...
 
bool IncrementalReadBegin (ON_BinaryArchive &archive, bool bManageComponents, unsigned int table_filter, ON_TextLog *error_log)
 Reads everything up to the object table. More...
 
bool IncrementalReadFinish (ON_BinaryArchive &archive, bool bManageComponents, unsigned int table_filter, ON_TextLog *error_log)
 Reads everything up to the object table. More...
 
bool IncrementalReadModelGeometry (ON_BinaryArchive &archive, bool bManageModelGeometryComponent, bool bManageGeometry, bool bManageAttributes, unsigned int model_object_type_filter, ON_ModelComponentReference &model_geometry_reference)
 Reads the next item in the model geometry table. More...
 
ON_ModelComponentReference LayerFromAttributes (const ON_3dmObjectAttributes &attributes) const
 
ON_ModelComponentReference LayerFromId (ON_UUID layer_model_id) const
 
ON_ModelComponentReference LayerFromIndex (int layer_model_index) const
 Get a layer from its model index. More...
 
ON_ModelComponentReference LayerFromName (ON_UUID layer_parent_id, const wchar_t *layer_name) const
 
ON_ModelComponentReference LayerFromNameHash (const ON_NameHash &layer_model_name_hash) const
 
ON_ModelComponentReference LinePatternFromAttributes (const ON_3dmObjectAttributes &attributes) const
 Get linetype from object attributes. More...
 
ON_ModelComponentReference LinePatternFromId (ON_UUID line_pattern_model_id) const
 
ON_ModelComponentReference LinePatternFromIndex (int line_pattern_model_index) const
 Get a line pattern from its model index. More...
 
ON_ModelComponentReference LinePatternFromLayerIndex (int layer_index) const
 
ON_ModelComponentReference LinePatternFromName (const wchar_t *line_pattern_name) const
 
ON_ModelComponentReference LinePatternFromNameHash (ON_NameHash line_pattern_model_name_hash) const
 
const ON_ComponentManifestManifest () const
 A manifest of every model component in this ONX_Model. More...
 
ON__UINT64 ModelContentVersionNumber () const
 This number changes every time the content of the ONX_Model is modified. More...
 
ON_BoundingBox ModelGeometryBoundingBox () const
 
ON_ModelGeometryComponent ModelGeometryFromId (unsigned int model_object_index)
 
ON_ModelGeometryComponent ModelGeometryFromIndex (int model_object_index)
 
ON_ModelGeometryComponent ModelGeometryFromUnsignedIndex (unsigned int model_object_index)
 
const ON_ManifestMapModelToOriginalMap () const
 
const ON_ManifestMapOriginalToModelMap () const
 
bool Read (ON_BinaryArchive &archive, unsigned int table_filter, unsigned int model_object_type_filter, ON_TextLog *error_log)
 Reads an openNURBS archive and saves the information in this model More...
 
bool Read (const char *filename, unsigned int table_filter, unsigned int model_object_type_filter, ON_TextLog *error_log)
 
bool Read (const wchar_t *filename, unsigned int table_filter, unsigned int model_object_type_filter, ON_TextLog *error_log)
 
bool Read (ON_BinaryArchive &archive, ON_TextLog *error_log=nullptr)
 
bool Read (const char *filename, ON_TextLog *error_log=nullptr)
 
bool Read (const wchar_t *filename, ON_TextLog *error_log=nullptr)
 
ON_ModelComponentReference RemoveModelComponent (ON_ModelComponent::Type component_type, ON_UUID component_id)
 
ON_BoundingBox RenderLightBoundingBox () const
 
ON_ModelComponentReference RenderMaterialFromAttributes (const ON_3dmObjectAttributes &attributes) const
 
ON_ModelComponentReference RenderMaterialFromId (ON_UUID render_material_id) const
 
ON_ModelComponentReference RenderMaterialFromIndex (int render_material_index) const
 
ON_ModelComponentReference RenderMaterialFromLayerIndex (int layer_index) const
 Get render material from object attributes. More...
 
void Reset ()
 
bool SetCurrentDimensionStyleId (ON_UUID dimension_style_id)
 
bool SetDocumentUserString (const wchar_t *key, const wchar_t *string_value)
 Attach a user string to the document. More...
 
int UsesIDef (const ON_InstanceRef &iref, ON_UUID idef_uuid) const
 See if the instance reference iref refers to an instance definition. More...
 
bool ValdateComponentIdAndName (ON_ModelComponent::Type component_type, const ON_UUID &candidate_id, const ON_UUID &component_parent_id, const wchar_t *candidate_name, bool bResolveIdConflict, bool bResolveNameConflict, ON_UUID &model_id, ON_wString &model_name) const
 
ON_Color WireframeColorFromAttributes (const ON_3dmObjectAttributes &attributes) const
 Get wireframe drawing color from object attributes. More...
 
bool Write (const char *filename, int version=0, ON_TextLog *error_log=nullptr) const
 Writes contents of this model to an openNURBS archive. More...
 
bool Write (const wchar_t *filename, int version=0, ON_TextLog *error_log=nullptr) const
 Writes contents of this model to an openNURBS archive. More...
 
bool Write (ON_BinaryArchive &archive, int version=0, ON_TextLog *error_log=nullptr) const
 Writes contents of this model to an openNURBS archive. More...
 

Static Public Member Functions

static bool GetRDKDocumentInformation (const ONX_Model_UserData &docud, ON_wString &rdk_xml_document_data)
 
static bool GetRDKObjectInformation (const ON_Object &object, ON_wString &rdk_xml_object_data)
 
static bool IsRDKDocumentInformation (const ONX_Model_UserData &docud)
 
static bool IsRDKObjectInformation (const ON_UserData &objectud)
 

Public Attributes

ON__UINT64 m_3dm_file_byte_count = 0
 
int m_3dm_file_version = 0
 3dm archive start section information More...
 
unsigned int m_3dm_opennurbs_version = 0
 
ON_3dmProperties m_properties
 
ON_3dmSettings m_settings
 
ON_String m_sStartSectionComments
 
ON_SimpleArray< ONX_Model_UserData * > m_userdata_table
 

Friends

class ONX_ModelComponentIterator
 

Detailed Description

Pedegodgical example of all the things in an OpenNURBS 3dm archive. The openNURBS examples use ONX_Model to store the information read from 3dm archives. Please study example_read.cpp for details.

Constructor & Destructor Documentation

◆ ONX_Model()

ONX_Model::ONX_Model ( )

◆ ~ONX_Model()

virtual ONX_Model::~ONX_Model ( )
virtual

Member Function Documentation

◆ ActiveAndDeletedComponentCount()

unsigned int ONX_Model::ActiveAndDeletedComponentCount ( ON_ModelComponent::Type  component_type) const
Returns
Number of active and deleted components. Count does not include system components.

◆ ActiveComponentCount()

unsigned int ONX_Model::ActiveComponentCount ( ON_ModelComponent::Type  component_type) const
Returns
Number of active components. Count does not include system components.

◆ AddDefaultDimensionStyle()

int ONX_Model::AddDefaultDimensionStyle ( const wchar_t *  dimension_style_name,
ON::LengthUnitSystem  length_unit_system,
double  model_tolerance 
)

Easy way to add a default dimension style to the model.

Parameters
dimension_style_name[in] can be nullptr or empty
length_unit_system[in] If ON::LengthUnitSystem::Unset, then settings length unit system is used.
tolerance[in] If not > 0, then settings tolerance is used.
Returns
The default dimension style's index (>=0) is returned.

◆ AddDefaultLayer()

int ONX_Model::AddDefaultLayer ( const wchar_t *  layer_name,
ON_Color  layer_color 
)

Easy way to add a default layer to the model. Properties: layer_name - [in] can be nullptr or empty. layer_color - [in] can be ON_Color::UnsetColor

Returns
The default layer's index (>=0) is returned.

◆ AddLayer()

int ONX_Model::AddLayer ( const wchar_t *  layer_name,
ON_Color  layer_color 
)

Easy way to add a layer to the model.

Returns
If layer_name is valid, the layer's index (>=0) is returned. Otherwise, ON_UNSET_INT_INDEX is returned.

◆ AddManagedModelComponent() [1/2]

ON_ModelComponentReference ONX_Model::AddManagedModelComponent ( class ON_ModelComponent managed_model_component,
bool  bResolveIdAndNameConflicts 
)

Add a managed model component (ON_Layer, ON_DimStyle, ...) to this model.

managed_model_component - [in] managed_model_component must be created by operator new and on the heap. It will be deleted when the model and last ON_ModelComponentReference are destroyed.

bResolveIdAndNameConflicts - [in] If bResolveIdAndNameConflicts is false, then model_component.Id() must be non-nil and not used in this model and model_component.Name() must be correctly set. If bResolveIdAndNameConflicts is true, then id and name will be modified as needed in managed_model_component, the model, and the manifest.

Returns
A reference to the added model component. If the reference is empty (ON_ModelComponent::IsEmpty() is true) then the input was not valid.

◆ AddManagedModelComponent() [2/2]

ON_ModelComponentReference ONX_Model::AddManagedModelComponent ( class ON_ModelComponent managed_model_component)

◆ AddManagedModelGeometryComponent() [1/2]

ON_ModelComponentReference ONX_Model::AddManagedModelGeometryComponent ( class ON_Object managed_geometry_object,
class ON_3dmObjectAttributes managed_attributes,
bool  bResolveIdAndNameConflicts 
)

Add an copy of the model_geometry and attrbutes to this model.

Parameters
managed_geometry_object[in] managed_geometry_object must point to an instance geometric object (curve, surface, brep, mesh, points, ...), a render light, an annotation object, or a detail object created by operator new and on the heap. It will be deleted when the this ONX_Model and the last ON_ModelComponentReference are destroyed.
managed_attributes[in] managed_attributes should be nullptr or point to an instance created by operator new and on the heap. It will be deleted when the this ONX_Model and the last ON_ModelComponentReference are destroyed.
bResolveIdAndNameConflicts[in] If bResolveIdAndNameConflicts is false, then managed_attributes must be nullptr or managed_attributes->m_uuid must be non-nil and not used in this model. If bResolveIdAndNameConflicts is true, then id will be modified as needed.
Returns
A reference to the added model component. If the reference is empty (ON_ModelComponent::IsEmpty() is true) then the input was not valid.

◆ AddManagedModelGeometryComponent() [2/2]

ON_ModelComponentReference ONX_Model::AddManagedModelGeometryComponent ( class ON_Object managed_geometry_object,
class ON_3dmObjectAttributes managed_attributes 
)

◆ AddModelComponent() [1/2]

ON_ModelComponentReference ONX_Model::AddModelComponent ( const class ON_ModelComponent model_component,
bool  bResolveIdAndNameConflicts 
)

Add an copy of a model_compoent to this model. model_component - [in] A copy of model_component is added to this model. The index, id, and name of the copied component are set the the model values (Manifest() "Manifest" index, name, and id).

bResolveIdAndNameConflicts - [in] If bResolveIdAndNameConflicts is false, then model_component.Id() must be non-nil and not used in this model and model_component.Name() must be correctly set. If bResolveIdAndNameConflicts is true, then id and name will be modified as needed in the model and manifest.

Returns
A reference to the added model component. If the reference is empty (ON_ModelComponent::IsEmpty() is true) then the input was not valid.

◆ AddModelComponent() [2/2]

ON_ModelComponentReference ONX_Model::AddModelComponent ( const class ON_ModelComponent model_component)

◆ AddModelComponentForExperts()

ON_ModelComponentReference ONX_Model::AddModelComponentForExperts ( class ON_ModelComponent model_component,
bool  bManagedComponent,
bool  bResolveIdAndNameConflicts,
bool  bUpdateComponentIdentification 
)

Add a model component to this model and control how the model_component instance is managed.

model_component - [in] An ON_ModelComponent created on the heap by calling new X where X is derived from ON_ModelComponent.

bManagedComponent - [in] If bManagedComponent is true, then ~ONX_Model will delete the component. If bManagedComponent is false, then you are responsible for insuring the component exists past the desctruction of this ONX_Model.

bResolveIdAndNameConflicts - [in] If bResolveIdAndNameConflicts is false, then model_component.Id() must be non-nil and not used in this model and model_component.Name() must be correctly set. If bResolveIdAndNameConflicts is true, then id and name will be modified as needed.

bUpdateComponentIdentification - [in] The model_component Index(), Id(), and Name() values are set to match the ones used in the model (Manifest() "Manifest" values.)

Returns
A reference to the added model component. If the reference is empty (ON_ModelComponentReference::IsEmpty() is true), then the input was not valid and the model component was not added.

◆ AddModelGeometryComponent() [1/2]

ON_ModelComponentReference ONX_Model::AddModelGeometryComponent ( const class ON_Object geometry_object,
const class ON_3dmObjectAttributes attributes,
bool  bResolveIdAndNameConflicts 
)

Add an copy of the model_geometry and attrbutes to this model.

Parameters
geometry_object[in] geometry_object must point to a geometric object (curve, surface, brep, mesh, points, ...), a render light, an annotation object, or a detail object. A copy of geometry_object is added to and managed by this model.
attributes[in] nullptr if not available. A copy of attributes is added to and managed by this model.
bResolveIdAndNameConflicts[in] If bResolveIdAndNameConflicts is false, then attributes must be nullptr or attributes->m_uid must be non-nil and not used in this model. If bResolveIdAndNameConflicts is true, then id will be modified as needed.
Returns
A reference to the added model component. If the reference is empty (ON_ModelComponent::IsEmpty() is true) then the input was not valid.

◆ AddModelGeometryComponent() [2/2]

ON_ModelComponentReference ONX_Model::AddModelGeometryComponent ( const class ON_Object geometry_object,
const class ON_3dmObjectAttributes attributes 
)

◆ AddModelGeometryComponentForExperts()

ON_ModelComponentReference ONX_Model::AddModelGeometryComponentForExperts ( bool  bManageGeometry,
class ON_Object geometry_object,
bool  bManageAttributes,
class ON_3dmObjectAttributes attributes,
bool  bResolveIdAndNameConflicts 
)

Add geometry and attibutes to this model and control how the instances are managed.

Parameters
bManageGeometry[in] If true, geometry_object should point to an instance created by operator new and on the heap. It will be deleted when the this ONX_Model and the last ON_ModelComponentReference are destroyed. If false, the expert caller is carefully managing the instance and memory to insure model_geometry is a valid instance while this ONX_Model and any ON_ModelComponentReference are active.
geometry_object[in] geometry_object should point to a geometric object (curve, surface, brep, mesh, points, ...), a render light, an annotation object, or a detail object.
bManageAttributes[in] If true, attributes should be nullptr or point to an instance created by operator new and on the heap. It will be deleted when the this ONX_Model and the last ON_ModelComponentReference are destroyed. If false, the expert caller is carefully managing the instance and memory to insure attributes is a valid instance while this ONX_Model and and ON_ModelComponentReference are active.
attributes[in] nullptr if not avaiable.
bResolveIdAndNameConflicts[in] If bResolveIdAndNameConflicts is false, then attributes must be nullptr or attributes->m_uid must be non-nil and not used in this model. If bResolveIdAndNameConflicts is true, then id will be modified as needed.
Returns
A reference to the added model component. If the reference is empty (ON_ModelComponent::IsEmpty() is true) then the input was not valid.

◆ ComponentFromId()

ON_ModelComponentReference ONX_Model::ComponentFromId ( ON_ModelComponent::Type  component_type,
ON_UUID  component_model_id 
) const

◆ ComponentFromIndex()

ON_ModelComponentReference ONX_Model::ComponentFromIndex ( ON_ModelComponent::Type  component_type,
int  component_model_index 
) const

◆ ComponentFromName()

ON_ModelComponentReference ONX_Model::ComponentFromName ( ON_ModelComponent::Type  component_type,
ON_UUID  component_parent_id,
const wchar_t *  component_model_name 
) const

◆ ComponentFromNameHash()

ON_ModelComponentReference ONX_Model::ComponentFromNameHash ( ON_ModelComponent::Type  component_type,
const ON_NameHash component_model_name_hash 
) const

◆ ComponentFromUnsignedIndex()

ON_ModelComponentReference ONX_Model::ComponentFromUnsignedIndex ( ON_ModelComponent::Type  component_type,
unsigned int  component_model_index 
) const

◆ ComponentIndexLimit()

unsigned int ONX_Model::ComponentIndexLimit ( ON_ModelComponent::Type  component_type) const

◆ ContentHash()

ON_SHA1_Hash ONX_Model::ContentHash ( ) const
Returns
A SHA-1 hash of the model's content. If two models have identical content, then the have equal ContentHash() values.

◆ CurrentDimensionStyle()

ON_ModelComponentReference ONX_Model::CurrentDimensionStyle ( ) const
Returns
Current dimension style = DimensionStyleFromId(CurrentDimensionStyleId())

◆ CurrentDimensionStyleId()

ON_UUID ONX_Model::CurrentDimensionStyleId ( ) const
Returns
Id of the current dimension style or nil if the current style is not set or not in this model.

◆ DefaultDimensionStyle()

ON_ModelComponentReference ONX_Model::DefaultDimensionStyle ( ) const
Returns
A system dimension style that is the default for this model and is used when a referenced dimension style is missing from this model.

◆ DeletedComponentCount()

unsigned int ONX_Model::DeletedComponentCount ( ON_ModelComponent::Type  component_type) const
Returns
Number of deleted components.

◆ DimensionStyleFromId()

ON_ModelComponentReference ONX_Model::DimensionStyleFromId ( ON_UUID  dimension_styleid) const

◆ DimensionStyleFromIndex()

ON_ModelComponentReference ONX_Model::DimensionStyleFromIndex ( int  dimension_style_index) const

Get a dimension style from its model index.

Parameters
dimension_style_model_index[in]
Returns
An ON_ModelComponentReference to the dimension style.

Model index and Manifest() manifest item index are the same.

◆ DimensionStyleFromName()

ON_ModelComponentReference ONX_Model::DimensionStyleFromName ( const wchar_t *  dimension_style_name) const

◆ DimensionStyleFromNameHash()

ON_ModelComponentReference ONX_Model::DimensionStyleFromNameHash ( ON_NameHash  dimension_style_name_hash) const

◆ DimensionStyleWithFontCharacteristics()

ON_ModelComponentReference ONX_Model::DimensionStyleWithFontCharacteristics ( const ON_Font font_characteristics,
double  model_space_text_scale 
)

Find or create a dimension style with the specified font characteristics.

◆ Dump()

void ONX_Model::Dump ( ON_TextLog ) const

text dump of entire model

◆ DumpComponentList()

void ONX_Model::DumpComponentList ( ON_ModelComponent::Type  component_type,
ON_TextLog text_log 
) const

◆ DumpComponentLists()

void ONX_Model::DumpComponentLists ( ON_TextLog text_log) const
Returns
A text dump of all component lists.

◆ DumpSummary()

void ONX_Model::DumpSummary ( ON_TextLog ) const

text dump of model properties and settings

◆ DumpUserDataTable()

void ONX_Model::DumpUserDataTable ( ON_TextLog ) const

text dump of user data table

◆ FirstDimensionStyleFromFont()

ON_ModelComponentReference ONX_Model::FirstDimensionStyleFromFont ( const ON_Font font,
double  model_space_text_scale,
bool  bIgnoreSystemDimStyles 
) const
Parameters
font[in]
model_space_text_scale[in] If model_space_text_scale > 0, then the DimScale() must be equal to model_space_text_scale.
bIgnoreSystemDimStyles[in]
Returns
The first dimension style with the specified font.

dimension styles with a non-nil parent id are ignored.

◆ FirstDimensionStyleFromManagedFontSerialNumber()

ON_ModelComponentReference ONX_Model::FirstDimensionStyleFromManagedFontSerialNumber ( unsigned int  managed_font_serial_number,
double  model_space_text_scale,
bool  bIgnoreSystemDimStyles 
) const
Parameters
managed_font_serial_number[in]
model_space_text_scale[in] If model_space_text_scale > 0, then the DimScale() must be equal to model_space_text_scale.
bIgnoreSystemDimStyles[in]
Returns
The first dimension style with the specified font.

dimension styles with a non-nil parent id are ignored.

◆ GetDocumentUserString()

bool ONX_Model::GetDocumentUserString ( const wchar_t *  key,
ON_wString string_value 
) const

Get user string from the document.

Parameters
key[in] id used to retrieve the string.
string_value[out]
Returns
True if a string with id was found.

◆ GetDocumentUserStrings()

int ONX_Model::GetDocumentUserStrings ( ON_ClassArray< ON_UserString > &  user_strings) const

Get a list of all user strings in the document.

Parameters
user_strings[out] user strings are appended to this list.
Returns
Number of elements appended to the user_strings list.

◆ GetRDKDocumentInformation()

static bool ONX_Model::GetRDKDocumentInformation ( const ONX_Model_UserData docud,
ON_wString rdk_xml_document_data 
)
static

◆ GetRDKObjectInformation()

static bool ONX_Model::GetRDKObjectInformation ( const ON_Object object,
ON_wString rdk_xml_object_data 
)
static

◆ ImageFromFileContent()

ON_ModelComponentReference ONX_Model::ImageFromFileContent ( const ON_ContentHash image_file_content_hash) const

◆ ImageFromFileFullPath()

ON_ModelComponentReference ONX_Model::ImageFromFileFullPath ( const wchar_t *  image_file_full_path_name) const

◆ ImageFromFileReference()

ON_ModelComponentReference ONX_Model::ImageFromFileReference ( const ON_FileReference file_reference) const

◆ ImageFromId()

ON_ModelComponentReference ONX_Model::ImageFromId ( ON_UUID  image_id) const

◆ ImageFromIndex()

ON_ModelComponentReference ONX_Model::ImageFromIndex ( int  image_model_index) const

Get an image from its model index.

Parameters
image_model_index[in]
Returns
An ON_ModelComponentReference to the image.

Model index and Manifest() manifest item index are the same.

◆ IncrementalReadBegin()

bool ONX_Model::IncrementalReadBegin ( ON_BinaryArchive archive,
bool  bManageComponents,
unsigned int  table_filter,
ON_TextLog error_log 
)

Reads everything up to the object table.

Parameters
archive[in] archive to read from
bManageComponents[in] true: The ONX_Model destructor will delete the model components created by this function. false: The caller must delete the ON_ModelComponent components after the ONX_Model is destroyed.
table_filter[in] If table_filter is zero, then everything in the archive before the model object table is read. Otherwise the bits in table_filter identify what tables should be read. The bits are defined by the ON_BInaryArchive::table_type enum.
error_log[out] any archive reading errors are logged here. pass nullptr if you don't want to log errors
Returns

If the input is valid and everything before the model object table is successfully read, then true is returned. Otherwise false is returned.

@verbatim
// for ASCII file names
const char* sFileName = ....;
FILE* fp = ON::OpenFile( sFileName, "rb");
// for UNICODE file names
const wchar_t* wsFileName = ....;
FILE* fp = ON::OpenFile( wsFileName, L"rb");
bool bModelRead = false;
bool bModelIsValid = false;
ON_TextLog error_log;
if ( 0 != fp )
{
ON_BinaryFile archive( ON::archive_mode::read3dm, fp );
ONX_Model model;
// Read settings, layer information, and other tables
// with information that is referenced by model object
// attributes.
bModelRead = model.IncrementalReadBegin( archive, error_log );
if ( bModelRead )
{
object_filter = ON::mesh_object // read meshes
| ON::curve_object // and curves
;
for(;;)
{
// read the next model object
ON_ModelGeometryComponent* pModelObject = model.IncrementalReadModelObject(object_filter,0);
if ( 0 == pModelObject )
break;
... // work with this model object
// done with this object.
pModelObject = 0;
model.m_object_table.Remove();
}
}
ON::CloseFile( fp );
}
@endverbatim
See also
ONX_Model::IsValid, ONX_Model::Write, ONX_Model::m_crc_error_count

◆ IncrementalReadFinish()

bool ONX_Model::IncrementalReadFinish ( ON_BinaryArchive archive,
bool  bManageComponents,
unsigned int  table_filter,
ON_TextLog error_log 
)

Reads everything up to the object table.

Parameters
archive[in] archive to read from
bManageComponents[in] true: The ONX_Model destructor will delete the model components created by this function. false: The caller must delete the ON_ModelComponent components after the ONX_Model is destroyed.
table_filter[in] If table_filter is zero, then everything in the archive before the model object table is read. Otherwise the bits in table_filter identify what tables should be read. The bits are defined by the ON_BInaryArchive::table_type enum.
error_log[out] any archive reading errors are logged here. pass nullptr if you don't want to log errors
Returns

If the input is valid and everything before the model object table is successfully read, then true is returned. Otherwise false is returned.

See also
ONX_Model::IsValid, ONX_Model::Write, ONX_Model::m_crc_error_count

◆ IncrementalReadModelGeometry()

bool ONX_Model::IncrementalReadModelGeometry ( ON_BinaryArchive archive,
bool  bManageModelGeometryComponent,
bool  bManageGeometry,
bool  bManageAttributes,
unsigned int  model_object_type_filter,
ON_ModelComponentReference model_geometry_reference 
)

Reads the next item in the model geometry table.

Parameters
archive[in]
bManageModelGeometryComponent[in] true: The ONX_Model destructor will delete the ON_ModelGeometryComponent components created by this function. false: The caller must delete the ON_ModelGeometryComponent components after the ONX_Model is destroyed.
bManageGeometry[in] true: The ON_ModelGeometryComponent destructor will delete the ON_Geometry classes created by this function. false: The caller must delete the ON_Geometry classes after the ONX_Model and ON_ModelGeometryComponent components are destroyed.
bManageAttributes[in] true: The ON_ModelGeometryComponent destructor will delete the ON_3dmObjectAttributes classes created by this function. false: The caller must delete the ON_3dmObjectAttributes classes after the ONX_Model and ON_ModelGeometryComponent components are destroyed.
model_object_type_filter[in] If model_object_type_filter is not zero, then it is a bitfield filter made by bitwise oring ON::object_type values to select which types of objects will be read from the model object table.
model_geometry_reference[out] A reference to an ON_ModelGeometryComponent. This referenced ON_ModelGeometryComponent component is also added to the ONX_Model. Call ONX_Model.RemoveComponent() if you want to discard it before continuing.
Returns
True Succesful. If model_geometry_reference.IsEmpty() is true, then no more geometry objects are available and you should call IncrementalReadFinish(). False An error occured and reading should terminate.

You must call IncrementalReadBegin() before making any calls to IncrementalReadModelObject().

◆ IsRDKDocumentInformation()

static bool ONX_Model::IsRDKDocumentInformation ( const ONX_Model_UserData docud)
static

◆ IsRDKObjectInformation()

static bool ONX_Model::IsRDKObjectInformation ( const ON_UserData objectud)
static

◆ LayerFromAttributes()

ON_ModelComponentReference ONX_Model::LayerFromAttributes ( const ON_3dmObjectAttributes attributes) const

◆ LayerFromId()

ON_ModelComponentReference ONX_Model::LayerFromId ( ON_UUID  layer_model_id) const

◆ LayerFromIndex()

ON_ModelComponentReference ONX_Model::LayerFromIndex ( int  layer_model_index) const

Get a layer from its model index.

Parameters
layer_model_index[in]
Returns
An ON_ModelComponentReference to the layer.

Model index and Manifest() manifest item index are the same.

◆ LayerFromName()

ON_ModelComponentReference ONX_Model::LayerFromName ( ON_UUID  layer_parent_id,
const wchar_t *  layer_name 
) const

◆ LayerFromNameHash()

ON_ModelComponentReference ONX_Model::LayerFromNameHash ( const ON_NameHash layer_model_name_hash) const

◆ LinePatternFromAttributes()

ON_ModelComponentReference ONX_Model::LinePatternFromAttributes ( const ON_3dmObjectAttributes attributes) const

Get linetype from object attributes.

Parameters
attributes[in] object attributes.
line_pattern[out] linetype

◆ LinePatternFromId()

ON_ModelComponentReference ONX_Model::LinePatternFromId ( ON_UUID  line_pattern_model_id) const

◆ LinePatternFromIndex()

ON_ModelComponentReference ONX_Model::LinePatternFromIndex ( int  line_pattern_model_index) const

Get a line pattern from its model index.

Parameters
line_pattern_model_index[in]
Returns
An ON_ModelComponentReference to the line pattern.

Model index and Manifest() manifest item index are the same.

◆ LinePatternFromLayerIndex()

ON_ModelComponentReference ONX_Model::LinePatternFromLayerIndex ( int  layer_index) const

◆ LinePatternFromName()

ON_ModelComponentReference ONX_Model::LinePatternFromName ( const wchar_t *  line_pattern_name) const

◆ LinePatternFromNameHash()

ON_ModelComponentReference ONX_Model::LinePatternFromNameHash ( ON_NameHash  line_pattern_model_name_hash) const

◆ Manifest()

const ON_ComponentManifest& ONX_Model::Manifest ( ) const

A manifest of every model component in this ONX_Model.

Use the manifest to find model objects from a name, id or index.

The manifest Id, Name, and Index values are values used in the model. These are assigned when a component is added to the ONX_Model. When possible the id and name are not changed.

The manifest=model and original component values are different when:

  • The original component Id or Name was not set and a value was automatically assigned.
  • The original component Id or Name was not unique and was modified when the component was added to the model.
  • Generally the original component index differs from the manifest=model component index.

The OriginalToModelMap() can be used to convert original component index and id to the manifest=model index and id.

The ModelToOriginalMap() can be used to manifest=model index and id to the original component index and id.

◆ ModelContentVersionNumber()

ON__UINT64 ONX_Model::ModelContentVersionNumber ( ) const

This number changes every time the content of the ONX_Model is modified.

◆ ModelGeometryBoundingBox()

ON_BoundingBox ONX_Model::ModelGeometryBoundingBox ( ) const
Returns
Bounding box of every object in m_object_table[].

◆ ModelGeometryFromId()

ON_ModelGeometryComponent ONX_Model::ModelGeometryFromId ( unsigned int  model_object_index)

◆ ModelGeometryFromIndex()

ON_ModelGeometryComponent ONX_Model::ModelGeometryFromIndex ( int  model_object_index)

◆ ModelGeometryFromUnsignedIndex()

ON_ModelGeometryComponent ONX_Model::ModelGeometryFromUnsignedIndex ( unsigned int  model_object_index)

◆ ModelToOriginalMap()

const ON_ManifestMap& ONX_Model::ModelToOriginalMap ( ) const
Returns
A map from manifest=model index and id to original component index and id.

ON_ManifestMapItem Source = model-manifest index and id. ON_ManifestMapItem Destination = original component index and id.

◆ OriginalToModelMap()

const ON_ManifestMap& ONX_Model::OriginalToModelMap ( ) const
Returns
A map from original component index and id to manifest=model index and id.

ON_ManifestMapItem Source = original component index and id. ON_ManifestMapItem Destination = model-manifest index and id.

◆ Read() [1/6]

bool ONX_Model::Read ( ON_BinaryArchive archive,
unsigned int  table_filter,
unsigned int  model_object_type_filter,
ON_TextLog error_log 
)

Reads an openNURBS archive and saves the information in this model

Parameters
archive[in] archive to read from
table_filter[in] If table_filter is zero, then everything in the archive is read. Otherwise the bits in table_filter identify what tables should be read. The bits are defined by the ON_BInaryArchive::table_type enum.
model_object_type_filter[in] If model_object_type_filter is not zero, then it is a bitfield filter made by bitwise oring ON::object_type values to select which types of objects will be read from the model object table.
error_log[out] any archive reading errors are logged here.
Returns
true if archive is read with no error. False if errors occur. Error details are logged in error_log. If crc errors are in the archive, then ONX_Model::m_crc_error_count is set to the number of crc errors.
@verbatim
// for ASCII file names
const char* sFileName = ....;
FILE* fp = ON::OpenFile( sFileName, "rb");
// for UNICODE file names
const wchar_t* wsFileName = ....;
FILE* fp = ON::OpenFile( wsFileName, L"rb");
bool bModelRead = false;
bool bModelIsValid = false;
ON_TextLog error_log;
ONX_Model model;
if ( 0 != fp )
{
ON_BinaryFile archive( ON::archive_mode::read3dm, fp );
bModelRead = model.Read( archive, error_log );
ON::CloseFile( fp );
}
if ( bModelRead )
{
bModelIsValid = model.Validate(error_log);
}
@endverbatim
See also
ONX_Model::IsValid, ONX_Model::Write, ONX_Model::m_crc_error_count

◆ Read() [2/6]

bool ONX_Model::Read ( const char *  filename,
unsigned int  table_filter,
unsigned int  model_object_type_filter,
ON_TextLog error_log 
)

◆ Read() [3/6]

bool ONX_Model::Read ( const wchar_t *  filename,
unsigned int  table_filter,
unsigned int  model_object_type_filter,
ON_TextLog error_log 
)

◆ Read() [4/6]

bool ONX_Model::Read ( ON_BinaryArchive archive,
ON_TextLog error_log = nullptr 
)

◆ Read() [5/6]

bool ONX_Model::Read ( const char *  filename,
ON_TextLog error_log = nullptr 
)

◆ Read() [6/6]

bool ONX_Model::Read ( const wchar_t *  filename,
ON_TextLog error_log = nullptr 
)

◆ RemoveModelComponent()

ON_ModelComponentReference ONX_Model::RemoveModelComponent ( ON_ModelComponent::Type  component_type,
ON_UUID  component_id 
)

◆ RenderLightBoundingBox()

ON_BoundingBox ONX_Model::RenderLightBoundingBox ( ) const
Returns
Bounding box of every render light in m_light_table[].

◆ RenderMaterialFromAttributes()

ON_ModelComponentReference ONX_Model::RenderMaterialFromAttributes ( const ON_3dmObjectAttributes attributes) const

◆ RenderMaterialFromId()

ON_ModelComponentReference ONX_Model::RenderMaterialFromId ( ON_UUID  render_material_id) const

◆ RenderMaterialFromIndex()

ON_ModelComponentReference ONX_Model::RenderMaterialFromIndex ( int  render_material_index) const

◆ RenderMaterialFromLayerIndex()

ON_ModelComponentReference ONX_Model::RenderMaterialFromLayerIndex ( int  layer_index) const

Get render material from object attributes.

Parameters
attributes[in] object attributes.
material[out] render material

◆ Reset()

void ONX_Model::Reset ( )

◆ SetCurrentDimensionStyleId()

bool ONX_Model::SetCurrentDimensionStyleId ( ON_UUID  dimension_style_id)
Parameters
dimension_style_id[in] Id of a dimension style in this model, a system dimension style, or ON_nil_uuid.
Returns
true if dimension_style_id is valid and is set.

◆ SetDocumentUserString()

bool ONX_Model::SetDocumentUserString ( const wchar_t *  key,
const wchar_t *  string_value 
)

Attach a user string to the document.

Parameters
key[in] id used to retrieve this string.
string_value[in] If nullptr, the string with this id will be removed.
Returns
True if successful.

◆ UsesIDef()

int ONX_Model::UsesIDef ( const ON_InstanceRef iref,
ON_UUID  idef_uuid 
) const

See if the instance reference iref refers to an instance definition.

Parameters
iref[in]
idef_uuid[in] id of idef we are looking for
Returns
table 0 iref does not use idef 1 iref directly references idef >1 iref has a nested reference to idef (nesting depth returned) -1 iref.m_instance_definition_uuid is not valid -2 invalid idef found

◆ ValdateComponentIdAndName()

bool ONX_Model::ValdateComponentIdAndName ( ON_ModelComponent::Type  component_type,
const ON_UUID candidate_id,
const ON_UUID component_parent_id,
const wchar_t *  candidate_name,
bool  bResolveIdConflict,
bool  bResolveNameConflict,
ON_UUID model_id,
ON_wString model_name 
) const

◆ WireframeColorFromAttributes()

ON_Color ONX_Model::WireframeColorFromAttributes ( const ON_3dmObjectAttributes attributes) const

Get wireframe drawing color from object attributes.

Parameters
attributes[in] object attributes.
Returns
Wireframe drawing color.

◆ Write() [1/3]

bool ONX_Model::Write ( const char *  filename,
int  version = 0,
ON_TextLog error_log = nullptr 
) const

Writes contents of this model to an openNURBS archive.

Parameters
filename[in]
version[in] Version of the openNURBS archive to write. 0 default value and suggested. When 0 is passed in, the value of ON_BinaryArchive::CurrentArchiveVersion() is used. 2, 3, 4, 50, 60, ... If you pass in a value < ON_BinaryArchive::CurrentArchiveVersion(), then some information in current data structures will not be saved in the 3dm archive. Rhino 2.x can read version 2 files. Rhino 3.x can read version 2 and 3 files. Rhino 4.x can read version 2, 3, and 4 files. Rhino 5.x can read version 2, 3, 4, 5, and 50 files. Rhino 6.x can read version 2, 3, 4, 5, 50, and 60 files.
error_log[out] any archive writing errors are logged here.
Returns
True if archive is written with no error. False if errors occur. Error details are logged in error_log.

◆ Write() [2/3]

bool ONX_Model::Write ( const wchar_t *  filename,
int  version = 0,
ON_TextLog error_log = nullptr 
) const

Writes contents of this model to an openNURBS archive.

Parameters
filename[in]
version[in] Version of the openNURBS archive to write. 0 default value and suggested. When 0 is passed in, the value of ON_BinaryArchive::CurrentArchiveVersion() is used. 2, 3, 4, 50, 60, ... If you pass in a value < ON_BinaryArchive::CurrentArchiveVersion(), then some information in current data structures will not be saved in the 3dm archive. Rhino 2.x can read version 2 files. Rhino 3.x can read version 2 and 3 files. Rhino 4.x can read version 2, 3, and 4 files. Rhino 5.x can read version 2, 3, 4, 5, and 50 files. Rhino 6.x can read version 2, 3, 4, 5, 50, and 60 files.
error_log[out] any archive writing errors are logged here.
Returns
True if archive is written with no error. False if errors occur. Error details are logged in error_log.

◆ Write() [3/3]

bool ONX_Model::Write ( ON_BinaryArchive archive,
int  version = 0,
ON_TextLog error_log = nullptr 
) const

Writes contents of this model to an openNURBS archive.

Parameters
archive[in] archive to write to You must call archive.SetArchiveFullPath(...) i order for file references to work correctly.
version[in] Version of the openNURBS archive to write. 0 default value and suggested. When 0 is passed in, the value of ON_BinaryArchive::CurrentArchiveVersion() is used. 2, 3, 4, 50, 60, ... If you pass in a value < ON_BinaryArchive::CurrentArchiveVersion(), then some information in current data structures will not be saved in the 3dm archive. Rhino 2.x can read version 2 files. Rhino 3.x can read version 2 and 3 files. Rhino 4.x can read version 2, 3, and 4 files. Rhino 5.x can read version 2, 3, 4, 5, and 50 files. Rhino 6.x can read version 2, 3, 4, 5, 50, and 60 files.
error_log[out] any archive writing errors are logged here.
Returns

True if archive is written with no error. False if errors occur. Error details are logged in error_log.

@verbatim
model = ...;
if ( model.IsValid( error_log ) )
{
const wchar_t* wsFileName = ....;
FILE* fp = ON::OpenFile( wsFileName, L"wb");
bool ok = false;
if ( 0 != fp )
{
const char* sStartSectionComment = "...";
int version = 5; // 2, 3, 4 or 5 are valid
ON_BinaryFile archive( ON::archive_mode::write3dm, fp );
archive.SetArchiveFullPath(wsFileName);
ok = model.write( archive,
version,
sStartSectionComment,
error_log );
ON::CloseFile( fp );
}
}
@endverbatim

Friends And Related Function Documentation

◆ ONX_ModelComponentIterator

friend class ONX_ModelComponentIterator
friend

Member Data Documentation

◆ m_3dm_file_byte_count

ON__UINT64 ONX_Model::m_3dm_file_byte_count = 0

◆ m_3dm_file_version

int ONX_Model::m_3dm_file_version = 0

3dm archive start section information

◆ m_3dm_opennurbs_version

unsigned int ONX_Model::m_3dm_opennurbs_version = 0

◆ m_properties

ON_3dmProperties ONX_Model::m_properties

◆ m_settings

ON_3dmSettings ONX_Model::m_settings

◆ m_sStartSectionComments

ON_String ONX_Model::m_sStartSectionComments

◆ m_userdata_table

ON_SimpleArray<ONX_Model_UserData*> ONX_Model::m_userdata_table