Salome HOME
4e8f42a612edd0c3e5c8dbd9c2fdbe68f7daaa1f
[modules/geom.git] / src / NMTTools / NMTTools_CommonBlock.cxx
1 // Copyright (C) 2007-2013  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
23 // File:        NMTTools_CommonBlock.cxx
24 // Created:     Tue Dec  9 12:23:29 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_CommonBlock.hxx>
29
30 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
31 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32
33 //=======================================================================
34 // function:  NMTTools_CommonBlock::NMTTools_CommonBlock()
35 // purpose:
36 //=======================================================================
37   NMTTools_CommonBlock::NMTTools_CommonBlock()
38 {
39 }
40 //=======================================================================
41 // function:  AddPaveBlock
42 // purpose:
43 //=======================================================================
44   void NMTTools_CommonBlock::AddPaveBlock(const BOPTools_PaveBlock& aPB)
45 {
46   myPaveBlocks.Append(aPB);
47 }
48 //=======================================================================
49 // function:  AddFace
50 // purpose:
51 //=======================================================================
52   void NMTTools_CommonBlock::AddFace(const Standard_Integer aF)
53 {
54   myFaces.Append(aF);
55 }
56 //=======================================================================
57 // function:  AddFaces
58 // purpose:
59 //=======================================================================
60   void NMTTools_CommonBlock::AddFaces(const TColStd_ListOfInteger& aLF)
61 {
62   TColStd_ListIteratorOfListOfInteger aIt(aLF);
63   //
64   for (; aIt.More(); aIt.Next()) {
65     myFaces.Append(aIt.Value());
66   }
67 }
68 //=======================================================================
69 // function:  PaveBlocks
70 // purpose:
71 //=======================================================================
72   const BOPTools_ListOfPaveBlock& NMTTools_CommonBlock::PaveBlocks()const
73 {
74   return myPaveBlocks;
75 }
76 //=======================================================================
77 // function:  Faces
78 // purpose:
79 //=======================================================================
80   const TColStd_ListOfInteger& NMTTools_CommonBlock::Faces()const
81 {
82   return myFaces;
83 }
84 //=======================================================================
85 // function:  PaveBlock1
86 // purpose:
87 //=======================================================================
88   const BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1()const
89 {
90   return myPaveBlocks.First();
91 }
92 //=======================================================================
93 // function:  PaveBlock1
94 // purpose:
95 //=======================================================================
96    BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1(const Standard_Integer aIx)
97 {
98   return PaveBlockOnEdge(aIx);
99 }
100 //=======================================================================
101 // function:  PaveBlockOnEdge
102 // purpose:
103 //=======================================================================
104    BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx)
105 {
106   static BOPTools_PaveBlock aPBs;
107   Standard_Integer aIOr;
108   BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks);
109   //
110   for (; anIt.More(); anIt.Next()) {
111     BOPTools_PaveBlock& aPB=anIt.Value();
112     aIOr=aPB.OriginalEdge();
113     if (aIOr==aIx){
114       return aPB;
115     }
116   }
117   return aPBs;
118 }
119 //=======================================================================
120 // function:  IsPaveBlockOnFace
121 // purpose:
122 //=======================================================================
123   Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const
124 {
125   Standard_Boolean bFound=Standard_False;
126   Standard_Integer nF;
127   TColStd_ListIteratorOfListOfInteger anIt(myFaces);
128   //
129   for (; anIt.More(); anIt.Next()) {
130     nF=anIt.Value();
131     if (nF==aIx){
132       return !bFound;
133     }
134   }
135   return bFound;
136 }
137 //=======================================================================
138 // function:  IsPaveBlockOnEdge
139 // purpose:
140 //=======================================================================
141   Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const
142 {
143   Standard_Boolean bFound=Standard_False;
144   Standard_Integer aIOr;
145   BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks);
146   //
147   for (; anIt.More(); anIt.Next()) {
148     const BOPTools_PaveBlock& aPB=anIt.Value();
149     aIOr=aPB.OriginalEdge();
150     if (aIOr==aIx){
151       return !bFound;
152     }
153   }
154   return bFound;
155 }
156 //=======================================================================
157 // function:  IsEqual
158 // purpose:
159 //=======================================================================
160   Standard_Boolean NMTTools_CommonBlock::IsEqual(const NMTTools_CommonBlock& aOther)const
161 {
162   Standard_Boolean bFound=Standard_True;
163   Standard_Integer aNb1, aNb2;
164   BOPTools_ListIteratorOfListOfPaveBlock anIt;
165   //
166   aNb1=myPaveBlocks.Extent();
167   aNb2=aOther.myPaveBlocks.Extent();
168   //
169   if (!aNb1 && !aNb2) {
170     return bFound;
171   }
172   if (!aNb1) {
173     return !bFound;
174   }
175   if (!aNb2) {
176     return !bFound;
177   }
178   //
179   const BOPTools_PaveBlock& aPB=PaveBlock1();
180   //
181   anIt.Initialize(aOther.myPaveBlocks);
182   for (; anIt.More(); anIt.Next()) {
183     const BOPTools_PaveBlock& aPBOther=anIt.Value();
184     if (aPB.IsEqual(aPBOther)){
185       return bFound;
186     }
187   }
188   return !bFound;
189 }
190 //=======================================================================
191 // function:  Contains
192 // purpose:
193 //=======================================================================
194   Standard_Boolean NMTTools_CommonBlock::Contains(const BOPTools_PaveBlock& aPBx)const
195 {
196   Standard_Boolean bFound=Standard_False;
197   Standard_Integer aNb1;
198   BOPTools_ListIteratorOfListOfPaveBlock anIt;
199   //
200   aNb1=myPaveBlocks.Extent();
201   //
202   if (!aNb1) {
203     return bFound;
204   }
205   //
206   anIt.Initialize(myPaveBlocks);
207   for (; anIt.More(); anIt.Next()) {
208     const BOPTools_PaveBlock& aPB=anIt.Value();
209     if (aPB.IsEqual(aPBx)) {
210       return !bFound;
211     }
212   }
213   return bFound;
214 }
215 /*
216 //=======================================================================
217 // function:  SetEdge
218 // purpose:
219 //=======================================================================
220   void NMTTools_CommonBlock::SetEdge(const Standard_Integer anEdge)
221 {
222   BOPTools_ListIteratorOfListOfPaveBlock anIt;
223   //
224   anIt.Initialize(myPaveBlocks);
225   for (; anIt.More(); anIt.Next()) {
226     BOPTools_PaveBlock& aPB=anIt.Value();
227     aPB.SetEdge(anEdge);
228   }
229 }
230 //=======================================================================
231 // function:  Edge
232 // purpose:
233 //=======================================================================
234   Standard_Integer NMTTools_CommonBlock::Edge()const
235 {
236   Standard_Integer aNb;
237   //
238   aNb=myPaveBlocks.Extent();
239   //
240   if (!aNb) {
241     return aNb;
242   }
243   //
244   const BOPTools_PaveBlock& aPB=PaveBlock1();
245   aNb=aPB.Edge();
246   return aNb;
247 }
248 */