1 // Copyright (C) 2007-2010 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
100 TopTools_ListOfShape *pL;
101 TopTools_MapIteratorOfMapOfOrientedShape aIt;
103 pL=(TopTools_ListOfShape *)&myList;
105 aIt.Initialize(myMap);
106 for (; aIt.More(); aIt.Next()) {
107 pL->Append(aIt.Key());
112 //=======================================================================
113 //function : Contains
115 //=======================================================================
116 Standard_Boolean GEOMAlgo_ShapeSet::Contains(const GEOMAlgo_ShapeSet& theOther)const
118 Standard_Boolean bRet;
119 TopAbs_Orientation aOr;
120 TopTools_ListIteratorOfListOfShape aIt;
123 const TopTools_ListOfShape& aLS=theOther.GetSet();
125 for (; aIt.More(); aIt.Next()) {
126 const TopoDS_Shape& aF=aIt.Value();
127 aOr=aF.Orientation();
128 if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
129 bRet=myMap.Contains(aF);
137 //=======================================================================
138 //function : Subtract
140 //=======================================================================
141 void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther)
144 TopTools_MapIteratorOfMapOfOrientedShape aIt;
146 aIt.Initialize(theOther.myMap);
147 for (; aIt.More(); aIt.Next()) {
148 const TopoDS_Shape& aS=aIt.Key();
153 TopTools_ListIteratorOfListOfShape aIt;
154 TopTools_ListOfShape aLS;
157 aIt.Initialize(myList);
158 for (; aIt.More(); aIt.Next()) {
159 const TopoDS_Shape& aS=aIt.Value();
160 if (!theOther.myMap.Contains(aS)) {