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