Open CASCADE Technology  7.4.0
Public Member Functions | Static Public Member Functions

XCAFDoc_ShapeTool Class Reference

A tool to store shapes in an XDE document in the form of assembly structure, and to maintain this structure. Attribute containing Shapes section of DECAF document. Provide tools for management of Shapes section. The API provided by this class allows to work with this structure regardless of its low-level implementation. All the shapes are stored on child labels of a main label which is XCAFDoc_DocumentTool::LabelShapes(). The label for assembly also has sub-labels, each of which represents the instance of another shape in that assembly (component). Such sub-label stores reference to the label of the original shape in the form of TDataStd_TreeNode with GUID XCAFDoc::ShapeRefGUID(), and its location encapsulated into the NamedShape. For correct work with an XDE document, it is necessary to use methods for analysis and methods for working with shapes. For example: if ( STool->IsAssembly(aLabel) ) { Standard_Boolean subchilds = Standard_False; (default) Standard_Integer nbc = STool->NbComponents (aLabel[,subchilds]); } If subchilds is True, commands also consider sub-levels. By default, only level one is checked. In this example, number of children from the first level of assembly will be returned. Methods for creation and initialization: Constructor: XCAFDoc_ShapeTool::XCAFDoc_ShapeTool() Getting a guid: Standard_GUID GetID (); Creation (if does not exist) of ShapeTool on label L: Handle(XCAFDoc_ShapeTool) XCAFDoc_ShapeTool::Set(const TDF_Label& L) Analyze whether shape is a simple shape or an instance or a component of an assembly or it is an assembly ( methods of analysis). For example: STool->IsShape(aLabel) ; Analyze that the label represents a shape (simple shape, assembly or reference) or STool->IsTopLevel(aLabel); Analyze that the label is a label of a top-level shape. Work with simple shapes, assemblies and instances ( methods for work with shapes). For example: Add shape: Standard_Boolean makeAssembly; // True to interpret a Compound as an Assembly, False to take it as a whole aLabel = STool->AddShape(aShape, makeAssembly); Get shape: TDF_Label aLabel... // A label must be present if (aLabel.IsNull()) { ... no such label : abandon .. } TopoDS_Shape aShape; aShape = STool->GetShape(aLabel); if (aShape.IsNull()) { ... this label is not for a Shape ... } To get a label from shape. Standard_Boolean findInstance = Standard_False; (this is default value) aLabel = STool->FindShape(aShape [,findInstance]); if (aLabel.IsNull()) { ... no label found for this shape ... }. More...

#include <XCAFDoc_ShapeTool.hxx>

Inheritance diagram for XCAFDoc_ShapeTool:
Inheritance graph
[legend]

Public Member Functions

 XCAFDoc_ShapeTool ()
 Creates an empty tool Creates a tool to work with a document <Doc> Attaches to label XCAFDoc::LabelShapes() More...
 
Standard_Boolean IsTopLevel (const TDF_Label &L) const
 Returns True if the label is a label of top-level shape, as opposed to component of assembly or subshape. More...
 
Standard_Boolean IsSubShape (const TDF_Label &shapeL, const TopoDS_Shape &sub) const
 Checks whether shape is subshape of shape stored on label shapeL. More...
 
Standard_Boolean SearchUsingMap (const TopoDS_Shape &S, TDF_Label &L, const Standard_Boolean findWithoutLoc, const Standard_Boolean findSubshape) const
 
Standard_Boolean Search (const TopoDS_Shape &S, TDF_Label &L, const Standard_Boolean findInstance=Standard_True, const Standard_Boolean findComponent=Standard_True, const Standard_Boolean findSubshape=Standard_True) const
 General tool to find a (sub) shape in the document. More...
 
Standard_Boolean FindShape (const TopoDS_Shape &S, TDF_Label &L, const Standard_Boolean findInstance=Standard_False) const
 Returns the label corresponding to shape S (searches among top-level shapes, not including subcomponents of assemblies and subshapes) If findInstance is False (default), seach for the input shape without location If findInstance is True, searches for the input shape as is. Return True if <S> is found. More...
 
TDF_Label FindShape (const TopoDS_Shape &S, const Standard_Boolean findInstance=Standard_False) const
 Does the same as previous method Returns Null label if not found. More...
 
TDF_Label NewShape () const
 Creates new (empty) top-level shape. Initially it holds empty TopoDS_Compound. More...
 
void SetShape (const TDF_Label &L, const TopoDS_Shape &S)
 Sets representation (TopoDS_Shape) for top-level shape. More...
 
TDF_Label AddShape (const TopoDS_Shape &S, const Standard_Boolean makeAssembly=Standard_True, const Standard_Boolean makePrepare=Standard_True)
 Adds a new top-level (creates and returns a new label) If makeAssembly is True, treats TopAbs_COMPOUND shapes as assemblies (creates assembly structure). NOTE: <makePrepare> replace components without location in assmebly by located components to avoid some problems. If AutoNaming() is True then automatically attaches names. More...
 
Standard_Boolean RemoveShape (const TDF_Label &L, const Standard_Boolean removeCompletely=Standard_True) const
 Removes shape (whole label and all its sublabels) If removeCompletely is true, removes complete shape If removeCompletely is false, removes instance(location) only Returns False (and does nothing) if shape is not free or is not top-level shape. More...
 
void Init ()
 set hasComponents into false More...
 
void ComputeShapes (const TDF_Label &L)
 recursive More...
 
void ComputeSimpleShapes ()
 Compute a sequence of simple shapes. More...
 
void GetShapes (TDF_LabelSequence &Labels) const
 Returns a sequence of all top-level shapes. More...
 
void GetFreeShapes (TDF_LabelSequence &FreeLabels) const
 Returns a sequence of all top-level shapes which are free (i.e. not referred by any other) More...
 
