1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: GEOMAlgo_ShapeSet.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_ShapeSet.ixx>
28 #include <TopExp_Explorer.hxx>
30 #include <TopTools_ListIteratorOfListOfShape.hxx>
31 #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
33 //=======================================================================
36 //=======================================================================
37 GEOMAlgo_ShapeSet::GEOMAlgo_ShapeSet()
40 //=======================================================================
43 //=======================================================================
44 void GEOMAlgo_ShapeSet::Clear()
49 //=======================================================================
52 //=======================================================================
53 void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape)
55 if (myMap.Add(theShape)) {
56 myList.Append(theShape);
59 //=======================================================================
62 //=======================================================================
63 void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape,
64 const TopAbs_ShapeEnum theType)
68 aExp.Init(theShape, theType);
69 for (; aExp.More(); aExp.Next()) {
70 const TopoDS_Shape& aS=aExp.Current();
76 //=======================================================================
79 //=======================================================================
80 void GEOMAlgo_ShapeSet::Add(const TopTools_ListOfShape& theLS)
82 TopTools_ListIteratorOfListOfShape aIt;
84 aIt.Initialize(theLS);
85 for (; aIt.More(); aIt.Next()) {
86 const TopoDS_Shape& aS=aIt.Value();
92 //=======================================================================
95 //=======================================================================
96 const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const
99 TopTools_ListOfShape *pL;
100 TopTools_MapIteratorOfMapOfOrientedShape aIt;
102 pL=(TopTools_ListOfShape *)&myList;
104 aIt.Initialize(myMap);
105 for (; aIt.More(); aIt.Next()) {
106 pL->Append(aIt.Key());
111 //=======================================================================
112 //function : Contains
114 //=======================================================================
115 Standard_Boolean GEOMAlgo_ShapeSet::Contains(const GEOMAlgo_ShapeSet& theOther)const
117 Standard_Boolean bRet;
118 TopAbs_Orientation aOr;
119 TopTools_ListIteratorOfListOfShape aIt;
122 const TopTools_ListOfShape& aLS=theOther.GetSet();
124 for (; aIt.More(); aIt.Next()) {
125 const TopoDS_Shape& aF=aIt.Value();
126 aOr=aF.Orientation();
127 if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
128 bRet=myMap.Contains(aF);
136 //=======================================================================
137 //function : Subtract
139 //=======================================================================
140 void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther)
143 TopTools_MapIteratorOfMapOfOrientedShape aIt;
145 aIt.Initialize(theOther.myMap);
146 for (; aIt.More(); aIt.Next()) {
147 const TopoDS_Shape& aS=aIt.Key();
152 TopTools_ListIteratorOfListOfShape aIt;
153 TopTools_ListOfShape aLS;
156 aIt.Initialize(myList);
157 for (; aIt.More(); aIt.Next()) {
158 const TopoDS_Shape& aS=aIt.Value();
159 if (!theOther.myMap.Contains(aS)) {