1 // Created on: 2000-08-03
2 // Created by: data exchange team
3 // Copyright (c) 2000-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 #include <XCAFDoc_ShapeTool.hxx>
18 #include <BRep_Builder.hxx>
20 #include <gp_Trsf.hxx>
21 #include <Standard_Type.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TCollection_ExtendedString.hxx>
24 #include <TCollection_HAsciiString.hxx>
25 #include <TColStd_SequenceOfHAsciiString.hxx>
26 #include <TDataStd_Name.hxx>
27 #include <TDataStd_TreeNode.hxx>
28 #include <TDataStd_UAttribute.hxx>
29 #include <TDF_Attribute.hxx>
30 #include <TDF_ChildIDIterator.hxx>
31 #include <TDF_ChildIterator.hxx>
32 #include <TDF_Label.hxx>
33 #include <TDF_LabelMap.hxx>
34 #include <TDF_LabelSequence.hxx>
35 #include <TDF_RelocationTable.hxx>
36 #include <TDF_Tool.hxx>
37 #include <TDocStd_Document.hxx>
38 #include <TNaming_Builder.hxx>
39 #include <TNaming_Tool.hxx>
40 #include <TopLoc_IndexedMapOfLocation.hxx>
41 #include <TopLoc_Location.hxx>
42 #include <TopoDS_Compound.hxx>
43 #include <TopoDS_Iterator.hxx>
44 #include <TopoDS_Shape.hxx>
45 #include <TopTools_ListOfShape.hxx>
46 #include <TopTools_MapOfOrientedShape.hxx>
47 #include <XCAFDoc.hxx>
48 #include <XCAFDoc_GraphNode.hxx>
49 #include <XCAFDoc_Location.hxx>
50 #include <XCAFDoc_ShapeMapTool.hxx>
51 #include <TopLoc_Datum3D.hxx>
53 IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_ShapeTool,TDataStd_GenericEmpty,"xcaf","ShapeTool")
55 static Standard_Boolean theAutoNaming = Standard_True;
57 // attribute methods //////////////////////////////////////////////////
59 //=======================================================================
62 //=======================================================================
64 const Standard_GUID& XCAFDoc_ShapeTool::GetID()
66 static Standard_GUID ShapeToolID ("efd212ee-6dfd-11d4-b9c8-0060b0ee281b");
71 //=======================================================================
74 //=======================================================================
76 Handle(XCAFDoc_ShapeTool) XCAFDoc_ShapeTool::Set(const TDF_Label& L)
78 Handle(XCAFDoc_ShapeTool) A;
79 if (!L.FindAttribute (XCAFDoc_ShapeTool::GetID(), A)) {
80 A = new XCAFDoc_ShapeTool ();
88 //=======================================================================
89 //function : Constructor
91 //=======================================================================
93 XCAFDoc_ShapeTool::XCAFDoc_ShapeTool()
95 hasSimpleShapes = Standard_False;
99 //=======================================================================
102 //=======================================================================
104 const Standard_GUID& XCAFDoc_ShapeTool::ID() const
109 // Auxiliary methods //////////////////////////////////////////////////
111 //=======================================================================
112 //function : SetLabelNameByLink
114 //=======================================================================
115 static void SetLabelNameByLink(const TDF_Label L)
117 Handle(TDataStd_TreeNode) Node;
118 if (! L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) ||
119 ! Node->HasFather()) {
121 std::cout<<"Error: XCAFDoc_ShapeTool, SetLabelNameByLink(): NO NODE"<<std::endl;
125 TCollection_AsciiString Entry;
126 TDF_Tool::Entry ( Node->Father()->Label(), Entry );
127 Entry.Insert(1, "=>[");
130 TDataStd_Name::Set(L, TCollection_ExtendedString( Entry ));
134 //=======================================================================
135 //function : SetLabelNameByShape
137 //=======================================================================
138 static void SetLabelNameByShape(const TDF_Label L)
141 if (XCAFDoc_ShapeTool::GetShape(L, S) &&
142 ! L.IsAttribute(TDataStd_Name::GetID()) ) {
143 Standard_SStream Stream;
144 // TopAbs_ShapeEnum Type = S.ShapeType();
145 // if (Type == TopAbs_COMPOUND) Stream<<"ASSEMBLY";
147 TopAbs::Print(S.ShapeType(), Stream);
148 TCollection_AsciiString aName (Stream.str().c_str());
149 TDataStd_Name::Set(L, TCollection_ExtendedString(aName));
154 //=======================================================================
155 //function : SearchUsingMap
157 //=======================================================================
159 Standard_Boolean XCAFDoc_ShapeTool::SearchUsingMap(const TopoDS_Shape &S, TDF_Label &L,
160 const Standard_Boolean findWithoutLoc,
161 const Standard_Boolean findSubShape) const
164 if(myShapeLabels.IsBound(S)) {
165 L = myShapeLabels.Find(S);
166 return Standard_True;
171 if(myShapeLabels.IsBound(S0)) {
172 TDF_Label L1 = myShapeLabels.Find(S0);
173 TDF_LabelSequence Labels;
174 if(GetUsers(L1, Labels, Standard_True)) {
175 for(Standard_Integer i=1; i<=Labels.Length(); i++) {
176 TopoDS_Shape c = GetShape(Labels.Value(i));
179 return Standard_True;
185 return Standard_True;
189 if(hasSimpleShapes) {
190 if(mySimpleShapes.IsBound(S)) {
191 L = mySimpleShapes.Find(S);
192 return Standard_True;
194 if(mySimpleShapes.IsBound(S0)) {
195 L = mySimpleShapes.Find(S0);
196 return Standard_True;
200 if(!findSubShape) return Standard_False;
201 TDF_Label mainL = FindMainShapeUsingMap(S);
202 if(mainL.IsNull()) return Standard_False;
203 L = AddSubShape(mainL,S);
204 return !L.IsNull();//Standard_True;
208 //=======================================================================
211 //=======================================================================
213 Standard_Boolean XCAFDoc_ShapeTool::Search (const TopoDS_Shape &S,
215 const Standard_Boolean findInstance,
216 const Standard_Boolean findComponent,
217 const Standard_Boolean findSubShape) const
219 // search among shapes
220 Standard_Boolean isLocated = ! S.Location().IsIdentity();
223 // try to find top-level instance
224 if ( findInstance && FindShape ( S, L, Standard_True ) )
225 return Standard_True;
226 // try to find component of assembly
227 if ( findComponent ) {
228 TDF_LabelSequence labels;
229 GetShapes ( labels );
230 for ( Standard_Integer i=1; i <= labels.Length(); i++ ) {
231 if ( ! IsAssembly ( labels.Value(i) ) ) continue;
232 TDF_LabelSequence comp;
233 GetComponents ( labels.Value(i), comp );
234 for ( Standard_Integer j=1; j <= comp.Length(); j++ ) {
235 TopoDS_Shape c = GetShape ( comp.Value(j) );
236 if ( c.IsSame ( S ) ) {
238 return Standard_True;
244 // try to find top-level simple shape
245 if ( FindShape ( S, L, Standard_False ) ) return Standard_True;
248 if ( ! findSubShape ) return Standard_False;
249 TDF_Label mainL = FindMainShape ( S );
250 if ( mainL.IsNull() ) return Standard_False;
251 L = AddSubShape ( mainL, S );
252 return !L.IsNull();//Standard_True;
255 //=======================================================================
256 //function : FindShape
258 //=======================================================================
260 Standard_Boolean XCAFDoc_ShapeTool::FindShape (const TopoDS_Shape& S,
262 const Standard_Boolean findInstance) const
264 // search for null-located shape
266 if ( ! findInstance ) {
271 // this code is used instead of the following for performance reasons
272 if (TNaming_Tool::HasLabel(Label(), S0)) {
274 L = TNaming_Tool::Label(Label(), S0, TransDef);
277 return Standard_False;
280 return Standard_True;
282 // Try to find shape manually
283 TDF_ChildIDIterator it(Label(), TNaming_NamedShape::GetID());
284 for (; it.More(); it.Next()) {
285 TDF_Label aLabel = it.Value()->Label();
286 Handle(TNaming_NamedShape) NS;
287 if ( aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) &&
288 S0.IsSame ( TNaming_Tool::GetShape(NS) ) ) {
290 return Standard_True;
295 return Standard_False;
298 //=======================================================================
299 //function : FindShape
301 //=======================================================================
303 TDF_Label XCAFDoc_ShapeTool::FindShape (const TopoDS_Shape& S,
304 const Standard_Boolean findInstance) const
307 if (FindShape(S, L, findInstance))
312 //=======================================================================
313 //function : GetShape
315 //=======================================================================
317 Standard_Boolean XCAFDoc_ShapeTool::GetShape (const TDF_Label& L, TopoDS_Shape& S)
319 Handle(XCAFDoc_Location) LocationAttribute;
322 TopoDS_Compound EmptyComp;
324 B.MakeCompound(EmptyComp);
328 // for instance, get referred shape
329 Handle(TDataStd_TreeNode) Node;
330 if ( L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) && Node->HasFather() &&
331 L.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute)) {
332 if ( ! GetShape(Node->Father()->Label(), S) ) return Standard_False;
333 S.Move ( LocationAttribute->Get(), Standard_False );
334 return Standard_True;
337 // else just return shape on this label
338 Handle(TNaming_NamedShape) NS;
339 if ( ! L.FindAttribute(TNaming_NamedShape::GetID(), NS) ) return Standard_False;
340 S = TNaming_Tool::GetShape(NS);
341 return Standard_True;
344 //=======================================================================
345 //function : GetShape
347 //=======================================================================
349 TopoDS_Shape XCAFDoc_ShapeTool::GetShape(const TDF_Label& L)
356 //=======================================================================
357 //function : NewShape
359 //=======================================================================
361 TDF_Label XCAFDoc_ShapeTool::NewShape() const
363 TopoDS_Compound aShape;
365 tdsB.MakeCompound ( aShape );
368 TDF_Label aLabel = aTag.NewChild(Label());
370 TNaming_Builder tnBuild(aLabel);
371 tnBuild.Generated(aShape);
376 //=======================================================================
377 //function : SetShape
379 //=======================================================================
381 void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S)
383 TNaming_Builder tnBuild(L);
384 tnBuild.Generated(S);
385 Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L);
386 // if ( ! L.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A) ) {
387 // A = XCAFDoc_ShapeMapTool::Set(L);
388 // L.AddAttribute(A);
392 if(!myShapeLabels.IsBound(S)) {
393 myShapeLabels.Bind(S,L);
397 //=======================================================================
398 //function : MakeReference
400 //=======================================================================
402 void XCAFDoc_ShapeTool::MakeReference (const TDF_Label &L,
403 const TDF_Label &refL,
404 const TopLoc_Location &loc)
407 XCAFDoc_Location::Set(L, loc);
410 Handle(TDataStd_TreeNode) refNode, mainNode;
411 mainNode = TDataStd_TreeNode::Set ( refL, XCAFDoc::ShapeRefGUID() );
412 refNode = TDataStd_TreeNode::Set ( L, XCAFDoc::ShapeRefGUID() );
413 refNode->Remove(); // abv: fix against bug in TreeNode::Append()
414 mainNode->Append(refNode);
417 SetLabelNameByLink(L);
420 //=======================================================================
421 // function : SetLocation
423 //=======================================================================
424 Standard_Boolean XCAFDoc_ShapeTool::SetLocation (const TDF_Label& theShapeLabel,
425 const TopLoc_Location& theLoc,
426 TDF_Label& theRefLabel)
428 if (theLoc.IsIdentity())
430 theRefLabel = theShapeLabel;
431 return Standard_True;
433 // if input label is reference -> just change the location attribute
434 if (IsReference (theShapeLabel))
436 TopLoc_Location anOldLoc;
437 anOldLoc = GetLocation (theShapeLabel);
438 TopLoc_Location aNewLoc (theLoc.Transformation() * anOldLoc.Transformation());
439 XCAFDoc_Location::Set(theShapeLabel, aNewLoc);
440 theRefLabel = theShapeLabel;
441 return Standard_True;
443 // if input label is shape, and it is free -> create reference to the shape
444 if (IsShape(theShapeLabel) && IsFree(theShapeLabel))
446 theRefLabel = TDF_TagSource::NewChild (Label());
447 MakeReference (theRefLabel, theShapeLabel, theLoc);
448 return Standard_True;
450 // other cases of label meaning doesn't need to apply new location
451 return Standard_False;
454 //=======================================================================
455 //function : addShape
457 //=======================================================================
459 TDF_Label XCAFDoc_ShapeTool::addShape (const TopoDS_Shape& S, const Standard_Boolean makeAssembly)
461 TDF_Label ShapeLabel;
464 // search if the shape already exists (with the same location)
465 if ( S.IsNull() || FindShape ( S, ShapeLabel, Standard_True ) ) return ShapeLabel;
467 // else add a new label
468 ShapeLabel = aTag.NewChild(Label());
470 // if shape has location, make a reference to the same shape without location
471 if ( ! S.Location().IsIdentity() /*&& FindShape ( S, L )*/ ) {
475 TDF_Label L = addShape ( S0, makeAssembly );
476 MakeReference ( ShapeLabel, L, S.Location() );
480 // else add a shape to a label
481 TNaming_Builder tnBuild(ShapeLabel);
482 tnBuild.Generated(S);
484 Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(ShapeLabel);
485 // if ( ! ShapeLabel.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A) ) {
486 // A = XCAFDoc_ShapeMapTool::Set(ShapeLabel);
487 // ShapeLabel.AddAttribute(A);
492 SetLabelNameByShape(ShapeLabel);
494 // if shape is Compound and flag is set, create assembly
495 if ( makeAssembly && S.ShapeType() == TopAbs_COMPOUND ) {
496 // mark assembly by assigning UAttribute
497 Handle(TDataStd_UAttribute) Uattr;
498 Uattr = TDataStd_UAttribute::Set ( ShapeLabel, XCAFDoc::AssemblyGUID() );
500 TDataStd_Name::Set(ShapeLabel, TCollection_ExtendedString("ASSEMBLY"));
502 // iterate on components
503 TopoDS_Iterator Iterator(S);
504 for (; Iterator.More(); Iterator.Next()) {
505 // get label for component`s shape
506 TopoDS_Shape Scomp = Iterator.Value(), S0 = Scomp;
509 TDF_Label compL = addShape ( S0, makeAssembly );
511 // add a component as reference
512 TDF_Label RefLabel = aTag.NewChild(ShapeLabel);
513 MakeReference ( RefLabel, compL, Scomp.Location() );
517 if(!IsAssembly(ShapeLabel)) {
518 //const TopTools_IndexedMapOfShape tmpMap = A->GetMap();
519 //for(Standard_Integer i=1; i<=tmpMap.Extent(); i++)
520 //mySubShapes.Bind(tmpMap.FindKey(i),ShapeLabel);
521 for(Standard_Integer i=1; i<=A->GetMap().Extent(); i++)
523 TopoDS_Shape aSh = A->GetMap().FindKey(i);
524 mySubShapes.Bind(aSh,ShapeLabel);
525 //if shape has location, make a reference to the same shape without location
526 if (!aSh.Location().IsIdentity()) {
527 TopoDS_Shape S0 = aSh;
530 mySubShapes.Bind(S0, ShapeLabel);
533 //mySubShapes.Bind(ShapeLabel,A->GetMap());
540 //=======================================================================
541 //function : prepareAssembly
542 //purpose : auxiliary
543 //=======================================================================
544 static Standard_Boolean prepareAssembly (const TopoDS_Shape& theShape,
545 TopoDS_Shape& theOUTShape)
547 // iterate on components
548 theOUTShape = theShape;
549 if (theShape.ShapeType() == TopAbs_COMPOUND) {
551 // check if shape if frosen
552 if (!theOUTShape.Free())
553 theOUTShape.Free(Standard_True);
555 TopTools_SequenceOfShape aSubShapeSeq;
556 TopoDS_Iterator Iterator(theShape);
557 for (; Iterator.More(); Iterator.Next())
558 aSubShapeSeq.Append(Iterator.Value());
559 for (Standard_Integer i = 1; i <= aSubShapeSeq.Length(); i++) {
560 TopoDS_Shape Scomp = aSubShapeSeq.Value(i);
561 TopoDS_Shape aNewScomp;
562 B.Remove(theOUTShape, Scomp);
563 prepareAssembly( Scomp, aNewScomp );
564 TopLoc_Location aLoc;
565 aLoc = aNewScomp.Location();
566 if ( aLoc.IsIdentity() ) {
567 // create an "empty" location
569 aTrsf.SetScale(gp_Pnt(0,0,0), 1);
570 aLoc = TopLoc_Location( aTrsf );
571 aNewScomp.Location( aLoc, Standard_False );
573 B.Add(theOUTShape, aNewScomp);
576 return Standard_True;
580 //=======================================================================
581 //function : AddShape
583 //=======================================================================
585 TDF_Label XCAFDoc_ShapeTool::AddShape (const TopoDS_Shape& theShape,
586 const Standard_Boolean makeAssembly,
587 const Standard_Boolean makePrepare)
589 // PTV 17.02.2003 to avoid components without location.
590 TopoDS_Shape S = theShape;
591 if ( makePrepare && makeAssembly && S.ShapeType() == TopAbs_COMPOUND )
592 prepareAssembly( theShape, S ); // OCC1669
594 TDF_Label L = addShape(S,makeAssembly);
596 if(!myShapeLabels.IsBound(S)) {
597 myShapeLabels.Bind(S,L);
602 //return addShape( S, makeAssembly );
605 //=======================================================================
606 //function : RemoveShape
608 //=======================================================================
610 Standard_Boolean XCAFDoc_ShapeTool::RemoveShape (const TDF_Label& L,
611 const Standard_Boolean removeCompletely) const
613 if ( ! IsTopLevel ( L ) || ! IsFree ( L ) ) return Standard_False;
615 Handle(TDataStd_TreeNode) aNode;
617 if (removeCompletely &&
618 L.FindAttribute (XCAFDoc::ShapeRefGUID(), aNode) &&
619 aNode->HasFather() &&
620 L.IsAttribute (XCAFDoc_Location::GetID()))
622 aLabel = aNode->Father()->Label();
625 L.ForgetAllAttributes (Standard_True);
627 if (removeCompletely && !aLabel.IsNull())
629 return RemoveShape(aLabel);
631 return Standard_True;
635 //=======================================================================
638 //=======================================================================
640 void XCAFDoc_ShapeTool::Init()
642 hasSimpleShapes = Standard_False;
646 //=======================================================================
647 //function : SetAutoNaming
649 //=======================================================================
651 void XCAFDoc_ShapeTool::SetAutoNaming (const Standard_Boolean V)
657 //=======================================================================
658 //function : AutoNaming
660 //=======================================================================
662 Standard_Boolean XCAFDoc_ShapeTool::AutoNaming()
664 return theAutoNaming;
668 //=======================================================================
669 //function : ComputeShapes
671 //=======================================================================
673 void XCAFDoc_ShapeTool::ComputeShapes(const TDF_Label& L)
675 TDF_ChildIterator it(L);
676 for(; it.More(); it.Next()) {
677 TDF_Label L1 = it.Value();
680 if(!myShapeLabels.IsBound(S)) {
681 mySimpleShapes.Bind(S,L1);
689 //=======================================================================
690 //function : ComputeSimpleShapes
692 //=======================================================================
694 void XCAFDoc_ShapeTool::ComputeSimpleShapes()
696 ComputeShapes(Label());
697 hasSimpleShapes = Standard_True;
701 //=======================================================================
702 //function : GetShapes
704 //=======================================================================
706 void XCAFDoc_ShapeTool::GetShapes(TDF_LabelSequence& Labels) const
710 TDF_ChildIterator it(Label());
711 for (; it.More(); it.Next()) {
712 TDF_Label L = it.Value();
714 if ( GetShape ( L, S ) ) Labels.Append ( L );
719 //=======================================================================
720 //function : GetFreeShapes
722 //=======================================================================
724 void XCAFDoc_ShapeTool::GetFreeShapes (TDF_LabelSequence& FreeLabels) const
728 TDF_ChildIterator it(Label());
729 for (; it.More(); it.Next()) {
730 TDF_Label L = it.Value();
732 if ( GetShape ( L, S ) && IsFree ( L ) ) FreeLabels.Append ( L );
736 //=======================================================================
737 //function : IsTopLevel
739 //=======================================================================
741 Standard_Boolean XCAFDoc_ShapeTool::IsTopLevel (const TDF_Label& L) const
743 return L.Father() == Label();
746 //=======================================================================
749 //=======================================================================
751 Standard_Boolean XCAFDoc_ShapeTool::IsShape (const TDF_Label& L)
753 return IsSimpleShape ( L ) || IsAssembly ( L ) || IsReference ( L );
756 //=======================================================================
757 //function : IsSimpleShape
759 //=======================================================================
761 Standard_Boolean XCAFDoc_ShapeTool::IsSimpleShape (const TDF_Label& L)
763 Handle(TNaming_NamedShape) NS;
764 return L.FindAttribute ( TNaming_NamedShape::GetID(), NS ) &&
765 ! IsAssembly ( L ) && ! IsReference ( L );
768 //=======================================================================
769 //function : IsReference
771 //=======================================================================
773 Standard_Boolean XCAFDoc_ShapeTool::IsReference (const TDF_Label& L)
775 Handle(TDataStd_TreeNode) Node;
776 return L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) && Node->HasFather();
779 //=======================================================================
780 //function : IsAssembly
782 //=======================================================================
784 Standard_Boolean XCAFDoc_ShapeTool::IsAssembly (const TDF_Label& L)
786 Handle(TDataStd_UAttribute) Uattr;
787 return L.FindAttribute(XCAFDoc::AssemblyGUID(), Uattr);
790 //=======================================================================
791 //function : IsComponent
793 //=======================================================================
795 Standard_Boolean XCAFDoc_ShapeTool::IsComponent (const TDF_Label& L)
797 return IsReference ( L ) && IsAssembly ( L.Father() );
800 //=======================================================================
801 //function : IsCompound
803 //=======================================================================
805 Standard_Boolean XCAFDoc_ShapeTool::IsCompound (const TDF_Label& L)
807 Handle(TDataStd_Name) Name;
808 if (L.FindAttribute(TDataStd_Name::GetID(),Name)) {
809 TCollection_ExtendedString estr1 = Name->Get();
810 TCollection_ExtendedString estr2("COMPOUND");
812 return Standard_True;
815 return Standard_False;
818 //=======================================================================
819 //function : IsSubShape
821 //=======================================================================
823 Standard_Boolean XCAFDoc_ShapeTool::IsSubShape (const TDF_Label& L)
825 return IsSimpleShape ( L ) && IsShape ( L.Father() );
828 //=======================================================================
831 //=======================================================================
833 Standard_Boolean XCAFDoc_ShapeTool::IsFree (const TDF_Label& L)
835 Handle(TDataStd_TreeNode) Node;
836 if ( ! L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) ||
837 ! Node->HasFirst() ) return Standard_True;
839 return Standard_False;
842 //=======================================================================
843 //function : GetUsers
844 //purpose : Returns number of users (0 if shape is free)
845 //=======================================================================
847 Standard_Integer XCAFDoc_ShapeTool::GetUsers (const TDF_Label& L,
848 TDF_LabelSequence& Labels,
849 const Standard_Boolean getsubchilds)
851 Standard_Integer NbUsers=0;
852 Handle(TDataStd_TreeNode) Node ;
854 if ( ! L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) ) return NbUsers;
856 Node = Node->First();
857 while ( ! Node.IsNull() ) {
859 if ( getsubchilds ) {
860 TDF_Label underL = Node->Label().Father();
861 NbUsers += GetUsers ( underL, Labels, getsubchilds );
864 Labels.Append(Node->Label());
871 //=======================================================================
872 //function : NbComponents
874 //=======================================================================
876 Standard_Integer XCAFDoc_ShapeTool::NbComponents (const TDF_Label& L,
877 const Standard_Boolean getsubchilds)
879 TDF_LabelSequence subLabels;
880 GetComponents (L, subLabels, getsubchilds);
881 return subLabels.Length();
884 //=======================================================================
885 //function : GetComponents
887 //=======================================================================
889 Standard_Boolean XCAFDoc_ShapeTool::GetComponents (const TDF_Label& L, TDF_LabelSequence& Labels,
890 const Standard_Boolean getsubchilds)
892 if ( ! IsAssembly(L) ) return Standard_False;
894 TDF_ChildIterator It(L);
895 for (; It.More(); It.Next() ) {
896 TDF_Label comp = It.Value();
897 if ( IsComponent ( comp ) ) {
898 if ( getsubchilds ) {
900 if ( GetReferredShape ( comp, underL ) )
901 GetComponents ( underL, Labels, getsubchilds);
903 Labels.Append ( comp );
906 return Standard_True;
909 //=======================================================================
910 //function : GetLocation
912 //=======================================================================
914 TopLoc_Location XCAFDoc_ShapeTool::GetLocation (const TDF_Label& L)
916 Handle(XCAFDoc_Location) LocationAttribute;
917 if (L.FindAttribute(XCAFDoc_Location::GetID(), LocationAttribute))
918 return LocationAttribute->Get();
920 Handle(TNaming_NamedShape) NS;
922 if ( L.FindAttribute ( TNaming_NamedShape::GetID(), NS ) ) {
923 S = TNaming_Tool::GetShape(NS);
928 //=======================================================================
929 //function : GetReferredShape
931 //=======================================================================
933 Standard_Boolean XCAFDoc_ShapeTool::GetReferredShape (const TDF_Label& L,
936 if ( ! IsReference(L) ) return Standard_False;
938 Handle (TDataStd_TreeNode) Node;
939 L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node);
940 Label = Node->Father()->Label();
941 return Standard_True;
944 //=======================================================================
945 //function : AddComponent
947 //=======================================================================
949 TDF_Label XCAFDoc_ShapeTool::AddComponent (const TDF_Label& assembly,
950 const TDF_Label& compL,
951 const TopLoc_Location &Loc)
955 // check that shape is assembly
956 if ( ! IsAssembly(assembly) ) {
957 // if it is simple shape, make it assembly
958 if ( IsSimpleShape(assembly) )
959 TDataStd_UAttribute::Set ( assembly, XCAFDoc::AssemblyGUID() );
963 // add a component as reference
965 L = aTag.NewChild(assembly);
966 MakeReference ( L, compL, Loc );
968 // map shape to label
970 if (GetShape(L, aShape))
972 if (!myShapeLabels.IsBound(aShape))
973 myShapeLabels.Bind(aShape, L);
979 //=======================================================================
980 //function : AddComponent
982 //=======================================================================
984 TDF_Label XCAFDoc_ShapeTool::AddComponent (const TDF_Label& assembly,
985 const TopoDS_Shape& comp,
986 const Standard_Boolean expand)
988 // get label for component`s shape
989 TopoDS_Shape S0 = comp;
993 compL = AddShape ( S0, expand );
995 // add component by its label
996 return AddComponent ( assembly, compL, comp.Location() );
999 //=======================================================================
1000 //function : RemoveComponent
1002 //=======================================================================
1004 void XCAFDoc_ShapeTool::RemoveComponent (const TDF_Label& comp) const
1006 if ( IsComponent(comp) )
1008 comp.ForgetAllAttributes();
1012 //=======================================================================
1013 //function : UpdateAssemblies
1015 //=======================================================================
1017 void XCAFDoc_ShapeTool::UpdateAssemblies()
1019 // We start from the free shapes (roots in the assembly structure)
1020 TDF_LabelSequence aRootLabels;
1021 GetFreeShapes(aRootLabels);
1023 // Iterate over the free shapes
1024 TDF_LabelMap anUpdated;
1025 for ( TDF_LabelSequence::Iterator anIt(aRootLabels); anIt.More(); anIt.Next() )
1027 TDF_Label aRefLabel = anIt.Value();
1028 if (IsReference(aRefLabel))
1030 GetReferredShape(aRefLabel, aRefLabel);
1032 const TDF_Label& aRootLab = aRefLabel;
1033 TopoDS_Shape anAssemblyShape;
1034 updateComponent(aRootLab, anAssemblyShape, anUpdated);
1038 //=======================================================================
1039 //function : IsSubShape
1041 //=======================================================================
1043 //static Standard_Boolean CheckSubShape (const TopoDS_Shape &S, const TopoDS_Shape &sub)
1045 // if ( S.IsSame ( sub ) ) return Standard_True;
1047 // if ( S.ShapeType() >= sub.ShapeType() ) return Standard_False;
1049 // for ( TopoDS_Iterator it(S); it.More(); it.Next() ) {
1050 // if ( CheckSubShape ( it.Value(), sub ) ) return Standard_True;
1052 // return Standard_False;
1055 //=======================================================================
1056 //function : IsSubShape
1058 //=======================================================================
1060 Standard_Boolean XCAFDoc_ShapeTool::IsSubShape (const TDF_Label &shapeL,
1061 const TopoDS_Shape &sub) const
1063 Handle(XCAFDoc_ShapeMapTool) A;
1064 if (!shapeL.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A))
1066 TopoDS_Shape aShape = GetShape(shapeL);
1067 if (aShape.IsNull())
1068 return Standard_False;
1069 A = XCAFDoc_ShapeMapTool::Set(shapeL);
1070 A->SetShape(aShape);
1073 return A->IsSubShape(sub);
1076 //=======================================================================
1077 //function : FindSubShape
1079 //=======================================================================
1081 Standard_Boolean XCAFDoc_ShapeTool::FindSubShape (const TDF_Label &shapeL,
1082 const TopoDS_Shape &sub,
1086 return Standard_False;
1088 if (TNaming_Tool::HasLabel(Label(), sub)) {
1090 L = TNaming_Tool::Label(Label(), sub, TransDef);
1092 return Standard_False;
1093 if (L.Father() == shapeL)
1094 return Standard_True;
1098 return Standard_False;
1101 // if subshape was found wrong, try to do it manually
1102 // it can be possible if several part shapes has the same subshapes
1104 TDF_ChildIterator aChldLabIt(shapeL);
1105 for (; aChldLabIt.More(); aChldLabIt.Next() ) {
1106 TDF_Label aSubLabel = aChldLabIt.Value();
1107 Handle(TNaming_NamedShape) NS;
1108 if (!aSubLabel.FindAttribute(TNaming_NamedShape::GetID(), NS))
1110 TopoDS_Shape aSubShape = TNaming_Tool::GetShape(NS);
1111 if (!aSubShape.IsNull() && aSubShape.IsSame(sub)) {
1113 return Standard_True;
1117 return Standard_False;
1120 //=======================================================================
1121 //function : AddSubShape
1123 //=======================================================================
1125 TDF_Label XCAFDoc_ShapeTool::AddSubShape (const TDF_Label &shapeL,
1126 const TopoDS_Shape &sub) const
1129 AddSubShape(shapeL, sub, L);
1134 //=======================================================================
1135 //function : AddSubShape
1137 //=======================================================================
1139 Standard_Boolean XCAFDoc_ShapeTool::AddSubShape(const TDF_Label &shapeL,
1140 const TopoDS_Shape &sub,
1141 TDF_Label &addedSubShapeL) const
1143 addedSubShapeL = TDF_Label();
1144 // Check if adding subshape is possible
1145 if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
1146 return Standard_False;
1148 TopoDS_Shape aSubShape = sub;
1149 Standard_Boolean isDefined = Standard_True;
1150 if (!IsSubShape(shapeL, sub))
1152 isDefined = Standard_False;
1153 // Try to find a subshape as a part of the main shape.
1154 // If location of subshape has been removed,
1155 // take the shape with the location from the main shape
1156 if (sub.Location().IsIdentity())
1158 TDF_LabelSequence aShapeLSeq;
1159 for (TopoDS_Iterator it(GetShape(shapeL)); it.More() && !isDefined; it.Next())
1161 TopoDS_Shape aShape = it.Value();
1162 if (sub.IsSame(aShape.Located(TopLoc_Location())))
1164 isDefined = Standard_True;
1171 return Standard_False;
1173 // Try to find already existed subshape
1174 if (FindSubShape(shapeL, aSubShape, addedSubShapeL))
1175 return Standard_False;
1178 addedSubShapeL = aTag.NewChild(shapeL);
1179 TNaming_Builder tnBuild(addedSubShapeL);
1180 tnBuild.Generated(aSubShape);
1182 return Standard_True;
1186 //=======================================================================
1187 //function : FindMainShapeUsingMap
1189 //=======================================================================
1191 TDF_Label XCAFDoc_ShapeTool::FindMainShapeUsingMap(const TopoDS_Shape &sub) const
1193 //for(Standard_Integer i=1; i<=myNotAssemblies.Length(); i++) {
1194 // TDF_Label L = myNotAssemblies.Value(i);
1195 // if(IsSubShape(L,sub)) return L;
1197 if(mySubShapes.IsBound(sub))
1198 return mySubShapes.Find(sub);
1204 //=======================================================================
1205 //function : FindMainShape
1207 //=======================================================================
1209 TDF_Label XCAFDoc_ShapeTool::FindMainShape (const TopoDS_Shape &sub) const
1211 TDF_ChildIterator it(Label());
1212 for (; it.More(); it.Next()) {
1213 TDF_Label L = it.Value();
1215 if ( IsSimpleShape( L ) && IsSubShape ( L, sub ) ) return L;
1222 //=======================================================================
1223 //function : GetSubShapes
1225 //=======================================================================
1227 Standard_Boolean XCAFDoc_ShapeTool::GetSubShapes (const TDF_Label &L,
1228 TDF_LabelSequence& Labels)
1230 TDF_ChildIterator It(L);
1231 for (; It.More(); It.Next() ) {
1232 TDF_Label sub = It.Value();
1233 if ( IsSubShape ( sub ) ) Labels.Append ( sub );
1235 return Labels.Length() >0;
1238 //=======================================================================
1239 //function : BaseLabel
1241 //=======================================================================
1243 TDF_Label XCAFDoc_ShapeTool::BaseLabel () const
1248 //=======================================================================
1249 //function : DumpAssembly
1250 //purpose : recursive part of Dump()
1251 //=======================================================================
1253 static void DumpAssembly(Standard_OStream& theDumpLog,
1255 const Standard_Integer level,
1256 const Standard_Boolean deep)
1259 XCAFDoc_ShapeTool::GetShape(L, S);
1262 for (Standard_Integer i=0; i<level; i++)
1265 TCollection_AsciiString Entry;
1266 TDF_Tool::Entry(L, Entry);
1268 if(XCAFDoc_ShapeTool::IsAssembly(L))
1270 theDumpLog<<"ASSEMBLY ";
1272 else if (XCAFDoc_ShapeTool::IsSimpleShape(L))
1274 if(L.Father().Father().Father().IsRoot())
1275 theDumpLog<<"PART ";
1279 theDumpLog<<"INSTANCE ";
1281 TopAbs::Print(S.ShapeType(), theDumpLog);
1283 theDumpLog<<" "<<Entry;
1284 if(XCAFDoc_ShapeTool::IsReference(L))
1286 Handle(TDataStd_TreeNode) aRef;
1287 L.FindAttribute(XCAFDoc::ShapeRefGUID(), aRef);
1288 TDF_Tool::Entry(aRef->Father()->Label(), Entry);
1289 theDumpLog<<" (refers to "<<Entry<<")";
1291 Handle(TDataStd_Name) Name;
1292 if (L.FindAttribute(TDataStd_Name::GetID(), Name))
1293 theDumpLog<<" \""<<Name->Get()<<"\" ";
1296 theDumpLog<<"("<<*(void**)&S.TShape();
1297 if (! S.Location().IsIdentity())
1298 theDumpLog<<", "<< *(void**)&S.Location();
1301 theDumpLog<<std::endl;
1303 Handle(TDataStd_TreeNode) Node;
1304 TDF_ChildIterator NodeIterator(L);
1305 for (; NodeIterator.More(); NodeIterator.Next()) {
1306 DumpAssembly(theDumpLog, NodeIterator.Value(), level+1, deep);
1309 theDumpLog<<std::endl;
1312 //=======================================================================
1315 //=======================================================================
1317 Standard_OStream& XCAFDoc_ShapeTool::Dump(Standard_OStream& theDumpLog, const Standard_Boolean deep) const
1319 Standard_Integer level = 0;
1320 // TopTools_SequenceOfShape SeqShapes;
1321 TDF_LabelSequence SeqLabels;
1322 GetShapes( SeqLabels);
1324 if (SeqLabels.Length()>0) theDumpLog<<std::endl;
1326 for (i=1; i<=SeqLabels.Length(); i++) {
1327 DumpAssembly(theDumpLog, SeqLabels.Value(i), level, deep);
1331 GetFreeShapes(SeqLabels);
1332 theDumpLog<<std::endl<<"Free Shapes: "<<SeqLabels.Length()<<std::endl;
1333 for (i = 1; i<=SeqLabels.Length(); i++) {
1334 DumpShape(theDumpLog, SeqLabels.Value(i), level, deep);
1335 theDumpLog<<std::endl;
1340 //=======================================================================
1342 //purpose : override
1343 //=======================================================================
1345 Standard_OStream& XCAFDoc_ShapeTool::Dump(Standard_OStream& theDumpLog) const
1347 TDF_Attribute::Dump (theDumpLog);
1348 Dump (theDumpLog, Standard_False);
1352 //=======================================================================
1353 //function : DumpShape
1355 //=======================================================================
1357 void XCAFDoc_ShapeTool::DumpShape(Standard_OStream& theDumpLog, const TDF_Label& L,const Standard_Integer level,const Standard_Boolean deep)
1360 if(! XCAFDoc_ShapeTool::GetShape(L, S) ) return;
1361 for (Standard_Integer i=0; i<level; i++)
1364 if(XCAFDoc_ShapeTool::IsAssembly(L))
1366 theDumpLog<<"ASSEMBLY ";
1368 else if (XCAFDoc_ShapeTool::IsSimpleShape(L))
1370 if(L.Father().Father().Father().IsRoot())
1371 theDumpLog<<"PART ";
1375 theDumpLog<<"INSTANCE ";
1377 TopAbs::Print(S.ShapeType(), theDumpLog);
1379 TCollection_AsciiString Entry;
1380 TDF_Tool::Entry(L, Entry);
1381 theDumpLog<<" "<<Entry;
1382 if(XCAFDoc_ShapeTool::IsReference(L))
1384 Handle(TDataStd_TreeNode) aRef;
1385 L.FindAttribute(XCAFDoc::ShapeRefGUID(), aRef);
1386 TDF_Tool::Entry(aRef->Father()->Label(), Entry);
1387 theDumpLog<<" (refers to "<<Entry<<")";
1389 //std::cout<<std::endl;
1390 Handle(TDataStd_Name) Name;
1391 if (L.FindAttribute(TDataStd_Name::GetID(),Name))
1392 theDumpLog<<" \""<<Name->Get()<<"\" ";
1395 theDumpLog<<"("<<*(void**)&S.TShape();
1396 if (! S.Location().IsIdentity())
1397 theDumpLog<<", "<< *(void**)&S.Location();
1402 //=======================================================================
1403 //function : IsExternRef
1405 //=======================================================================
1407 Standard_Boolean XCAFDoc_ShapeTool::IsExternRef(const TDF_Label& L)
1409 Handle(TDataStd_UAttribute) Uattr;
1410 return L.FindAttribute(XCAFDoc::ExternRefGUID(), Uattr);
1413 //=======================================================================
1414 //function : SetExternRefs
1416 //=======================================================================
1418 void XCAFDoc_ShapeTool::SetExternRefs(const TDF_Label& L,
1419 const TColStd_SequenceOfHAsciiString& SHAS) const
1421 TDF_Label ShapeLabel = L.NewChild();
1422 TDataStd_UAttribute::Set(ShapeLabel,XCAFDoc::ExternRefGUID());
1423 for(Standard_Integer i=1; i<=SHAS.Length(); i++) {
1424 TDF_Label tmplbl = ShapeLabel.FindChild(i,Standard_True);
1425 Handle(TCollection_HAsciiString) str = SHAS(i);
1426 TCollection_ExtendedString extstr(str->String());
1427 TDataStd_Name::Set(tmplbl,extstr);
1431 //=======================================================================
1432 //function : SetExternRefs
1434 //=======================================================================
1436 TDF_Label XCAFDoc_ShapeTool::SetExternRefs(const TColStd_SequenceOfHAsciiString& SHAS) const
1438 TDF_Label ShapeLabel;
1441 ShapeLabel = aTag.NewChild(Label());
1442 TDataStd_UAttribute::Set(ShapeLabel,XCAFDoc::ExternRefGUID());
1443 for(Standard_Integer i=1; i<=SHAS.Length(); i++) {
1444 TDF_Label tmplbl = ShapeLabel.FindChild(i,Standard_True);
1445 Handle(TCollection_HAsciiString) str = SHAS(i);
1446 TCollection_ExtendedString extstr(str->String());
1447 TDataStd_Name::Set(tmplbl,extstr);
1452 //=======================================================================
1453 //function : GetExternRefs
1455 //=======================================================================
1457 void XCAFDoc_ShapeTool::GetExternRefs(const TDF_Label& L,
1458 TColStd_SequenceOfHAsciiString& SHAS)
1460 Handle(TDataStd_Name) TDN;
1462 for(Standard_Integer i=1; i<=L.NbChildren(); i++) {
1463 tmplbl = L.FindChild(i);
1464 if(tmplbl.FindAttribute(TDataStd_Name::GetID(),TDN)) {
1465 TCollection_ExtendedString extstr = TDN->Get();
1466 Handle(TCollection_HAsciiString) str =
1467 new TCollection_HAsciiString(TCollection_AsciiString(extstr));
1473 // API: API work with SHUO (Specified Higher Usage Occurrence) structure
1475 //=======================================================================
1476 //function : GetSHUO
1478 //=======================================================================
1480 Standard_Boolean XCAFDoc_ShapeTool::GetSHUO (const TDF_Label& SHUOLabel,
1481 Handle(XCAFDoc_GraphNode)& aSHUOAttr)
1483 if ( !SHUOLabel.FindAttribute( XCAFDoc::SHUORefGUID(), aSHUOAttr ) )
1484 return Standard_False;
1485 return Standard_True;
1488 //=======================================================================
1489 //function : GetAllComponentSHUO
1491 //=======================================================================
1493 Standard_Boolean XCAFDoc_ShapeTool::GetAllComponentSHUO (const TDF_Label& theCompLabel,
1494 TDF_AttributeSequence& theSHUOAttrs)
1496 TDF_ChildIterator it(theCompLabel);
1497 for (; it.More(); it.Next()) {
1498 TDF_Label L = it.Value();
1499 Handle(XCAFDoc_GraphNode) aSHUOAttr;
1500 if ( GetSHUO( L, aSHUOAttr ) )
1501 theSHUOAttrs.Append( aSHUOAttr );
1503 return (theSHUOAttrs.Length() > 0);
1506 //=======================================================================
1507 //function : SetSHUO
1509 //=======================================================================
1511 Standard_Boolean XCAFDoc_ShapeTool::SetSHUO (const TDF_LabelSequence& labels,
1512 Handle(XCAFDoc_GraphNode)& MainSHUOAttr) const
1514 MainSHUOAttr.Nullify();
1515 // check number of labels
1516 if (labels.Length() < 2)
1517 return Standard_False;
1518 // check is all labels contains components of any assemblyies
1520 for (i = 1; i <= labels.Length(); i++)
1521 if ( !IsComponent(labels.Value(i)) )
1522 return Standard_False;
1525 TDF_Label UpperSubL = aTag.NewChild( labels( 1 ) );
1526 if (theAutoNaming) {
1527 TCollection_ExtendedString Entry("SHUO");
1528 TDataStd_Name::Set(UpperSubL, TCollection_ExtendedString( Entry ));
1530 Handle(XCAFDoc_GraphNode) aUpperSHUO;
1531 aUpperSHUO = XCAFDoc_GraphNode::Set( UpperSubL, XCAFDoc::SHUORefGUID() );
1532 // init out argument by main upper usage SHUO
1533 MainSHUOAttr = aUpperSHUO;
1534 // add other next_usage occurrences.
1535 for (i = 2; i <= labels.Length(); i++) {
1536 TDF_Label NextSubL = aTag.NewChild( labels( i ) );
1537 if (theAutoNaming) {
1538 TCollection_ExtendedString EntrySub("SHUO-");
1540 TDataStd_Name::Set(NextSubL, TCollection_ExtendedString( EntrySub ));
1542 Handle(XCAFDoc_GraphNode) aNextSHUO;
1543 aNextSHUO = XCAFDoc_GraphNode::Set( NextSubL, XCAFDoc::SHUORefGUID() );
1545 aUpperSHUO->SetChild( aNextSHUO );
1546 aNextSHUO->SetFather( aUpperSHUO );
1547 // now lets next_usage become upper_usage for next level of SHUO
1548 aUpperSHUO = aNextSHUO;
1549 UpperSubL = NextSubL;
1552 return Standard_True;
1555 //=======================================================================
1556 //function : GetSHUOUpperUsage
1558 //=======================================================================
1560 Standard_Boolean XCAFDoc_ShapeTool::GetSHUOUpperUsage (const TDF_Label& NextUsageL,
1561 TDF_LabelSequence& aLabels)
1563 Handle(XCAFDoc_GraphNode) aNextSHUO;
1564 if( !GetSHUO( NextUsageL, aNextSHUO ) || aNextSHUO->NbFathers()<1 )
1565 return Standard_False;
1567 // get upper_usage SHAO
1568 for (Standard_Integer i = 1; i <= aNextSHUO->NbFathers(); i++)
1569 aLabels.Append( aNextSHUO->GetFather(i)->Label() );
1570 return Standard_True;
1573 //=======================================================================
1574 //function : GetSHUONextUsage
1576 //=======================================================================
1578 Standard_Boolean XCAFDoc_ShapeTool::GetSHUONextUsage (const TDF_Label& UpperUsageL,
1579 TDF_LabelSequence& aLabels)
1581 Handle(XCAFDoc_GraphNode) aUpperSHUO;
1582 if ( !GetSHUO( UpperUsageL, aUpperSHUO ) || aUpperSHUO->NbChildren()<1 )
1583 return Standard_False;
1584 // get upper_usage SHAO
1585 for (Standard_Integer i = 1; i <= aUpperSHUO->NbChildren(); i++)
1586 aLabels.Append( aUpperSHUO->GetChild(i)->Label() );
1587 return Standard_True;
1590 //=======================================================================
1591 //function : RemoveSHUO
1593 //=======================================================================
1595 Standard_Boolean XCAFDoc_ShapeTool::RemoveSHUO (const TDF_Label& L) const
1597 L.ForgetAllAttributes (Standard_True);
1598 return Standard_True;
1601 //=======================================================================
1602 //function : checkForShape
1603 //purpose : auxiliary
1604 //=======================================================================
1606 static Standard_Boolean IsEqual (const TopLoc_Location& theLoc1, const TopLoc_Location& theLoc2)
1608 if (theLoc1.IsEqual (theLoc2)) {return Standard_True; }
1609 if (theLoc1.IsIdentity() || theLoc2.IsIdentity()) {return Standard_False; }
1610 const Handle(TopLoc_Datum3D)& aDatum1 = theLoc1.FirstDatum();
1611 const Handle(TopLoc_Datum3D)& aDatum2 = theLoc2.FirstDatum();
1612 if (aDatum1 && aDatum2)
1614 NCollection_Mat4<double> aMat41;
1615 NCollection_Mat4<double> aMat42;
1616 theLoc1.FirstDatum()->Transformation().GetMat4(aMat41);
1617 theLoc2.FirstDatum()->Transformation().GetMat4(aMat42);
1618 if ( !aMat41.IsEqual (aMat42)) {return Standard_False; }
1620 else if (aDatum1 || aDatum2) {return Standard_False; }
1621 if (theLoc1.FirstPower() != theLoc2.FirstPower() ) {return Standard_False; }
1622 else { return IsEqual (theLoc1.NextLocation(), theLoc2.NextLocation());}
1625 static Standard_Boolean IsSame (const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
1628 return theShape1.TShape() == theShape2.TShape()
1629 && theShape1.Orientation() == theShape2.Orientation()
1630 && IsEqual (theShape1.Location(), theShape2.Location());
1633 static Standard_Boolean checkForShape (const TopoDS_Shape& theShape,
1634 const TopoDS_Shape& theCurSh,
1635 const TDF_Label& theUserL,
1636 TDF_LabelSequence& theLabels)
1638 // the label of an assembly which contains this component
1639 TDF_Label aSuperUserL = theUserL.Father();
1640 TopLoc_Location aSupLoc, aCompLoc;
1641 aSupLoc = ::XCAFDoc_ShapeTool::GetLocation ( aSuperUserL );
1642 aCompLoc = ::XCAFDoc_ShapeTool::GetLocation ( theUserL );
1643 TopoDS_Shape aCopySh = theCurSh;
1644 aCompLoc = aCompLoc.Multiplied( theCurSh.Location() );
1645 aSupLoc = aSupLoc.Multiplied( aCompLoc );
1646 aCopySh.Location( aSupLoc, Standard_False );
1647 if ( IsSame ( theShape, aCopySh ) ) {
1648 theLabels.Prepend( theUserL );
1649 return Standard_True;
1651 // try to search deeply (upper by assembly structure)
1652 TDF_LabelSequence aNewLabels;
1653 for (Standard_Integer j = 1; j <= theLabels.Length(); j++)
1654 aNewLabels.Append( theLabels.Value( j ) );
1655 aNewLabels.Prepend( theUserL );
1656 TDF_LabelSequence aUsers;
1657 ::XCAFDoc_ShapeTool::GetUsers( aSuperUserL, aUsers );
1658 for (Standard_Integer i = 1; i <= aUsers.Length(); i++)
1659 if ( checkForShape( theShape, aCopySh, aUsers.Value( i ), aNewLabels ) ) {
1661 theLabels = aNewLabels;
1662 return Standard_True;
1664 return Standard_False;
1667 //=======================================================================
1668 //function : FindComponent
1670 //=======================================================================
1672 Standard_Boolean XCAFDoc_ShapeTool::FindComponent (const TopoDS_Shape& theShape,
1673 TDF_LabelSequence& theLabels) const
1676 // search for a top-level shape that corresponds to this component
1677 TopoDS_Shape S0 = theShape;
1678 TopLoc_Location loc;
1679 S0.Location ( loc );
1680 TDF_Label aRefL = FindShape( S0 );
1682 return Standard_False; // cannot find top-level shape.
1684 TDF_LabelSequence aUsers;
1685 ::XCAFDoc_ShapeTool::GetUsers( aRefL, aUsers );
1686 for (Standard_Integer i = 1; i <= aUsers.Length(); i++)
1687 if ( checkForShape( theShape, S0, aUsers.Value( i ), theLabels ) )
1690 return (theLabels.Length() > 0);
1693 //=======================================================================
1694 //function : getShapesOfSHUO
1695 //purpose : auxiliary
1696 //=======================================================================
1698 static Standard_Boolean getShapesOfSHUO (TopLoc_IndexedMapOfLocation& theaPrevLocMap,
1699 const Handle(XCAFDoc_ShapeTool)& theSTool,
1700 const TDF_Label& theSHUOlab,
1701 TopoDS_Shape& theShape)
1703 Handle(XCAFDoc_GraphNode) SHUO;
1704 TDF_LabelSequence aLabSeq;
1705 theSTool->GetSHUONextUsage( theSHUOlab, aLabSeq );
1706 if (aLabSeq.Length() >= 1)
1707 for (Standard_Integer i = 1; i <= aLabSeq.Length(); i++) {
1708 TDF_Label aSubCompL = aLabSeq.Value( i );
1709 TopLoc_Location compLoc = XCAFDoc_ShapeTool::GetLocation ( aSubCompL.Father() );
1710 // create new map of laocation (to not merge locations from different shapes)
1711 TopLoc_IndexedMapOfLocation aNewPrevLocMap;
1712 for (Standard_Integer m = 1; m <= theaPrevLocMap.Extent(); m++)
1713 aNewPrevLocMap.Add( theaPrevLocMap.FindKey( m ) );
1714 aNewPrevLocMap.Add( compLoc );
1715 // got for the new sublocations and corresponding shape
1716 getShapesOfSHUO( aNewPrevLocMap, theSTool, aSubCompL, theShape );
1719 TopoDS_Shape aSHUO_NUSh = theSTool->GetShape ( theSHUOlab.Father() );
1720 if ( aSHUO_NUSh.IsNull() ) return Standard_False;
1721 // cause got shape with location already.
1722 TopLoc_Location nullLoc;
1723 aSHUO_NUSh.Location ( nullLoc );
1724 // multiply the locations
1725 Standard_Integer intMapLenght = theaPrevLocMap.Extent();
1726 if ( intMapLenght < 1 )
1727 return Standard_False; // should not be, but to avoid exception...?
1728 TopLoc_Location SupcompLoc;
1729 SupcompLoc = theaPrevLocMap.FindKey( intMapLenght );
1730 if (intMapLenght > 1) {
1731 Standard_Integer l = intMapLenght - 1;
1733 SupcompLoc = theaPrevLocMap.FindKey( l ).Multiplied( SupcompLoc );
1737 aSHUO_NUSh.Location( SupcompLoc, Standard_False );
1738 theShape = aSHUO_NUSh;
1740 return (!theShape.IsNull());
1743 //=======================================================================
1744 //function : GetSHUOInstance
1746 //=======================================================================
1748 TopoDS_Shape XCAFDoc_ShapeTool::GetSHUOInstance (const Handle(XCAFDoc_GraphNode)& theSHUO) const
1750 TopoDS_Shape aShape;
1751 if (theSHUO.IsNull())
1754 TDF_Label aSHUOlab = theSHUO->Label();
1755 // get location of the assembly
1756 TopLoc_Location loc = XCAFDoc_ShapeTool::GetLocation ( aSHUOlab.Father().Father() );
1757 // get location of the component
1758 TopLoc_Location compLoc = XCAFDoc_ShapeTool::GetLocation ( aSHUOlab.Father() );
1759 TopLoc_IndexedMapOfLocation aPrevLocMap;
1760 // get previous set location
1761 if ( !loc.IsIdentity() )
1762 aPrevLocMap.Add( loc );
1763 aPrevLocMap.Add( compLoc );
1764 // get shape by recurse method
1765 const Handle(XCAFDoc_ShapeTool)& STool = this;
1766 getShapesOfSHUO( aPrevLocMap, STool, aSHUOlab, aShape );
1771 //=======================================================================
1772 //function : getUsersShapesOfSHUO
1773 //purpose : auxiliary
1774 //=======================================================================
1776 static Standard_Boolean getUsersShapesOfSHUO (TopLoc_IndexedMapOfLocation& aPrevLocMap,
1777 const Handle(XCAFDoc_ShapeTool)& STool,
1778 const TDF_Label& aSHUOlab,
1779 const TDF_Label& theUserL,
1780 TopTools_SequenceOfShape& theSHUOShapeSeq)
1782 TopLoc_IndexedMapOfLocation aNewPrevLocMap;
1783 // get location of the assembly
1784 TopLoc_Location loc = XCAFDoc_ShapeTool::GetLocation ( theUserL.Father() );
1785 // get location of the component
1786 TopLoc_Location compLoc = XCAFDoc_ShapeTool::GetLocation ( theUserL );
1787 // get previous set location
1788 aNewPrevLocMap.Add( loc );
1789 aNewPrevLocMap.Add( compLoc );
1791 for (i = 1; i <= aPrevLocMap.Extent(); i++)
1792 aNewPrevLocMap.Add( aPrevLocMap.FindKey(i) );
1793 TDF_Label L = theUserL.Father();
1794 TDF_LabelSequence usersLab;
1795 ::XCAFDoc_ShapeTool::GetUsers( L, usersLab );
1796 if (usersLab.Length() == 0) {
1797 TopoDS_Shape aShape;
1798 getShapesOfSHUO( aNewPrevLocMap, STool, aSHUOlab, aShape );
1799 if (!aShape.IsNull()) {
1800 theSHUOShapeSeq.Append(aShape);
1801 return Standard_True;
1804 // now iterates on users of this assembly as component
1805 for ( i = 1; i <= usersLab.Length(); i++ ) {
1806 TDF_Label aNewUserL = usersLab.Value(i);
1807 getUsersShapesOfSHUO( aNewPrevLocMap, STool, aSHUOlab, aNewUserL, theSHUOShapeSeq );
1810 return (theSHUOShapeSeq.Length() > 1);
1813 //=======================================================================
1814 //function : GetAllSHUOInstances
1815 //purpose : auxiliary
1816 //=======================================================================
1818 Standard_Boolean XCAFDoc_ShapeTool::GetAllSHUOInstances (const Handle(XCAFDoc_GraphNode)& theSHUO,
1819 TopTools_SequenceOfShape& theSHUOShapeSeq) const
1821 if (theSHUO.IsNull())
1822 return Standard_False;
1824 TDF_Label aSHUOlab = theSHUO->Label();
1825 TopLoc_IndexedMapOfLocation aPrevLocMap;
1826 // get location of the assembly
1827 TopLoc_Location loc = XCAFDoc_ShapeTool::GetLocation ( aSHUOlab.Father().Father() );
1828 // get location of the component
1829 TopLoc_Location compLoc = XCAFDoc_ShapeTool::GetLocation ( aSHUOlab.Father() );
1830 // get previous set location
1831 if ( !loc.IsIdentity() )
1832 aPrevLocMap.Add( loc );
1833 aPrevLocMap.Add( compLoc );
1834 // get label of assembly
1835 TDF_Label L = aSHUOlab.Father().Father();
1836 TDF_LabelSequence usersLab;
1837 ::XCAFDoc_ShapeTool::GetUsers( L, usersLab );
1838 TopoDS_Shape aShape;
1839 const Handle(XCAFDoc_ShapeTool)& STool = this;
1840 if (usersLab.Length() == 0) {
1841 getShapesOfSHUO( aPrevLocMap, STool, aSHUOlab, aShape );
1842 if (!aShape.IsNull()) {
1843 theSHUOShapeSeq.Append(aShape);
1844 return Standard_True;
1847 // now iterates on users of this assembly as component
1848 for (Standard_Integer i = 1; i <= usersLab.Length(); i++) {
1849 TDF_Label aUserL = usersLab.Value(i);
1850 getUsersShapesOfSHUO( aPrevLocMap, STool, aSHUOlab, aUserL, theSHUOShapeSeq );
1853 return (theSHUOShapeSeq.Length() > 1);
1856 //=======================================================================
1857 //function : SetInstanceSHUO
1859 //=======================================================================
1861 Handle(XCAFDoc_GraphNode) XCAFDoc_ShapeTool::SetInstanceSHUO (const TopoDS_Shape& theShape) const
1863 Handle(XCAFDoc_GraphNode) SHUO;
1864 TDF_LabelSequence aLabels;
1865 if ( FindComponent( theShape, aLabels ) )
1866 // set shuo structure on labels of component-assembly structure
1867 SetSHUO( aLabels, SHUO );
1871 //=======================================================================
1872 //function : FindSHUO
1874 //=======================================================================
1876 Standard_Boolean XCAFDoc_ShapeTool::FindSHUO (const TDF_LabelSequence& theLabels,
1877 Handle(XCAFDoc_GraphNode)& theSHUOAttr)
1879 TDF_AttributeSequence SHUOAttrs;
1880 TDF_Label aCompLabel = theLabels.Value(1);
1881 if (! ::XCAFDoc_ShapeTool::GetAllComponentSHUO( aCompLabel, SHUOAttrs ) )
1882 return Standard_False;
1883 // WARNING: manage that each SHUO upper_usage have only one SHUO next_usage
1884 for (Standard_Integer i = 1; i <= SHUOAttrs.Length(); i++) {
1885 TDF_LabelSequence aCondidate;
1886 Handle(XCAFDoc_GraphNode) anSHUO = Handle(XCAFDoc_GraphNode)::DownCast(SHUOAttrs.Value(i));
1887 aCondidate.Append( anSHUO->Label().Father() );
1888 while (anSHUO->NbChildren()) {
1889 anSHUO = anSHUO->GetChild( 1 );
1890 aCondidate.Append( anSHUO->Label().Father() );
1892 // check the label sequences
1893 Standard_Boolean isEqual = Standard_True;
1894 if (theLabels.Length() != aCondidate.Length())
1895 isEqual = Standard_False;
1897 for (Standard_Integer li = 1; li <= theLabels.Length(); li++)
1898 if ( theLabels.Value(li) != aCondidate.Value(li) ) {
1899 isEqual = Standard_False;
1905 theSHUOAttr = Handle(XCAFDoc_GraphNode)::DownCast(SHUOAttrs.Value(i));
1908 return ( !theSHUOAttr.IsNull() );
1911 //=======================================================================
1914 //=======================================================================
1915 Standard_Boolean XCAFDoc_ShapeTool::Expand (const TDF_Label& theShapeL)
1917 if (theShapeL.IsNull() || IsAssembly(theShapeL))
1918 return Standard_False;
1920 TopoDS_Shape aShape = GetShape(theShapeL);
1921 if (aShape.IsNull())
1922 return Standard_False;
1924 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
1925 Standard_Boolean isExpandedType = aShapeType == TopAbs_COMPOUND || aShapeType == TopAbs_COMPSOLID ||
1926 aShapeType == TopAbs_SHELL || aShapeType == TopAbs_WIRE;
1929 TopoDS_Iterator anIter(aShape);
1930 for(; anIter.More(); anIter.Next())
1932 const TopoDS_Shape& aChildShape = anIter.Value();
1933 TDF_Label aChild, aPart;
1935 // Find child shape as subshape of expanded shape
1936 FindSubShape(theShapeL, aChildShape, aChild);
1937 Handle(TDataStd_Name) anAttr;
1938 //make child (if color isn't set or if it is compound)
1939 if (aChild.IsNull()) {
1940 aChild = AddSubShape(theShapeL, aChildShape);
1944 aChild.FindAttribute(TDataStd_Name::GetID(), anAttr);
1947 // Try to find child shape as already existed part
1948 aPart = FindShape(aChildShape.Located(TopLoc_Location()));
1949 if (aPart.IsNull()) {
1950 // Create new part to link child shape
1951 aPart = AddShape(aChildShape.Located(TopLoc_Location()), Standard_False, Standard_False);
1953 // Add shape manually, if already existed subshape found instead of creation of new part
1954 if (!aPart.IsNull() && !IsTopLevel(aPart)) {
1955 if (!GetReferredShape(aPart, aPart)) {
1957 aPart = aTag.NewChild(Label());
1958 SetShape(aPart, aChildShape.Located(TopLoc_Location()));
1963 if (!anAttr.IsNull()) {
1964 TDataStd_Name::Set(aPart, anAttr->Get());
1967 Standard_SStream Stream;
1968 TopAbs::Print(aChildShape.ShapeType(), Stream);
1969 TCollection_AsciiString aName(Stream.str().c_str());
1970 TDataStd_Name::Set(aPart, TCollection_ExtendedString(aName));
1972 MakeReference(aChild, aPart, aChildShape.Location());
1973 makeSubShape(theShapeL, aPart, aChildShape, aChildShape.Location());
1975 //set assembly attribute
1976 TDataStd_UAttribute::Set(theShapeL, XCAFDoc::AssemblyGUID());
1977 return Standard_True;
1979 return Standard_False;
1982 //=======================================================================
1983 //function : makeSubShape
1985 //=======================================================================
1987 void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& theMainShapeL,
1988 const TDF_Label& thePart,
1989 const TopoDS_Shape& theShape,
1990 const TopLoc_Location& theLoc)
1992 TopoDS_Iterator anIter(theShape);
1993 Standard_Boolean isCompoundPart = (GetShape(thePart).ShapeType() == TopAbs_COMPOUND);
1994 Standard_Boolean isAssembly = IsAssembly(thePart);
1996 for(; anIter.More(); anIter.Next()) {
1997 const TopoDS_Shape& aChildShape = anIter.Value();
1998 TDF_Label aChildLabel;
1999 FindSubShape(theMainShapeL, aChildShape, aChildLabel);
2000 if(!aChildLabel.IsNull()) {
2002 aChildLabel.ForgetAllAttributes();
2003 makeSubShape(theMainShapeL, thePart, aChildShape, theLoc);
2007 Handle(TDataStd_Name) anAttr;
2008 aChildLabel.FindAttribute(TDataStd_Name::GetID(), anAttr);
2009 TopLoc_Location aSubLoc;
2010 // Calculate location for subshapes of compound parts
2011 aSubLoc = aChildShape.Location();
2013 aSubLoc = theLoc.Inverted() * aSubLoc;
2015 TDF_Label aSubLabel;
2016 // Identical location and empty location are not the same for ShapeTool, so try to process both
2017 // in case of aSubLoc is not identical, the second Add try will not affect algorithm.
2018 Standard_Boolean isNewSubL;
2019 isNewSubL = AddSubShape(thePart, aChildShape.Located(aSubLoc, Standard_False), aSubLabel);
2020 if (aSubLabel.IsNull())
2022 isNewSubL = AddSubShape(thePart, aChildShape.Located(TopLoc_Location()), aSubLabel);
2025 //set name to sub shape
2026 if (!anAttr.IsNull()) {
2027 TDataStd_Name::Set(aSubLabel, anAttr->Get());
2030 Standard_SStream Stream;
2031 TopAbs::Print(aChildShape.ShapeType(), Stream);
2032 TCollection_AsciiString aName(Stream.str().c_str());
2033 TDataStd_Name::Set(aSubLabel, TCollection_ExtendedString(aName));
2035 // Create auxiliary link, it will be removed during moving attributes
2036 MakeReference(aSubLabel, aChildLabel, aChildShape.Location());
2039 aChildLabel.ForgetAllAttributes();
2043 makeSubShape(theMainShapeL, thePart, aChildShape, theLoc);
2047 //=======================================================================
2048 //function : updateComponent
2050 //=======================================================================
2052 Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel,
2053 TopoDS_Shape& theUpdatedShape,
2054 TDF_LabelMap& theUpdated) const
2056 if ( !IsAssembly(theItemLabel) )
2057 return Standard_False; // Do nothing for non-assemblies
2059 // Get the currently stored compound for the assembly
2060 TopoDS_Shape aCurrentRootShape;
2061 GetShape(theItemLabel, aCurrentRootShape);
2063 // Check if the given assembly is already updated
2064 if (theUpdated.Contains(theItemLabel)) {
2065 theUpdatedShape = aCurrentRootShape;
2066 return Standard_True;
2069 TopTools_MapOfOrientedShape aCurrentRootShapeMap (aCurrentRootShape.NbChildren());
2071 // Get components of the assembly
2072 TDF_LabelSequence aComponentLabs;
2073 GetComponents(theItemLabel, aComponentLabs);
2075 // This flag indicates whether to update the compound of the assembly
2076 Standard_Boolean isModified = Standard_False;
2078 // Compare the number of components in XDE structure with the number of
2079 // components in topological structure. A component may happen to be removed,
2080 // so we have to update the assembly compound
2081 const Standard_Integer aNumTopoComponents = aCurrentRootShape.NbChildren();
2083 if ( aNumTopoComponents != aComponentLabs.Length() )
2084 isModified = Standard_True;
2086 // Iterate over the assembly components. If at least one component is
2087 // modified (this is the recursive check), then the actually stored
2088 // compound has to be updated
2089 TopTools_ListOfShape aComponentShapes;
2091 for ( TDF_LabelSequence::Iterator aCompIt(aComponentLabs); aCompIt.More(); aCompIt.Next() )
2093 const TDF_Label& aComponentLab = aCompIt.Value();
2095 // Take the referred assembly item (ultimately, a part for an instance)
2096 TDF_Label aComponentRefLab;
2097 GetReferredShape(aComponentLab, aComponentRefLab);
2099 // Shape comes with some placement transformation here
2100 TopoDS_Shape aComponentShape;
2101 GetShape(aComponentLab, aComponentShape);
2102 TopLoc_Location aComponentLoc = aComponentShape.Location();
2104 // If the component is a sub-assembly, then its associated compound
2105 // has to be processed in the same manner
2106 if ( IsAssembly(aComponentRefLab) )
2109 if ( updateComponent(aComponentRefLab, aComponentShape, theUpdated) )
2111 isModified = Standard_True;
2112 aComponentShape.Location(aComponentLoc, Standard_False); // Apply placement
2117 // Search for a part in the actual compound of the ultimate assembly.
2118 // If the part is there, then the compound is up-to-date, so it does not require rebuilding
2121 if (aCurrentRootShapeMap.IsEmpty())
2123 // optimize search for next labels in aComponentLabs
2124 for (TopoDS_Iterator aTopoIt(aCurrentRootShape); aTopoIt.More(); aTopoIt.Next())
2126 aCurrentRootShapeMap.Add (aTopoIt.Value());
2129 if (!aCurrentRootShapeMap.Contains (aComponentShape))
2131 // Part has been modified somewhere, so the compound has to be rebuilt
2132 isModified = Standard_True;
2137 // Fill the list of shapes composing a new compound for the assembly
2138 aComponentShapes.Append(aComponentShape);
2141 // If any component is modified, we update the currently stored shape
2144 TopoDS_Compound anUpdatedCompound;
2146 aBB.MakeCompound(anUpdatedCompound);
2148 // Compose new compound
2149 for ( TopTools_ListIteratorOfListOfShape aShapeIt(aComponentShapes); aShapeIt.More(); aShapeIt.Next() )
2151 aBB.Add( anUpdatedCompound, aShapeIt.Value() );
2154 // Store the updated shape as an output
2155 theUpdatedShape = anUpdatedCompound;
2157 // Use topological naming services to store the updated shape in XDE
2158 TNaming_Builder NB(theItemLabel);
2159 NB.Generated(theUpdatedShape);
2163 theUpdated.Add(theItemLabel);
2168 //=======================================================================
2169 //function : GetNamedProperties
2171 //=======================================================================
2173 Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TDF_Label& theLabel,
2174 const Standard_Boolean theToCreate) const
2176 Handle(TDataStd_NamedData) aNamedProperty;
2177 if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), aNamedProperty) && theToCreate)
2179 aNamedProperty = TDataStd_NamedData::Set(theLabel);
2182 return aNamedProperty;
2185 //=======================================================================
2186 //function : GetNamedProperties
2188 //=======================================================================
2190 Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TopoDS_Shape& theShape,
2191 const Standard_Boolean theToCreate) const
2193 Handle(TDataStd_NamedData) aNamedProperty;
2195 if (!Search (theShape, aLabel))
2196 return aNamedProperty;
2198 aNamedProperty = GetNamedProperties (aLabel, theToCreate);
2200 return aNamedProperty;
2203 //=======================================================================
2204 //function : DumpJson
2206 //=======================================================================
2207 void XCAFDoc_ShapeTool::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
2209 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
2211 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
2213 for (XCAFDoc_DataMapOfShapeLabel::Iterator aShapeLabelIt (myShapeLabels); aShapeLabelIt.More(); aShapeLabelIt.Next())
2215 const TopoDS_Shape aShape = aShapeLabelIt.Key();
2216 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &aShape)
2218 TCollection_AsciiString aShapeLabel;
2219 TDF_Tool::Entry (aShapeLabelIt.Value(), aShapeLabel);
2220 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aShapeLabel)
2223 for (XCAFDoc_DataMapOfShapeLabel::Iterator aSubShapeIt (mySubShapes); aSubShapeIt.More(); aSubShapeIt.Next())
2225 const TopoDS_Shape aSubShape = aSubShapeIt.Key();
2226 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &aSubShape)
2228 TCollection_AsciiString aSubShapeLabel;
2229 TDF_Tool::Entry (aSubShapeIt.Value(), aSubShapeLabel);
2230 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aSubShapeLabel)
2233 for (XCAFDoc_DataMapOfShapeLabel::Iterator aSimpleShapeIt (mySimpleShapes); aSimpleShapeIt.More(); aSimpleShapeIt.Next())
2235 const TopoDS_Shape aSimpleShape = aSimpleShapeIt.Key();
2236 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &aSimpleShape)
2238 TCollection_AsciiString aSimpleShapeLabel;
2239 TDF_Tool::Entry (aSimpleShapeIt.Value(), aSimpleShapeLabel);
2240 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aSimpleShapeLabel)
2243 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, hasSimpleShapes)