42cf5bc1 |
1 | // Created by: DAUTRY Philippe |
2 | // Copyright (c) 1997-1999 Matra Datavision |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _TDF_Tool_HeaderFile |
17 | #define _TDF_Tool_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
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> |
31 | class TDF_Label; |
32 | class TDF_IDFilter; |
33 | class TCollection_AsciiString; |
34 | class TDF_Data; |
35 | |
36 | |
37 | //! This class provides general services for a data framework. |
38 | class TDF_Tool |
39 | { |
40 | public: |
41 | |
42 | DEFINE_STANDARD_ALLOC |
43 | |
44 | |
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); |
49 | |
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); |
55 | |
56 | //! Returns the number of attributes of the tree, |
57 | //! selected by a<Filter>, including those of |
58 | //! <aLabel>. |
59 | Standard_EXPORT static Standard_Integer NbAttributes (const TDF_Label& aLabel, const TDF_IDFilter& aFilter); |
60 | |
61 | //! Returns true if <aLabel> and its descendants |
62 | //! reference only attributes or labels attached to |
63 | //! themselves. |
64 | Standard_EXPORT static Standard_Boolean IsSelfContained (const TDF_Label& aLabel); |
65 | |
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); |
70 | |
71 | //! Returns in <theAtts> the attributes having out |
72 | //! references. |
73 | //! |
74 | //! Caution: <theAtts> is not cleared before use! |
75 | Standard_EXPORT static void OutReferers (const TDF_Label& theLabel, TDF_AttributeMap& theAtts); |
76 | |
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); |
82 | |
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); |
86 | |
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); |
91 | |
92 | //! Returns the label having the same sub-entry as |
93 | //! <aLabel> but located as descendant as <toRoot> |
94 | //! instead of <fromRoot>. |
95 | //! |
96 | //! Exemple : |
97 | //! |
98 | //! aLabel = 0:3:24:7:2:7 |
99 | //! fromRoot = 0:3:24 |
100 | //! toRoot = 0:5 |
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); |
103 | |
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); |
108 | |
109 | //! Returns the entry of <aLabel> as list of integers |
110 | //! in <aTagList>. |
111 | Standard_EXPORT static void TagList (const TDF_Label& aLabel, TColStd_ListOfInteger& aTagList); |
112 | |
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); |
116 | |
117 | //! Returns the label expressed by <anEntry>; creates |
118 | //! the label if it does not exist and if <create> is |
119 | //! true. |
120 | Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const TCollection_AsciiString& anEntry, TDF_Label& aLabel, const Standard_Boolean create = Standard_False); |
121 | |
122 | //! Returns the label expressed by <anEntry>; creates |
123 | //! the label if it does not exist and if <create> is |
124 | //! true. |
125 | Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const Standard_CString anEntry, TDF_Label& aLabel, const Standard_Boolean create = Standard_False); |
126 | |
127 | //! Returns the label expressed by <anEntry>; creates |
128 | //! the label if it does not exist and if <create> is |
129 | //! true. |
130 | Standard_EXPORT static void Label (const Handle(TDF_Data)& aDF, const TColStd_ListOfInteger& aTagList, TDF_Label& aLabel, const Standard_Boolean create = Standard_False); |
131 | |
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); |
137 | |
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); |
143 | |
144 | //! Dumps <aDF> and its labels and their attributes. |
145 | Standard_EXPORT static void DeepDump (Standard_OStream& anOS, const Handle(TDF_Data)& aDF); |
146 | |
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); |
151 | |
152 | //! Dumps <aLabel>, its chilren and their attributes. |
153 | Standard_EXPORT static void DeepDump (Standard_OStream& anOS, const TDF_Label& aLabel); |
154 | |
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); |
159 | |
160 | |
161 | |
162 | |
163 | protected: |
164 | |
165 | |
166 | |
167 | |
168 | |
169 | private: |
170 | |
171 | |
172 | |
173 | |
174 | |
175 | }; |
176 | |
177 | |
178 | |
179 | |
180 | |
181 | |
182 | |
183 | #endif // _TDF_Tool_HeaderFile |