Provides CAD Exchanger data model. More...
Classes | |
class | CombinedElementVisitor |
Provides combined methods VisitEnter() and VisitLeave() to visit all elements. More... | |
class | ElementIterator |
Iterator over scene graph elements. More... | |
class | ElementVisitor |
Defines a visitor of the scene graph elements. More... | |
class | LayerVisitor |
Defines a visitor of the layers. More... | |
class | VoidElementVisitor |
Element visitor with empty implementation. More... | |
Public Types | |
enum | FileFormatType { Xml , Binary } |
Defines file format used to store model contents. More... | |
Public Member Functions | |
ModelData_Model (const Base_UTF16String &theName=Base_UTF16String()) | |
Constructor. | |
~ModelData_Model () | |
Destructor. | |
void | Merge (const ModelData_Model &theSrcModel, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) |
Adds all roots of another model to the current model. | |
void | SetName (const Base_UTF16String &theName) |
Sets a model name. | |
const Base_UTF16String & | Name () const |
Returns a model name. | |
bool | Open (const Base_UTF16String &theFileName, bool theToAppend=false, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) |
Loads the model object from the file. | |
bool | Save (const Base_UTF16String &theFileName, FileFormatType theFormat=Xml, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) const |
bool | Save (const Base_UTF16String &theFileName, const ModelData_WriterParameters &theParameters, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) const |
Saves the model object to a file. | |
void | Clear () |
Clears the model contents. | |
bool | IsEmpty () const |
Returns true if the model is empty. | |
void | AssignUuids () |
const ModelData_SceneGraphElement & | AddRoot (const ModelData_SceneGraphElement &theElement) |
Adds new root element into the scene graph. | |
bool | RemoveRoot (const ModelData_SceneGraphElement &theElement) |
Removes root scene graph element from the model. | |
size_t | NumberOfRoots () const |
Returns number of root elements in the graph. | |
void | SetDrawing (const ModelData_Drawing &theDrawing) |
Sets the drawing of the model. | |
ModelData_Drawing | Drawing () const |
Returns the drawing of the model. | |
void | AddLayer (const ModelData_Layer &theLayer) |
void | Accept (ElementVisitor &theVisitor) const |
Accepts a visitor. | |
void | Accept (LayerVisitor &theVisitor) const |
internal::ModelData_ModelImpl * | Impl () const |
Returns an implementation object (reserved for internal use). | |
Provides CAD Exchanger data model.
The model encapsulates a scene graph (hierarchy of assemblies and parts) and is thus an entry point to entire 3D model data.
A model contains a shared pointer to its internal implementation, so simple copying an object will just copy a shared pointer:
The model object can be saved to and restored from a file in native CAD Exchanger format. Currently XML is used as a file type. Future versions may introduce binary format.
Defines file format used to store model contents.
cadex::ModelData_Model::ModelData_Model | ( | const Base_UTF16String & | theName = Base_UTF16String() | ) |
Constructor.
Creates an empty model. IsEmpty() returns true.
const ModelData_SceneGraphElement & cadex::ModelData_Model::AddRoot | ( | const ModelData_SceneGraphElement & | theElement | ) |
Adds new root element into the scene graph.
If the passed element is an instance of ModelData_Instance, it will be automatically nested in ModelData_Assembly according to product structure requirements.
void cadex::ModelData_Model::AssignUuids | ( | ) |
Assigns uuid's (persistent id's) to scene graph elements and part representations (if not assigned yet).
void cadex::ModelData_Model::Clear | ( | ) |
Clears the model contents.
Detaches the model contents. Only cleans up contents of this object. Other copies of this object will remain unaffected. For instance, in the following code
the aM2 object will continue to have entire previous contents. Respectively, all previous pointers (e.g. to objects of ModelData_BaseObject subclasses) remain valid.
bool cadex::ModelData_Model::IsEmpty | ( | ) | const |
Returns true if the model is empty.
Returns true if the model has no roots, i.e. NumberOfRoots() returns 0.
void cadex::ModelData_Model::Merge | ( | const ModelData_Model & | theSrcModel, |
const Base_ProgressStatus & | theProgressStatus = Base_ProgressStatus() |
||
) |
Adds all roots of another model to the current model.
Adds roots from another model to current.
const Base_UTF16String & cadex::ModelData_Model::Name | ( | ) | const |
Returns a model name.
Returns empty string if the model has no name (by default).
size_t cadex::ModelData_Model::NumberOfRoots | ( | ) | const |
Returns number of root elements in the graph.
bool cadex::ModelData_Model::Open | ( | const Base_UTF16String & | theFileName, |
bool | theToAppend = false , |
||
const Base_ProgressStatus & | theProgressStatus = Base_ProgressStatus() |
||
) |
Loads the model object from the file.
If theToAppend is true then appends to this model, otherwise resets it first.
The method can be called on a nullified model.
bool cadex::ModelData_Model::RemoveRoot | ( | const ModelData_SceneGraphElement & | theElement | ) |
Removes root scene graph element from the model.
Returns true if removal took place and false otherwise.
true
value invalidates the instances of ModelData_Model::ElementVisitor and ModelData_Model::ElementIterator over model's roots, making further behavior of these objects undefined. bool cadex::ModelData_Model::Save | ( | const Base_UTF16String & | theFileName, |
const ModelData_WriterParameters & | theParameters, | ||
const Base_ProgressStatus & | theProgressStatus = Base_ProgressStatus() |
||
) | const |
Saves the model object to a file.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Any folders you specify in the output path that are not yet present in the filesystem will be created automatically.
bool cadex::ModelData_Model::Save | ( | const Base_UTF16String & | theFileName, |
FileFormatType | theFormat = Xml , |
||
const Base_ProgressStatus & | theProgressStatus = Base_ProgressStatus() |
||
) | const |
Saves the model object to a file. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Kept for preserving binary compatibility. Invokes ModelData_Model::Save(const Base_UTF16String&, const ModelData_WriterParameters&, const Base_ProgressStatus&);
void cadex::ModelData_Model::SetName | ( | const Base_UTF16String & | theName | ) |