TDF_Label AddComponent (const TDF_Label &assembly, const TDF_Label &comp, const TopLoc_Location &Loc)
 Adds a component given by its label and location to the assembly Note: assembly must be IsAssembly() or IsSimpleShape() More...
 
TDF_Label AddComponent (const TDF_Label &assembly, const TopoDS_Shape &comp, const Standard_Boolean expand=Standard_False)
 Adds a shape (located) as a component to the assembly If necessary, creates an additional top-level shape for component and return the Label of component. If expand is True and component is Compound, it will be created as assembly also Note: assembly must be IsAssembly() or IsSimpleShape() More...
 
void RemoveComponent (const TDF_Label &comp) const
 Removes a component from its assembly. More...
 
void UpdateAssemblies ()
 Top-down update for all assembly compounds stored in the document. More...
 
Standard_Boolean FindSubShape (const TDF_Label &shapeL, const TopoDS_Shape &sub, TDF_Label &L) const
 Finds a label for subshape of shape stored on label shapeL Returns Null label if it is not found. More...
 
TDF_Label AddSubShape (const TDF_Label &shapeL, const TopoDS_Shape &sub) const
 Adds a label for subshape of shape stored on label shapeL Returns Null label if it is not subshape. More...
 
Standard_Boolean AddSubShape (const TDF_Label &shapeL, const TopoDS_Shape &sub, TDF_Label &addedSubShapeL) const
 Adds (of finds already existed) a label for subshape of shape stored on label shapeL. Label addedSubShapeL returns added (found) label or empty in case of wrong subshape. Returns True, if new shape was added, False in case of already existed subshape/wrong subshape. More...
 
TDF_Label FindMainShapeUsingMap (const TopoDS_Shape &sub) const
 
TDF_Label FindMainShape (const TopoDS_Shape &sub) const
 Performs a search among top-level shapes to find the shape containing as subshape Checks only simple shapes, and returns the first found label (which should be the only one for valid model) More...
 
TDF_Label BaseLabel () const
 returns the label under which shapes are stored More...
 
Standard_OStreamDump (Standard_OStream &theDumpLog, const Standard_Boolean deep) const
 
virtual Standard_OStreamDump (Standard_OStream &theDumpLog) const override
 Dumps the minimum information about <me> on <aStream>. More...
 
const Standard_GUIDID () const override
 Returns the ID of the attribute. More...
 
void Restore (const Handle< TDF_Attribute > &with) override
 Restores the backuped contents from <anAttribute> into this one. It is used when aborting a transaction. More...
 
Handle< TDF_AttributeNewEmpty () const override
 Returns an new empty attribute from the good end type. It is used by the copy algorithm. More...
 
void Paste (const Handle< TDF_Attribute > &into, const Handle< TDF_RelocationTable > &RT) const override
 This method is different from the "Copy" one, because it is used when copying an attribute from a source structure into a target structure. This method may paste the contents of <me> into <intoAttribute>. More...
 
TDF_Label SetExternRefs (const TColStd_SequenceOfHAsciiString &SHAS) const
 Sets the names of references on the no-step files. More...
 
void SetExternRefs (const TDF_Label &L, const TColStd_SequenceOfHAsciiString &SHAS) const
 Sets the names of references on the no-step files. More...
 
Standard_Boolean SetSHUO (const TDF_LabelSequence &Labels, Handle< XCAFDoc_GraphNode > &MainSHUOAttr) const
 Sets the SHUO structure between upper_usage and next_usage create multy-level (if number of labels > 2) SHUO from first to last Initialise out <MainSHUOAttr> by main upper_usage SHUO attribute. Returns FALSE if some of labels in not component label. More...
 
Standard_Boolean RemoveSHUO (const TDF_Label &SHUOLabel) const
 Remove SHUO from component sublabel, remove all dependencies on other SHUO. Returns FALSE if cannot remove SHUO dependencies. NOTE: remove any styles that associated with this SHUO. More...
 
Standard_Boolean FindComponent (const TopoDS_Shape &theShape, TDF_LabelSequence &Labels) const
 Serach the path of labels in the document, that corresponds the component from any assembly Try to search the sequence of labels with location that produce this shape as component of any assembly NOTE: Clear sequence of labels before filling. More...
 
TopoDS_Shape GetSHUOInstance (const Handle< XCAFDoc_GraphNode > &theSHUO) const
 Search for the component shape that styled by shuo Returns null shape if no any shape is found. More...
 
Handle< XCAFDoc_GraphNodeSetInstanceSHUO (const TopoDS_Shape &theShape) const
 Search for the component shape by labelks path and set SHUO structure for founded label structure Returns null attribute if no component in any assembly found. More...
 
Standard_Boolean GetAllSHUOInstances (const Handle< XCAFDoc_GraphNode > &theSHUO, TopTools_SequenceOfShape &theSHUOShapeSeq) const
 Seaching for component shapes that styled by shuo Returns empty sequence of shape if no any shape is found. More...
 
Standard_Boolean Expand (const TDF_Label &Shape)
 Convert Shape (compound/compsolid/shell/wire) to assembly. More...
 
Handle< TDataStd_NamedDataGetNamedProperties (const TDF_Label &theLabel, const Standard_Boolean theToCreate=Standard_False) const
 Method to get NamedData attribute assigned to the given shape label. More...
 
Handle< TDataStd_NamedDataGetNamedProperties (const TopoDS_Shape &theShape, const Standard_Boolean theToCreate=Standard_False) const
 Method to get NamedData attribute assigned to a label of the given shape. More...
 
- Public Member Functions inherited from TDF_Attribute
virtual void SetID (const Standard_GUID &)
 Sets specific ID of the attribute (supports several attributes of one type at the same label feature). More...
 
virtual void SetID ()
 Sets default ID defined in nested class (to be used for attributes having User ID feature). More...
 
