1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
20 #include <XCAFDoc_ShapeMapTool.ixx>
21 #include <TopoDS_Iterator.hxx>
23 #define AUTONAMING // automatically set names for labels
25 // attribute methods //////////////////////////////////////////////////
27 //=======================================================================
30 //=======================================================================
32 const Standard_GUID& XCAFDoc_ShapeMapTool::GetID()
34 static Standard_GUID ShapeToolID ("3B913F4D-4A82-44ef-A0BF-9E01E9FF317A");
38 //=======================================================================
41 //=======================================================================
43 Handle(XCAFDoc_ShapeMapTool) XCAFDoc_ShapeMapTool::Set(const TDF_Label& L)
45 Handle(XCAFDoc_ShapeMapTool) A;
46 if (!L.FindAttribute (XCAFDoc_ShapeMapTool::GetID(), A)) {
47 A = new XCAFDoc_ShapeMapTool ();
53 //=======================================================================
56 //=======================================================================
58 const Standard_GUID& XCAFDoc_ShapeMapTool::ID() const
63 //=======================================================================
66 //=======================================================================
68 void XCAFDoc_ShapeMapTool::Restore(const Handle(TDF_Attribute)& /*with*/)
72 //=======================================================================
75 //=======================================================================
77 Handle(TDF_Attribute) XCAFDoc_ShapeMapTool::NewEmpty() const
79 return new XCAFDoc_ShapeMapTool;
82 //=======================================================================
85 //=======================================================================
87 void XCAFDoc_ShapeMapTool::Paste (const Handle(TDF_Attribute)& /*into*/,
88 const Handle(TDF_RelocationTable)& /*RT*/) const
92 //=======================================================================
93 //function : Constructor
95 //=======================================================================
97 XCAFDoc_ShapeMapTool::XCAFDoc_ShapeMapTool()
102 //=======================================================================
103 //function : IsSubShape
105 //=======================================================================
107 Standard_Boolean XCAFDoc_ShapeMapTool::IsSubShape(const TopoDS_Shape& sub) const
109 return myMap.Contains(sub);
113 //=======================================================================
114 //function : SetShape
116 //=======================================================================
117 static void AddSubShape(const TopoDS_Shape& S,
118 TopTools_IndexedMapOfShape& myMap)
121 for ( TopoDS_Iterator it(S); it.More(); it.Next() )
122 AddSubShape(it.Value(),myMap);
126 //=======================================================================
127 //function : SetShape
129 //=======================================================================
131 void XCAFDoc_ShapeMapTool::SetShape(const TopoDS_Shape& S)
134 for ( TopoDS_Iterator it(S); it.More(); it.Next() )
135 AddSubShape(it.Value(),myMap);
140 //=======================================================================
143 //=======================================================================
145 const TopTools_IndexedMapOfShape& XCAFDoc_ShapeMapTool::GetMap() const