1 // Copyright (C) 2007-2013 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: GEOMAlgo_GetInPlace.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_GetInPlace.hxx>
29 #include <NCollection_UBTreeFiller.hxx>
31 #include <Bnd_Box.hxx>
34 #include <TColStd_ListOfInteger.hxx>
35 #include <TColStd_ListIteratorOfListOfInteger.hxx>
37 #include <TopAbs_ShapeEnum.hxx>
39 #include <TopoDS_Iterator.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Vertex.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS_Face.hxx>
44 #include <TopoDS_Compound.hxx>
46 #include <BRep_Tool.hxx>
47 #include <BRep_Builder.hxx>
49 #include <BRepBndLib.hxx>
53 #include <TopTools_IndexedMapOfShape.hxx>
54 #include <TopTools_ListOfShape.hxx>
55 #include <TopTools_DataMapOfShapeListOfShape.hxx>
56 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
57 #include <TopTools_ListIteratorOfListOfShape.hxx>
58 #include <TopTools_MapOfShape.hxx>
59 #include <TopTools_MapIteratorOfMapOfShape.hxx>
61 #include <GEOMAlgo_BoxBndTree.hxx>
62 #include <GEOMAlgo_CoupleOfShapes.hxx>
66 void MapBRepShapes(const TopoDS_Shape& aS,
67 TopTools_IndexedMapOfShape& aM);
70 //=======================================================================
71 //function : GEOMAlgo_GetInPlace
73 //=======================================================================
74 GEOMAlgo_GetInPlace::GEOMAlgo_GetInPlace()
82 myFound=Standard_False;
83 myCheckGeometry=Standard_True;
85 //=======================================================================
88 //=======================================================================
89 GEOMAlgo_GetInPlace::~GEOMAlgo_GetInPlace()
92 //=======================================================================
93 //function : SetTolMass
95 //=======================================================================
96 void GEOMAlgo_GetInPlace::SetTolMass(const Standard_Real theTol)
100 //=======================================================================
103 //=======================================================================
104 Standard_Real GEOMAlgo_GetInPlace::TolMass()const
108 //=======================================================================
109 //function : SetTolCG
111 //=======================================================================
112 void GEOMAlgo_GetInPlace::SetTolCG(const Standard_Real theTol)
116 //=======================================================================
119 //=======================================================================
120 Standard_Real GEOMAlgo_GetInPlace::TolCG()const
124 //=======================================================================
127 //=======================================================================
128 Standard_Boolean GEOMAlgo_GetInPlace::IsFound()const
132 //=======================================================================
133 //function : SetShapeWhere
135 //=======================================================================
136 void GEOMAlgo_GetInPlace::SetShapeWhere(const TopoDS_Shape& theShape)
138 myShapeWhere=theShape;
140 //=======================================================================
141 //function : ShapeWhere
143 //=======================================================================
144 const TopoDS_Shape& GEOMAlgo_GetInPlace::ShapeWhere()const
148 //=======================================================================
149 //function : ShapesIn
151 //=======================================================================
152 const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesIn()const
156 //=======================================================================
157 //function : ShapesOn
159 //=======================================================================
160 const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesOn()const
164 //=======================================================================
167 //=======================================================================
168 void GEOMAlgo_GetInPlace::Clear()
173 GEOMAlgo_GluerAlgo::Clear();
177 myMapShapePnt.Clear();
179 //=======================================================================
182 //=======================================================================
183 void GEOMAlgo_GetInPlace::Perform()
185 myFound=Standard_False;
199 // Initialize the context
200 GEOMAlgo_GluerAlgo::Perform();
272 //=======================================================================
273 //function : CheckData
275 //=======================================================================
276 void GEOMAlgo_GetInPlace::CheckData()
281 if (myArgument.IsNull()) {
286 if (myShapeWhere.IsNull()) {
291 //=======================================================================
292 //function : Intersect
294 //=======================================================================
295 void GEOMAlgo_GetInPlace::Intersect()
297 Standard_Integer i, j, aNbS1, aNbS2, aNbSD;
298 TColStd_ListIteratorOfListOfInteger aItLI;
299 TopTools_IndexedMapOfShape aMS1, aMS2;
300 TopTools_DataMapOfShapeListOfShape aDMSLS;
301 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS;
302 TopTools_ListIteratorOfListOfShape aItLS;
303 GEOMAlgo_CoupleOfShapes aCS;
305 GEOMAlgo_BoxBndTreeSelector aSelector;
306 GEOMAlgo_BoxBndTree aBBTree;
307 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
314 MapBRepShapes(myArgument, aMS1);
316 for (i=1; i<=aNbS1; ++i) {
319 const TopoDS_Shape& aS1=aMS1(i);
320 BRepBndLib::Add(aS1, aBox1);
321 //modified by NIZNHY-PKV Fri Jun 10 08:20:03 2011f
322 //aBox1.SetGap(myTolerance);
323 aBox1.Enlarge(myTolerance);
324 //modified by NIZNHY-PKV Fri Jun 10 08:20:06 2011t
326 aTreeFiller.Add(i, aBox1);
331 MapBRepShapes(myShapeWhere, aMS2);
333 for (j=1; j<=aNbS2; ++j) {
336 const TopoDS_Shape& aS2=aMS2(j);
337 BRepBndLib::Add(aS2, aBox2);
338 //modified by NIZNHY-PKV Fri Jun 10 08:20:23 2011f
339 //aBox2.SetGap(myTolerance);
340 aBox2.Enlarge(myTolerance);
341 //modified by NIZNHY-PKV Fri Jun 10 08:20:25 2011t
344 aSelector.SetBox(aBox2);
345 aNbSD=aBBTree.Select(aSelector);
347 continue; // it should not be
350 const TColStd_ListOfInteger& aLI=aSelector.Indices();
351 aItLI.Initialize(aLI);
352 for (; aItLI.More(); aItLI.Next()) {
354 const TopoDS_Shape& aS1=aMS1(i);
356 if (aDMSLS.IsBound(aS1)) {
357 TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aS1);
361 TopTools_ListOfShape aLS;
364 aDMSLS.Bind(aS1, aLS);
367 }// for (j=1; j<=aNbS2; ++j) {
369 aItDMSLS.Initialize(aDMSLS);
370 for (; aItDMSLS.More(); aItDMSLS.Next()) {
371 const TopoDS_Shape& aS1=aItDMSLS.Key();
372 const TopTools_ListOfShape& aLS2=aItDMSLS.Value();
374 aItLS.Initialize(aLS2);
375 for (; aItLS.More(); aItLS.Next()) {
376 const TopoDS_Shape& aS2=aItLS.Value();
378 myIterator.AppendPair(aCS);
382 //=======================================================================
383 //function : PerformVV
385 //=======================================================================
386 void GEOMAlgo_GetInPlace::PerformVV()
391 myIterator.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
392 for (; myIterator.More(); myIterator.Next()) {
393 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
394 const TopoDS_Shape& aV1=aCS.Shape1();
395 const TopoDS_Shape& aV2=aCS.Shape2();
397 FillShapesOn(aV1, aV2);
400 //=======================================================================
401 //function : FillEdgesOn
403 //=======================================================================
404 void GEOMAlgo_GetInPlace::FillEdgesOn()
406 Standard_Integer i, aNbE;
408 TopTools_IndexedMapOfShape aME;
409 TopTools_MapIteratorOfMapOfShape aItMS;
411 TopExp::MapShapes(myArgument, TopAbs_EDGE, aME);
413 for (i=1; i<=aNbE; ++i) {
414 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
415 if (BRep_Tool::Degenerated(aE1)) {
420 for (; aIt.More(); aIt.Next()) {
421 const TopoDS_Shape& aV1=aIt.Value();
422 if (myShapesOn.IsBound(aV1)) {
423 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aV1);
424 //aNbSOn=aMSOn.Extent();
425 aItMS.Initialize(aMSOn);
426 for (; aItMS.More(); aItMS.Next()) {
427 const TopoDS_Shape& aV2=aItMS.Key();
428 FillShapesOn(aE1, aV2);
434 //=======================================================================
435 //function : PerformVE
437 //=======================================================================
438 void GEOMAlgo_GetInPlace::PerformVE()
440 Standard_Boolean bFound;
446 myIterator.Initialize(TopAbs_EDGE, TopAbs_VERTEX);
447 for (; myIterator.More(); myIterator.Next()) {
448 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
449 const TopoDS_Shape& aE1=aCS.Shape1();
450 const TopoDS_Shape& aV2=aCS.Shape2();
452 if (myShapesOn.IsBound(aE1)) {
453 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
454 if (aMSOn.Contains(aV2)) {
459 bFound=CheckCoincidence(aE1, aV2);
464 FillShapesIn(aE1, aV2);
468 //=======================================================================
469 //function : PerformEE
471 //=======================================================================
472 void GEOMAlgo_GetInPlace::PerformEE()
474 Standard_Boolean bHasOn, bHasIn, bFound;
476 TopTools_MapOfShape aMSX;
481 myIterator.Initialize(TopAbs_EDGE, TopAbs_EDGE);
482 for (; myIterator.More(); myIterator.Next()) {
483 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
484 const TopoDS_Shape& aE1=aCS.Shape1();
485 const TopoDS_Shape& aE2=aCS.Shape2();
487 bHasOn=myShapesOn.IsBound(aE1);
488 bHasIn=myShapesIn.IsBound(aE1);
489 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
490 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
492 bFound=Standard_True;
494 for (; aIt.More(); aIt.Next()) {
495 const TopoDS_Shape& aV2=aIt.Value();
496 if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
505 bFound=CheckCoincidence(aE1, aE2);
510 FillShapesIn(aE1, aE2);
514 //=======================================================================
515 //function : PerformVF
517 //=======================================================================
518 void GEOMAlgo_GetInPlace::PerformVF()
520 Standard_Boolean bHasOn, bHasIn, bFound;
521 Standard_Integer i, aNbE;
522 TopTools_MapOfShape aMSX;
523 TopTools_IndexedMapOfShape aME;
528 myIterator.Initialize(TopAbs_FACE, TopAbs_VERTEX);
529 for (; myIterator.More(); myIterator.Next()) {
530 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
531 const TopoDS_Shape& aF1=aCS.Shape1();
532 const TopoDS_Shape& aV2=aCS.Shape2();
535 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
537 bFound=Standard_False;
539 for (i=1; i<=aNbE; ++i) {
540 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
541 if (BRep_Tool::Degenerated(aE1)) {
545 bHasOn=myShapesOn.IsBound(aE1);
546 bHasIn=myShapesIn.IsBound(aE1);
547 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
548 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
549 bFound= (aMSOn.Contains(aV2) || aMSIn.Contains(aV2));
559 bFound=CheckCoincidence(aF1, aV2);
564 FillShapesIn(aF1, aV2);
568 //=======================================================================
569 //function : FillFacesOn
571 //=======================================================================
572 void GEOMAlgo_GetInPlace::FillFacesOn()
574 Standard_Integer i, j, aNbF, aNbE;
576 TopTools_IndexedMapOfShape aMF, aME;
577 TopTools_MapIteratorOfMapOfShape aItMS;
579 TopExp::MapShapes(myArgument, TopAbs_FACE, aMF);
581 for (i=1; i<=aNbF; ++i) {
582 const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i));
585 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
587 for (j=1; j<=aNbE; ++j) {
588 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(j));
589 if (BRep_Tool::Degenerated(aE1)) {
593 if (myShapesOn.IsBound(aE1)) {
594 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
595 aItMS.Initialize(aMSOn);
596 for (; aItMS.More(); aItMS.Next()) {
597 const TopoDS_Shape& aS2=aItMS.Key();
598 FillShapesOn(aF1, aS2);
602 if (myShapesIn.IsBound(aE1)) {
603 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aE1);
604 aItMS.Initialize(aMSIn);
605 for (; aItMS.More(); aItMS.Next()) {
606 const TopoDS_Shape& aS2=aItMS.Key();
607 FillShapesOn(aF1, aS2);
610 }//for (j=1; j<=aNbE; ++j) {
611 }//for (i=1; i<=aNbF; ++i) {
613 //=======================================================================
614 //function : PerformEF
616 //=======================================================================
617 void GEOMAlgo_GetInPlace::PerformEF()
619 Standard_Boolean bFound, bHasOnF, bHasInF;
621 TopTools_MapOfShape aMSX;
626 myIterator.Initialize(TopAbs_FACE, TopAbs_EDGE);
627 for (; myIterator.More(); myIterator.Next()) {
628 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
629 const TopoDS_Shape& aF1=aCS.Shape1();
630 const TopoDS_Shape& aE2=aCS.Shape2();
633 bHasOnF=myShapesOn.IsBound(aF1);
634 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
635 bFound=aMSOnF.Contains(aE2);
641 bHasInF=myShapesIn.IsBound(aF1);
642 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
645 for (; aIt.More(); aIt.Next()) {
646 const TopoDS_Shape& aV2=aIt.Value();
647 bFound=(aMSOnF.Contains(aV2) || aMSInF.Contains(aV2));
655 //------------------------------
656 bFound=CheckCoincidence(aF1, aE2);
661 FillShapesIn(aF1, aE2);
665 //=======================================================================
666 //function : PerformFF
668 //=======================================================================
669 void GEOMAlgo_GetInPlace::PerformFF()
671 Standard_Boolean bFound, bHasOnF, bHasInF;
672 Standard_Integer i, aNbS2;
673 TopTools_MapOfShape aMSX;
674 TopTools_IndexedMapOfShape aMS2;
679 myIterator.Initialize(TopAbs_FACE, TopAbs_FACE);
680 for (; myIterator.More(); myIterator.Next()) {
681 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
682 const TopoDS_Shape& aF1=aCS.Shape1();
683 const TopoDS_Shape& aF2=aCS.Shape2();
685 bHasOnF=myShapesOn.IsBound(aF1);
686 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
688 bHasInF=myShapesIn.IsBound(aF1);
689 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
692 MapBRepShapes(aF2, aMS2);
694 bFound=Standard_False;
696 for (i=1; i<=aNbS2; ++i) {
697 const TopoDS_Shape& aS2=aMS2(i);
698 if (aS2.IsSame(aF2)) {
701 bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
710 bFound=CheckCoincidence(aF1, aF2);
715 FillShapesIn(aF1, aF2);
719 //=======================================================================
720 //function : FillSolidsOn
722 //=======================================================================
723 void GEOMAlgo_GetInPlace::FillSolidsOn()
725 Standard_Integer i, j, aNbS, aNbF;
726 TopTools_IndexedMapOfShape aMS, aMF;
727 TopTools_MapIteratorOfMapOfShape aItMS;
729 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
732 for (i=1; i<=aNbS; ++i) {
733 const TopoDS_Shape& aSD1=aMS(i);
736 TopExp::MapShapes(aSD1, TopAbs_FACE, aMF);
738 for (j=1; j<=aNbF; ++j) {
739 const TopoDS_Shape& aF1=aMF(j);
741 if (myShapesOn.IsBound(aF1)) {
742 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aF1);
743 aItMS.Initialize(aMSOn);
744 for (; aItMS.More(); aItMS.Next()) {
745 const TopoDS_Shape& aS2=aItMS.Key();
746 FillShapesOn(aSD1, aS2);
750 if (myShapesIn.IsBound(aF1)) {
751 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aF1);
752 aItMS.Initialize(aMSIn);
753 for (; aItMS.More(); aItMS.Next()) {
754 const TopoDS_Shape& aS2=aItMS.Key();
755 FillShapesOn(aSD1, aS2);
758 }//for (j=1; j<=aNbF; ++j) {
759 }//for (i=1; i<=aNbS; ++i) {
761 //=======================================================================
762 //function : PerformZF
764 //=======================================================================
765 void GEOMAlgo_GetInPlace::PerformZF()
767 Standard_Boolean bFound, bHasOnF;
768 TopTools_MapOfShape aMSX;
773 myIterator.Initialize(TopAbs_SOLID, TopAbs_FACE);
774 for (; myIterator.More(); myIterator.Next()) {
775 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
776 const TopoDS_Shape& aSo1=aCS.Shape1();
777 const TopoDS_Shape& aF2=aCS.Shape2();
779 bHasOnF=myShapesOn.IsBound(aSo1);
780 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aSo1) : aMSX;
781 bFound=aMSOnF.Contains(aF2);
785 //------------------------------
786 bFound=CheckCoincidence(aSo1, aF2);
791 FillShapesIn(aSo1, aF2);
795 //=======================================================================
796 //function : PerformZZ
798 //=======================================================================
799 void GEOMAlgo_GetInPlace::PerformZZ()
801 Standard_Boolean bFound, bHasOn, bHasIn;
802 Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
803 TopTools_MapOfShape aMSX;
804 TopTools_IndexedMapOfShape aMS2;
809 myIterator.Initialize(TopAbs_SOLID, TopAbs_SOLID);
810 for (; myIterator.More(); myIterator.Next()) {
811 const GEOMAlgo_CoupleOfShapes& aCS=myIterator.Value();
812 const TopoDS_Shape& aSo1=aCS.Shape1();
813 const TopoDS_Shape& aSo2=aCS.Shape2();
815 bHasOn=myShapesOn.IsBound(aSo1);
816 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX;
818 bHasIn=myShapesIn.IsBound(aSo1);
819 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX;
822 TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2);
827 bFound=Standard_False;
829 for (i=1; i<=aNbS2; ++i) {
830 const TopoDS_Shape& aF2=aMS2(i);
832 if (aMSIn.Contains(aF2)) {
834 bFound=Standard_True;
837 else if (!aMSOn.Contains(aF2)) {
839 bFound=Standard_False;// out
847 if (!bFound && iCntOut) {
852 bFound=CheckCoincidence(aSo1, aSo2);
858 FillShapesIn(aSo1, aSo2);
860 }// for (; myIterator.More(); myIterator.Next()) {
862 //=======================================================================
863 //function : FillImages
865 //=======================================================================
866 void GEOMAlgo_GetInPlace::FillImages()
868 Standard_Integer i, aNbS, aNbSx, aNbSi;
869 TopAbs_ShapeEnum aType;
871 TopTools_ListOfShape aLSx;
872 TopTools_ListIteratorOfListOfShape aItLS;
873 TopTools_IndexedMapOfShape aMS;
874 TopTools_MapIteratorOfMapOfShape aItMS;
883 TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS);
885 for (i=1; i<=aNbS; ++i) {
886 const TopoDS_Shape& aV=aMS(i);
887 if (myShapesOn.IsBound(aV)) {
888 const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV);
892 aItMS.Initialize(aMSx);
893 for (; aItMS.More(); aItMS.Next()) {
894 const TopoDS_Shape& aVx=aItMS.Key();
898 myImages.Bind(aV, aLSx);
904 TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS);
906 for (i=1; i<=aNbS; ++i) {
907 const TopoDS_Shape& aE=aMS(i);
908 if (myShapesIn.IsBound(aE)) {
909 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE);
913 aItMS.Initialize(aMSx);
914 for (; aItMS.More(); aItMS.Next()) {
915 const TopoDS_Shape& aEx=aItMS.Key();
916 aType=aEx.ShapeType();
917 if (aType==TopAbs_EDGE){
922 myImages.Bind(aE, aLSx);
928 TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS);
930 for (i=1; i<=aNbS; ++i) {
931 const TopoDS_Shape& aW=aMS(i);
934 for(; aIt.More(); aIt.Next()) {
935 const TopoDS_Shape& aE=aIt.Value();
936 if (myImages.IsBound(aE)) {
937 const TopTools_ListOfShape& aLSi=myImages.Find(aE);
940 aItLS.Initialize(aLSi);
941 for (; aItLS.More(); aItLS.Next()) {
942 const TopoDS_Shape& aEi=aItLS.Value();
947 myImages.Bind(aW, aLSx);
952 TopExp::MapShapes(myArgument, TopAbs_FACE, aMS);
954 for (i=1; i<=aNbS; ++i) {
955 const TopoDS_Shape& aF=aMS(i);
956 if (myShapesIn.IsBound(aF)) {
957 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF);
961 aItMS.Initialize(aMSx);
962 for (; aItMS.More(); aItMS.Next()) {
963 const TopoDS_Shape& aFx=aItMS.Key();
964 aType=aFx.ShapeType();
965 if (aType==TopAbs_FACE){
970 myImages.Bind(aF, aLSx);
976 TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS);
978 for (i=1; i<=aNbS; ++i) {
979 const TopoDS_Shape& aSh=aMS(i);
982 for(; aIt.More(); aIt.Next()) {
983 const TopoDS_Shape& aF=aIt.Value();
984 if (myImages.IsBound(aF)) {
985 const TopTools_ListOfShape& aLSi=myImages.Find(aF);
988 aItLS.Initialize(aLSi);
989 for (; aItLS.More(); aItLS.Next()) {
990 const TopoDS_Shape& aFi=aItLS.Value();
995 myImages.Bind(aSh, aLSx);
1000 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
1002 for (i=1; i<=aNbS; ++i) {
1003 const TopoDS_Shape& aZ=aMS(i);
1004 if (myShapesIn.IsBound(aZ)) {
1005 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ);
1006 aNbSx=aMSx.Extent();
1009 aItMS.Initialize(aMSx);
1010 for (; aItMS.More(); aItMS.Next()) {
1011 const TopoDS_Shape& aZx=aItMS.Key();
1012 aType=aZx.ShapeType();
1013 if (aType==TopAbs_SOLID){
1018 myImages.Bind(aZ, aLSx);
1024 TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS);
1026 for (i=1; i<=aNbS; ++i) {
1027 const TopoDS_Shape& aCs=aMS(i);
1029 aIt.Initialize(aCs);
1030 for(; aIt.More(); aIt.Next()) {
1031 const TopoDS_Shape& aZ=aIt.Value();
1032 if (myImages.IsBound(aZ)) {
1033 const TopTools_ListOfShape& aLSi=myImages.Find(aZ);
1034 aNbSi=aLSi.Extent();
1036 aItLS.Initialize(aLSi);
1037 for (; aItLS.More(); aItLS.Next()) {
1038 const TopoDS_Shape& aZi=aItLS.Value();
1043 myImages.Bind(aCs, aLSx);
1047 aType=myArgument.ShapeType();
1048 if (aType==TopAbs_COMPOUND) {
1049 FillImagesCompound(myArgument);
1052 //=======================================================================
1053 //function : FillImagesCompound
1055 //=======================================================================
1056 void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS)
1058 TopAbs_ShapeEnum aType;
1059 TopoDS_Iterator aIt;
1060 TopTools_ListOfShape aLSx;
1061 TopTools_ListIteratorOfListOfShape aItLS;
1064 for(; aIt.More(); aIt.Next()) {
1065 const TopoDS_Shape& aSx=aIt.Value();
1066 aType=aSx.ShapeType();
1068 if (aType==TopAbs_COMPOUND) {
1069 FillImagesCompound(aSx);
1072 if (myImages.IsBound(aSx)) {
1073 const TopTools_ListOfShape& aLSi=myImages.Find(aSx);
1074 aItLS.Initialize(aLSi);
1075 for (; aItLS.More(); aItLS.Next()) {
1076 const TopoDS_Shape& aSi=aItLS.Value();
1081 myImages.Bind(aS, aLSx);
1084 //=======================================================================
1085 //function : FillShapesIn
1087 //=======================================================================
1088 void GEOMAlgo_GetInPlace::FillShapesIn(const TopoDS_Shape& aS1,
1089 const TopoDS_Shape& aS2)
1091 if (myShapesIn.IsBound(aS1)) {
1092 TopTools_MapOfShape& aMS=myShapesIn.ChangeFind(aS1);
1096 TopTools_MapOfShape aMS;
1099 myShapesIn.Bind(aS1, aMS);
1102 //=======================================================================
1103 //function : FillShapesOn
1105 //=======================================================================
1106 void GEOMAlgo_GetInPlace::FillShapesOn(const TopoDS_Shape& aS1,
1107 const TopoDS_Shape& aS2)
1109 if (myShapesOn.IsBound(aS1)) {
1110 TopTools_MapOfShape& aMS=myShapesOn.ChangeFind(aS1);
1114 TopTools_MapOfShape aMS;
1117 myShapesOn.Bind(aS1, aMS);
1120 //=======================================================================
1121 //function : MapBRepShapes
1123 //=======================================================================
1124 void MapBRepShapes(const TopoDS_Shape& aS,
1125 TopTools_IndexedMapOfShape& aM)
1127 Standard_Boolean bDegenerated;
1128 TopAbs_ShapeEnum aType;
1129 TopoDS_Iterator aIt;
1131 aType=aS.ShapeType();
1132 if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
1133 aType==TopAbs_FACE || aType==TopAbs_SOLID) {
1134 bDegenerated=Standard_False;
1135 if (aType==TopAbs_EDGE) {
1136 TopoDS_Edge *pE=(TopoDS_Edge*)&aS;
1137 bDegenerated=BRep_Tool::Degenerated(*pE);
1139 if (!bDegenerated) {
1145 for(; aIt.More(); aIt.Next()) {
1146 const TopoDS_Shape& aSx=aIt.Value();
1147 aType=aSx.ShapeType();
1148 MapBRepShapes(aSx, aM);