1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _TDF_Tool_HeaderFile
17 #define _TDF_Tool_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <TDF_AttributeMap.hxx>
26 #include <TColStd_ListOfInteger.hxx>
27 #include <Standard_CString.hxx>
28 #include <TDF_LabelList.hxx>
29 #include <TDF_LabelIntegerMap.hxx>
30 #include <Standard_OStream.hxx>
33 class TCollection_AsciiString;
37 //! This class provides general services for a data framework.
45 //! Returns the number of labels of the tree,
46 //! including <aLabel>. aLabel is also included in this figure.
47 //! This information is useful in setting the size of an array.
48 Standard_EXPORT static Standard_Integer NbLabels (const TDF_Label& aLabel);
50 //! Returns the total number of attributes attached
51 //! to the labels dependent on the label aLabel.
52 //! The attributes of aLabel are also included in this figure.
53 //! This information is useful in setting the size of an array.
54 Standard_EXPORT static Standard_Integer NbAttributes (const TDF_Label& aLabel);
56 //! Returns the number of attributes of the tree,
57 //! selected by a<Filter>, including those of
59 Standard_EXPORT static Standard_Integer NbAttributes (const TDF_Label& aLabel, const TDF_IDFilter& aFilter);
61 //! Returns true if <aLabel> and its descendants
62 //! reference only attributes or labels attached to
64 Standard_EXPORT static Standard_Boolean IsSelfContained (const TDF_Label& aLabel);
66 //! Returns true if <aLabel> and its descendants
67 //! reference only attributes or labels attached to
68 //! themselves and kept by <aFilter>.
69 Standard_EXPORT static Standard_Boolean IsSelfContained (const TDF_Label& aLabel, const TDF_IDFilter& aFilter);
71 //! Returns in <theAtts> the attributes having out
74 //! Caution: <theAtts> is not cleared before use!
75 Standard_EXPORT static void OutReferers (const TDF_Label& theLabel, TDF_AttributeMap& theAtts);
77 //! Returns in <atts> the attributes having out
78 //! references and kept by <aFilterForReferers>.
79 //! It considers only the references kept by <aFilterForReferences>.
80 //! Caution: <atts> is not cleared before use!
81 Standard_EXPORT static void OutReferers (const TDF_Label& aLabel, const TDF_IDFilter& aFilterForReferers, const TDF_IDFilter& aFilterForReferences, TDF_AttributeMap& atts);
83 //! Returns in <atts> the referenced attributes.
84 //! Caution: <atts> is not cleared before use!
85 Standard_EXPORT static void OutReferences (const TDF_Label& aLabel, TDF_AttributeMap& atts);
87 //! Returns in <atts> the referenced attributes and kept by <aFilterForReferences>.
88 //! It considers only the referers kept by <aFilterForReferers>.
89 //! Caution: <atts> is not cleared before use!
90 Standard_EXPORT static void OutReferences (const TDF_Label& aLabel, const TDF_IDFilter& aFilterForReferers, const TDF_IDFilter& aFilterForReferences, TDF_AttributeMap& atts);
92 //! Returns the label having the same sub-entry as
93 //! <aLabel> but located as descendant as <toRoot>
94 //! instead of <fromRoot>.
98 //! aLabel = 0:3:24:7:2:7
101 //! returned label = 0:5:7:2:7
102 Standard_EXPORT static void RelocateLabel (const TDF_Label& aSourceLabel, const TDF_Label& fromRoot, const TDF_Label& toRoot, TDF_Label& aTargetLabel, const Standard_Boolean create = Standard_False);
104 //! Returns the entry for the label aLabel in the form
105 //! of the ASCII character string anEntry containing
106 //! the tag list for aLabel.
107 Standard_EXPORT static void Entry (const TDF_Label& aLabel, TCollection_AsciiString& anEntry);
109 //! Returns the entry of <aLabel> as list of integers
111 Standard_EXPORT static void TagList (const TDF_Label& aLabel, TColStd_ListOfInteger& aTagList);
113 //! Returns the entry expressed by <anEntry> as list
114 //! of integers in <aTagList>.
115 Standard_EXPORT static void TagList (const TCollection_AsciiString& anEntry, TColStd_ListOfInteger& aTagList);
117 //! Returns the label expressed by <anEntry>; creates
118 //! the label if it does not exist and if <create> is
120 Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const TCollection_AsciiString& anEntry, TDF_Label& aLabel, const Standard_Boolean create = Standard_False);
122 //! Returns the label expressed by <anEntry>; creates
123 //! the label if it does not exist and if <create> is
125 Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const Standard_CString anEntry, TDF_Label& aLabel, const Standard_Boolean create = Standard_False);
127 //! Returns the label expressed by <anEntry>; creates
128 //! the label if it does not exist and if <create> is
130 Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const TColStd_ListOfInteger& aTagList, TDF_Label& aLabel, const Standard_Boolean create = Standard_False);
132 //! Adds the labels of <aLabelList> to <aLabelMap> if
133 //! they are unbound, or increases their reference
134 //! counters. At the end of the process, <aLabelList>
135 //! contains only the ADDED labels.
136 Standard_EXPORT static void CountLabels (TDF_LabelList& aLabelList, TDF_LabelIntegerMap& aLabelMap);
138 //! Decreases the reference counters of the labels of
139 //! <aLabelList> to <aLabelMap>, and removes labels
140 //! with null counter. At the end of the process,
141 //! <aLabelList> contains only the SUPPRESSED labels.
142 Standard_EXPORT static void DeductLabels (TDF_LabelList& aLabelList, TDF_LabelIntegerMap& aLabelMap);
144 //! Dumps <aDF> and its labels and their attributes.
145 Standard_EXPORT static void DeepDump (Standard_OStream& anOS, const Handle(TDF_Data)& aDF);
147 //! Dumps <aDF> and its labels and their attributes,
148 //! if their IDs are kept by <aFilter>. Dumps also the
149 //! attributes content.
150 Standard_EXPORT static void ExtendedDeepDump (Standard_OStream& anOS, const Handle(TDF_Data)& aDF, const TDF_IDFilter& aFilter);
152 //! Dumps <aLabel>, its chilren and their attributes.
153 Standard_EXPORT static void DeepDump (Standard_OStream& anOS, const TDF_Label& aLabel);
155 //! Dumps <aLabel>, its chilren and their attributes,
156 //! if their IDs are kept by <aFilter>. Dumps also the
157 //! attributes content.
158 Standard_EXPORT static void ExtendedDeepDump (Standard_OStream& anOS, const TDF_Label& aLabel, const TDF_IDFilter& aFilter);
183 #endif // _TDF_Tool_HeaderFile