1 // File: TopOpeBRepTool_connexity.cxx
2 // Created: Wed Dec 9 14:47:29 1998
3 // Author: Xuan PHAM PHU
4 // <xpu@poulopox.paris1.matra-dtv.fr>
7 #include <TopOpeBRepTool_connexity.ixx>
8 #include <TopOpeBRepTool_define.hxx>
9 #include <TopOpeBRepTool_TOOL.hxx>
11 #define M_FORWARD(sta) (sta == TopAbs_FORWARD)
12 #define M_REVERSED(sta) (sta == TopAbs_REVERSED)
13 #define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
14 #define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
22 //=======================================================================
23 //function : TopOpeBRepTool_connexity
25 //=======================================================================
27 TopOpeBRepTool_connexity::TopOpeBRepTool_connexity()
31 //=======================================================================
32 //function : TopOpeBRepTool_connexity
34 //=======================================================================
36 TopOpeBRepTool_connexity::TopOpeBRepTool_connexity(const TopoDS_Shape& Key)
37 : theKey(Key), theItems(1,5)
41 //=======================================================================
44 //=======================================================================
46 void TopOpeBRepTool_connexity::SetKey(const TopoDS_Shape& Key)
53 //=======================================================================
56 //=======================================================================
58 const TopoDS_Shape& TopOpeBRepTool_connexity::Key() const
63 /*static Standard_Integer FUN_toI(const TopAbs_Orientation& O)
65 Standard_Integer Index = 0;
66 if (O == TopAbs_FORWARD) Index = 1;
67 else if (O == TopAbs_REVERSED) Index = 2;
68 else if (O == TopAbs_INTERNAL) Index = 3;
69 else if (O == TopAbs_EXTERNAL) Index = 0;
73 //=======================================================================
76 //=======================================================================
78 Standard_Integer TopOpeBRepTool_connexity::Item(const Standard_Integer OriKey, TopTools_ListOfShape& Item) const
81 Item = theItems(OriKey);
82 return (Item.Extent());
85 //=======================================================================
88 //=======================================================================
90 Standard_Integer TopOpeBRepTool_connexity::AllItems(TopTools_ListOfShape& Item) const
93 for (Standard_Integer i = 1; i <=4; i++) {
94 TopTools_ListOfShape copy; copy.Assign(theItems.Value(i));
100 //=======================================================================
103 //=======================================================================
105 void TopOpeBRepTool_connexity::AddItem(const Standard_Integer OriKey, const TopTools_ListOfShape& Item)
107 TopTools_ListOfShape copy; copy.Assign(Item);
108 theItems(OriKey).Append(copy);
111 void TopOpeBRepTool_connexity::AddItem(const Standard_Integer OriKey, const TopoDS_Shape& Item)
113 TopTools_ListOfShape copy; copy.Append(Item);
114 theItems(OriKey).Append(copy);
117 //=======================================================================
118 //function : RemoveItem
120 //=======================================================================
122 Standard_Boolean TopOpeBRepTool_connexity::RemoveItem(const Standard_Integer OriKey, const TopoDS_Shape& Item)
124 TopTools_ListOfShape& item = theItems.ChangeValue(OriKey);
125 TopTools_ListIteratorOfListOfShape it(item);
127 if (it.Value().IsEqual(Item)) {item.Remove(it); return Standard_True;}
130 return Standard_False;
133 //=======================================================================
134 //function : RemoveItem
136 //=======================================================================
138 Standard_Boolean TopOpeBRepTool_connexity::RemoveItem(const TopoDS_Shape& Item)
140 Standard_Boolean removed = Standard_False;
141 for (Standard_Integer i = 1; i<= 5; i++) {
142 Standard_Boolean found = RemoveItem(i,Item);
143 if (found) removed = Standard_True;
150 //=======================================================================
151 //function : ChangeItem
153 //=======================================================================
155 TopTools_ListOfShape& TopOpeBRepTool_connexity::ChangeItem(const Standard_Integer OriKey)
157 return theItems.ChangeValue(OriKey);
160 //=======================================================================
161 //function : IsMultiple
163 //=======================================================================
165 Standard_Boolean TopOpeBRepTool_connexity::IsMultiple() const
167 TopTools_ListOfShape lfound;
168 Standard_Integer nkeyitem = Item(FORWARD,lfound);
169 // nkeyRitem += Item(INTERNAL,lfound); NOT VALID
170 // if key is vertex : key appears F in closing E, only one time
171 nkeyitem += Item(CLOSING,lfound);
172 Standard_Boolean multiple = (nkeyitem > 1);
176 //=======================================================================
177 //function : IsFaulty
179 //=======================================================================
181 Standard_Boolean TopOpeBRepTool_connexity::IsFaulty() const
183 TopTools_ListOfShape lfound;
184 Standard_Integer nkeyRintem = Item(FORWARD,lfound);
185 Standard_Integer nkeyFitem = Item(REVERSED,lfound);
186 Standard_Boolean faulty = (nkeyRintem != nkeyFitem);
190 //=======================================================================
191 //function : IsInternal
193 //=======================================================================
195 Standard_Integer TopOpeBRepTool_connexity::IsInternal(TopTools_ListOfShape& Item) const
199 // all subshapes of INTERNAL(EXTERNAL) are oriented INTERNAL(EXTERNAL)
200 TopTools_ListOfShape lINT; lINT.Assign(theItems.Value(INTERNAL));
201 TopTools_ListIteratorOfListOfShape it1(lINT);
203 const TopoDS_Shape& item1 = it1.Value();
204 TopAbs_Orientation o1 = item1.Orientation();
205 if (!M_INTERNAL(o1)) {it1.Next(); continue;}
206 Standard_Integer oKey1 = TopOpeBRepTool_TOOL::OriinSor(theKey,item1.Oriented(TopAbs_FORWARD));
207 if (oKey1 != INTERNAL) lINT.Remove(it1);
211 TopTools_ListOfShape lEXT; lEXT.Assign(theItems.Value(EXTERNAL));
212 TopTools_ListIteratorOfListOfShape it2(lEXT);
214 const TopoDS_Shape& item2 = it2.Value();
215 TopAbs_Orientation o2 = item2.Orientation();
216 if (!M_EXTERNAL(o2)) {it2.Next(); continue;}
217 Standard_Integer oKey2 = TopOpeBRepTool_TOOL::OriinSor(theKey,item2.Oriented(TopAbs_FORWARD));
218 if (oKey2 == INTERNAL) lINT.Append(item2);
223 return Item.Extent();