1 // Copyright (C) 2007-2024 CEA, EDF, 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, or (at your option) any later version.
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_GetInPlaceIterator.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_GetInPlace.hxx>
28 #include <GEOMAlgo_CoupleOfShapes.hxx>
31 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
32 const TopAbs_ShapeEnum aType2);
34 //=======================================================================
37 //=======================================================================
38 GEOMAlgo_GetInPlaceIterator::GEOMAlgo_GetInPlaceIterator()
42 //=======================================================================
45 //=======================================================================
46 GEOMAlgo_GetInPlaceIterator::~GEOMAlgo_GetInPlaceIterator()
49 //=======================================================================
52 //=======================================================================
53 void GEOMAlgo_GetInPlaceIterator::Clear()
57 for (i=0; i<myDim; ++i) {
61 //=======================================================================
62 //function : AppendPair
64 //=======================================================================
65 void GEOMAlgo_GetInPlaceIterator::AppendPair(const GEOMAlgo_CoupleOfShapes& theCS)
68 TopAbs_ShapeEnum aType1, aType2;
70 const TopoDS_Shape& aS1=theCS.Shape1();
71 const TopoDS_Shape& aS2=theCS.Shape2();
72 aType1=aS1.ShapeType();
73 aType2=aS2.ShapeType();
75 iX=TypeToInteger(aType1, aType2);
77 myLists[iX].Append(theCS);
79 // Add inverted pair of shapes.
80 iX=TypeToInteger(aType2, aType1);
83 GEOMAlgo_CoupleOfShapes aCSInv;
85 aCSInv.SetShapes(aS2, aS1);
86 myLists[iX].Append(aCSInv);
90 //=======================================================================
91 //function : ShapeWhere
93 //=======================================================================
94 void GEOMAlgo_GetInPlaceIterator::Initialize(const TopAbs_ShapeEnum aType1,
95 const TopAbs_ShapeEnum aType2)
99 iX=TypeToInteger(aType1, aType2);
101 myIterator.Initialize(myLists[iX]);
104 myIterator.Initialize(myEmptyList);
107 //=======================================================================
110 //=======================================================================
111 Standard_Boolean GEOMAlgo_GetInPlaceIterator::More()const
113 return myIterator.More();
115 //=======================================================================
118 //=======================================================================
119 void GEOMAlgo_GetInPlaceIterator::Next()
123 //=======================================================================
126 //=======================================================================
127 const GEOMAlgo_CoupleOfShapes& GEOMAlgo_GetInPlaceIterator::Value()const
129 return myIterator.Value();
131 //=======================================================================
132 //function : TypeToInteger
134 //=======================================================================
135 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
136 const TopAbs_ShapeEnum aType2)
138 Standard_Integer iRet;
142 if (aType1==TopAbs_VERTEX) {
143 if (aType2==TopAbs_VERTEX) {
147 else if (aType1==TopAbs_EDGE) {
148 if (aType2==TopAbs_VERTEX) {
151 else if (aType2==TopAbs_EDGE) {
155 else if (aType1==TopAbs_FACE) {
156 if (aType2==TopAbs_VERTEX) {
159 else if (aType2==TopAbs_EDGE) {
162 else if (aType2==TopAbs_FACE) {
167 else if (aType1==TopAbs_SOLID) {
168 if (aType2==TopAbs_VERTEX) {
171 else if (aType2==TopAbs_EDGE) {
174 else if (aType2==TopAbs_FACE) {
177 else if (aType2==TopAbs_SOLID) {