CAD Exchanger SDK
cadex::ModelData_Model Class Reference

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.
 

Public Member Functions

 ModelData_Model (const Base_UTF16String &theName=Base_UTF16String())
 Constructor. More...
 
 ~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. More...
 
void SetName (const Base_UTF16String &theName)
 Sets a model name. More...
 
const Base_UTF16StringName () const
 Returns a model name. More...
 
bool Open (const Base_UTF16String &theFileName, bool theToAppend=false, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus())
 Loads the model object from the file. More...
 
bool Save (const Base_UTF16String &theFileName, FileFormatType theFormat=Xml, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) const
 Saves the model object to a file. More...
 
bool Save (const Base_UTF16String &theFileName, const ModelData_WriterParameters &theParameters, const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus()) const
 Saves the model object to a file. More...
 
void Clear ()
 Clears the model contents. More...
 
bool IsEmpty () const
 Returns true if the model is empty. More...
 
const ModelData_SceneGraphElementAddRoot (const ModelData_SceneGraphElement &theElement)
 
size_t NumberOfRoots () const
 Returns number of root elements in the graph. More...
 
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).
 

Detailed Description

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:

ModelData_Model aModel2 = aModel; //both objects will point to the same contents

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.

bool anIsOk = aModel.Save ("mydocument.xml");
ModelData_Model aNewModel;
anIsOk = aNewModel.Open ("mydocument.xml");
Examples:
assemblycreator/main.cxx, brepmodeling/main.cxx, cadexgen/main.cxx, meshing/main.cxx, modelexplorer/main.cxx, and progressindicator/main.cxx.

Constructor & Destructor Documentation

◆ ModelData_Model()

cadex::ModelData_Model::ModelData_Model ( const Base_UTF16String theName = Base_UTF16String())

Constructor.

Creates an empty model. IsEmpty() returns true.

Member Function Documentation

◆ Clear()

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

//... populate aM1;
ModelData_Model aM2 = aM1;
aM1.Clear();

the aM2 object will continue to have entire previous contents. Respectively, all previous pointers (e.g. to objects of ModelData_BaseObject subclasses) remain valid.

See also
IsEmpty().

◆ IsEmpty()

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.

See also
Clear().

◆ Merge()

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.

◆ Name()

const Base_UTF16String & cadex::ModelData_Model::Name ( ) const

Returns a model name.

Returns empty string if the model has no name (by default).

See also
SetName().

◆ NumberOfRoots()

size_t cadex::ModelData_Model::NumberOfRoots ( ) const

Returns number of root elements in the graph.

See also
AddRoot(), ElementIterator, IsEmpty().

◆ Open()

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.

See also
Save().

◆ Save() [1/2]

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.

See also
Open().
Examples:
assemblycreator/main.cxx, and brepmodeling/main.cxx.

◆ Save() [2/2]

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.

See also
Open().

◆ SetName()

void cadex::ModelData_Model::SetName ( const Base_UTF16String theName)

Sets a model name.

Accepts a string as a unicode string.

See also
Name().