0024171: Eliminate CLang compiler warning -Wreorder
[occt.git] / src / XCAFDoc / XCAFDoc_ShapeMapTool.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
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.
7 //
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.
10 //
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.
17
18
19
20 #include <XCAFDoc_ShapeMapTool.ixx>
21 #include <TopoDS_Iterator.hxx>
22
23 #define AUTONAMING // automatically set names for labels
24
25 // attribute methods //////////////////////////////////////////////////
26
27 //=======================================================================
28 //function : GetID
29 //purpose  : 
30 //=======================================================================
31
32 const Standard_GUID& XCAFDoc_ShapeMapTool::GetID() 
33 {
34   static Standard_GUID ShapeToolID ("3B913F4D-4A82-44ef-A0BF-9E01E9FF317A");
35   return ShapeToolID; 
36 }
37
38 //=======================================================================
39 //function : Set
40 //purpose  : 
41 //=======================================================================
42
43 Handle(XCAFDoc_ShapeMapTool) XCAFDoc_ShapeMapTool::Set(const TDF_Label& L) 
44 {
45   Handle(XCAFDoc_ShapeMapTool) A;
46   if (!L.FindAttribute (XCAFDoc_ShapeMapTool::GetID(), A)) {
47     A = new XCAFDoc_ShapeMapTool ();
48     L.AddAttribute(A);
49   }
50   return A;
51 }
52
53 //=======================================================================
54 //function : ID
55 //purpose  : 
56 //=======================================================================
57
58 const Standard_GUID& XCAFDoc_ShapeMapTool::ID() const
59 {
60   return GetID();
61 }
62
63 //=======================================================================
64 //function : Restore
65 //purpose  : 
66 //=======================================================================
67
68 void XCAFDoc_ShapeMapTool::Restore(const Handle(TDF_Attribute)& /*with*/) 
69 {
70 }
71
72 //=======================================================================
73 //function : NewEmpty
74 //purpose  : 
75 //=======================================================================
76
77 Handle(TDF_Attribute) XCAFDoc_ShapeMapTool::NewEmpty() const
78 {
79   return new XCAFDoc_ShapeMapTool;
80 }
81
82 //=======================================================================
83 //function : Paste
84 //purpose  : 
85 //=======================================================================
86
87 void XCAFDoc_ShapeMapTool::Paste (const Handle(TDF_Attribute)& /*into*/,
88                                   const Handle(TDF_RelocationTable)& /*RT*/) const
89 {
90 }
91
92 //=======================================================================
93 //function : Constructor
94 //purpose  : 
95 //=======================================================================
96
97 XCAFDoc_ShapeMapTool::XCAFDoc_ShapeMapTool()
98 {
99 }
100
101
102 //=======================================================================
103 //function : IsSubShape
104 //purpose  : 
105 //=======================================================================
106
107 Standard_Boolean XCAFDoc_ShapeMapTool::IsSubShape(const TopoDS_Shape& sub) const
108 {
109   return myMap.Contains(sub);
110 }
111
112
113 //=======================================================================
114 //function : SetShape
115 //purpose  : auxilary
116 //=======================================================================
117 static void AddSubShape(const TopoDS_Shape& S,
118                         TopTools_IndexedMapOfShape& myMap) 
119 {
120   myMap.Add(S);
121   for ( TopoDS_Iterator it(S); it.More(); it.Next() )
122     AddSubShape(it.Value(),myMap);
123 }
124
125
126 //=======================================================================
127 //function : SetShape
128 //purpose  : 
129 //=======================================================================
130
131 void XCAFDoc_ShapeMapTool::SetShape(const TopoDS_Shape& S)
132 {
133   myMap.Clear();
134   for ( TopoDS_Iterator it(S); it.More(); it.Next() )
135     AddSubShape(it.Value(),myMap);
136   
137 }
138
139
140 //=======================================================================
141 //function : GetMap
142 //purpose  : 
143 //=======================================================================
144
145 const TopTools_IndexedMapOfShape& XCAFDoc_ShapeMapTool::GetMap() const
146 {
147   return myMap;
148 }