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/ or email : webmaster.salome@opencascade.com
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_MapOfInteger.hxx>
29 #include <TColStd_ListOfInteger.hxx>
30 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32 #include <BooleanOperations_ShapesDataStructure.hxx>
33 #include <BooleanOperations_OnceExplorer.hxx>
35 #include <BOPTools_PaveBlock.hxx>
36 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
37 #include <BOPTools_ListOfPaveBlock.hxx>
39 #include <NMTDS_ShapesDataStructure.hxx>
41 #include <NMTTools_ListOfCommonBlock.hxx>
42 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
43 #include <NMTTools_CommonBlock.hxx>
44 #include <NMTTools_CommonBlockAPI.hxx>
47 // Modified to add new method Thu Sep 14 14:35:18 2006
48 // Contribution of Samtech www.samcef.com BEGIN
49 //=======================================================================
50 // function: SharedEdges
52 //=======================================================================
53 void NMTTools_PaveFiller::SharedEdges(const Standard_Integer nF1,
54 const Standard_Integer nF2,
55 TColStd_ListOfInteger& aLNE,
56 TopTools_ListOfShape& aLSE)
58 Standard_Integer nE1, nE2;
59 TColStd_MapOfInteger aM1;
61 BooleanOperations_ShapesDataStructure *pDS=myDS;
62 BooleanOperations_OnceExplorer aExp(*pDS);
64 aExp.Init(nF1, TopAbs_EDGE);
65 for (; aExp.More(); aExp.Next()) {
70 aExp.Init(nF2, TopAbs_EDGE);
71 for (; aExp.More(); aExp.Next()) {
73 if (aM1.Contains(nE2)) {
75 const TopoDS_Shape& aE2=myDS->Shape(nE2);
80 // Contribution of Samtech www.samcef.com END
82 //=======================================================================
83 // function: RealPaveBlock
85 //=======================================================================
86 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB,
87 TColStd_ListOfInteger& aLB)
89 Standard_Integer nE, nSpx;
90 BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
93 nE=aPB.OriginalEdge();
94 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
95 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
96 if (aCBAPI.IsCommonBlock(aPB)) {
97 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
99 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
100 aItPBx.Initialize(aLPBx);
101 for (; aItPBx.More(); aItPBx.Next()) {
102 const BOPTools_PaveBlock& aPBx=aItPBx.Value();
107 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
113 //=======================================================================
114 // function: RealPaveBlock
116 //=======================================================================
117 const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB)
121 nE=aPB.OriginalEdge();
122 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
123 NMTTools_CommonBlockAPI aCBAPI(aLCBE);
124 if (aCBAPI.IsCommonBlock(aPB)) {
125 NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
126 const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
131 //=======================================================================
132 // function: CommonBlocksFace
134 //=======================================================================
135 Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF,
136 NMTTools_ListOfCommonBlock& aLCB)
140 NMTTools_ListIteratorOfListOfCommonBlock anIt;
142 aT=myDS->GetShapeType(nF);
144 if (aT!=TopAbs_FACE) {
145 return 1; // Type mismatch
148 BooleanOperations_ShapesDataStructure *pDS=myDS;
149 BooleanOperations_OnceExplorer aExp(*pDS);
151 aExp.Init(nF, TopAbs_EDGE);
152 for (; aExp.More(); aExp.Next()) {
154 const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
155 anIt.Initialize(aLCBE);
156 for (; anIt.More(); anIt.Next()) {
157 const NMTTools_CommonBlock& aCBE=anIt.Value();
167 //=======================================================================
168 // function: RealSplitsFace
170 //=======================================================================
171 void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF,
172 BOPTools_ListOfPaveBlock& aLPB)
175 BOPTools_ListIteratorOfListOfPaveBlock anIt;
177 BooleanOperations_ShapesDataStructure *pDS=myDS;
178 BooleanOperations_OnceExplorer aExp(*pDS);
180 aExp.Init(nF, TopAbs_EDGE);
181 for (; aExp.More(); aExp.Next()) {
183 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
184 anIt.Initialize(aLPBE);
185 for (; anIt.More(); anIt.Next()) {
186 const BOPTools_PaveBlock& aPB=anIt.Value();
187 const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
192 //=======================================================================
193 // function: HasRealSplitsInOnFace
195 //=======================================================================
196 Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1,
197 const Standard_Integer nF2)
199 Standard_Boolean bFlag;
200 BOPTools_ListOfPaveBlock aLPB;
202 RealSplitsInFace(0, nF1, nF2, aLPB);
204 bFlag=!aLPB.IsEmpty();
209 RealSplitsInFace(0, nF1, nF2, aLPB);
211 bFlag=!aLPB.IsEmpty();
214 //=======================================================================
215 // function: RealSplitsInFace
217 //=======================================================================
218 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding
219 const Standard_Integer nF1,
220 const Standard_Integer nF2,
221 BOPTools_ListOfPaveBlock& aLPB)
223 Standard_Integer nE1;
225 BooleanOperations_ShapesDataStructure *pDS=myDS;
226 BooleanOperations_OnceExplorer aExp(*pDS);
227 aExp.Init(nF1, TopAbs_EDGE);
228 for (; aExp.More(); aExp.Next()) {
230 RealSplitsInFace (nE1, nF2, aLPB);
233 //=======================================================================
234 // function: RealSplitsInFace
236 //=======================================================================
237 void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1,
238 const Standard_Integer nF2,
239 BOPTools_ListOfPaveBlock& aLPB)
241 Standard_Integer nF1;
243 TColStd_ListIteratorOfListOfInteger anItLFCB;
244 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
246 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
248 anItCB.Initialize(aLCB);
249 for (; anItCB.More(); anItCB.Next()) {
250 NMTTools_CommonBlock& aCB=anItCB.Value();
251 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
252 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
254 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
255 anItLFCB.Initialize(aLFCB);
256 for (; anItLFCB.More(); anItLFCB.Next()) {
257 nF1=anItLFCB.Value();
264 //=======================================================================
265 // function: RealSplitsOnEdge
267 //=======================================================================
268 void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1,
269 const Standard_Integer nE2,
270 BOPTools_ListOfPaveBlock& aLPB)
274 BOPTools_ListIteratorOfListOfPaveBlock anIt;
275 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
277 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
279 anItCB.Initialize(aLCB);
280 for (; anItCB.More(); anItCB.Next()) {
281 NMTTools_CommonBlock& aCB=anItCB.Value();
282 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
283 const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
285 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
286 anIt.Initialize(aLPBx);
287 for (; anIt.More(); anIt.Next()) {
288 const BOPTools_PaveBlock& aPB2=anIt.Value();
289 nE=aPB2.OriginalEdge();
296 //=======================================================================
297 // function: RealSplitsOnFace
299 //=======================================================================
300 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1,
301 const Standard_Integer nF2,
302 BOPTools_ListOfPaveBlock& aLPB)
304 Standard_Integer nE2;
306 BooleanOperations_ShapesDataStructure *pDS=myDS;
307 BooleanOperations_OnceExplorer aExp(*pDS);
308 aExp.Init(nF2, TopAbs_EDGE);
309 for (; aExp.More(); aExp.Next()) {
311 RealSplitsOnEdge(nE1, nE2, aLPB);
314 //=======================================================================
315 // function: RealSplitsOnFace
317 //=======================================================================
318 void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding
319 const Standard_Integer nF1,
320 const Standard_Integer nF2,
321 BOPTools_ListOfPaveBlock& aLPB)
323 Standard_Integer nE1;
325 BooleanOperations_ShapesDataStructure *pDS=myDS;
326 BooleanOperations_OnceExplorer aExp(*myDS);
327 aExp.Init(nF1, TopAbs_EDGE);
328 for (; aExp.More(); aExp.Next()) {
330 RealSplitsOnFace(nE1, nF2, aLPB);
335 //=======================================================================
336 // function: SplitsFace
338 //=======================================================================
339 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
340 BOPTools_ListOfPaveBlock& aLPB)
344 BOPTools_ListIteratorOfListOfPaveBlock anIt;
346 aT=myDS->GetShapeType(nF);
348 if (aT!=TopAbs_FACE) {
349 return 1; // Type mismatch
352 BooleanOperations_ShapesDataStructure *pDS=myDS;
353 BooleanOperations_OnceExplorer aExp(*pDS);
355 aExp.Init(nF, TopAbs_EDGE);
356 for (; aExp.More(); aExp.Next()) {
358 const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
359 anIt.Initialize(aLPBE);
360 for (; anIt.More(); anIt.Next()) {
361 const BOPTools_PaveBlock& aPBE=anIt.Value();
368 //=======================================================================
369 // function: SplitsInFace
370 // purpose: splits of edges from nF1 in nF2
371 //=======================================================================
372 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
373 const Standard_Integer nF1,
374 const Standard_Integer nF2,
375 BOPTools_ListOfPaveBlock& aLPB)
377 Standard_Integer nE1;
378 TopAbs_ShapeEnum aT1, aT2;
380 aT1=myDS->GetShapeType(nF1);
381 aT2=myDS->GetShapeType(nF2);
383 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
384 return 1; // Type mismatch
386 BooleanOperations_ShapesDataStructure *pDS=myDS;
387 BooleanOperations_OnceExplorer aExp(*pDS);
388 aExp.Init(nF1, TopAbs_EDGE);
389 for (; aExp.More(); aExp.Next()) {
391 SplitsInFace (nE1, nF2, aLPB);
395 //=======================================================================
396 // function: SplitsInFace
397 // purpose: splits of edge nE1 in aFace2
398 //=======================================================================
399 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
400 const Standard_Integer nF2,
401 BOPTools_ListOfPaveBlock& aLPB)
403 Standard_Integer nF1;
404 TopAbs_ShapeEnum aT1, aT2;
406 aT1=myDS->GetShapeType(nE1);
407 aT2=myDS->GetShapeType(nF2);
409 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
410 return 1; // Type mismatch
413 TColStd_ListIteratorOfListOfInteger anItLFCB;
414 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
416 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
418 anItCB.Initialize(aLCB);
419 for (; anItCB.More(); anItCB.Next()) {
420 NMTTools_CommonBlock& aCB=anItCB.Value();
421 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
423 const TColStd_ListOfInteger& aLFCB=aCB.Faces();
424 anItLFCB.Initialize(aLFCB);
425 for (; anItLFCB.More(); anItLFCB.Next()) {
426 nF1=anItLFCB.Value();
434 //=======================================================================
435 // function: SplitsOnEdge
436 // purpose: splits of edge nE1 on nE2
437 //=======================================================================
438 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
439 const Standard_Integer nE2,
440 BOPTools_ListOfPaveBlock& aLPB)
443 TopAbs_ShapeEnum aT1, aT2;
445 aT1=myDS->GetShapeType(nE1);
446 aT2=myDS->GetShapeType(nE2);
448 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
449 return 1; // Type mismatch
452 BOPTools_ListIteratorOfListOfPaveBlock anIt;
453 NMTTools_ListIteratorOfListOfCommonBlock anItCB;
455 const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
457 anItCB.Initialize(aLCB);
458 for (; anItCB.More(); anItCB.Next()) {
459 NMTTools_CommonBlock& aCB=anItCB.Value();
460 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX
462 const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
463 anIt.Initialize(aLPBx);
464 for (; anIt.More(); anIt.Next()) {
465 const BOPTools_PaveBlock& aPB2=anIt.Value();
466 nE=aPB2.OriginalEdge();
474 //=======================================================================
475 // function: SplitsOnFace
476 // purpose: splits of edge nE1 on face nF2
477 //=======================================================================
478 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
479 const Standard_Integer nF2,
480 BOPTools_ListOfPaveBlock& aLPB)
482 Standard_Integer nE2, ip;
483 TopAbs_ShapeEnum aT1, aT2;
485 aT1=myDS->GetShapeType(nE1);
486 aT2=myDS->GetShapeType(nF2);
488 if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
489 return 1; // Type mismatch
491 BooleanOperations_ShapesDataStructure *pDS=myDS;
492 BooleanOperations_OnceExplorer aExp(*pDS);
493 aExp.Init(nF2, TopAbs_EDGE);
494 for (; aExp.More(); aExp.Next()) {
496 ip=SplitsOnEdge(nE1, nE2, aLPB);
503 //=======================================================================
504 // function: SplitsOnFace
505 // purpose: splits of edges from face nF1 on face nF2
506 //=======================================================================
507 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
508 const Standard_Integer nF1,
509 const Standard_Integer nF2,
510 BOPTools_ListOfPaveBlock& aLPB)
512 Standard_Integer nE1, ip;
513 TopAbs_ShapeEnum aT1, aT2;
515 aT1=myDS->GetShapeType(nF1);
516 aT2=myDS->GetShapeType(nF2);
518 if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
519 return 1; // Type mismatch
521 BooleanOperations_ShapesDataStructure *pDS=myDS;
522 BooleanOperations_OnceExplorer aExp(*myDS);
523 aExp.Init(nF1, TopAbs_EDGE);
524 for (; aExp.More(); aExp.Next()) {
526 ip=SplitsOnFace(nE1, nF2, aLPB);
534 // 3 Simple Splits indices
535 //=======================================================================
536 // function: SplitsFace
538 //=======================================================================
539 Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
540 TColStd_ListOfInteger& aSplits)
542 Standard_Integer nE, iErr;
543 BOPTools_ListIteratorOfListOfPaveBlock aIt;
544 BOPTools_ListOfPaveBlock aLPB;
546 iErr=SplitsFace(nF, aLPB);
551 aIt.Initialize(aLPB);
552 for (; aIt.More(); aIt.Next()) {
553 const BOPTools_PaveBlock& aPB=aIt.Value();
560 //=======================================================================
561 // function: SplitsInFace
562 // purpose: splits of edges from nF1 in nF2
563 //=======================================================================
564 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
565 const Standard_Integer nF1,
566 const Standard_Integer nF2,
567 TColStd_ListOfInteger& aSplits)
569 Standard_Integer nE, iErr;
570 BOPTools_ListIteratorOfListOfPaveBlock aIt;
571 BOPTools_ListOfPaveBlock aLPB;
573 iErr=SplitsInFace(0, nF1, nF2, aLPB);
577 aIt.Initialize(aLPB);
578 for (; aIt.More(); aIt.Next()) {
579 const BOPTools_PaveBlock& aPB=aIt.Value();
585 //=======================================================================
586 // function: SplitsInFace
587 // purpose: splits of edge nE1 in aFace2
588 //=======================================================================
589 Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
590 const Standard_Integer nF2,
591 TColStd_ListOfInteger& aSplits)
593 Standard_Integer nE, iErr;
594 BOPTools_ListIteratorOfListOfPaveBlock aIt;
595 BOPTools_ListOfPaveBlock aLPB;
597 iErr=SplitsInFace(nE1, nF2, aLPB);
601 aIt.Initialize(aLPB);
602 for (; aIt.More(); aIt.Next()) {
603 const BOPTools_PaveBlock& aPB=aIt.Value();
609 //=======================================================================
610 // function: SplitsOnEdge
611 // purpose: splits of edge nE1 on nE2
612 //=======================================================================
613 Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
614 const Standard_Integer nE2,
615 TColStd_ListOfInteger& aSplits)
617 Standard_Integer nE, iErr;
618 BOPTools_ListIteratorOfListOfPaveBlock aIt;
619 BOPTools_ListOfPaveBlock aLPB;
621 iErr=SplitsOnEdge(nE1, nE2, aLPB);
625 aIt.Initialize(aLPB);
626 for (; aIt.More(); aIt.Next()) {
627 const BOPTools_PaveBlock& aPB=aIt.Value();
633 //=======================================================================
634 // function: SplitsOnFace
635 // purpose: splits of edge nE1 on face nF2
636 //=======================================================================
637 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
638 const Standard_Integer nF2,
639 TColStd_ListOfInteger& aSplits)
641 Standard_Integer nE, iErr;
642 BOPTools_ListIteratorOfListOfPaveBlock aIt;
643 BOPTools_ListOfPaveBlock aLPB;
645 iErr=SplitsOnEdge(nE1, nF2, aLPB);
649 aIt.Initialize(aLPB);
650 for (; aIt.More(); aIt.Next()) {
651 const BOPTools_PaveBlock& aPB=aIt.Value();
657 //=======================================================================
658 // function: SplitsOnFace
659 // purpose: splits of edges from face nF1 on face nF2
660 //=======================================================================
661 Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
662 const Standard_Integer nF1,
663 const Standard_Integer nF2,
664 TColStd_ListOfInteger& aSplits)
666 Standard_Integer nE, iErr;
667 BOPTools_ListIteratorOfListOfPaveBlock aIt;
668 BOPTools_ListOfPaveBlock aLPB;
670 iErr=SplitsOnFace(0, nF1, nF2, aLPB);
675 aIt.Initialize(aLPB);
676 for (; aIt.More(); aIt.Next()) {
677 const BOPTools_PaveBlock& aPB=aIt.Value();