1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTTools_PaveFiller_8.cxx
23 // Created: Fri Dec 19 11:15:53 2003
24 // Author: Peter KURNEV
27 #include <NMTTools_PaveFiller.ixx>
29 #include <TColStd_MapOfInteger.hxx>
30 #include <TColStd_ListOfInteger.hxx>
31 #include <TColStd_ListIteratorOfListOfInteger.hxx>
33 #include <BooleanOperations_ShapesDataStructure.hxx>
34 #include <BooleanOperations_OnceExplorer.hxx>
36 #include <BOPTools_PaveBlock.hxx>
37 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
38 #include <BOPTools_ListOfPaveBlock.hxx>
40 #include <NMTDS_ShapesDataStructure.hxx>
42 #include <NMTTools_ListOfCommonBlock.hxx>
43 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
44 #include <NMTTools_CommonBlock.hxx>
45 #include <NMTTools_CommonBlockAPI.hxx>
48 // Modified to add new method Thu Sep 14 14:35:18 2006
49 // Contribution of Samtech www.samcef.com BEGIN
50 //=======================================================================
51 // function: SharedEdges
53 //=======================================================================
54 void NMTTools_PaveFiller::SharedEdges(const Standard_Integer nF1,
55 const Standard_Integer nF2,
56 TColStd_ListOfInteger& aLNE,
57 TopTools_ListOfShape& aLSE)
59 Standard_Integer nE1, nE2;
60 TColStd_MapOfInteger aM1;
62 BooleanOperations_ShapesDataStructure *pDS=myDS;
63 BooleanOperations_OnceExplorer aExp(*pDS);
65 aExp.Init(nF1, TopAbs_EDGE);
66 for (; aExp.More(); aExp.Next()) {
71 aExp.Init(nF2, TopAbs_EDGE);
72 for (; aExp.More(); aExp.Next()) {
74 if (aM1.Contains(nE2)) {
76 const TopoDS_Shape& aE2=myDS->Shape(nE2);
81 // Contribution of Samtech www.samcef.com END
83 //=======================================================================
84 // function: RealPaveBlock
86 //=======================================================================
87 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock
88 (const BOPTools_PaveBlock& aPB,
89 TColStd_ListOfInteger& aLB,
90 Standard_Integer& aIsCommonBlock)
92 Standard_Integer nE, nSpx;
93 BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
97 nE=aPB.OriginalEdge();
98 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
99 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
100 if (aCBAPI.IsCommonBlock(aPB)) {
101 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
105 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
106 aItPBx.Initialize(aLPBx);
107 for (; aItPBx.More(); aItPBx.Next()) {
108 const BOPTools_PaveBlock& aPBx=aItPBx.Value();
113 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
119 //=======================================================================
120 // function: RealPaveBlock
122 //=======================================================================
123 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB)
127 nE=aPB.OriginalEdge();
128 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
129 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
130 if (aCBAPI.IsCommonBlock(aPB)) {
131 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
132 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
137 //=======================================================================
138 // function: CommonBlocksFace
140 //=======================================================================
141 Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF,
142 NMTTools_ListOfCommonBlock& aLCB)
146 NMTTools_ListIteratorOfListOfCommonBlock anIt;
148 aT=myDS->GetShapeType(nF);
150 if (aT!=TopAbs_FACE) {
151 return 1; // Type mismatch
154 BooleanOperations_ShapesDataStructure *pDS=myDS;
155 BooleanOperations_OnceExplorer aExp(*pDS);
157 aExp.Init(nF, TopAbs_EDGE);
158 for (; aExp.More(); aExp.Next()) {
160 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
161 anIt.Initialize(aLCBE);
162 for (; anIt.More(); anIt.Next()) {
163 const NMTTools_CommonBlock& aCBE=anIt.Value();
173 //=======================================================================
174 // function: RealSplitsFace
176 //=======================================================================
177 void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF,
178 BOPTools_ListOfPaveBlock& aLPB)
181 BOPTools_ListIteratorOfListOfPaveBlock anIt;
183 BooleanOperations_ShapesDataStructure *pDS=myDS;
184 BooleanOperations_OnceExplorer aExp(*pDS);
186 aExp.Init(nF, TopAbs_EDGE);
187 for (; aExp.More(); aExp.Next()) {
189 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
190 anIt.Initialize(aLPBE);
191 for (; anIt.More(); anIt.Next()) {
192 const BOPTools_PaveBlock& aPB=anIt.Value();
193 const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
198 //=======================================================================
199 // function: HasRealSplitsInOnFace
201 //=======================================================================
202 Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1,
203 const Standard_Integer nF2)
205 Standard_Boolean bFlag;
206 BOPTools_ListOfPaveBlock aLPB;
208 RealSplitsInFace(0, nF1, nF2, aLPB);
210 bFlag=!aLPB.IsEmpty();
215 RealSplitsInFace(0, nF1, nF2, aLPB);
217 bFlag=!aLPB.IsEmpty();
220 //=======================================================================
221 // function: RealSplitsInFace
223 //=======================================================================
224 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding
225 const Standard_Integer nF1,
226 const Standard_Integer nF2,
227 BOPTools_ListOfPaveBlock& aLPB)
229 Standard_Integer nE1;
231 BooleanOperations_ShapesDataStructure *pDS=myDS;
232 BooleanOperations_OnceExplorer aExp(*pDS);
233 aExp.Init(nF1, TopAbs_EDGE);
234 for (; aExp.More(); aExp.Next()) {
236 RealSplitsInFace (nE1, nF2, aLPB);
239 //=======================================================================
240 // function: RealSplitsInFace
242 //=======================================================================
243 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1,
244 const Standard_Integer nF2,
245 BOPTools_ListOfPaveBlock& aLPB)
247 Standard_Integer nF1;
249 TColStd_ListIteratorOfListOfInteger anItLFCB;
250 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
252 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
254 anItCB.Initialize(aLCB);
255 for (; anItCB.More(); anItCB.Next()) {
256 NMTTools_CommonBlock& aCB=anItCB.Value();
257 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
258 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
260 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
261 anItLFCB.Initialize(aLFCB);
262 for (; anItLFCB.More(); anItLFCB.Next()) {
263 nF1=anItLFCB.Value();
270 //=======================================================================
271 // function: RealSplitsOnEdge
273 //=======================================================================
274 void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1,
275 const Standard_Integer nE2,
276 BOPTools_ListOfPaveBlock& aLPB)
280 BOPTools_ListIteratorOfListOfPaveBlock anIt;
281 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
283 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
285 anItCB.Initialize(aLCB);
286 for (; anItCB.More(); anItCB.Next()) {
287 NMTTools_CommonBlock& aCB=anItCB.Value();
288 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
289 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
291 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
292 anIt.Initialize(aLPBx);
293 for (; anIt.More(); anIt.Next()) {
294 const BOPTools_PaveBlock& aPB2=anIt.Value();
295 nE=aPB2.OriginalEdge();
302 //=======================================================================
303 // function: RealSplitsOnFace
305 //=======================================================================
306 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1,
307 const Standard_Integer nF2,
308 BOPTools_ListOfPaveBlock& aLPB)
310 Standard_Integer nE2;
312 BooleanOperations_ShapesDataStructure *pDS=myDS;
313 BooleanOperations_OnceExplorer aExp(*pDS);
314 aExp.Init(nF2, TopAbs_EDGE);
315 for (; aExp.More(); aExp.Next()) {
317 RealSplitsOnEdge(nE1, nE2, aLPB);
320 //=======================================================================
321 // function: RealSplitsOnFace
323 //=======================================================================
324 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding
325 const Standard_Integer nF1,
326 const Standard_Integer nF2,
327 BOPTools_ListOfPaveBlock& aLPB)
329 Standard_Integer nE1;
331 BooleanOperations_ShapesDataStructure *pDS=myDS;
332 BooleanOperations_OnceExplorer aExp(*myDS);
333 aExp.Init(nF1, TopAbs_EDGE);
334 for (; aExp.More(); aExp.Next()) {
336 RealSplitsOnFace(nE1, nF2, aLPB);
341 //=======================================================================
342 // function: SplitsFace
344 //=======================================================================
345 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
346 BOPTools_ListOfPaveBlock& aLPB)
350 BOPTools_ListIteratorOfListOfPaveBlock anIt;
352 aT=myDS->GetShapeType(nF);
354 if (aT!=TopAbs_FACE) {
355 return 1; // Type mismatch
358 BooleanOperations_ShapesDataStructure *pDS=myDS;
359 BooleanOperations_OnceExplorer aExp(*pDS);
361 aExp.Init(nF, TopAbs_EDGE);
362 for (; aExp.More(); aExp.Next()) {
364 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
365 anIt.Initialize(aLPBE);
366 for (; anIt.More(); anIt.Next()) {
367 const BOPTools_PaveBlock& aPBE=anIt.Value();
374 //=======================================================================
375 // function: SplitsInFace
376 // purpose: splits of edges from nF1 in nF2
377 //=======================================================================
378 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
379 const Standard_Integer nF1,
380 const Standard_Integer nF2,
381 BOPTools_ListOfPaveBlock& aLPB)
383 Standard_Integer nE1;
384 TopAbs_ShapeEnum aT1, aT2;
386 aT1=myDS->GetShapeType(nF1);
387 aT2=myDS->GetShapeType(nF2);
389 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
390 return 1; // Type mismatch
392 BooleanOperations_ShapesDataStructure *pDS=myDS;
393 BooleanOperations_OnceExplorer aExp(*pDS);
394 aExp.Init(nF1, TopAbs_EDGE);
395 for (; aExp.More(); aExp.Next()) {
397 SplitsInFace (nE1, nF2, aLPB);
401 //=======================================================================
402 // function: SplitsInFace
403 // purpose: splits of edge nE1 in aFace2
404 //=======================================================================
405 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
406 const Standard_Integer nF2,
407 BOPTools_ListOfPaveBlock& aLPB)
409 Standard_Integer nF1;
410 TopAbs_ShapeEnum aT1, aT2;
412 aT1=myDS->GetShapeType(nE1);
413 aT2=myDS->GetShapeType(nF2);
415 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
416 return 1; // Type mismatch
419 TColStd_ListIteratorOfListOfInteger anItLFCB;
420 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
422 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
424 anItCB.Initialize(aLCB);
425 for (; anItCB.More(); anItCB.Next()) {
426 NMTTools_CommonBlock& aCB=anItCB.Value();
427 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
429 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
430 anItLFCB.Initialize(aLFCB);
431 for (; anItLFCB.More(); anItLFCB.Next()) {
432 nF1=anItLFCB.Value();
440 //=======================================================================
441 // function: SplitsOnEdge
442 // purpose: splits of edge nE1 on nE2
443 //=======================================================================
444 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
445 const Standard_Integer nE2,
446 BOPTools_ListOfPaveBlock& aLPB)
449 TopAbs_ShapeEnum aT1, aT2;
451 aT1=myDS->GetShapeType(nE1);
452 aT2=myDS->GetShapeType(nE2);
454 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
455 return 1; // Type mismatch
458 BOPTools_ListIteratorOfListOfPaveBlock anIt;
459 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
461 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
463 anItCB.Initialize(aLCB);
464 for (; anItCB.More(); anItCB.Next()) {
465 NMTTools_CommonBlock& aCB=anItCB.Value();
466 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX
468 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
469 anIt.Initialize(aLPBx);
470 for (; anIt.More(); anIt.Next()) {
471 const BOPTools_PaveBlock& aPB2=anIt.Value();
472 nE=aPB2.OriginalEdge();
480 //=======================================================================
481 // function: SplitsOnFace
482 // purpose: splits of edge nE1 on face nF2
483 //=======================================================================
484 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
485 const Standard_Integer nF2,
486 BOPTools_ListOfPaveBlock& aLPB)
488 Standard_Integer nE2, ip;
489 TopAbs_ShapeEnum aT1, aT2;
491 aT1=myDS->GetShapeType(nE1);
492 aT2=myDS->GetShapeType(nF2);
494 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
495 return 1; // Type mismatch
497 BooleanOperations_ShapesDataStructure *pDS=myDS;
498 BooleanOperations_OnceExplorer aExp(*pDS);
499 aExp.Init(nF2, TopAbs_EDGE);
500 for (; aExp.More(); aExp.Next()) {
502 ip=SplitsOnEdge(nE1, nE2, aLPB);
509 //=======================================================================
510 // function: SplitsOnFace
511 // purpose: splits of edges from face nF1 on face nF2
512 //=======================================================================
513 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
514 const Standard_Integer nF1,
515 const Standard_Integer nF2,
516 BOPTools_ListOfPaveBlock& aLPB)
518 Standard_Integer nE1, ip;
519 TopAbs_ShapeEnum aT1, aT2;
521 aT1=myDS->GetShapeType(nF1);
522 aT2=myDS->GetShapeType(nF2);
524 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
525 return 1; // Type mismatch
527 BooleanOperations_ShapesDataStructure *pDS=myDS;
528 BooleanOperations_OnceExplorer aExp(*myDS);
529 aExp.Init(nF1, TopAbs_EDGE);
530 for (; aExp.More(); aExp.Next()) {
532 ip=SplitsOnFace(nE1, nF2, aLPB);
540 // 3 Simple Splits indices
541 //=======================================================================
542 // function: SplitsFace
544 //=======================================================================
545 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
546 TColStd_ListOfInteger& aSplits)
548 Standard_Integer nE, iErr;
549 BOPTools_ListIteratorOfListOfPaveBlock aIt;
550 BOPTools_ListOfPaveBlock aLPB;
552 iErr=SplitsFace(nF, aLPB);
557 aIt.Initialize(aLPB);
558 for (; aIt.More(); aIt.Next()) {
559 const BOPTools_PaveBlock& aPB=aIt.Value();
566 //=======================================================================
567 // function: SplitsInFace
568 // purpose: splits of edges from nF1 in nF2
569 //=======================================================================
570 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
571 const Standard_Integer nF1,
572 const Standard_Integer nF2,
573 TColStd_ListOfInteger& aSplits)
575 Standard_Integer nE, iErr;
576 BOPTools_ListIteratorOfListOfPaveBlock aIt;
577 BOPTools_ListOfPaveBlock aLPB;
579 iErr=SplitsInFace(0, nF1, nF2, aLPB);
583 aIt.Initialize(aLPB);
584 for (; aIt.More(); aIt.Next()) {
585 const BOPTools_PaveBlock& aPB=aIt.Value();
591 //=======================================================================
592 // function: SplitsInFace
593 // purpose: splits of edge nE1 in aFace2
594 //=======================================================================
595 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
596 const Standard_Integer nF2,
597 TColStd_ListOfInteger& aSplits)
599 Standard_Integer nE, iErr;
600 BOPTools_ListIteratorOfListOfPaveBlock aIt;
601 BOPTools_ListOfPaveBlock aLPB;
603 iErr=SplitsInFace(nE1, nF2, aLPB);
607 aIt.Initialize(aLPB);
608 for (; aIt.More(); aIt.Next()) {
609 const BOPTools_PaveBlock& aPB=aIt.Value();
615 //=======================================================================
616 // function: SplitsOnEdge
617 // purpose: splits of edge nE1 on nE2
618 //=======================================================================
619 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
620 const Standard_Integer nE2,
621 TColStd_ListOfInteger& aSplits)
623 Standard_Integer nE, iErr;
624 BOPTools_ListIteratorOfListOfPaveBlock aIt;
625 BOPTools_ListOfPaveBlock aLPB;
627 iErr=SplitsOnEdge(nE1, nE2, aLPB);
631 aIt.Initialize(aLPB);
632 for (; aIt.More(); aIt.Next()) {
633 const BOPTools_PaveBlock& aPB=aIt.Value();
639 //=======================================================================
640 // function: SplitsOnFace
641 // purpose: splits of edge nE1 on face nF2
642 //=======================================================================
643 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
644 const Standard_Integer nF2,
645 TColStd_ListOfInteger& aSplits)
647 Standard_Integer nE, iErr;
648 BOPTools_ListIteratorOfListOfPaveBlock aIt;
649 BOPTools_ListOfPaveBlock aLPB;
651 iErr=SplitsOnEdge(nE1, nF2, aLPB);
655 aIt.Initialize(aLPB);
656 for (; aIt.More(); aIt.Next()) {
657 const BOPTools_PaveBlock& aPB=aIt.Value();
663 //=======================================================================
664 // function: SplitsOnFace
665 // purpose: splits of edges from face nF1 on face nF2
666 //=======================================================================
667 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
668 const Standard_Integer nF1,
669 const Standard_Integer nF2,
670 TColStd_ListOfInteger& aSplits)
672 Standard_Integer nE, iErr;
673 BOPTools_ListIteratorOfListOfPaveBlock aIt;
674 BOPTools_ListOfPaveBlock aLPB;
676 iErr=SplitsOnFace(0, nF1, nF2, aLPB);
681 aIt.Initialize(aLPB);
682 for (; aIt.More(); aIt.Next()) {
683 const BOPTools_PaveBlock& aPB=aIt.Value();