const TDF_Label Label () const
 Returns the label to which the attribute is attached. If the label is not included in a DF, the label is null. See Label. Warning If the label is not included in a data framework, it is null. This function should not be redefined inline. More...
 
Standard_Integer Transaction () const
 Returns the transaction index in which the attribute has been created or modified. More...
 
Standard_Integer UntilTransaction () const
 Returns the upper transaction index until which the attribute is/was valid. This number may vary. A removed attribute validity range is reduced to its transaction index. More...
 
Standard_Boolean IsValid () const
 Returns true if the attribute is valid; i.e. not a backuped or removed one. More...
 
Standard_Boolean IsNew () const
 Returns true if the attribute has no backup. More...
 
Standard_Boolean IsForgotten () const
 Returns true if the attribute forgotten status is set. More...
 
Standard_Boolean IsAttribute (const Standard_GUID &anID) const
 Returns true if it exists an associated attribute of <me> with <anID> as ID. More...
 
Standard_Boolean FindAttribute (const Standard_GUID &anID, Handle< TDF_Attribute > &anAttribute) const
 Finds an associated attribute of <me>, according to <anID>. the returned <anAttribute> is a valid one. The method returns True if found, False otherwise. A removed attribute cannot be found using this method. More...
 
template<class T >
Standard_Boolean FindAttribute (const Standard_GUID &theID, Handle< T > &theAttr) const
 Safe variant for arbitrary type of argument. More...
 
void AddAttribute (const Handle< TDF_Attribute > &other) const
 Adds an Attribute <other> to the label of <me>.Raises if there is already one of the same GUID fhan <other>. More...
 
Standard_Boolean ForgetAttribute (const Standard_GUID &aguid) const
 Forgets the Attribute of GUID <aguid> associated to the label of <me>. Be carefull that if <me> is the attribute of <guid>, <me> will have a null label after this call. If the attribute doesn't exist returns False. Otherwise returns True. More...
 
void ForgetAllAttributes (const Standard_Boolean clearChildren=Standard_True) const
 Forgets all the attributes attached to the label of <me>. Does it on the sub-labels if <clearChildren> is set to true. Of course, this method is compatible with Transaction & Delta mecanisms. Be carefull that if <me> will have a null label after this call. More...
 
virtual void AfterAddition ()
 Something to do after adding an Attribute to a label. More...
 
virtual void BeforeRemoval ()
 Something to do before removing an Attribute from a label. More...
 
virtual void BeforeForget ()
 Something to do before forgetting an Attribute to a label. More...
 
virtual void AfterResume ()
 Something to do after resuming an Attribute from a label. More...
 
virtual Standard_Boolean AfterRetrieval (const Standard_Boolean forceIt=Standard_False)
 Something to do AFTER creation of an attribute by persistent-transient translation. The returned status says if AfterUndo has been performed (true) or if this callback must be called once again further (false). If <forceIt> is set to true, the method MUST perform and return true. Does nothing by default and returns true. More...
 
virtual Standard_Boolean BeforeUndo (const Handle< TDF_AttributeDelta > &anAttDelta, const Standard_Boolean forceIt=Standard_False)
 Something to do before applying <anAttDelta>. The returned status says if AfterUndo has been performed (true) or if this callback must be called once again further (false). If <forceIt> is set to true, the method MUST perform and return true. Does nothing by default and returns true. More...
 
virtual Standard_Boolean AfterUndo (const Handle< TDF_AttributeDelta > &anAttDelta, const Standard_Boolean forceIt=Standard_False)
 Something to do after applying <anAttDelta>. The returned status says if AfterUndo has been performed (true) or if this callback must be called once again further (false). If <forceIt> is set to true, the method MUST perform and return true. Does nothing by default and returns true. More...
 
virtual void BeforeCommitTransaction ()
 A callback. By default does nothing. It is called by TDF_Data::CommitTransaction() method. More...
 
void Backup ()
 Backups the attribute. The backuped attribute is flagged "Backuped" and not "Valid". More...
 
Standard_Boolean IsBackuped () const
 Returns true if the attribute backup status is set. This status is set/unset by the Backup() method. More...
 
virtual Handle< TDF_AttributeBackupCopy () const
 Copies the attribute contents into a new other attribute. It is used by Backup(). More...
 
virtual Handle< TDF_DeltaOnAdditionDeltaOnAddition () const
 Makes an AttributeDelta because <me> appeared. The only known use of a redefinition of this method is to return a null handle (no delta). More...
 
virtual Handle< TDF_DeltaOnForgetDeltaOnForget () const
 Makes an AttributeDelta because <me> has been forgotten. More...
 
virtual Handle< TDF_DeltaOnResumeDeltaOnResume () const
 Makes an AttributeDelta because <me> has been resumed. More...
 
virtual Handle< TDF_DeltaOnModificationDeltaOnModification (const Handle< TDF_Attribute > &anOldAttribute) const
 Makes a DeltaOnModification between <me> and <anOldAttribute. More...
 
virtual void DeltaOnModification (const Handle< TDF_DeltaOnModification > &aDelta)
 Applies a DeltaOnModification to <me>. More...
 
virtual Handle< TDF_DeltaOnRemovalDeltaOnRemoval () const
 Makes a DeltaOnRemoval on <me> because <me> has disappeared from the DS. More...
 
virtual void References (const Handle< TDF_DataSet > &aDataSet) const
 Adds the first level referenced attributes and labels to <aDataSet>. More...
 
Standard_OStreamoperator<< (Standard_OStream &anOS) const
 
virtual void ExtendedDump (Standard_OStream &anOS, const TDF_IDFilter &aFilter, TDF_AttributeIndexedMap &aMap) const
 Dumps the attribute content on <aStream>, using <aMap> like this: if an attribute is not in the map, first put add it to the map and then dump it. Use the map rank instead of dumping each attribute field. More...
 
