42cf5bc1 |
1 | // Created on: 2000-06-15 |
2 | // Created by: Edward AGAPOV |
3 | // Copyright (c) 2000-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 _XCAFDoc_ShapeTool_HeaderFile |
17 | #define _XCAFDoc_ShapeTool_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
22 | #include <XCAFDoc_DataMapOfShapeLabel.hxx> |
23 | #include <Standard_Boolean.hxx> |
07f20646 |
24 | #include <TDataStd_NamedData.hxx> |
42cf5bc1 |
25 | #include <TDF_Attribute.hxx> |
26 | #include <TDF_LabelSequence.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <Standard_OStream.hxx> |
29 | #include <TColStd_SequenceOfHAsciiString.hxx> |
30 | #include <TDF_AttributeSequence.hxx> |
31 | #include <TopTools_SequenceOfShape.hxx> |
32 | class Standard_GUID; |
33 | class TDF_Label; |
34 | class TopoDS_Shape; |
35 | class TopLoc_Location; |
36 | class TDF_Attribute; |
37 | class TDF_RelocationTable; |
38 | class XCAFDoc_GraphNode; |
39 | |
40 | |
41 | class XCAFDoc_ShapeTool; |
42 | DEFINE_STANDARD_HANDLE(XCAFDoc_ShapeTool, TDF_Attribute) |
43 | |
44 | //! A tool to store shapes in an XDE |
45 | //! document in the form of assembly structure, and to maintain this structure. |
46 | //! Attribute containing Shapes section of DECAF document. |
47 | //! Provide tools for management of Shapes section. |
48 | //! The API provided by this class allows to work with this |
49 | //! structure regardless of its low-level implementation. |
50 | //! All the shapes are stored on child labels of a main label which is |
51 | //! XCAFDoc_DocumentTool::LabelShapes(). The label for assembly also has |
52 | //! sub-labels, each of which represents the instance of |
53 | //! another shape in that assembly (component). Such sub-label |
54 | //! stores reference to the label of the original shape in the form |
55 | //! of TDataStd_TreeNode with GUID XCAFDoc::ShapeRefGUID(), and its |
56 | //! location encapsulated into the NamedShape. |
57 | //! For correct work with an XDE document, it is necessary to use |
58 | //! methods for analysis and methods for working with shapes. |
59 | //! For example: |
60 | //! if ( STool->IsAssembly(aLabel) ) |
61 | //! { Standard_Boolean subchilds = Standard_False; (default) |
62 | //! Standard_Integer nbc = STool->NbComponents |
63 | //! (aLabel[,subchilds]); |
64 | //! } |
65 | //! If subchilds is True, commands also consider sub-levels. By |
66 | //! default, only level one is checked. |
67 | //! In this example, number of children from the first level of |
68 | //! assembly will be returned. Methods for creation and initialization: |
69 | //! Constructor: |
70 | //! XCAFDoc_ShapeTool::XCAFDoc_ShapeTool() |
71 | //! Getting a guid: |
72 | //! Standard_GUID GetID (); |
73 | //! Creation (if does not exist) of ShapeTool on label L: |
74 | //! Handle(XCAFDoc_ShapeTool) XCAFDoc_ShapeTool::Set(const TDF_Label& L) |
75 | //! Analyze whether shape is a simple shape or an instance or a |
76 | //! component of an assembly or it is an assembly ( methods of analysis). |
77 | //! For example: |
78 | //! STool->IsShape(aLabel) ; |
79 | //! Analyze that the label represents a shape (simple |
80 | //! shape, assembly or reference) or |
81 | //! STool->IsTopLevel(aLabel); |
82 | //! Analyze that the label is a label of a top-level shape. |
83 | //! Work with simple shapes, assemblies and instances ( |
84 | //! methods for work with shapes). |
85 | //! For example: |
86 | //! Add shape: |
87 | //! Standard_Boolean makeAssembly; |
88 | //! // True to interpret a Compound as an Assembly, False to take it |
89 | //! as a whole |
90 | //! aLabel = STool->AddShape(aShape, makeAssembly); |
91 | //! Get shape: |
92 | //! TDF_Label aLabel... |
93 | //! // A label must be present if |
94 | //! (aLabel.IsNull()) { ... no such label : abandon .. } |
95 | //! TopoDS_Shape aShape; |
96 | //! aShape = STool->GetShape(aLabel); |
97 | //! if (aShape.IsNull()) |
98 | //! { ... this label is not for a Shape ... } |
99 | //! To get a label from shape. |
100 | //! Standard_Boolean findInstance = Standard_False; |
101 | //! (this is default value) |
102 | //! aLabel = STool->FindShape(aShape [,findInstance]); |
103 | //! if (aLabel.IsNull()) |
104 | //! { ... no label found for this shape ... } |
105 | class XCAFDoc_ShapeTool : public TDF_Attribute |
106 | { |
107 | |
108 | public: |
109 | |
110 | |
111 | Standard_EXPORT static const Standard_GUID& GetID(); |
112 | |
113 | //! Create (if not exist) ShapeTool from XCAFDoc on <L>. |
114 | Standard_EXPORT static Handle(XCAFDoc_ShapeTool) Set (const TDF_Label& L); |
115 | |
116 | //! Creates an empty tool |
117 | //! Creates a tool to work with a document <Doc> |
118 | //! Attaches to label XCAFDoc::LabelShapes() |
119 | Standard_EXPORT XCAFDoc_ShapeTool(); |
120 | |
121 | //! Returns True if the label is a label of top-level shape, |
122 | //! as opposed to component of assembly or subshape |
123 | Standard_EXPORT Standard_Boolean IsTopLevel (const TDF_Label& L) const; |
124 | |
125 | //! Returns True if the label is not used by any assembly, i.e. |
126 | //! contains sublabels which are assembly components |
127 | //! This is relevant only if IsShape() is True |
128 | //! (There is no Father TreeNode on this <L>) |
129 | Standard_EXPORT static Standard_Boolean IsFree (const TDF_Label& L); |
130 | |
131 | //! Returns True if the label represents a shape (simple shape, |
132 | //! assembly or reference) |
133 | Standard_EXPORT static Standard_Boolean IsShape (const TDF_Label& L); |
134 | |
135 | //! Returns True if the label is a label of simple shape |
136 | Standard_EXPORT static Standard_Boolean IsSimpleShape (const TDF_Label& L); |
137 | |
138 | //! Return true if <L> is a located instance of other shape |
139 | //! i.e. reference |
140 | Standard_EXPORT static Standard_Boolean IsReference (const TDF_Label& L); |
141 | |
142 | //! Returns True if the label is a label of assembly, i.e. |
143 | //! contains sublabels which are assembly components |
144 | //! This is relevant only if IsShape() is True |
145 | Standard_EXPORT static Standard_Boolean IsAssembly (const TDF_Label& L); |
146 | |
147 | //! Return true if <L> is reference serving as component |
148 | //! of assembly |
149 | Standard_EXPORT static Standard_Boolean IsComponent (const TDF_Label& L); |
150 | |
151 | //! Returns True if the label is a label of compound, i.e. |
152 | //! contains some sublabels |
153 | //! This is relevant only if IsShape() is True |
154 | Standard_EXPORT static Standard_Boolean IsCompound (const TDF_Label& L); |
155 | |
156 | //! Return true if <L> is subshape of the top-level shape |
157 | Standard_EXPORT static Standard_Boolean IsSubShape (const TDF_Label& L); |
158 | |
159 | //! Checks whether shape <sub> is subshape of shape stored on |
160 | //! label shapeL |
161 | Standard_EXPORT Standard_Boolean IsSubShape (const TDF_Label& shapeL, const TopoDS_Shape& sub) const; |
162 | |
163 | Standard_EXPORT Standard_Boolean SearchUsingMap (const TopoDS_Shape& S, TDF_Label& L, const Standard_Boolean findWithoutLoc, const Standard_Boolean findSubshape) const; |
164 | |
165 | //! General tool to find a (sub) shape in the document |
166 | //! * If findInstance is True, and S has a non-null location, |
167 | //! first tries to find the shape among the top-level shapes |
168 | //! with this location |
169 | //! * If not found, and findComponent is True, tries to find the shape |
170 | //! among the components of assemblies |
171 | //! * If not found, tries to find the shape without location |
172 | //! among top-level shapes |
173 | //! * If not found and findSubshape is True, tries to find a |
174 | //! shape as a subshape of top-level simple shapes |
175 | //! Returns False if nothing is found |
176 | Standard_EXPORT 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; |
177 | |
178 | //! Returns the label corresponding to shape S |
179 | //! (searches among top-level shapes, not including subcomponents |
7783ba11 |
180 | //! of assemblies and subshapes) |
181 | //! If findInstance is False (default), seach for the |
182 | //! input shape without location |
183 | //! If findInstance is True, searches for the |
184 | //! input shape as is. |
42cf5bc1 |
185 | //! Return True if <S> is found. |
186 | Standard_EXPORT Standard_Boolean FindShape (const TopoDS_Shape& S, TDF_Label& L, const Standard_Boolean findInstance = Standard_False) const; |
187 | |
188 | //! Does the same as previous method |
189 | //! Returns Null label if not found |
190 | Standard_EXPORT TDF_Label FindShape (const TopoDS_Shape& S, const Standard_Boolean findInstance = Standard_False) const; |
191 | |
192 | //! To get TopoDS_Shape from shape's label |
193 | //! For component, returns new shape with correct location |
194 | //! Returns False if label does not contain shape |
195 | Standard_EXPORT static Standard_Boolean GetShape (const TDF_Label& L, TopoDS_Shape& S); |
196 | |
197 | //! To get TopoDS_Shape from shape's label |
198 | //! For component, returns new shape with correct location |
199 | //! Returns Null shape if label does not contain shape |
200 | Standard_EXPORT static TopoDS_Shape GetShape (const TDF_Label& L); |
201 | |
202 | //! Creates new (empty) top-level shape. |
203 | //! Initially it holds empty TopoDS_Compound |
204 | Standard_EXPORT TDF_Label NewShape() const; |
205 | |
206 | //! Sets representation (TopoDS_Shape) for top-level shape. |
42cf5bc1 |
207 | Standard_EXPORT void SetShape (const TDF_Label& L, const TopoDS_Shape& S); |
208 | |
209 | //! Adds a new top-level (creates and returns a new label) |
210 | //! If makeAssembly is True, treats TopAbs_COMPOUND shapes |
211 | //! as assemblies (creates assembly structure). |
212 | //! NOTE: <makePrepare> replace components without location |
213 | //! in assmebly by located components to avoid some problems. |
214 | //! If AutoNaming() is True then automatically attaches names. |
215 | Standard_EXPORT TDF_Label AddShape (const TopoDS_Shape& S, const Standard_Boolean makeAssembly = Standard_True, const Standard_Boolean makePrepare = Standard_True); |
216 | |
217 | //! Removes shape (whole label and all its sublabels) |
218 | //! If removeCompletely is true, removes complete shape |
219 | //! If removeCompletely is false, removes instance(location) only |
220 | //! Returns False (and does nothing) if shape is not free |
221 | //! or is not top-level shape |
222 | Standard_EXPORT Standard_Boolean RemoveShape (const TDF_Label& L, const Standard_Boolean removeCompletely = Standard_True) const; |
223 | |
224 | //! set hasComponents into false |
225 | Standard_EXPORT void Init(); |
226 | |
227 | //! Sets auto-naming mode to <V>. If True then for added |
228 | //! shapes, links, assemblies and SHUO's, the TDataStd_Name attribute |
229 | //! is automatically added. For shapes it contains a shape type |
230 | //! (e.g. "SOLID", "SHELL", etc); for links it has a form |
231 | //! "=>[0:1:1:2]" (where a tag is a label containing a shape |
232 | //! without a location); for assemblies it is "ASSEMBLY", and |
233 | //! "SHUO" for SHUO's. |
234 | //! This setting is global; it cannot be made a member function |
235 | //! as it is used by static methods as well. |
236 | //! By default, auto-naming is enabled. |
237 | //! See also AutoNaming(). |
238 | Standard_EXPORT static void SetAutoNaming (const Standard_Boolean V); |
239 | |
240 | //! Returns current auto-naming mode. See SetAutoNaming() for |
241 | //! description. |
242 | Standard_EXPORT static Standard_Boolean AutoNaming(); |
243 | |
244 | //! recursive |
245 | Standard_EXPORT void ComputeShapes (const TDF_Label& L); |
246 | |
247 | //! Compute a sequence of simple shapes |
248 | Standard_EXPORT void ComputeSimpleShapes(); |
249 | |
250 | //! Returns a sequence of all top-level shapes |
251 | Standard_EXPORT void GetShapes (TDF_LabelSequence& Labels) const; |
252 | |
253 | //! Returns a sequence of all top-level shapes |
254 | //! which are free (i.e. not referred by any other) |
255 | Standard_EXPORT void GetFreeShapes (TDF_LabelSequence& FreeLabels) const; |
256 | |
257 | //! Returns list of labels which refer shape L as component |
258 | //! Returns number of users (0 if shape is free) |
259 | Standard_EXPORT static Standard_Integer GetUsers (const TDF_Label& L, TDF_LabelSequence& Labels, const Standard_Boolean getsubchilds = Standard_False); |
260 | |
261 | //! Returns location of instance |
262 | Standard_EXPORT static TopLoc_Location GetLocation (const TDF_Label& L); |
263 | |
264 | //! Returns label which corresponds to a shape referred by L |
265 | //! Returns False if label is not reference |
266 | Standard_EXPORT static Standard_Boolean GetReferredShape (const TDF_Label& L, TDF_Label& Label); |
267 | |
268 | //! Returns number of Assembles components |
269 | Standard_EXPORT static Standard_Integer NbComponents (const TDF_Label& L, const Standard_Boolean getsubchilds = Standard_False); |
270 | |
271 | //! Returns list of components of assembly |
272 | //! Returns False if label is not assembly |
273 | Standard_EXPORT static Standard_Boolean GetComponents (const TDF_Label& L, TDF_LabelSequence& Labels, const Standard_Boolean getsubchilds = Standard_False); |
274 | |
275 | //! Adds a component given by its label and location to the assembly |
276 | //! Note: assembly must be IsAssembly() or IsSimpleShape() |
63cdf48e |
277 | Standard_EXPORT TDF_Label AddComponent (const TDF_Label& assembly, const TDF_Label& comp, const TopLoc_Location& Loc); |
42cf5bc1 |
278 | |
279 | //! Adds a shape (located) as a component to the assembly |
280 | //! If necessary, creates an additional top-level shape for |
281 | //! component and return the Label of component. |
282 | //! If expand is True and component is Compound, it will |
283 | //! be created as assembly also |
284 | //! Note: assembly must be IsAssembly() or IsSimpleShape() |
285 | Standard_EXPORT TDF_Label AddComponent (const TDF_Label& assembly, const TopoDS_Shape& comp, const Standard_Boolean expand = Standard_False); |
286 | |
287 | //! Removes a component from its assembly |
288 | Standard_EXPORT void RemoveComponent (const TDF_Label& comp) const; |
289 | |
acc909a8 |
290 | //! Top-down update for all assembly compounds stored in the document. |
291 | Standard_EXPORT void UpdateAssemblies(); |
42cf5bc1 |
292 | |
293 | //! Finds a label for subshape <sub> of shape stored on |
294 | //! label shapeL |
295 | //! Returns Null label if it is not found |
296 | Standard_EXPORT Standard_Boolean FindSubShape (const TDF_Label& shapeL, const TopoDS_Shape& sub, TDF_Label& L) const; |
297 | |
298 | //! Adds a label for subshape <sub> of shape stored on |
299 | //! label shapeL |
300 | //! Returns Null label if it is not subshape |
301 | Standard_EXPORT TDF_Label AddSubShape (const TDF_Label& shapeL, const TopoDS_Shape& sub) const; |
d6b200e0 |
302 | |
303 | //! Adds (of finds already existed) a label for subshape <sub> of shape stored on |
304 | //! label shapeL. Label addedSubShapeL returns added (found) label or empty in case of wrong subshape. |
305 | //! Returns True, if new shape was added, False in case of already existed subshape/wrong subshape |
306 | Standard_EXPORT Standard_Boolean AddSubShape(const TDF_Label& shapeL, const TopoDS_Shape& sub, TDF_Label& addedSubShapeL) const; |
42cf5bc1 |
307 | |
308 | Standard_EXPORT TDF_Label FindMainShapeUsingMap (const TopoDS_Shape& sub) const; |
309 | |
310 | //! Performs a search among top-level shapes to find |
311 | //! the shape containing <sub> as subshape |
312 | //! Checks only simple shapes, and returns the first found |
313 | //! label (which should be the only one for valid model) |
314 | Standard_EXPORT TDF_Label FindMainShape (const TopoDS_Shape& sub) const; |
315 | |
316 | //! Returns list of labels identifying subshapes of the given shape |
317 | //! Returns False if no subshapes are placed on that label |
318 | Standard_EXPORT static Standard_Boolean GetSubShapes (const TDF_Label& L, TDF_LabelSequence& Labels); |
319 | |
320 | //! returns the label under which shapes are stored |
321 | Standard_EXPORT TDF_Label BaseLabel() const; |
322 | |
201c2208 |
323 | Standard_EXPORT Standard_OStream& Dump (Standard_OStream& theDumpLog, const Standard_Boolean deep) const; |
324 | |
325 | Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& theDumpLog) const Standard_OVERRIDE; |
326 | |
04232180 |
327 | //! Print to std::ostream <theDumpLog> type of shape found on <L> label |
42cf5bc1 |
328 | //! and the entry of <L>, with <level> tabs before. |
329 | //! If <deep>, print also TShape and Location addresses |
330 | Standard_EXPORT static void DumpShape (Standard_OStream& theDumpLog, const TDF_Label& L, const Standard_Integer level = 0, const Standard_Boolean deep = Standard_False); |
331 | |
79104795 |
332 | Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; |
42cf5bc1 |
333 | |
79104795 |
334 | Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE; |
42cf5bc1 |
335 | |
79104795 |
336 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; |
42cf5bc1 |
337 | |
79104795 |
338 | Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE; |
42cf5bc1 |
339 | |
340 | //! Returns True if the label is a label of external references, i.e. |
341 | //! there are some reference on the no-step files, which are |
342 | //! described in document only their names |
343 | Standard_EXPORT static Standard_Boolean IsExternRef (const TDF_Label& L); |
344 | |
345 | //! Sets the names of references on the no-step files |
346 | Standard_EXPORT TDF_Label SetExternRefs (const TColStd_SequenceOfHAsciiString& SHAS) const; |
347 | |
348 | //! Sets the names of references on the no-step files |
349 | Standard_EXPORT void SetExternRefs (const TDF_Label& L, const TColStd_SequenceOfHAsciiString& SHAS) const; |
350 | |
351 | //! Gets the names of references on the no-step files |
352 | Standard_EXPORT static void GetExternRefs (const TDF_Label& L, TColStd_SequenceOfHAsciiString& SHAS); |
353 | |
354 | //! Sets the SHUO structure between upper_usage and next_usage |
355 | //! create multy-level (if number of labels > 2) SHUO from first to last |
356 | //! Initialise out <MainSHUOAttr> by main upper_usage SHUO attribute. |
357 | //! Returns FALSE if some of labels in not component label |
358 | Standard_EXPORT Standard_Boolean SetSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& MainSHUOAttr) const; |
359 | |
360 | //! Returns founded SHUO GraphNode attribute <aSHUOAttr> |
361 | //! Returns false in other case |
362 | Standard_EXPORT static Standard_Boolean GetSHUO (const TDF_Label& SHUOLabel, Handle(XCAFDoc_GraphNode)& aSHUOAttr); |
363 | |
364 | //! Returns founded SHUO GraphNodes of indicated component |
365 | //! Returns false in other case |
366 | Standard_EXPORT static Standard_Boolean GetAllComponentSHUO (const TDF_Label& CompLabel, TDF_AttributeSequence& SHUOAttrs); |
367 | |
368 | //! Returns the sequence of labels of SHUO attributes, |
369 | //! which is upper_usage for this next_usage SHUO attribute |
370 | //! (that indicated by label) |
371 | //! NOTE: returns upper_usages only on one level (not recurse) |
372 | //! NOTE: do not clear the sequence before filling |
373 | Standard_EXPORT static Standard_Boolean GetSHUOUpperUsage (const TDF_Label& NextUsageL, TDF_LabelSequence& Labels); |
374 | |
375 | //! Returns the sequence of labels of SHUO attributes, |
376 | //! which is next_usage for this upper_usage SHUO attribute |
377 | //! (that indicated by label) |
378 | //! NOTE: returns next_usages only on one level (not recurse) |
379 | //! NOTE: do not clear the sequence before filling |
380 | Standard_EXPORT static Standard_Boolean GetSHUONextUsage (const TDF_Label& UpperUsageL, TDF_LabelSequence& Labels); |
381 | |
382 | //! Remove SHUO from component sublabel, |
383 | //! remove all dependencies on other SHUO. |
384 | //! Returns FALSE if cannot remove SHUO dependencies. |
385 | //! NOTE: remove any styles that associated with this SHUO. |
386 | Standard_EXPORT Standard_Boolean RemoveSHUO (const TDF_Label& SHUOLabel) const; |
387 | |
388 | //! Serach the path of labels in the document, |
389 | //! that corresponds the component from any assembly |
390 | //! Try to search the sequence of labels with location that |
391 | //! produce this shape as component of any assembly |
392 | //! NOTE: Clear sequence of labels before filling |
393 | Standard_EXPORT Standard_Boolean FindComponent (const TopoDS_Shape& theShape, TDF_LabelSequence& Labels) const; |
394 | |
395 | //! Search for the component shape that styled by shuo |
396 | //! Returns null shape if no any shape is found. |
397 | Standard_EXPORT TopoDS_Shape GetSHUOInstance (const Handle(XCAFDoc_GraphNode)& theSHUO) const; |
398 | |
399 | //! Search for the component shape by labelks path |
400 | //! and set SHUO structure for founded label structure |
401 | //! Returns null attribute if no component in any assembly found. |
402 | Standard_EXPORT Handle(XCAFDoc_GraphNode) SetInstanceSHUO (const TopoDS_Shape& theShape) const; |
403 | |
404 | //! Seaching for component shapes that styled by shuo |
405 | //! Returns empty sequence of shape if no any shape is found. |
406 | Standard_EXPORT Standard_Boolean GetAllSHUOInstances (const Handle(XCAFDoc_GraphNode)& theSHUO, TopTools_SequenceOfShape& theSHUOShapeSeq) const; |
407 | |
408 | //! Searchs the SHUO by labels of components |
409 | //! from upper_usage componet to next_usage |
410 | //! Returns null attribute if no SHUO found |
411 | Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr); |
5f07d05d |
412 | |
00dfcc76 |
413 | //! Convert Shape (compound/compsolid/shell/wire) to assembly |
07f20646 |
414 | Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape); |
42cf5bc1 |
415 | |
07f20646 |
416 | //! Method to get NamedData attribute assigned to the given shape label. |
417 | //! @param theLabel [in] the shape Label |
418 | //! @param theToCreate [in] create and assign attribute if it doesn't exist |
419 | //! @return Handle to the NamedData attribute or Null if there is none |
420 | Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties (const TDF_Label& theLabel, const Standard_Boolean theToCreate = Standard_False) const; |
421 | |
422 | //! Method to get NamedData attribute assigned to a label of the given shape. |
423 | //! @param theShape [in] input shape |
424 | //! @param theToCreate [in] create and assign attribute if it doesn't exist |
425 | //! @return Handle to the NamedData attribute or Null if there is none |
426 | Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties(const TopoDS_Shape& theShape, const Standard_Boolean theToCreate = Standard_False) const; |
bc73b006 |
427 | |
428 | //! Dumps the content of me into the stream |
429 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
42cf5bc1 |
430 | |
92efcf78 |
431 | DEFINE_STANDARD_RTTIEXT(XCAFDoc_ShapeTool,TDF_Attribute) |
42cf5bc1 |
432 | |
433 | protected: |
434 | |
435 | |
436 | |
437 | |
438 | private: |
439 | |
acc909a8 |
440 | //! Checks recursively if the given assembly item is modified. If so, its |
441 | //! associated compound is updated. Returns true if the assembly item is |
442 | //! modified, false -- otherwise. |
443 | Standard_EXPORT Standard_Boolean updateComponent(const TDF_Label& theAssmLabel, |
444 | TopoDS_Shape& theUpdatedShape) const; |
445 | |
42cf5bc1 |
446 | //! Adds a new top-level (creates and returns a new label) |
447 | //! For internal use. Used by public method AddShape. |
448 | Standard_EXPORT TDF_Label addShape (const TopoDS_Shape& S, const Standard_Boolean makeAssembly = Standard_True); |
449 | |
450 | //! Makes a shape on label L to be a reference to shape refL |
451 | //! with location loc |
452 | Standard_EXPORT static void MakeReference (const TDF_Label& L, const TDF_Label& refL, const TopLoc_Location& loc); |
453 | |
f277ba37 |
454 | //! Auxiliary method for Expand |
fcdb829c |
455 | //! Add declared under expanded theMainShapeL subshapes to new part label thePart |
456 | //! Recursively iterate all subshapes of shape from thePart, current shape to iterate its subshapes is theShape. |
f277ba37 |
457 | Standard_EXPORT void makeSubShape(const TDF_Label& theMainShapeL, const TDF_Label& thePart, const TopoDS_Shape& theShape, const TopLoc_Location& theLoc); |
458 | |
42cf5bc1 |
459 | XCAFDoc_DataMapOfShapeLabel myShapeLabels; |
460 | XCAFDoc_DataMapOfShapeLabel mySubShapes; |
461 | XCAFDoc_DataMapOfShapeLabel mySimpleShapes; |
462 | Standard_Boolean hasSimpleShapes; |
463 | |
464 | |
465 | }; |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | #endif // _XCAFDoc_ShapeTool_HeaderFile |