Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions
TObj_Model Class Referenceabstract

#include <TObj_Model.hxx>

Inheritance diagram for TObj_Model:
Inheritance graph
[legend]

Public Member Functions

void SetMessenger (const occ::handle< Message_Messenger > &theMsgr)
 Set messenger to use for messages output.
 
occ::handle< Message_MessengerMessenger () const
 Get messenger used for messages output (by default, the messenger from application is used)
 
virtual bool Load (const TCollection_ExtendedString &theFile)
 Load the OCAF model from a file. If the filename is empty or file does not exists, it just initializes model by empty data.
 
virtual bool Load (Standard_IStream &theIStream)
 Load the OCAF model from a stream. If case of failure, it initializes the model by empty data.
 
virtual bool SaveAs (const TCollection_ExtendedString &theFile)
 Save the model to a file.
 
virtual bool SaveAs (Standard_OStream &theOStream)
 Save the model to a stream.
 
bool Save ()
 Save the model to the same file.
 
virtual bool Close ()
 Close the model.
 
void CloseDocument (const occ::handle< TDocStd_Document > &theDoc)
 Close Free OCAF document.
 
virtual occ::handle< TCollection_HExtendedStringGetFile () const
 Returns the full file name this model is to be saved to, or null if the model was not saved yet.
 
virtual occ::handle< TObj_ObjectIteratorGetObjects () const
 Returns an Iterator on all objects in the Model.
 
virtual occ::handle< TObj_ObjectIteratorGetChildren () const
 Returns an Iterator on objects in the main partition.
 
virtual occ::handle< TObj_ObjectFindObject (const occ::handle< TCollection_HExtendedString > &theName, const occ::handle< TObj_TNameContainer > &theDictionary) const
 Returns an Object by given Name (or Null if not found).
 
virtual occ::handle< TObj_CheckModelGetChecker () const
 Returns the tool checking model consistency. Descendant may redefine it to return its own tool.
 
virtual occ::handle< TObj_ObjectGetRoot () const
 Returns root object of model.
 
occ::handle< TObj_PartitionGetMainPartition () const
 Returns root object of model.
 
TDF_Label GetLabel () const
 Returns OCAF label on which model data are stored.
 
virtual occ::handle< TCollection_HExtendedStringGetModelName () const
 Returns the name of the model.
 
bool IsRegisteredName (const occ::handle< TCollection_HExtendedString > &theName, const occ::handle< TObj_TNameContainer > &theDictionary) const
 Returns True is name is registered in the names map The input argument may be NULL handle, then model check in own global container.
 
void RegisterName (const occ::handle< TCollection_HExtendedString > &theName, const TDF_Label &theLabel, const occ::handle< TObj_TNameContainer > &theDictionary) const
 Register name in the map The input argument may be NULL handle, then model check in own global container.
 
void UnRegisterName (const occ::handle< TCollection_HExtendedString > &theName, const occ::handle< TObj_TNameContainer > &theDictionary) const
 Unregisters name from the map The input argument may be NULL handle, then model check in own global container.
 
bool HasOpenCommand () const
 Returns True if a Command transaction is open Starting, finishing the transaction.
 
void OpenCommand () const
 Open a new command transaction.
 
void CommitCommand () const
 Commit the Command transaction. Do nothing If there is no Command transaction open.
 
void AbortCommand () const
 Abort the Command transaction. Do nothing If there is no Command transaction open.
 
virtual bool IsModified () const
 Modification status.
 
void SetModified (const bool theModified)
 Sets modification status.
 
virtual const occ::handle< TObj_ApplicationGetApplication ()
 Returns handle to static instance of the relevant application class.
 
virtual TCollection_ExtendedString GetFormat () const
 Returns the format for save/restore. This implementation returns "BinOcaf". The method should be redefined for those models that should use another format.
 
int GetFormatVersion () const
 Returns the version of format stored in TObj file.
 
virtual bool Update ()
 this method is called before activating this model
 
virtual Standard_GUID GetGUID () const
 Defines interface GUID for TObj_Model.
 
occ::handle< TObj_TNameContainerGetDictionary () const
 Returns the map of names of the objects.
 
occ::handle< TDocStd_DocumentGetDocument () const
 Returns OCAF document of Model.
 
