1 // Copyright (C) 2007-2011 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
23 // File: NMTTools_PaveFiller_8.cxx
24 // Created: Fri Dec 19 11:15:53 2003
25 // Author: Peter KURNEV
28 #include <NMTTools_PaveFiller.ixx>
30 #include <TColStd_MapOfInteger.hxx>
31 #include <TColStd_ListOfInteger.hxx>
32 #include <TColStd_ListIteratorOfListOfInteger.hxx>
34 #include <BooleanOperations_ShapesDataStructure.hxx>
35 #include <BooleanOperations_OnceExplorer.hxx>
37 #include <BOPTools_PaveBlock.hxx>
38 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
39 #include <BOPTools_ListOfPaveBlock.hxx>
41 #include <NMTDS_ShapesDataStructure.hxx>
43 #include <NMTTools_ListOfCommonBlock.hxx>
44 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
45 #include <NMTTools_CommonBlock.hxx>
46 #include <NMTTools_CommonBlockAPI.hxx>
49 // Modified to add new method Thu Sep 14 14:35:18 2006
50 // Contribution of Samtech www.samcef.com BEGIN
51 //=======================================================================
52 // function: SharedEdges
54 //=======================================================================
55 void NMTTools_PaveFiller::SharedEdges(const Standard_Integer nF1,
56 const Standard_Integer nF2,
57 TColStd_ListOfInteger& aLNE,
58 TopTools_ListOfShape& aLSE)
60 Standard_Integer nE1, nE2;
61 TColStd_MapOfInteger aM1;
63 BooleanOperations_ShapesDataStructure *pDS=myDS;
64 BooleanOperations_OnceExplorer aExp(*pDS);
66 aExp.Init(nF1, TopAbs_EDGE);
67 for (; aExp.More(); aExp.Next()) {
72 aExp.Init(nF2, TopAbs_EDGE);
73 for (; aExp.More(); aExp.Next()) {
75 if (aM1.Contains(nE2)) {
77 const TopoDS_Shape& aE2=myDS->Shape(nE2);
82 // Contribution of Samtech www.samcef.com END
84 //=======================================================================
85 // function: RealPaveBlock
87 //=======================================================================
88 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock
89 (const BOPTools_PaveBlock& aPB,
90 TColStd_ListOfInteger& aLB,
91 Standard_Integer& aIsCommonBlock)
93 Standard_Integer nE, nSpx;
94 BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
98 nE=aPB.OriginalEdge();
99 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
100 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
101 if (aCBAPI.IsCommonBlock(aPB)) {
102 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
106 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
107 aItPBx.Initialize(aLPBx);
108 for (; aItPBx.More(); aItPBx.Next()) {
109 const BOPTools_PaveBlock& aPBx=aItPBx.Value();
114 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
120 //=======================================================================
121 // function: RealPaveBlock
123 //=======================================================================
124 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB)
128 nE=aPB.OriginalEdge();
129 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
130 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
131 if (aCBAPI.IsCommonBlock(aPB)) {
132 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
133 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
138 //=======================================================================
139 // function: CommonBlocksFace
141 //=======================================================================
142 Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF,
143 NMTTools_ListOfCommonBlock& aLCB)
147 NMTTools_ListIteratorOfListOfCommonBlock anIt;
149 aT=myDS->GetShapeType(nF);
151 if (aT!=TopAbs_FACE) {
152 return 1; // Type mismatch
155 BooleanOperations_ShapesDataStructure *pDS=myDS;
156 BooleanOperations_OnceExplorer aExp(*pDS);
158 aExp.Init(nF, TopAbs_EDGE);
159 for (; aExp.More(); aExp.Next()) {
161 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
162 anIt.Initialize(aLCBE);
163 for (; anIt.More(); anIt.Next()) {
164 const NMTTools_CommonBlock& aCBE=anIt.Value();
174 //=======================================================================
175 // function: RealSplitsFace
177 //=======================================================================
178 void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF,
179 BOPTools_ListOfPaveBlock& aLPB)
182 BOPTools_ListIteratorOfListOfPaveBlock anIt;
184 BooleanOperations_ShapesDataStructure *pDS=myDS;
185 BooleanOperations_OnceExplorer aExp(*pDS);
187 aExp.Init(nF, TopAbs_EDGE);
188 for (; aExp.More(); aExp.Next()) {
190 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
191 anIt.Initialize(aLPBE);
192 for (; anIt.More(); anIt.Next()) {
193 const BOPTools_PaveBlock& aPB=anIt.Value();
194 const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
199 //=======================================================================
200 // function: HasRealSplitsInOnFace
202 //=======================================================================
203 Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1,
204 const Standard_Integer nF2)
206 Standard_Boolean bFlag;
207 BOPTools_ListOfPaveBlock aLPB;
209 RealSplitsInFace(0, nF1, nF2, aLPB);
211 bFlag=!aLPB.IsEmpty();
216 RealSplitsInFace(0, nF1, nF2, aLPB);
218 bFlag=!aLPB.IsEmpty();
221 //=======================================================================
222 // function: RealSplitsInFace
224 //=======================================================================
225 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding
226 const Standard_Integer nF1,
227 const Standard_Integer nF2,
228 BOPTools_ListOfPaveBlock& aLPB)
230 Standard_Integer nE1;
232 BooleanOperations_ShapesDataStructure *pDS=myDS;
233 BooleanOperations_OnceExplorer aExp(*pDS);
234 aExp.Init(nF1, TopAbs_EDGE);
235 for (; aExp.More(); aExp.Next()) {
237 RealSplitsInFace (nE1, nF2, aLPB);
240 //=======================================================================
241 // function: RealSplitsInFace
243 //=======================================================================
244 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1,
245 const Standard_Integer nF2,
246 BOPTools_ListOfPaveBlock& aLPB)
248 Standard_Integer nF1;
250 TColStd_ListIteratorOfListOfInteger anItLFCB;
251 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
253 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
255 anItCB.Initialize(aLCB);
256 for (; anItCB.More(); anItCB.Next()) {
257 NMTTools_CommonBlock& aCB=anItCB.Value();
258 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
259 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
261 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
262 anItLFCB.Initialize(aLFCB);
263 for (; anItLFCB.More(); anItLFCB.Next()) {
264 nF1=anItLFCB.Value();
271 //=======================================================================
272 // function: RealSplitsOnEdge
274 //=======================================================================
275 void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1,
276 const Standard_Integer nE2,
277 BOPTools_ListOfPaveBlock& aLPB)
281 BOPTools_ListIteratorOfListOfPaveBlock anIt;
282 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
284 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
286 anItCB.Initialize(aLCB);
287 for (; anItCB.More(); anItCB.Next()) {
288 NMTTools_CommonBlock& aCB=anItCB.Value();
289 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
290 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
292 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
293 anIt.Initialize(aLPBx);
294 for (; anIt.More(); anIt.Next()) {
295 const BOPTools_PaveBlock& aPB2=anIt.Value();
296 nE=aPB2.OriginalEdge();
303 //=======================================================================
304 // function: RealSplitsOnFace
306 //=======================================================================
307 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1,
308 const Standard_Integer nF2,
309 BOPTools_ListOfPaveBlock& aLPB)
311 Standard_Integer nE2;
313 BooleanOperations_ShapesDataStructure *pDS=myDS;
314 BooleanOperations_OnceExplorer aExp(*pDS);
315 aExp.Init(nF2, TopAbs_EDGE);
316 for (; aExp.More(); aExp.Next()) {
318 RealSplitsOnEdge(nE1, nE2, aLPB);
321 //=======================================================================
322 // function: RealSplitsOnFace
324 //=======================================================================
325 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding
326 const Standard_Integer nF1,
327 const Standard_Integer nF2,
328 BOPTools_ListOfPaveBlock& aLPB)
330 Standard_Integer nE1;
332 // BooleanOperations_ShapesDataStructure *pDS=myDS;
333 BooleanOperations_OnceExplorer aExp(*myDS);
334 aExp.Init(nF1, TopAbs_EDGE);
335 for (; aExp.More(); aExp.Next()) {
337 RealSplitsOnFace(nE1, nF2, aLPB);
342 //=======================================================================
343 // function: SplitsFace
345 //=======================================================================
346 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
347 BOPTools_ListOfPaveBlock& aLPB)
351 BOPTools_ListIteratorOfListOfPaveBlock anIt;
353 aT=myDS->GetShapeType(nF);
355 if (aT!=TopAbs_FACE) {
356 return 1; // Type mismatch
359 BooleanOperations_ShapesDataStructure *pDS=myDS;
360 BooleanOperations_OnceExplorer aExp(*pDS);
362 aExp.Init(nF, TopAbs_EDGE);
363 for (; aExp.More(); aExp.Next()) {
365 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
366 anIt.Initialize(aLPBE);
367 for (; anIt.More(); anIt.Next()) {
368 const BOPTools_PaveBlock& aPBE=anIt.Value();
375 //=======================================================================
376 // function: SplitsInFace
377 // purpose: splits of edges from nF1 in nF2
378 //=======================================================================
379 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
380 const Standard_Integer nF1,
381 const Standard_Integer nF2,
382 BOPTools_ListOfPaveBlock& aLPB)
384 Standard_Integer nE1;
385 TopAbs_ShapeEnum aT1, aT2;
387 aT1=myDS->GetShapeType(nF1);
388 aT2=myDS->GetShapeType(nF2);
390 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
391 return 1; // Type mismatch
393 BooleanOperations_ShapesDataStructure *pDS=myDS;
394 BooleanOperations_OnceExplorer aExp(*pDS);
395 aExp.Init(nF1, TopAbs_EDGE);
396 for (; aExp.More(); aExp.Next()) {
398 SplitsInFace (nE1, nF2, aLPB);
402 //=======================================================================
403 // function: SplitsInFace
404 // purpose: splits of edge nE1 in aFace2
405 //=======================================================================
406 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
407 const Standard_Integer nF2,
408 BOPTools_ListOfPaveBlock& aLPB)
410 Standard_Integer nF1;
411 TopAbs_ShapeEnum aT1, aT2;
413 aT1=myDS->GetShapeType(nE1);
414 aT2=myDS->GetShapeType(nF2);
416 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
417 return 1; // Type mismatch
420 TColStd_ListIteratorOfListOfInteger anItLFCB;
421 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
423 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
425 anItCB.Initialize(aLCB);
426 for (; anItCB.More(); anItCB.Next()) {
427 NMTTools_CommonBlock& aCB=anItCB.Value();
428 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
430 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
431 anItLFCB.Initialize(aLFCB);
432 for (; anItLFCB.More(); anItLFCB.Next()) {
433 nF1=anItLFCB.Value();
441 //=======================================================================
442 // function: SplitsOnEdge
443 // purpose: splits of edge nE1 on nE2
444 //=======================================================================
445 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
446 const Standard_Integer nE2,
447 BOPTools_ListOfPaveBlock& aLPB)
450 TopAbs_ShapeEnum aT1, aT2;
452 aT1=myDS->GetShapeType(nE1);
453 aT2=myDS->GetShapeType(nE2);
455 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
456 return 1; // Type mismatch
459 BOPTools_ListIteratorOfListOfPaveBlock anIt;
460 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
462 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
464 anItCB.Initialize(aLCB);
465 for (; anItCB.More(); anItCB.Next()) {
466 NMTTools_CommonBlock& aCB=anItCB.Value();
467 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX
469 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
470 anIt.Initialize(aLPBx);
471 for (; anIt.More(); anIt.Next()) {
472 const BOPTools_PaveBlock& aPB2=anIt.Value();
473 nE=aPB2.OriginalEdge();
481 //=======================================================================
482 // function: SplitsOnFace
483 // purpose: splits of edge nE1 on face nF2
484 //=======================================================================
485 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
486 const Standard_Integer nF2,
487 BOPTools_ListOfPaveBlock& aLPB)
489 Standard_Integer nE2, ip;
490 TopAbs_ShapeEnum aT1, aT2;
492 aT1=myDS->GetShapeType(nE1);
493 aT2=myDS->GetShapeType(nF2);
495 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
496 return 1; // Type mismatch
498 BooleanOperations_ShapesDataStructure *pDS=myDS;
499 BooleanOperations_OnceExplorer aExp(*pDS);
500 aExp.Init(nF2, TopAbs_EDGE);
501 for (; aExp.More(); aExp.Next()) {
503 ip=SplitsOnEdge(nE1, nE2, aLPB);
510 //=======================================================================
511 // function: SplitsOnFace
512 // purpose: splits of edges from face nF1 on face nF2
513 //=======================================================================
514 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
515 const Standard_Integer nF1,
516 const Standard_Integer nF2,
517 BOPTools_ListOfPaveBlock& aLPB)
519 Standard_Integer nE1, ip;
520 TopAbs_ShapeEnum aT1, aT2;
522 aT1=myDS->GetShapeType(nF1);
523 aT2=myDS->GetShapeType(nF2);
525 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
526 return 1; // Type mismatch
528 // BooleanOperations_ShapesDataStructure *pDS=myDS;
529 BooleanOperations_OnceExplorer aExp(*myDS);
530 aExp.Init(nF1, TopAbs_EDGE);
531 for (; aExp.More(); aExp.Next()) {
533 ip=SplitsOnFace(nE1, nF2, aLPB);
541 // 3 Simple Splits indices
542 //=======================================================================
543 // function: SplitsFace
545 //=======================================================================
546 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
547 TColStd_ListOfInteger& aSplits)
549 Standard_Integer nE, iErr;
550 BOPTools_ListIteratorOfListOfPaveBlock aIt;
551 BOPTools_ListOfPaveBlock aLPB;
553 iErr=SplitsFace(nF, aLPB);
558 aIt.Initialize(aLPB);
559 for (; aIt.More(); aIt.Next()) {
560 const BOPTools_PaveBlock& aPB=aIt.Value();
567 //=======================================================================
568 // function: SplitsInFace
569 // purpose: splits of edges from nF1 in nF2
570 //=======================================================================
571 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
572 const Standard_Integer nF1,
573 const Standard_Integer nF2,
574 TColStd_ListOfInteger& aSplits)
576 Standard_Integer nE, iErr;
577 BOPTools_ListIteratorOfListOfPaveBlock aIt;
578 BOPTools_ListOfPaveBlock aLPB;
580 iErr=SplitsInFace(0, nF1, nF2, aLPB);
584 aIt.Initialize(aLPB);
585 for (; aIt.More(); aIt.Next()) {
586 const BOPTools_PaveBlock& aPB=aIt.Value();
592 //=======================================================================
593 // function: SplitsInFace
594 // purpose: splits of edge nE1 in aFace2
595 //=======================================================================
596 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
597 const Standard_Integer nF2,
598 TColStd_ListOfInteger& aSplits)
600 Standard_Integer nE, iErr;
601 BOPTools_ListIteratorOfListOfPaveBlock aIt;
602 BOPTools_ListOfPaveBlock aLPB;
604 iErr=SplitsInFace(nE1, nF2, aLPB);
608 aIt.Initialize(aLPB);
609 for (; aIt.More(); aIt.Next()) {
610 const BOPTools_PaveBlock& aPB=aIt.Value();
616 //=======================================================================
617 // function: SplitsOnEdge
618 // purpose: splits of edge nE1 on nE2
619 //=======================================================================
620 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
621 const Standard_Integer nE2,
622 TColStd_ListOfInteger& aSplits)
624 Standard_Integer nE, iErr;
625 BOPTools_ListIteratorOfListOfPaveBlock aIt;
626 BOPTools_ListOfPaveBlock aLPB;
628 iErr=SplitsOnEdge(nE1, nE2, aLPB);
632 aIt.Initialize(aLPB);
633 for (; aIt.More(); aIt.Next()) {
634 const BOPTools_PaveBlock& aPB=aIt.Value();
640 //=======================================================================
641 // function: SplitsOnFace
642 // purpose: splits of edge nE1 on face nF2
643 //=======================================================================
644 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
645 const Standard_Integer nF2,
646 TColStd_ListOfInteger& aSplits)
648 Standard_Integer nE, iErr;
649 BOPTools_ListIteratorOfListOfPaveBlock aIt;
650 BOPTools_ListOfPaveBlock aLPB;
652 iErr=SplitsOnEdge(nE1, nF2, aLPB);
656 aIt.Initialize(aLPB);
657 for (; aIt.More(); aIt.Next()) {
658 const BOPTools_PaveBlock& aPB=aIt.Value();
664 //=======================================================================
665 // function: SplitsOnFace
666 // purpose: splits of edges from face nF1 on face nF2
667 //=======================================================================
668 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
669 const Standard_Integer nF1,
670 const Standard_Integer nF2,
671 TColStd_ListOfInteger& aSplits)
673 Standard_Integer nE, iErr;
674 BOPTools_ListIteratorOfListOfPaveBlock aIt;
675 BOPTools_ListOfPaveBlock aLPB;
677 iErr=SplitsOnFace(0, nF1, nF2, aLPB);
682 aIt.Initialize(aLPB);
683 for (; aIt.More(); aIt.Next()) {
684 const BOPTools_PaveBlock& aPB=aIt.Value();