Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_GetInPlace_3.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:        GEOMAlgo_GetInPlaceIterator.cxx
23 // Created:
24 // Author:      Peter KURNEV
25
26 #include <GEOMAlgo_GetInPlace.hxx>
27
28 #include <NMTTools_CoupleOfShape.hxx>
29
30 static
31   Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
32                                  const TopAbs_ShapeEnum aType2);
33
34 //=======================================================================
35 //function :
36 //purpose  :
37 //=======================================================================
38 GEOMAlgo_GetInPlaceIterator::GEOMAlgo_GetInPlaceIterator()
39 {
40   myDim=10;
41 }
42 //=======================================================================
43 //function : ~
44 //purpose  :
45 //=======================================================================
46 GEOMAlgo_GetInPlaceIterator::~GEOMAlgo_GetInPlaceIterator()
47 {
48 }
49 //=======================================================================
50 //function : Clear
51 //purpose  :
52 //=======================================================================
53 void GEOMAlgo_GetInPlaceIterator::Clear()
54 {
55   Standard_Integer i;
56   //
57   for (i=0; i<myDim; ++i) {
58     myLists[i].Clear();
59   }
60 }
61 //=======================================================================
62 //function : AppendPair
63 //purpose  :
64 //=======================================================================
65 void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS)
66 {
67   Standard_Integer iX;
68   TopAbs_ShapeEnum aType1, aType2;
69   //
70   const TopoDS_Shape& aS1=theCS.Shape1();
71   const TopoDS_Shape& aS2=theCS.Shape2();
72   aType1=aS1.ShapeType();
73   aType2=aS2.ShapeType();
74   //
75   iX=TypeToInteger(aType1, aType2);
76   if (iX>=0) {
77     myLists[iX].Append(theCS);
78   }
79 }
80 //=======================================================================
81 //function : ShapeWhere
82 //purpose  :
83 //=======================================================================
84 void GEOMAlgo_GetInPlaceIterator::Initialize(const TopAbs_ShapeEnum aType1,
85                                              const TopAbs_ShapeEnum aType2)
86 {
87   Standard_Integer iX;
88   //
89   iX=TypeToInteger(aType1, aType2);
90   if (iX>=0) {
91     myIterator.Initialize(myLists[iX]);
92   }
93   else {
94     myIterator.Initialize(myEmptyList);
95   }
96 }
97 //=======================================================================
98 // function: More
99 // purpose:
100 //=======================================================================
101 Standard_Boolean GEOMAlgo_GetInPlaceIterator::More()const
102 {
103   return myIterator.More();
104 }
105 //=======================================================================
106 // function: Next
107 // purpose:
108 //=======================================================================
109 void GEOMAlgo_GetInPlaceIterator::Next()
110 {
111   myIterator.Next();
112 }
113 //=======================================================================
114 // function: Value
115 // purpose:
116 //=======================================================================
117 const NMTTools_CoupleOfShape& GEOMAlgo_GetInPlaceIterator::Value()const
118 {
119   return myIterator.Value();
120 }
121 //=======================================================================
122 //function : TypeToInteger
123 //purpose  :
124 //=======================================================================
125 Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
126                                const TopAbs_ShapeEnum aType2)
127 {
128   Standard_Integer iRet, iT1, iT2, iX;
129   //
130   iRet=-1;
131   //
132   if (aType1==TopAbs_VERTEX) {
133     if (aType2==TopAbs_VERTEX) {
134       iRet=0;
135     }
136   }
137   else if (aType1==TopAbs_EDGE) {
138     if (aType2==TopAbs_VERTEX) {
139       iRet=1;
140     }
141     else if (aType2==TopAbs_EDGE) {
142       iRet=2;
143     }
144   }
145   else if (aType1==TopAbs_FACE) {
146     if (aType2==TopAbs_VERTEX) {
147       iRet=3;
148     }
149     else if (aType2==TopAbs_EDGE) {
150       iRet=4;
151     }
152     else if (aType2==TopAbs_FACE) {
153       iRet=5;
154     }
155   }
156   // So_1,*_2
157   else if (aType1==TopAbs_SOLID) {
158     if (aType2==TopAbs_VERTEX) {
159       iRet=6;
160     }
161     else if (aType2==TopAbs_EDGE) {
162       iRet=7;
163     }
164     else if (aType2==TopAbs_FACE) {
165       iRet=8;
166     }
167     else if (aType2==TopAbs_SOLID) {
168       iRet=9;
169     }
170   }
171   return iRet;
172 }