void Forget (const Standard_Integer aTransaction)
 Forgets the attribute. <aTransaction> is the current transaction in which the forget is done. A forgotten attribute is also flagged not "Valid". More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean 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. More...
 
Standard_Boolean IsKind (const Standard_CString 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. More...
 
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. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Static Public Member Functions

static const Standard_GUIDGetID ()
 
static Handle< XCAFDoc_ShapeToolSet (const TDF_Label &L)
 Create (if not exist) ShapeTool from XCAFDoc on <L>. More...
 
static Standard_Boolean IsFree (const TDF_Label &L)
 Returns True if the label is not used by any assembly, i.e. contains sublabels which are assembly components This is relevant only if IsShape() is True (There is no Father TreeNode on this <L>) More...
 
static Standard_Boolean IsShape (const TDF_Label &L)
 Returns True if the label represents a shape (simple shape, assembly or reference) More...
 
static Standard_Boolean IsSimpleShape (const TDF_Label &L)
 Returns True if the label is a label of simple shape. More...
 
static Standard_Boolean IsReference (const TDF_Label &L)
 Return true if <L> is a located instance of other shape i.e. reference. More...
 
static Standard_Boolean IsAssembly (const TDF_Label &L)
 Returns True if the label is a label of assembly, i.e. contains sublabels which are assembly components This is relevant only if IsShape() is True. More...
 
static Standard_Boolean IsComponent (const TDF_Label &L)
 Return true if <L> is reference serving as component of assembly. More...
 
static Standard_Boolean IsCompound (const TDF_Label &L)
 Returns True if the label is a label of compound, i.e. contains some sublabels This is relevant only if IsShape() is True. More...
 
static Standard_Boolean IsSubShape (const TDF_Label &L)
 Return true if <L> is subshape of the top-level shape. More...
 
static Standard_Boolean GetShape (const TDF_Label &L, TopoDS_Shape &S)
 To get TopoDS_Shape from shape's label For component, returns new shape with correct location Returns False if label does not contain shape. More...
 
static TopoDS_Shape GetShape (const TDF_Label &L)
 To get TopoDS_Shape from shape's label For component, returns new shape with correct location Returns Null shape if label does not contain shape. More...
 
static void SetAutoNaming (const Standard_Boolean V)
 Sets auto-naming mode to <V>. If True then for added shapes, links, assemblies and SHUO's, the TDataStd_Name attribute is automatically added. For shapes it contains a shape type (e.g. "SOLID", "SHELL", etc); for links it has a form "=>[0:1:1:2]" (where a tag is a label containing a shape without a location); for assemblies it is "ASSEMBLY", and "SHUO" for SHUO's. This setting is global; it cannot be made a member function as it is used by static methods as well. By default, auto-naming is enabled. See also AutoNaming(). More...
 
static Standard_Boolean AutoNaming ()
 Returns current auto-naming mode. See SetAutoNaming() for description. More...
 
static Standard_Integer GetUsers (const TDF_Label &L, TDF_LabelSequence &Labels, const Standard_Boolean getsubchilds=Standard_False)
 Returns list of labels which refer shape L as component Returns number of users (0 if shape is free) More...
 
static TopLoc_Location GetLocation (const TDF_Label &L)
 Returns location of instance. More...
 
static Standard_Boolean GetReferredShape (const TDF_Label &L, TDF_Label &Label)
 Returns label which corresponds to a shape referred by L Returns False if label is not reference. More...
 
static Standard_Integer NbComponents (const TDF_Label &L, const Standard_Boolean getsubchilds=Standard_False)
 Returns number of Assembles components. More...
 
static Standard_Boolean GetComponents (const TDF_Label &L, TDF_LabelSequence &Labels, const Standard_Boolean getsubchilds=Standard_False)
 Returns list of components of assembly Returns False if label is not assembly. More...
 
static Standard_Boolean GetSubShapes (const TDF_Label &L, TDF_LabelSequence &Labels)
 Returns list of labels identifying subshapes of the given shape Returns False if no subshapes are placed on that label. More...
 
static void DumpShape (Standard_OStream &theDumpLog, const TDF_Label &L, const Standard_Integer level=0, const Standard_Boolean deep=Standard_False)
 Print to std::ostream <theDumpLog> type of shape found on <L> label and the entry of <L>, with <level> tabs before. If <deep>, print also TShape and Location addresses. More...
 
static Standard_Boolean IsExternRef (const TDF_Label &L)
 Returns True if the label is a label of external references, i.e. there are some reference on the no-step files, which are described in document only their names. More...
 
static void GetExternRefs (const TDF_Label &L, TColStd_SequenceOfHAsciiString &SHAS)
 Gets the names of references on the no-step files. More...
 
static Standard_Boolean GetSHUO (const TDF_Label &SHUOLabel, Handle< XCAFDoc_GraphNode > &aSHUOAttr)
 Returns founded SHUO GraphNode attribute <aSHUOAttr> Returns false in other case. More...
 
static Standard_Boolean GetAllComponentSHUO (const TDF_Label &CompLabel, TDF_AttributeSequence &SHUOAttrs)
 Returns founded SHUO GraphNodes of indicated component Returns false in other case. More...
 
static Standard_Boolean GetSHUOUpperUsage (const TDF_Label &NextUsageL, TDF_LabelSequence &Labels)
 Returns the sequence of labels of SHUO attributes, which is upper_usage for this next_usage SHUO attribute (that indicated by label) NOTE: returns upper_usages only on one level (not recurse) NOTE: do not clear the sequence before filling. More...
 
static Standard_Boolean GetSHUONextUsage (const TDF_Label &UpperUsageL, TDF_LabelSequence &Labels)
 Returns the sequence of labels of SHUO attributes, which is next_usage for this upper_usage SHUO attribute (that indicated by label) NOTE: returns next_usages only on one level (not recurse) NOTE: do not clear the sequence before filling. More...
 
static Standard_Boolean FindSHUO (const TDF_LabelSequence &Labels, Handle< XCAFDoc_GraphNode > &theSHUOAttr)
 Searchs the SHUO by labels of components from upper_usage componet to next_usage Returns null attribute if no SHUO found. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Protected Member Functions inherited from TDF_Attribute
 TDF_Attribute ()
 Initializes fields. More...
 

Detailed Description

A tool to store shapes in an XDE document in the form of assembly structure, and to maintain this structure. Attribute containing Shapes section of DECAF document. Provide tools for management of Shapes section. The API provided by this class allows to work with this structure regardless of its low-level implementation. All the shapes are stored on child labels of a main label which is XCAFDoc_DocumentTool::LabelShapes(). The label for assembly also has sub-labels, each of which represents the instance of another shape in that assembly (component). Such sub-label stores reference to the label of the original shape in the form of TDataStd_TreeNode with GUID XCAFDoc::ShapeRefGUID(), and its location encapsulated into the NamedShape. For correct work with an XDE document, it is necessary to use methods for analysis and methods for working with shapes. For example: if ( STool->IsAssembly(aLabel) ) { Standard_Boolean subchilds = Standard_False; (default) Standard_Integer nbc = STool->NbComponents (aLabel[,subchilds]); } If subchilds is True, commands also consider sub-levels. By default, only level one is checked. In this example, number of children from the first level of assembly will be returned. Methods for creation and initialization: Constructor: XCAFDoc_ShapeTool::XCAFDoc_ShapeTool() Getting a guid: Standard_GUID GetID (); Creation (if does not exist) of ShapeTool on label L: Handle(XCAFDoc_ShapeTool) XCAFDoc_ShapeTool::Set(const TDF_Label& L) Analyze whether shape is a simple shape or an instance or a component of an assembly or it is an assembly ( methods of analysis). For example: STool->IsShape(aLabel) ; Analyze that the label represents a shape (simple shape, assembly or reference) or STool->IsTopLevel(aLabel); Analyze that the label is a label of a top-level shape. Work with simple shapes, assemblies and instances ( methods for work with shapes). For example: Add shape: Standard_Boolean makeAssembly; // True to interpret a Compound as an Assembly, False to take it as a whole aLabel = STool->AddShape(aShape, makeAssembly); Get shape: TDF_Label aLabel... // A label must be present if (aLabel.IsNull()) { ... no such label : abandon .. } TopoDS_Shape aShape; aShape = STool->GetShape(aLabel); if (aShape.IsNull()) { ... this label is not for a Shape ... } To get a label from shape. Standard_Boolean findInstance = Standard_False; (this is default value) aLabel = STool->FindShape(aShape [,findInstance]); if (aLabel.IsNull()) { ... no label found for this shape ... }.

Constructor & Destructor Documentation

◆ XCAFDoc_ShapeTool()

XCAFDoc_ShapeTool::XCAFDoc_ShapeTool ( )

Creates an empty tool Creates a tool to work with a document <Doc> Attaches to label XCAFDoc::LabelShapes()

Member Function Documentation

◆ AddComponent() [1/2]

TDF_Label XCAFDoc_ShapeTool::AddComponent ( const TDF_Label assembly,
const TDF_Label comp,
const TopLoc_Location Loc 
)

Adds a component given by its label and location to the assembly Note: assembly must be IsAssembly() or IsSimpleShape()

◆ AddComponent() [2/2]

TDF_Label XCAFDoc_ShapeTool::AddComponent ( const TDF_Label assembly,
const TopoDS_Shape comp,
const Standard_Boolean  expand = Standard_False 
)

Adds a shape (located) as a component to the assembly If necessary, creates an additional top-level shape for component and return the Label of component. If expand is True and component is Compound, it will be created as assembly also Note: assembly must be IsAssembly() or IsSimpleShape()

◆ AddShape()

TDF_Label XCAFDoc_ShapeTool::AddShape ( const TopoDS_Shape S,
const Standard_Boolean  makeAssembly = Standard_True,
const Standard_Boolean  makePrepare = Standard_True 
)

Adds a new top-level (creates and returns a new label) If makeAssembly is True, treats TopAbs_COMPOUND shapes as assemblies (creates assembly structure). NOTE: <makePrepare> replace components without location in assmebly by located components to avoid some problems. If AutoNaming() is True then automatically attaches names.

◆ AddSubShape() [1/2]

TDF_Label XCAFDoc_ShapeTool::AddSubShape ( const TDF_Label shapeL,
const TopoDS_Shape sub 
) const

Adds a label for subshape of shape stored on label shapeL Returns Null label if it is not subshape.

◆ AddSubShape() [2/2]

Standard_Boolean XCAFDoc_ShapeTool::AddSubShape ( const TDF_Label shapeL,
const TopoDS_Shape sub,
TDF_Label addedSubShapeL 
) const

Adds (of finds already existed) a label for subshape of shape stored on label shapeL. Label addedSubShapeL returns added (found) label or empty in case of wrong subshape. Returns True, if new shape was added, False in case of already existed subshape/wrong subshape.

◆ AutoNaming()

static Standard_Boolean XCAFDoc_ShapeTool::AutoNaming ( )
static

Returns current auto-naming mode. See SetAutoNaming() for description.

◆ BaseLabel()

TDF_Label XCAFDoc_ShapeTool::BaseLabel ( ) const

returns the label under which shapes are stored

◆ ComputeShapes()

void XCAFDoc_ShapeTool::ComputeShapes ( const TDF_Label L)

recursive

◆ ComputeSimpleShapes()

void XCAFDoc_ShapeTool::ComputeSimpleShapes ( )

Compute a sequence of simple shapes.

◆ Dump() [1/2]

Standard_OStream& XCAFDoc_ShapeTool::Dump ( Standard_OStream theDumpLog,
const Standard_Boolean  deep 
) const

◆ Dump() [2/2]

virtual Standard_OStream& XCAFDoc_ShapeTool::Dump ( Standard_OStream anOS) const
overridevirtual

Dumps the minimum information about <me> on <aStream>.

Reimplemented from TDF_Attribute.

◆ DumpShape()

static void XCAFDoc_ShapeTool::DumpShape ( Standard_OStream theDumpLog,
const TDF_Label L,
const Standard_Integer  level = 0,
const Standard_Boolean  deep = Standard_False 
)
static

Print to std::ostream <theDumpLog> type of shape found on <L> label and the entry of <L>, with <level> tabs before. If <deep>, print also TShape and Location addresses.

◆ Expand()

Standard_Boolean XCAFDoc_ShapeTool::Expand ( const TDF_Label Shape)

Convert Shape (compound/compsolid/shell/wire) to assembly.

◆ FindComponent()

Standard_Boolean XCAFDoc_ShapeTool::FindComponent ( const TopoDS_Shape theShape,
TDF_LabelSequence Labels 
) const

Serach the path of labels in the document, that corresponds the component from any assembly Try to search the sequence of labels with location that produce this shape as component of any assembly NOTE: Clear sequence of labels before filling.

◆ FindMainShape()

TDF_Label XCAFDoc_ShapeTool::FindMainShape ( const TopoDS_Shape sub) const

Performs a search among top-level shapes to find the shape containing as subshape Checks only simple shapes, and returns the first found label (which should be the only one for valid model)

◆ FindMainShapeUsingMap()

TDF_Label XCAFDoc_ShapeTool::FindMainShapeUsingMap ( const TopoDS_Shape sub) const

◆ FindShape() [1/2]

Standard_Boolean XCAFDoc_ShapeTool::FindShape ( const TopoDS_Shape S,
TDF_Label L,
const Standard_Boolean  findInstance = Standard_False 
) const

Returns the label corresponding to shape S (searches among top-level shapes, not including subcomponents of assemblies and subshapes) If findInstance is False (default), seach for the input shape without location If findInstance is True, searches for the input shape as is. Return True if <S> is found.

◆ FindShape() [2/2]

TDF_Label XCAFDoc_ShapeTool::FindShape ( const TopoDS_Shape S,
const Standard_Boolean  findInstance = Standard_False 
) const

Does the same as previous method Returns Null label if not found.

◆ FindSHUO()

static Standard_Boolean XCAFDoc_ShapeTool::FindSHUO ( const TDF_LabelSequence Labels,
Handle< XCAFDoc_GraphNode > &  theSHUOAttr 
)
static

Searchs the SHUO by labels of components from upper_usage componet to next_usage Returns null attribute if no SHUO found.

◆ FindSubShape()

Standard_Boolean XCAFDoc_ShapeTool::FindSubShape ( const TDF_Label shapeL,
const TopoDS_Shape sub,
TDF_Label L 
) const

Finds a label for subshape of shape stored on label shapeL Returns Null label if it is not found.

◆ GetAllComponentSHUO()

static Standard_Boolean XCAFDoc_ShapeTool::GetAllComponentSHUO ( const TDF_Label CompLabel,
TDF_AttributeSequence SHUOAttrs 
)
static

Returns founded SHUO GraphNodes of indicated component Returns false in other case.

◆ GetAllSHUOInstances()

Standard_Boolean XCAFDoc_ShapeTool::GetAllSHUOInstances ( const Handle< XCAFDoc_GraphNode > &  theSHUO,
TopTools_SequenceOfShape theSHUOShapeSeq 
) const

Seaching for component shapes that styled by shuo Returns empty sequence of shape if no any shape is found.

◆ GetComponents()

static Standard_Boolean XCAFDoc_ShapeTool::GetComponents ( const TDF_Label L,
TDF_LabelSequence Labels,
const Standard_Boolean  getsubchilds = Standard_False 
)
static

Returns list of components of assembly Returns False if label is not assembly.

◆ GetExternRefs()

static void XCAFDoc_ShapeTool::GetExternRefs ( const TDF_Label L,
TColStd_SequenceOfHAsciiString SHAS 
)
static

Gets the names of references on the no-step files.

◆ GetFreeShapes()

void XCAFDoc_ShapeTool::GetFreeShapes ( TDF_LabelSequence FreeLabels) const

Returns a sequence of all top-level shapes which are free (i.e. not referred by any other)

◆ GetID()

static const Standard_GUID& XCAFDoc_ShapeTool::GetID ( )
static

◆ GetLocation()

static TopLoc_Location XCAFDoc_ShapeTool::GetLocation ( const TDF_Label L)
static

Returns location of instance.

◆ GetNamedProperties() [1/2]

Handle< TDataStd_NamedData > XCAFDoc_ShapeTool::GetNamedProperties ( const TDF_Label theLabel,
const Standard_Boolean  theToCreate = Standard_False 
) const

Method to get NamedData attribute assigned to the given shape label.

Parameters
theLabel[in] the shape Label
theToCreate[in] create and assign attribute if it doesn't exist
Returns
Handle to the NamedData attribute or Null if there is none

◆ GetNamedProperties() [2/2]

Handle< TDataStd_NamedData > XCAFDoc_ShapeTool::GetNamedProperties ( const TopoDS_Shape theShape,
const Standard_Boolean  theToCreate = Standard_False 
) const

Method to get NamedData attribute assigned to a label of the given shape.

Parameters
theShape[in] input shape
theToCreate[in] create and assign attribute if it doesn't exist
Returns
Handle to the NamedData attribute or Null if there is none

◆ GetReferredShape()

static Standard_Boolean XCAFDoc_ShapeTool::GetReferredShape ( const TDF_Label L,
TDF_Label Label 
)
static

Returns label which corresponds to a shape referred by L Returns False if label is not reference.

◆ GetShape() [1/2]

static Standard_Boolean XCAFDoc_ShapeTool::GetShape ( const TDF_Label L,
TopoDS_Shape S 
)
static

To get TopoDS_Shape from shape's label For component, returns new shape with correct location Returns False if label does not contain shape.

◆ GetShape() [2/2]

static TopoDS_Shape XCAFDoc_ShapeTool::GetShape ( const TDF_Label L)
static

To get TopoDS_Shape from shape's label For component, returns new shape with correct location Returns Null shape if label does not contain shape.

◆ GetShapes()

void XCAFDoc_ShapeTool::GetShapes ( TDF_LabelSequence Labels) const

Returns a sequence of all top-level shapes.

◆ GetSHUO()

static Standard_Boolean XCAFDoc_ShapeTool::GetSHUO ( const TDF_Label SHUOLabel,
Handle< XCAFDoc_GraphNode > &  aSHUOAttr 
)
static

Returns founded SHUO GraphNode attribute <aSHUOAttr> Returns false in other case.

◆ GetSHUOInstance()

TopoDS_Shape XCAFDoc_ShapeTool::GetSHUOInstance ( const Handle< XCAFDoc_GraphNode > &  theSHUO) const

Search for the component shape that styled by shuo Returns null shape if no any shape is found.

◆ GetSHUONextUsage()

static Standard_Boolean XCAFDoc_ShapeTool::GetSHUONextUsage ( const TDF_Label UpperUsageL,
TDF_LabelSequence Labels 
)
static

Returns the sequence of labels of SHUO attributes, which is next_usage for this upper_usage SHUO attribute (that indicated by label) NOTE: returns next_usages only on one level (not recurse) NOTE: do not clear the sequence before filling.

◆ GetSHUOUpperUsage()

static Standard_Boolean XCAFDoc_ShapeTool::GetSHUOUpperUsage ( const TDF_Label NextUsageL,
TDF_LabelSequence Labels 
)
static

Returns the sequence of labels of SHUO attributes, which is upper_usage for this next_usage SHUO attribute (that indicated by label) NOTE: returns upper_usages only on one level (not recurse) NOTE: do not clear the sequence before filling.

◆ GetSubShapes()

static Standard_Boolean XCAFDoc_ShapeTool::GetSubShapes ( const TDF_Label L,
TDF_LabelSequence Labels 
)
static

Returns list of labels identifying subshapes of the given shape Returns False if no subshapes are placed on that label.

◆ GetUsers()

static Standard_Integer XCAFDoc_ShapeTool::GetUsers ( const TDF_Label L,
TDF_LabelSequence Labels,
const Standard_Boolean  getsubchilds = Standard_False 
)
static

Returns list of labels which refer shape L as component Returns number of users (0 if shape is free)

◆ ID()

const Standard_GUID& XCAFDoc_ShapeTool::ID ( ) const
overridevirtual

Returns the ID of the attribute.

Implements TDF_Attribute.

◆ Init()

void XCAFDoc_ShapeTool::Init ( )

set hasComponents into false

◆ IsAssembly()

static Standard_Boolean XCAFDoc_ShapeTool::IsAssembly ( const TDF_Label L)
static

Returns True if the label is a label of assembly, i.e. contains sublabels which are assembly components This is relevant only if IsShape() is True.

◆ IsComponent()

static Standard_Boolean XCAFDoc_ShapeTool::IsComponent ( const TDF_Label L)
static

Return true if <L> is reference serving as component of assembly.

◆ IsCompound()

static Standard_Boolean XCAFDoc_ShapeTool::IsCompound ( const TDF_Label L)
static

Returns True if the label is a label of compound, i.e. contains some sublabels This is relevant only if IsShape() is True.

◆ IsExternRef()

static Standard_Boolean XCAFDoc_ShapeTool::IsExternRef ( const TDF_Label L)
static

Returns True if the label is a label of external references, i.e. there are some reference on the no-step files, which are described in document only their names.

◆ IsFree()

static Standard_Boolean XCAFDoc_ShapeTool::IsFree ( const TDF_Label L)
static

Returns True if the label is not used by any assembly, i.e. contains sublabels which are assembly components This is relevant only if IsShape() is True (There is no Father TreeNode on this <L>)

◆ IsReference()

static Standard_Boolean XCAFDoc_ShapeTool::IsReference ( const TDF_Label L)
static

Return true if <L> is a located instance of other shape i.e. reference.

◆ IsShape()

static Standard_Boolean XCAFDoc_ShapeTool::IsShape ( const TDF_Label L)
static

Returns True if the label represents a shape (simple shape, assembly or reference)

◆ IsSimpleShape()

static Standard_Boolean XCAFDoc_ShapeTool::IsSimpleShape ( const TDF_Label L)
static

Returns True if the label is a label of simple shape.

◆ IsSubShape() [1/2]

static Standard_Boolean XCAFDoc_ShapeTool::IsSubShape ( const TDF_Label L)
static

Return true if <L> is subshape of the top-level shape.

◆ IsSubShape() [2/2]

Standard_Boolean XCAFDoc_ShapeTool::IsSubShape ( const TDF_Label shapeL,
const TopoDS_Shape sub 
) const

Checks whether shape is subshape of shape stored on label shapeL.

◆ IsTopLevel()

Standard_Boolean XCAFDoc_ShapeTool::IsTopLevel ( const TDF_Label L) const

Returns True if the label is a label of top-level shape, as opposed to component of assembly or subshape.

◆ NbComponents()

static Standard_Integer XCAFDoc_ShapeTool::NbComponents ( const TDF_Label L,
const Standard_Boolean  getsubchilds = Standard_False 
)
static

Returns number of Assembles components.

◆ NewEmpty()

Handle< TDF_Attribute > XCAFDoc_ShapeTool::NewEmpty ( ) const
overridevirtual

Returns an new empty attribute from the good end type. It is used by the copy algorithm.

Implements TDF_Attribute.

◆ NewShape()

TDF_Label XCAFDoc_ShapeTool::NewShape ( ) const

Creates new (empty) top-level shape. Initially it holds empty TopoDS_Compound.

◆ Paste()

void XCAFDoc_ShapeTool::Paste ( const Handle< TDF_Attribute > &  intoAttribute,
const Handle< TDF_RelocationTable > &  aRelocationTable 
) const
overridevirtual

This method is different from the "Copy" one, because it is used when copying an attribute from a source structure into a target structure. This method may paste the contents of <me> into <intoAttribute>.

The given pasted attribute can be full or empty of its contents. But don't make a NEW! Just set the contents!

It is possible to use <aRelocationTable> to get/set the relocation value of a source attribute.

Implements TDF_Attribute.

◆ RemoveComponent()

void XCAFDoc_ShapeTool::RemoveComponent ( const TDF_Label comp) const

Removes a component from its assembly.

◆ RemoveShape()

Standard_Boolean XCAFDoc_ShapeTool::RemoveShape ( const TDF_Label L,
const Standard_Boolean  removeCompletely = Standard_True 
) const

Removes shape (whole label and all its sublabels) If removeCompletely is true, removes complete shape If removeCompletely is false, removes instance(location) only Returns False (and does nothing) if shape is not free or is not top-level shape.

◆ RemoveSHUO()

Standard_Boolean XCAFDoc_ShapeTool::RemoveSHUO ( const TDF_Label SHUOLabel) const

Remove SHUO from component sublabel, remove all dependencies on other SHUO. Returns FALSE if cannot remove SHUO dependencies. NOTE: remove any styles that associated with this SHUO.

◆ Restore()

void XCAFDoc_ShapeTool::Restore ( const Handle< TDF_Attribute > &  anAttribute)
overridevirtual

Restores the backuped contents from <anAttribute> into this one. It is used when aborting a transaction.

Implements TDF_Attribute.

◆ Search()

Standard_Boolean XCAFDoc_ShapeTool::Search ( const TopoDS_Shape S,
TDF_Label L,
const Standard_Boolean  findInstance = Standard_True,
const Standard_Boolean  findComponent = Standard_True,
const Standard_Boolean  findSubshape = Standard_True 
) const

General tool to find a (sub) shape in the document.

  • If findInstance is True, and S has a non-null location, first tries to find the shape among the top-level shapes with this location
  • If not found, and findComponent is True, tries to find the shape among the components of assemblies
  • If not found, tries to find the shape without location among top-level shapes
  • If not found and findSubshape is True, tries to find a shape as a subshape of top-level simple shapes Returns False if nothing is found

◆ SearchUsingMap()

Standard_Boolean XCAFDoc_ShapeTool::SearchUsingMap ( const TopoDS_Shape S,
TDF_Label L,
const Standard_Boolean  findWithoutLoc,
const Standard_Boolean  findSubshape 
) const

◆ Set()

static Handle< XCAFDoc_ShapeTool > XCAFDoc_ShapeTool::Set ( const TDF_Label L)
static

Create (if not exist) ShapeTool from XCAFDoc on <L>.

◆ SetAutoNaming()

static void XCAFDoc_ShapeTool::SetAutoNaming ( const Standard_Boolean  V)
static

Sets auto-naming mode to <V>. If True then for added shapes, links, assemblies and SHUO's, the TDataStd_Name attribute is automatically added. For shapes it contains a shape type (e.g. "SOLID", "SHELL", etc); for links it has a form "=>[0:1:1:2]" (where a tag is a label containing a shape without a location); for assemblies it is "ASSEMBLY", and "SHUO" for SHUO's. This setting is global; it cannot be made a member function as it is used by static methods as well. By default, auto-naming is enabled. See also AutoNaming().

◆ SetExternRefs() [1/2]

TDF_Label XCAFDoc_ShapeTool::SetExternRefs ( const TColStd_SequenceOfHAsciiString SHAS) const

Sets the names of references on the no-step files.

◆ SetExternRefs() [2/2]

void XCAFDoc_ShapeTool::SetExternRefs ( const TDF_Label L,
const TColStd_SequenceOfHAsciiString SHAS 
) const

Sets the names of references on the no-step files.

◆ SetInstanceSHUO()

Handle< XCAFDoc_GraphNode > XCAFDoc_ShapeTool::SetInstanceSHUO ( const TopoDS_Shape theShape) const

Search for the component shape by labelks path and set SHUO structure for founded label structure Returns null attribute if no component in any assembly found.

◆ SetShape()

void XCAFDoc_ShapeTool::SetShape ( const TDF_Label L,
const TopoDS_Shape S 
)

Sets representation (TopoDS_Shape) for top-level shape.

◆ SetSHUO()

Standard_Boolean XCAFDoc_ShapeTool::SetSHUO ( const TDF_LabelSequence Labels,
Handle< XCAFDoc_GraphNode > &  MainSHUOAttr 
) const

Sets the SHUO structure between upper_usage and next_usage create multy-level (if number of labels > 2) SHUO from first to last Initialise out <MainSHUOAttr> by main upper_usage SHUO attribute. Returns FALSE if some of labels in not component label.

◆ UpdateAssemblies()

void XCAFDoc_ShapeTool::UpdateAssemblies ( )

Top-down update for all assembly compounds stored in the document.


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