Salome HOME
Update mail address
[modules/geom.git] / src / NMTTools / NMTTools_CommonBlock.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File:        NMTTools_CommonBlock.cxx
21 // Created:     Tue Dec  9 12:23:29 2003
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <NMTTools_CommonBlock.ixx>
27
28 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
30
31 //=======================================================================
32 // function:  NMTTools_CommonBlock::NMTTools_CommonBlock()
33 // purpose: 
34 //=======================================================================
35   NMTTools_CommonBlock::NMTTools_CommonBlock()
36 {
37 }
38 //=======================================================================
39 // function:  AddPaveBlock
40 // purpose: 
41 //=======================================================================
42   void NMTTools_CommonBlock::AddPaveBlock(const BOPTools_PaveBlock& aPB)
43 {
44   myPaveBlocks.Append(aPB);
45 }
46 //=======================================================================
47 // function:  AddFace
48 // purpose: 
49 //=======================================================================
50   void NMTTools_CommonBlock::AddFace(const Standard_Integer aF)
51 {
52   myFaces.Append(aF);
53 }
54 //=======================================================================
55 // function:  AddFaces
56 // purpose: 
57 //=======================================================================
58   void NMTTools_CommonBlock::AddFaces(const TColStd_ListOfInteger& aLF)
59 {
60   TColStd_ListIteratorOfListOfInteger aIt(aLF);
61   //
62   for (; aIt.More(); aIt.Next()) {
63     myFaces.Append(aIt.Value());
64   }
65 }
66 //=======================================================================
67 // function:  PaveBlocks
68 // purpose: 
69 //=======================================================================
70   const BOPTools_ListOfPaveBlock& NMTTools_CommonBlock::PaveBlocks()const
71 {
72   return myPaveBlocks;
73 }
74 //=======================================================================
75 // function:  Faces
76 // purpose: 
77 //=======================================================================
78   const TColStd_ListOfInteger& NMTTools_CommonBlock::Faces()const
79 {
80   return myFaces;
81 }
82 //=======================================================================
83 // function:  PaveBlock1
84 // purpose: 
85 //=======================================================================
86   const BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1()const
87 {
88   return myPaveBlocks.First();
89 }
90 //=======================================================================
91 // function:  PaveBlock1
92 // purpose: 
93 //=======================================================================
94    BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1(const Standard_Integer aIx)
95 {
96   return PaveBlockOnEdge(aIx);
97 }
98 //=======================================================================
99 // function:  PaveBlockOnEdge
100 // purpose: 
101 //=======================================================================
102    BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx)
103 {
104   static BOPTools_PaveBlock aPBs;
105   Standard_Integer aIOr;
106   BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks);
107   //
108   for (; anIt.More(); anIt.Next()) {
109     BOPTools_PaveBlock& aPB=anIt.Value();
110     aIOr=aPB.OriginalEdge();
111     if (aIOr==aIx){
112       return aPB;
113     }
114   }
115   return aPBs;
116 }
117 //=======================================================================
118 // function:  IsPaveBlockOnFace
119 // purpose: 
120 //=======================================================================
121   Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const
122 {
123   Standard_Boolean bFound=Standard_False;
124   Standard_Integer nF;
125   TColStd_ListIteratorOfListOfInteger anIt(myFaces);
126   //
127   for (; anIt.More(); anIt.Next()) {
128     nF=anIt.Value();
129     if (nF==aIx){
130       return !bFound;
131     }
132   }
133   return bFound;
134 }
135 //=======================================================================
136 // function:  IsPaveBlockOnEdge
137 // purpose: 
138 //=======================================================================
139   Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const
140 {
141   Standard_Boolean bFound=Standard_False;
142   Standard_Integer aIOr;
143   BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks);
144   //
145   for (; anIt.More(); anIt.Next()) {
146     const BOPTools_PaveBlock& aPB=anIt.Value();
147     aIOr=aPB.OriginalEdge();
148     if (aIOr==aIx){
149       return !bFound;
150     }
151   }
152   return bFound;
153 }
154 //=======================================================================
155 // function:  IsEqual
156 // purpose: 
157 //=======================================================================
158   Standard_Boolean NMTTools_CommonBlock::IsEqual(const NMTTools_CommonBlock& aOther)const
159 {
160   Standard_Boolean bFound=Standard_True;
161   Standard_Integer aNb1, aNb2;
162   BOPTools_ListIteratorOfListOfPaveBlock anIt;
163   //
164   aNb1=myPaveBlocks.Extent();
165   aNb2=aOther.myPaveBlocks.Extent();
166   //
167   if (!aNb1 && !aNb2) {
168     return bFound;
169   }
170   if (!aNb1) {
171     return !bFound;
172   }
173   if (!aNb2) {
174     return !bFound;
175   }
176   //
177   const BOPTools_PaveBlock& aPB=PaveBlock1();
178   //
179   anIt.Initialize(aOther.myPaveBlocks);
180   for (; anIt.More(); anIt.Next()) {
181     const BOPTools_PaveBlock& aPBOther=anIt.Value();
182     if (aPB.IsEqual(aPBOther)){
183       return bFound;
184     }
185   }
186   return !bFound;
187 }
188 //=======================================================================
189 // function:  Contains
190 // purpose: 
191 //=======================================================================
192   Standard_Boolean NMTTools_CommonBlock::Contains(const BOPTools_PaveBlock& aPBx)const
193 {
194   Standard_Boolean bFound=Standard_False;
195   Standard_Integer aNb1;
196   BOPTools_ListIteratorOfListOfPaveBlock anIt;
197   //
198   aNb1=myPaveBlocks.Extent();
199   //
200   if (!aNb1) {
201     return bFound;
202   }
203   //
204   anIt.Initialize(myPaveBlocks);
205   for (; anIt.More(); anIt.Next()) {
206     const BOPTools_PaveBlock& aPB=anIt.Value();
207     if (aPB.IsEqual(aPBx)) {
208       return !bFound;
209     }
210   }
211   return bFound;
212 }
213 /*
214 //=======================================================================
215 // function:  SetEdge
216 // purpose: 
217 //=======================================================================
218   void NMTTools_CommonBlock::SetEdge(const Standard_Integer anEdge)
219 {
220   BOPTools_ListIteratorOfListOfPaveBlock anIt;
221   //
222   anIt.Initialize(myPaveBlocks);
223   for (; anIt.More(); anIt.Next()) {
224     BOPTools_PaveBlock& aPB=anIt.Value();
225     aPB.SetEdge(anEdge);
226   }
227 }
228 //=======================================================================
229 // function:  Edge
230 // purpose: 
231 //=======================================================================
232   Standard_Integer NMTTools_CommonBlock::Edge()const
233 {
234   Standard_Integer aNb;
235   //
236   aNb=myPaveBlocks.Extent();
237   //
238   if (!aNb) {
239     return aNb;
240   }
241   //
242   const BOPTools_PaveBlock& aPB=PaveBlock1();
243   aNb=aPB.Edge();
244   return aNb;
245 }
246 */