1 // Copyright (C) 2007-2011 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
23 // File: GEOMAlgo_ShapeSet.cxx
25 // Author: Peter KURNEV
27 #include <GEOMAlgo_ShapeSet.ixx>
29 #include <TopExp_Explorer.hxx>
31 #include <TopTools_ListIteratorOfListOfShape.hxx>
32 #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
34 //=======================================================================
37 //=======================================================================
38 GEOMAlgo_ShapeSet::GEOMAlgo_ShapeSet()
41 //=======================================================================
44 //=======================================================================
45 void GEOMAlgo_ShapeSet::Clear()
50 //=======================================================================
53 //=======================================================================
54 void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape)
56 if (myMap.Add(theShape)) {
57 myList.Append(theShape);
60 //=======================================================================
63 //=======================================================================
64 void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape,
65 const TopAbs_ShapeEnum theType)
69 aExp.Init(theShape, theType);
70 for (; aExp.More(); aExp.Next()) {
71 const TopoDS_Shape& aS=aExp.Current();
77 //=======================================================================
80 //=======================================================================
81 void GEOMAlgo_ShapeSet::Add(const TopTools_ListOfShape& theLS)
83 TopTools_ListIteratorOfListOfShape aIt;
85 aIt.Initialize(theLS);
86 for (; aIt.More(); aIt.Next()) {
87 const TopoDS_Shape& aS=aIt.Value();
93 //=======================================================================
96 //=======================================================================
97 const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const
101 //=======================================================================
102 //function : Contains
104 //=======================================================================
105 Standard_Boolean GEOMAlgo_ShapeSet::Contains(const GEOMAlgo_ShapeSet& theOther)const
107 Standard_Boolean bRet;
108 TopAbs_Orientation aOr;
109 TopTools_ListIteratorOfListOfShape aIt;
112 const TopTools_ListOfShape& aLS=theOther.GetSet();
114 for (; aIt.More(); aIt.Next()) {
115 const TopoDS_Shape& aF=aIt.Value();
116 aOr=aF.Orientation();
117 if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
118 bRet=myMap.Contains(aF);
126 //=======================================================================
127 //function : Subtract
129 //=======================================================================
130 void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther)
132 TopTools_ListIteratorOfListOfShape aIt;
133 TopTools_ListOfShape aLS;
136 aIt.Initialize(myList);
137 for (; aIt.More(); aIt.Next()) {
138 const TopoDS_Shape& aS=aIt.Value();
139 if (!theOther.myMap.Contains(aS)) {
148 //modified by NIZNHY-PKV Wed Oct 28 13:51:36 2010f
149 //=======================================================================
152 //=======================================================================
153 Standard_Boolean GEOMAlgo_ShapeSet::IsEqual(const GEOMAlgo_ShapeSet& theOther)const
155 Standard_Boolean bRet;
156 Standard_Integer aNb1, aNb2;
157 TopTools_ListIteratorOfListOfShape aIt;
160 aNb1=myList.Extent();
161 const TopTools_ListOfShape& aLS2=theOther.GetSet();
167 aIt.Initialize(myList);
168 for (; aIt.More(); aIt.Next()) {
169 const TopoDS_Shape& aS=aIt.Value();
170 if(!theOther.myMap.Contains(aS)) {
177 //modified by NIZNHY-PKV Wed Oct 28 13:51:38 2010t