void SetLabel (const TDF_Label &theLabel)
 Sets OCAF label on which model data are stored. Used by persistence mechanism.
 
virtual bool Paste (occ::handle< TObj_Model > theModel, occ::handle< TDF_RelocationTable > theRelocTable=nullptr)
 Pastes me to the new model references will not be copied if theRelocTable is not 0 if theRelocTable is not NULL theRelocTable is filled by objects.
 
virtual occ::handle< TObj_ModelNewEmpty ()=0
 This function have to create a new model with type like me.
 
void CopyReferences (const occ::handle< TObj_Model > &theTarget, const occ::handle< TDF_RelocationTable > &theRelocTable)
 Copy references from me to the other.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
bool IsKind (const char *const theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Static Public Member Functions

static occ::handle< TObj_ModelGetDocumentModel (const TDF_Label &theLabel)
 Returns model which contains a document with the label, or NULL handle if label is NULL.
 
static void SetNewName (const occ::handle< TObj_Object > &theObject)
 Sets new unique name for the object.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Protected Types

enum  DataTag { DataTag_FormatVersion = TObj_Partition::DataTag_Last , DataTag_Last }
 Model may store some data on the data labels of its main partition See TObj_Object for. More...
 

Protected Member Functions

 TObj_Model ()
 Empty constructor.
 
 ~TObj_Model () override
 Destructor closes the model.
 
virtual bool checkDocumentEmpty (const TCollection_ExtendedString &theFile)
 Check whether the document contains the OCAF data.
 
void SetFormatVersion (const int theVersion)
 Sets the format version to save.
 
occ::handle< TObj_PartitiongetPartition (const TDF_Label &theLabel, const bool theHidden=false) const
 Returns (or creates a new) partition on a given label.
 
occ::handle< TObj_PartitiongetPartition (const TDF_Label &theLabel, const int theIndex, const TCollection_ExtendedString &theName, const bool theHidden=false) const
 Returns Partition specified by its index number on a given label If not exists, creates anew with specified name.
 
occ::handle< TObj_PartitiongetPartition (const int theIndex, const TCollection_ExtendedString &theName, const bool theHidden=false) const
 Returns Partition specified by its index number If not exists, creates anew with specified name.
 
TDF_Label GetDataLabel () const
 Returns the labels under which the data is stored. the data stored from the third sublabel of this one.
 
virtual bool initNewModel (const bool IsNew)
 Do the necessary initialisations after creation of a new model. This function is called by LoadModel after creation of OCAF document and setting myModel on its main label. Default implementation does nothing. Returns True is model sucsesfully initialized.
 
virtual void updateBackReferences (const occ::handle< TObj_Object > &theObject)
 Updates back references of object Recursive method.
 
virtual bool isToCheck () const
 Returns boolean value is to check model in Init new model The check could be useful if version of model changed Default implementation returns FALSE (check turned OFF)
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 

Detailed Description

Base class for OCAF based models. Defines common behaviour for all models based on TObject classes, basic services to access model objects and common operations with the model. Provides default implementation for many methods.

Member Enumeration Documentation

◆ DataTag

Model may store some data on the data labels of its main partition See TObj_Object for.

Enumerator
DataTag_FormatVersion 
DataTag_Last 

Constructor & Destructor Documentation

◆ TObj_Model()

TObj_Model::TObj_Model ( )
protected

Empty constructor.

Constructors and Persistence

◆ ~TObj_Model()

TObj_Model::~TObj_Model ( )
overrideprotected

Destructor closes the model.

Member Function Documentation

◆ AbortCommand()

void TObj_Model::AbortCommand ( ) const

Abort the Command transaction. Do nothing If there is no Command transaction open.

◆ checkDocumentEmpty()

virtual bool TObj_Model::checkDocumentEmpty ( const TCollection_ExtendedString & theFile)
protectedvirtual

Check whether the document contains the OCAF data.

◆ Close()

virtual bool TObj_Model::Close ( )
virtual

Close the model.

Work with document

◆ CloseDocument()

void TObj_Model::CloseDocument ( const occ::handle< TDocStd_Document > & theDoc)

Close Free OCAF document.

◆ CommitCommand()

void TObj_Model::CommitCommand ( ) const

Commit the Command transaction. Do nothing If there is no Command transaction open.

◆ CopyReferences()

void TObj_Model::CopyReferences ( const occ::handle< TObj_Model > & theTarget,
const occ::handle< TDF_RelocationTable > & theRelocTable )

Copy references from me to the other.

◆ FindObject()

virtual occ::handle< TObj_Object > TObj_Model::FindObject ( const occ::handle< TCollection_HExtendedString > & theName,
const occ::handle< TObj_TNameContainer > & theDictionary ) const
virtual

Returns an Object by given Name (or Null if not found).

◆ GetApplication()

virtual const occ::handle< TObj_Application > TObj_Model::GetApplication ( )
virtual

Returns handle to static instance of the relevant application class.

Methods for obtaining application

◆ GetChecker()

virtual occ::handle< TObj_CheckModel > TObj_Model::GetChecker ( ) const
virtual

Returns the tool checking model consistency. Descendant may redefine it to return its own tool.

◆ GetChildren()

virtual occ::handle< TObj_ObjectIterator > TObj_Model::GetChildren ( ) const
virtual

Returns an Iterator on objects in the main partition.

◆ GetDataLabel()

TDF_Label TObj_Model::GetDataLabel ( ) const
protected

Returns the labels under which the data is stored. the data stored from the third sublabel of this one.

◆ GetDictionary()

occ::handle< TObj_TNameContainer > TObj_Model::GetDictionary ( ) const

Returns the map of names of the objects.

Internal methods

◆ GetDocument()

occ::handle< TDocStd_Document > TObj_Model::GetDocument ( ) const

Returns OCAF document of Model.

◆ GetDocumentModel()

static occ::handle< TObj_Model > TObj_Model::GetDocumentModel ( const TDF_Label & theLabel)
static

Returns model which contains a document with the label, or NULL handle if label is NULL.

◆ GetFile()

virtual occ::handle< TCollection_HExtendedString > TObj_Model::GetFile ( ) const
virtual

Returns the full file name this model is to be saved to, or null if the model was not saved yet.

◆ GetFormat()

virtual TCollection_ExtendedString TObj_Model::GetFormat ( ) const
virtual

Returns the format for save/restore. This implementation returns "BinOcaf". The method should be redefined for those models that should use another format.

Methods for obtaining the version of Format

◆ GetFormatVersion()

int TObj_Model::GetFormatVersion ( ) const

Returns the version of format stored in TObj file.

◆ GetGUID()

virtual Standard_GUID TObj_Model::GetGUID ( ) const
virtual

Defines interface GUID for TObj_Model.

Definition of interface GUID

◆ GetLabel()

TDF_Label TObj_Model::GetLabel ( ) const
inline

Returns OCAF label on which model data are stored.

OCAF methods

◆ GetMainPartition()

occ::handle< TObj_Partition > TObj_Model::GetMainPartition ( ) const

Returns root object of model.

◆ GetModelName()

virtual occ::handle< TCollection_HExtendedString > TObj_Model::GetModelName ( ) const
virtual

Returns the name of the model.

Methods for supporting unique naming of the objects in model

◆ GetObjects()

virtual occ::handle< TObj_ObjectIterator > TObj_Model::GetObjects ( ) const
virtual

Returns an Iterator on all objects in the Model.

Access to the objects in the model

◆ getPartition() [1/3]

occ::handle< TObj_Partition > TObj_Model::getPartition ( const int theIndex,
const TCollection_ExtendedString & theName,
const bool theHidden = false ) const
protected

Returns Partition specified by its index number If not exists, creates anew with specified name.

◆ getPartition() [2/3]

occ::handle< TObj_Partition > TObj_Model::getPartition ( const TDF_Label & theLabel,
const bool theHidden = false ) const
protected

Returns (or creates a new) partition on a given label.

Internal methods

◆ getPartition() [3/3]

occ::handle< TObj_Partition > TObj_Model::getPartition ( const TDF_Label & theLabel,
const int theIndex,
const TCollection_ExtendedString & theName,
const bool theHidden = false ) const
protected

Returns Partition specified by its index number on a given label If not exists, creates anew with specified name.

◆ GetRoot()

virtual occ::handle< TObj_Object > TObj_Model::GetRoot ( ) const
virtual

Returns root object of model.

Methods for iteration on the model

◆ HasOpenCommand()

bool TObj_Model::HasOpenCommand ( ) const

Returns True if a Command transaction is open Starting, finishing the transaction.

API for transaction mechanism

◆ initNewModel()

virtual bool TObj_Model::initNewModel ( const bool IsNew)
protectedvirtual

Do the necessary initialisations after creation of a new model. This function is called by LoadModel after creation of OCAF document and setting myModel on its main label. Default implementation does nothing. Returns True is model sucsesfully initialized.

◆ IsModified()

virtual bool TObj_Model::IsModified ( ) const
virtual

Modification status.

◆ IsRegisteredName()

bool TObj_Model::IsRegisteredName ( const occ::handle< TCollection_HExtendedString > & theName,
const occ::handle< TObj_TNameContainer > & theDictionary ) const

Returns True is name is registered in the names map The input argument may be NULL handle, then model check in own global container.

◆ isToCheck()

virtual bool TObj_Model::isToCheck ( ) const
inlineprotectedvirtual

Returns boolean value is to check model in Init new model The check could be useful if version of model changed Default implementation returns FALSE (check turned OFF)

◆ Load() [1/2]

virtual bool TObj_Model::Load ( const TCollection_ExtendedString & theFile)
virtual

Load the OCAF model from a file. If the filename is empty or file does not exists, it just initializes model by empty data.

Implementation of Load/Save for OCAF based models

◆ Load() [2/2]

virtual bool TObj_Model::Load ( Standard_IStream & theIStream)
virtual

Load the OCAF model from a stream. If case of failure, it initializes the model by empty data.

◆ Messenger()

occ::handle< Message_Messenger > TObj_Model::Messenger ( ) const
inline

Get messenger used for messages output (by default, the messenger from application is used)

◆ NewEmpty()

virtual occ::handle< TObj_Model > TObj_Model::NewEmpty ( )
pure virtual

This function have to create a new model with type like me.

◆ OpenCommand()

void TObj_Model::OpenCommand ( ) const

Open a new command transaction.

◆ Paste()

virtual bool TObj_Model::Paste ( occ::handle< TObj_Model > theModel,
occ::handle< TDF_RelocationTable > theRelocTable = nullptr )
virtual

Pastes me to the new model references will not be copied if theRelocTable is not 0 if theRelocTable is not NULL theRelocTable is filled by objects.

Methods for clone model

◆ RegisterName()

void TObj_Model::RegisterName ( const occ::handle< TCollection_HExtendedString > & theName,
const TDF_Label & theLabel,
const occ::handle< TObj_TNameContainer > & theDictionary ) const

Register name in the map The input argument may be NULL handle, then model check in own global container.

◆ Save()

bool TObj_Model::Save ( )

Save the model to the same file.

◆ SaveAs() [1/2]

virtual bool TObj_Model::SaveAs ( const TCollection_ExtendedString & theFile)
virtual

Save the model to a file.

◆ SaveAs() [2/2]

virtual bool TObj_Model::SaveAs ( Standard_OStream & theOStream)
virtual

Save the model to a stream.

◆ SetFormatVersion()

void TObj_Model::SetFormatVersion ( const int theVersion)
protected

Sets the format version to save.

Methods for handling the version of the Format

◆ SetLabel()

void TObj_Model::SetLabel ( const TDF_Label & theLabel)
inline

Sets OCAF label on which model data are stored. Used by persistence mechanism.

◆ SetMessenger()

void TObj_Model::SetMessenger ( const occ::handle< Message_Messenger > & theMsgr)
inline

Set messenger to use for messages output.

Messages mechanism

◆ SetModified()

void TObj_Model::SetModified ( const bool theModified)

Sets modification status.

◆ SetNewName()

static void TObj_Model::SetNewName ( const occ::handle< TObj_Object > & theObject)
static

Sets new unique name for the object.

◆ UnRegisterName()

void TObj_Model::UnRegisterName ( const occ::handle< TCollection_HExtendedString > & theName,
const occ::handle< TObj_TNameContainer > & theDictionary ) const

Unregisters name from the map The input argument may be NULL handle, then model check in own global container.

◆ Update()

virtual bool TObj_Model::Update ( )
virtual

this method is called before activating this model

Methods for updating model

◆ updateBackReferences()

virtual void TObj_Model::updateBackReferences ( const occ::handle< TObj_Object > & theObject)
protectedvirtual

Updates back references of object Recursive method.


The documentation for this class was generated from the following file: