1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/
20 // File: NMTTools_PaveFiller_8.cxx
21 // Created: Fri Dec 19 11:15:53 2003
22 // Author: Peter KURNEV
26 #include <NMTTools_PaveFiller.ixx>
28 #include <TColStd_ListOfInteger.hxx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
31 #include <BooleanOperations_ShapesDataStructure.hxx>
32 #include <BooleanOperations_OnceExplorer.hxx>
34 #include <BOPTools_PaveBlock.hxx>
35 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
36 #include <BOPTools_ListOfPaveBlock.hxx>
38 #include <NMTDS_ShapesDataStructure.hxx>
40 #include <NMTTools_ListOfCommonBlock.hxx>
41 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
42 #include <NMTTools_CommonBlock.hxx>
43 #include <NMTTools_CommonBlockAPI.hxx>
45 //=======================================================================
46 // function: RealPaveBlock
48 //=======================================================================
49 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB)
53 nE=aPB.OriginalEdge();
54 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
55 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
56 if (aCBAPI.IsCommonBlock(aPB)) {
57 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
58 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
63 //=======================================================================
64 // function: CommonBlocksFace
66 //=======================================================================
67 Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF,
68 NMTTools_ListOfCommonBlock& aLCB)
72 NMTTools_ListIteratorOfListOfCommonBlock anIt;
74 aT=myDS->GetShapeType(nF);
76 if (aT!=TopAbs_FACE) {
77 return 1; // Type mismatch
80 BooleanOperations_ShapesDataStructure *pDS=myDS;
81 BooleanOperations_OnceExplorer aExp(*pDS);
83 aExp.Init(nF, TopAbs_EDGE);
84 for (; aExp.More(); aExp.Next()) {
86 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
87 anIt.Initialize(aLCBE);
88 for (; anIt.More(); anIt.Next()) {
89 const NMTTools_CommonBlock& aCBE=anIt.Value();
99 //=======================================================================
100 // function: RealSplitsFace
102 //=======================================================================
103 void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF,
104 BOPTools_ListOfPaveBlock& aLPB)
107 BOPTools_ListIteratorOfListOfPaveBlock anIt;
109 BooleanOperations_ShapesDataStructure *pDS=myDS;
110 BooleanOperations_OnceExplorer aExp(*pDS);
112 aExp.Init(nF, TopAbs_EDGE);
113 for (; aExp.More(); aExp.Next()) {
115 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
116 anIt.Initialize(aLPBE);
117 for (; anIt.More(); anIt.Next()) {
118 const BOPTools_PaveBlock& aPB=anIt.Value();
119 const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
124 //=======================================================================
125 // function: HasRealSplitsInOnFace
127 //=======================================================================
128 Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1,
129 const Standard_Integer nF2)
131 Standard_Boolean bFlag;
132 BOPTools_ListOfPaveBlock aLPB;
134 RealSplitsInFace(0, nF1, nF2, aLPB);
136 bFlag=!aLPB.IsEmpty();
141 RealSplitsInFace(0, nF1, nF2, aLPB);
143 bFlag=!aLPB.IsEmpty();
146 //=======================================================================
147 // function: RealSplitsInFace
149 //=======================================================================
150 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding
151 const Standard_Integer nF1,
152 const Standard_Integer nF2,
153 BOPTools_ListOfPaveBlock& aLPB)
155 Standard_Integer nE1;
157 BooleanOperations_ShapesDataStructure *pDS=myDS;
158 BooleanOperations_OnceExplorer aExp(*pDS);
159 aExp.Init(nF1, TopAbs_EDGE);
160 for (; aExp.More(); aExp.Next()) {
162 RealSplitsInFace (nE1, nF2, aLPB);
165 //=======================================================================
166 // function: RealSplitsInFace
168 //=======================================================================
169 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1,
170 const Standard_Integer nF2,
171 BOPTools_ListOfPaveBlock& aLPB)
173 Standard_Integer nF1;
175 TColStd_ListIteratorOfListOfInteger anItLFCB;
176 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
178 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
180 anItCB.Initialize(aLCB);
181 for (; anItCB.More(); anItCB.Next()) {
182 NMTTools_CommonBlock& aCB=anItCB.Value();
183 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
184 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
186 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
187 anItLFCB.Initialize(aLFCB);
188 for (; anItLFCB.More(); anItLFCB.Next()) {
189 nF1=anItLFCB.Value();
196 //=======================================================================
197 // function: RealSplitsOnEdge
199 //=======================================================================
200 void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1,
201 const Standard_Integer nE2,
202 BOPTools_ListOfPaveBlock& aLPB)
206 BOPTools_ListIteratorOfListOfPaveBlock anIt;
207 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
209 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
211 anItCB.Initialize(aLCB);
212 for (; anItCB.More(); anItCB.Next()) {
213 NMTTools_CommonBlock& aCB=anItCB.Value();
214 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
215 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
217 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
218 anIt.Initialize(aLPBx);
219 for (; anIt.More(); anIt.Next()) {
220 const BOPTools_PaveBlock& aPB2=anIt.Value();
221 nE=aPB2.OriginalEdge();
228 //=======================================================================
229 // function: RealSplitsOnFace
231 //=======================================================================
232 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1,
233 const Standard_Integer nF2,
234 BOPTools_ListOfPaveBlock& aLPB)
236 Standard_Integer nE2;
238 BooleanOperations_ShapesDataStructure *pDS=myDS;
239 BooleanOperations_OnceExplorer aExp(*pDS);
240 aExp.Init(nF2, TopAbs_EDGE);
241 for (; aExp.More(); aExp.Next()) {
243 RealSplitsOnEdge(nE1, nE2, aLPB);
246 //=======================================================================
247 // function: RealSplitsOnFace
249 //=======================================================================
250 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding
251 const Standard_Integer nF1,
252 const Standard_Integer nF2,
253 BOPTools_ListOfPaveBlock& aLPB)
255 Standard_Integer nE1;
257 BooleanOperations_ShapesDataStructure *pDS=myDS;
258 BooleanOperations_OnceExplorer aExp(*myDS);
259 aExp.Init(nF1, TopAbs_EDGE);
260 for (; aExp.More(); aExp.Next()) {
262 RealSplitsOnFace(nE1, nF2, aLPB);
267 //=======================================================================
268 // function: SplitsFace
270 //=======================================================================
271 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
272 BOPTools_ListOfPaveBlock& aLPB)
276 BOPTools_ListIteratorOfListOfPaveBlock anIt;
278 aT=myDS->GetShapeType(nF);
280 if (aT!=TopAbs_FACE) {
281 return 1; // Type mismatch
284 BooleanOperations_ShapesDataStructure *pDS=myDS;
285 BooleanOperations_OnceExplorer aExp(*pDS);
287 aExp.Init(nF, TopAbs_EDGE);
288 for (; aExp.More(); aExp.Next()) {
290 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
291 anIt.Initialize(aLPBE);
292 for (; anIt.More(); anIt.Next()) {
293 const BOPTools_PaveBlock& aPBE=anIt.Value();
300 //=======================================================================
301 // function: SplitsInFace
302 // purpose: splits of edges from nF1 in nF2
303 //=======================================================================
304 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
305 const Standard_Integer nF1,
306 const Standard_Integer nF2,
307 BOPTools_ListOfPaveBlock& aLPB)
309 Standard_Integer nE1;
310 TopAbs_ShapeEnum aT1, aT2;
312 aT1=myDS->GetShapeType(nF1);
313 aT2=myDS->GetShapeType(nF2);
315 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
316 return 1; // Type mismatch
318 BooleanOperations_ShapesDataStructure *pDS=myDS;
319 BooleanOperations_OnceExplorer aExp(*pDS);
320 aExp.Init(nF1, TopAbs_EDGE);
321 for (; aExp.More(); aExp.Next()) {
323 SplitsInFace (nE1, nF2, aLPB);
327 //=======================================================================
328 // function: SplitsInFace
329 // purpose: splits of edge nE1 in aFace2
330 //=======================================================================
331 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
332 const Standard_Integer nF2,
333 BOPTools_ListOfPaveBlock& aLPB)
335 Standard_Integer nF1;
336 TopAbs_ShapeEnum aT1, aT2;
338 aT1=myDS->GetShapeType(nE1);
339 aT2=myDS->GetShapeType(nF2);
341 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
342 return 1; // Type mismatch
345 TColStd_ListIteratorOfListOfInteger anItLFCB;
346 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
348 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
350 anItCB.Initialize(aLCB);
351 for (; anItCB.More(); anItCB.Next()) {
352 NMTTools_CommonBlock& aCB=anItCB.Value();
353 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
355 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
356 anItLFCB.Initialize(aLFCB);
357 for (; anItLFCB.More(); anItLFCB.Next()) {
358 nF1=anItLFCB.Value();
366 //=======================================================================
367 // function: SplitsOnEdge
368 // purpose: splits of edge nE1 on nE2
369 //=======================================================================
370 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
371 const Standard_Integer nE2,
372 BOPTools_ListOfPaveBlock& aLPB)
375 TopAbs_ShapeEnum aT1, aT2;
377 aT1=myDS->GetShapeType(nE1);
378 aT2=myDS->GetShapeType(nE2);
380 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
381 return 1; // Type mismatch
384 BOPTools_ListIteratorOfListOfPaveBlock anIt;
385 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
387 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
389 anItCB.Initialize(aLCB);
390 for (; anItCB.More(); anItCB.Next()) {
391 NMTTools_CommonBlock& aCB=anItCB.Value();
392 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX
394 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
395 anIt.Initialize(aLPBx);
396 for (; anIt.More(); anIt.Next()) {
397 const BOPTools_PaveBlock& aPB2=anIt.Value();
398 nE=aPB2.OriginalEdge();
406 //=======================================================================
407 // function: SplitsOnFace
408 // purpose: splits of edge nE1 on face nF2
409 //=======================================================================
410 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
411 const Standard_Integer nF2,
412 BOPTools_ListOfPaveBlock& aLPB)
414 Standard_Integer nE2, ip;
415 TopAbs_ShapeEnum aT1, aT2;
417 aT1=myDS->GetShapeType(nE1);
418 aT2=myDS->GetShapeType(nF2);
420 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
421 return 1; // Type mismatch
423 BooleanOperations_ShapesDataStructure *pDS=myDS;
424 BooleanOperations_OnceExplorer aExp(*pDS);
425 aExp.Init(nF2, TopAbs_EDGE);
426 for (; aExp.More(); aExp.Next()) {
428 ip=SplitsOnEdge(nE1, nE2, aLPB);
435 //=======================================================================
436 // function: SplitsOnFace
437 // purpose: splits of edges from face nF1 on face nF2
438 //=======================================================================
439 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
440 const Standard_Integer nF1,
441 const Standard_Integer nF2,
442 BOPTools_ListOfPaveBlock& aLPB)
444 Standard_Integer nE1, ip;
445 TopAbs_ShapeEnum aT1, aT2;
447 aT1=myDS->GetShapeType(nF1);
448 aT2=myDS->GetShapeType(nF2);
450 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
451 return 1; // Type mismatch
453 BooleanOperations_ShapesDataStructure *pDS=myDS;
454 BooleanOperations_OnceExplorer aExp(*myDS);
455 aExp.Init(nF1, TopAbs_EDGE);
456 for (; aExp.More(); aExp.Next()) {
458 ip=SplitsOnFace(nE1, nF2, aLPB);
466 // 3 Simple Splits indices
467 //=======================================================================
468 // function: SplitsFace
470 //=======================================================================
471 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
472 TColStd_ListOfInteger& aSplits)
474 Standard_Integer nE, iErr;
475 BOPTools_ListIteratorOfListOfPaveBlock aIt;
476 BOPTools_ListOfPaveBlock aLPB;
478 iErr=SplitsFace(nF, aLPB);
483 aIt.Initialize(aLPB);
484 for (; aIt.More(); aIt.Next()) {
485 const BOPTools_PaveBlock& aPB=aIt.Value();
492 //=======================================================================
493 // function: SplitsInFace
494 // purpose: splits of edges from nF1 in nF2
495 //=======================================================================
496 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
497 const Standard_Integer nF1,
498 const Standard_Integer nF2,
499 TColStd_ListOfInteger& aSplits)
501 Standard_Integer nE, iErr;
502 BOPTools_ListIteratorOfListOfPaveBlock aIt;
503 BOPTools_ListOfPaveBlock aLPB;
505 iErr=SplitsInFace(0, nF1, nF2, aLPB);
509 aIt.Initialize(aLPB);
510 for (; aIt.More(); aIt.Next()) {
511 const BOPTools_PaveBlock& aPB=aIt.Value();
517 //=======================================================================
518 // function: SplitsInFace
519 // purpose: splits of edge nE1 in aFace2
520 //=======================================================================
521 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
522 const Standard_Integer nF2,
523 TColStd_ListOfInteger& aSplits)
525 Standard_Integer nE, iErr;
526 BOPTools_ListIteratorOfListOfPaveBlock aIt;
527 BOPTools_ListOfPaveBlock aLPB;
529 iErr=SplitsInFace(nE1, nF2, aLPB);
533 aIt.Initialize(aLPB);
534 for (; aIt.More(); aIt.Next()) {
535 const BOPTools_PaveBlock& aPB=aIt.Value();
541 //=======================================================================
542 // function: SplitsOnEdge
543 // purpose: splits of edge nE1 on nE2
544 //=======================================================================
545 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
546 const Standard_Integer nE2,
547 TColStd_ListOfInteger& aSplits)
549 Standard_Integer nE, iErr;
550 BOPTools_ListIteratorOfListOfPaveBlock aIt;
551 BOPTools_ListOfPaveBlock aLPB;
553 iErr=SplitsOnEdge(nE1, nE2, aLPB);
557 aIt.Initialize(aLPB);
558 for (; aIt.More(); aIt.Next()) {
559 const BOPTools_PaveBlock& aPB=aIt.Value();
565 //=======================================================================
566 // function: SplitsOnFace
567 // purpose: splits of edge nE1 on face nF2
568 //=======================================================================
569 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
570 const Standard_Integer nF2,
571 TColStd_ListOfInteger& aSplits)
573 Standard_Integer nE, iErr;
574 BOPTools_ListIteratorOfListOfPaveBlock aIt;
575 BOPTools_ListOfPaveBlock aLPB;
577 iErr=SplitsOnEdge(nE1, nF2, aLPB);
581 aIt.Initialize(aLPB);
582 for (; aIt.More(); aIt.Next()) {
583 const BOPTools_PaveBlock& aPB=aIt.Value();
589 //=======================================================================
590 // function: SplitsOnFace
591 // purpose: splits of edges from face nF1 on face nF2
592 //=======================================================================
593 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
594 const Standard_Integer nF1,
595 const Standard_Integer nF2,
596 TColStd_ListOfInteger& aSplits)
598 Standard_Integer nE, iErr;
599 BOPTools_ListIteratorOfListOfPaveBlock aIt;
600 BOPTools_ListOfPaveBlock aLPB;
602 iErr=SplitsOnFace(0, nF1, nF2, aLPB);
607 aIt.Initialize(aLPB);
608 for (; aIt.More(); aIt.Next()) {
609 const BOPTools_PaveBlock& aPB=aIt.Value();