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
22 // File: GEOMAlgo_GetInPlace.cxx
24 // Author: Peter KURNEV
26 #include <GEOMAlgo_GetInPlace.hxx>
28 #include <NMTDS_BoxBndTree.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>
62 #include <NMTTools_CoupleOfShape.hxx>
63 #include <GEOMAlgo_Tools.hxx>
67 void MapBRepShapes(const TopoDS_Shape& aS,
68 TopTools_IndexedMapOfShape& aM);
71 //=======================================================================
72 //function : GEOMAlgo_GetInPlace
74 //=======================================================================
75 GEOMAlgo_GetInPlace::GEOMAlgo_GetInPlace()
83 myFound=Standard_False;
84 myCheckGeometry=Standard_True;
86 //=======================================================================
89 //=======================================================================
90 GEOMAlgo_GetInPlace::~GEOMAlgo_GetInPlace()
93 //=======================================================================
94 //function : SetTolMass
96 //=======================================================================
97 void GEOMAlgo_GetInPlace::SetTolMass(const Standard_Real theTol)
101 //=======================================================================
104 //=======================================================================
105 Standard_Real GEOMAlgo_GetInPlace::TolMass()const
109 //=======================================================================
110 //function : SetTolCG
112 //=======================================================================
113 void GEOMAlgo_GetInPlace::SetTolCG(const Standard_Real theTol)
117 //=======================================================================
120 //=======================================================================
121 Standard_Real GEOMAlgo_GetInPlace::TolCG()const
125 //=======================================================================
128 //=======================================================================
129 Standard_Boolean GEOMAlgo_GetInPlace::IsFound()const
133 //=======================================================================
134 //function : SetShapeWhere
136 //=======================================================================
137 void GEOMAlgo_GetInPlace::SetShapeWhere(const TopoDS_Shape& theShape)
139 myShapeWhere=theShape;
141 //=======================================================================
142 //function : ShapeWhere
144 //=======================================================================
145 const TopoDS_Shape& GEOMAlgo_GetInPlace::ShapeWhere()const
149 //=======================================================================
150 //function : ShapesIn
152 //=======================================================================
153 const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesIn()const
157 //=======================================================================
158 //function : ShapesOn
160 //=======================================================================
161 const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesOn()const
165 //=======================================================================
168 //=======================================================================
169 void GEOMAlgo_GetInPlace::Clear()
174 GEOMAlgo_GluerAlgo::Clear();
178 myMapShapePnt.Clear();
180 //=======================================================================
183 //=======================================================================
184 void GEOMAlgo_GetInPlace::Perform()
186 myFound=Standard_False;
270 //=======================================================================
271 //function : CheckData
273 //=======================================================================
274 void GEOMAlgo_GetInPlace::CheckData()
279 if (myArgument.IsNull()) {
284 if (myShapeWhere.IsNull()) {
289 //=======================================================================
290 //function : Intersect
292 //=======================================================================
293 void GEOMAlgo_GetInPlace::Intersect()
295 Standard_Integer i, j, aNbS1, aNbS2, aNbSD;
296 TColStd_ListIteratorOfListOfInteger aItLI;
297 TopTools_IndexedMapOfShape aMS1, aMS2;
298 TopTools_DataMapOfShapeListOfShape aDMSLS;
299 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS;
300 TopTools_ListIteratorOfListOfShape aItLS;
301 NMTTools_CoupleOfShape aCS;
303 NMTDS_BoxBndTreeSelector aSelector;
304 NMTDS_BoxBndTree aBBTree;
305 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
312 MapBRepShapes(myArgument, aMS1);
314 for (i=1; i<=aNbS1; ++i) {
317 const TopoDS_Shape& aS1=aMS1(i);
318 BRepBndLib::Add(aS1, aBox1);
319 //modified by NIZNHY-PKV Fri Jun 10 08:20:03 2011f
320 //aBox1.SetGap(myTolerance);
321 aBox1.Enlarge(myTolerance);
322 //modified by NIZNHY-PKV Fri Jun 10 08:20:06 2011t
324 aTreeFiller.Add(i, aBox1);
329 MapBRepShapes(myShapeWhere, aMS2);
331 for (j=1; j<=aNbS2; ++j) {
334 const TopoDS_Shape& aS2=aMS2(j);
335 BRepBndLib::Add(aS2, aBox2);
336 //modified by NIZNHY-PKV Fri Jun 10 08:20:23 2011f
337 //aBox2.SetGap(myTolerance);
338 aBox2.Enlarge(myTolerance);
339 //modified by NIZNHY-PKV Fri Jun 10 08:20:25 2011t
342 aSelector.SetBox(aBox2);
343 aNbSD=aBBTree.Select(aSelector);
345 continue; // it should not be
348 const TColStd_ListOfInteger& aLI=aSelector.Indices();
349 aItLI.Initialize(aLI);
350 for (; aItLI.More(); aItLI.Next()) {
352 const TopoDS_Shape& aS1=aMS1(i);
354 if (aDMSLS.IsBound(aS1)) {
355 TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aS1);
359 TopTools_ListOfShape aLS;
362 aDMSLS.Bind(aS1, aLS);
365 }// for (j=1; j<=aNbS2; ++j) {
367 aItDMSLS.Initialize(aDMSLS);
368 for (; aItDMSLS.More(); aItDMSLS.Next()) {
369 const TopoDS_Shape& aS1=aItDMSLS.Key();
370 const TopTools_ListOfShape& aLS2=aItDMSLS.Value();
372 aItLS.Initialize(aLS2);
373 for (; aItLS.More(); aItLS.Next()) {
374 const TopoDS_Shape& aS2=aItLS.Value();
376 myIterator.AppendPair(aCS);
380 //=======================================================================
381 //function : PerformVV
383 //=======================================================================
384 void GEOMAlgo_GetInPlace::PerformVV()
389 myIterator.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
390 for (; myIterator.More(); myIterator.Next()) {
391 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
392 const TopoDS_Shape& aV1=aCS.Shape1();
393 const TopoDS_Shape& aV2=aCS.Shape2();
395 FillShapesOn(aV1, aV2);
398 //=======================================================================
399 //function : FillEdgesOn
401 //=======================================================================
402 void GEOMAlgo_GetInPlace::FillEdgesOn()
404 Standard_Integer i, aNbE;
406 TopTools_IndexedMapOfShape aME;
407 TopTools_MapIteratorOfMapOfShape aItMS;
409 TopExp::MapShapes(myArgument, TopAbs_EDGE, aME);
411 for (i=1; i<=aNbE; ++i) {
412 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
413 if (BRep_Tool::Degenerated(aE1)) {
418 for (; aIt.More(); aIt.Next()) {
419 const TopoDS_Shape& aV1=aIt.Value();
420 if (myShapesOn.IsBound(aV1)) {
421 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aV1);
422 //aNbSOn=aMSOn.Extent();
423 aItMS.Initialize(aMSOn);
424 for (; aItMS.More(); aItMS.Next()) {
425 const TopoDS_Shape& aV2=aItMS.Key();
426 FillShapesOn(aE1, aV2);
432 //=======================================================================
433 //function : PerformVE
435 //=======================================================================
436 void GEOMAlgo_GetInPlace::PerformVE()
438 Standard_Boolean bFound;
444 myIterator.Initialize(TopAbs_EDGE, TopAbs_VERTEX);
445 for (; myIterator.More(); myIterator.Next()) {
446 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
447 const TopoDS_Shape& aE1=aCS.Shape1();
448 const TopoDS_Shape& aV2=aCS.Shape2();
450 if (myShapesOn.IsBound(aE1)) {
451 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
452 if (aMSOn.Contains(aV2)) {
457 bFound=CheckCoincidence(aE1, aV2);
462 FillShapesIn(aE1, aV2);
466 //=======================================================================
467 //function : PerformEE
469 //=======================================================================
470 void GEOMAlgo_GetInPlace::PerformEE()
472 Standard_Boolean bHasOn, bHasIn, bFound;
474 TopTools_MapOfShape aMSX;
479 myIterator.Initialize(TopAbs_EDGE, TopAbs_EDGE);
480 for (; myIterator.More(); myIterator.Next()) {
481 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
482 const TopoDS_Shape& aE1=aCS.Shape1();
483 const TopoDS_Shape& aE2=aCS.Shape2();
485 bHasOn=myShapesOn.IsBound(aE1);
486 bHasIn=myShapesIn.IsBound(aE1);
487 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
488 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
490 bFound=Standard_True;
492 for (; aIt.More(); aIt.Next()) {
493 const TopoDS_Shape& aV2=aIt.Value();
494 if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
503 bFound=CheckCoincidence(aE1, aE2);
508 FillShapesIn(aE1, aE2);
512 //=======================================================================
513 //function : PerformVF
515 //=======================================================================
516 void GEOMAlgo_GetInPlace::PerformVF()
518 Standard_Boolean bHasOn, bHasIn, bFound;
519 Standard_Integer i, aNbE;
520 TopTools_MapOfShape aMSX;
521 TopTools_IndexedMapOfShape aME;
526 myIterator.Initialize(TopAbs_FACE, TopAbs_VERTEX);
527 for (; myIterator.More(); myIterator.Next()) {
528 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
529 const TopoDS_Shape& aF1=aCS.Shape1();
530 const TopoDS_Shape& aV2=aCS.Shape2();
533 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
535 bFound=Standard_False;
537 for (i=1; i<=aNbE; ++i) {
538 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
539 if (BRep_Tool::Degenerated(aE1)) {
543 bHasOn=myShapesOn.IsBound(aE1);
544 bHasIn=myShapesIn.IsBound(aE1);
545 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
546 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
547 bFound= (aMSOn.Contains(aV2) || aMSIn.Contains(aV2));
557 bFound=CheckCoincidence(aF1, aV2);
562 FillShapesIn(aF1, aV2);
566 //=======================================================================
567 //function : FillFacesOn
569 //=======================================================================
570 void GEOMAlgo_GetInPlace::FillFacesOn()
572 Standard_Integer i, j, aNbF, aNbE;
574 TopTools_IndexedMapOfShape aMF, aME;
575 TopTools_MapIteratorOfMapOfShape aItMS;
577 TopExp::MapShapes(myArgument, TopAbs_FACE, aMF);
579 for (i=1; i<=aNbF; ++i) {
580 const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i));
583 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
585 for (j=1; j<=aNbE; ++j) {
586 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(j));
587 if (BRep_Tool::Degenerated(aE1)) {
591 if (myShapesOn.IsBound(aE1)) {
592 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
593 aItMS.Initialize(aMSOn);
594 for (; aItMS.More(); aItMS.Next()) {
595 const TopoDS_Shape& aS2=aItMS.Key();
596 FillShapesOn(aF1, aS2);
600 if (myShapesIn.IsBound(aE1)) {
601 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aE1);
602 aItMS.Initialize(aMSIn);
603 for (; aItMS.More(); aItMS.Next()) {
604 const TopoDS_Shape& aS2=aItMS.Key();
605 FillShapesOn(aF1, aS2);
608 }//for (j=1; j<=aNbE; ++j) {
609 }//for (i=1; i<=aNbF; ++i) {
611 //=======================================================================
612 //function : PerformEF
614 //=======================================================================
615 void GEOMAlgo_GetInPlace::PerformEF()
617 Standard_Boolean bFound, bHasOnF, bHasInF;
619 TopTools_MapOfShape aMSX;
624 myIterator.Initialize(TopAbs_FACE, TopAbs_EDGE);
625 for (; myIterator.More(); myIterator.Next()) {
626 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
627 const TopoDS_Shape& aF1=aCS.Shape1();
628 const TopoDS_Shape& aE2=aCS.Shape2();
631 bHasOnF=myShapesOn.IsBound(aF1);
632 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
633 bFound=aMSOnF.Contains(aE2);
639 bHasInF=myShapesIn.IsBound(aF1);
640 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
643 for (; aIt.More(); aIt.Next()) {
644 const TopoDS_Shape& aV2=aIt.Value();
645 bFound=(aMSOnF.Contains(aV2) || aMSInF.Contains(aV2));
653 //------------------------------
654 bFound=CheckCoincidence(aF1, aE2);
659 FillShapesIn(aF1, aE2);
663 //=======================================================================
664 //function : PerformFF
666 //=======================================================================
667 void GEOMAlgo_GetInPlace::PerformFF()
669 Standard_Boolean bFound, bHasOnF, bHasInF;
670 Standard_Integer i, aNbS2;
671 TopTools_MapOfShape aMSX;
672 TopTools_IndexedMapOfShape aMS2;
677 myIterator.Initialize(TopAbs_FACE, TopAbs_FACE);
678 for (; myIterator.More(); myIterator.Next()) {
679 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
680 const TopoDS_Shape& aF1=aCS.Shape1();
681 const TopoDS_Shape& aF2=aCS.Shape2();
683 bHasOnF=myShapesOn.IsBound(aF1);
684 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
686 bHasInF=myShapesIn.IsBound(aF1);
687 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
690 MapBRepShapes(aF2, aMS2);
692 bFound=Standard_False;
694 for (i=1; i<=aNbS2; ++i) {
695 const TopoDS_Shape& aS2=aMS2(i);
696 if (aS2.IsSame(aF2)) {
699 bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
708 bFound=CheckCoincidence(aF1, aF2);
713 FillShapesIn(aF1, aF2);
717 //=======================================================================
718 //function : FillSolidsOn
720 //=======================================================================
721 void GEOMAlgo_GetInPlace::FillSolidsOn()
723 Standard_Integer i, j, aNbS, aNbF;
724 TopTools_IndexedMapOfShape aMS, aMF;
725 TopTools_MapIteratorOfMapOfShape aItMS;
727 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
730 for (i=1; i<=aNbS; ++i) {
731 const TopoDS_Shape& aSD1=aMS(i);
734 TopExp::MapShapes(aSD1, TopAbs_FACE, aMF);
736 for (j=1; j<=aNbF; ++j) {
737 const TopoDS_Shape& aF1=aMF(j);
739 if (myShapesOn.IsBound(aF1)) {
740 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aF1);
741 aItMS.Initialize(aMSOn);
742 for (; aItMS.More(); aItMS.Next()) {
743 const TopoDS_Shape& aS2=aItMS.Key();
744 FillShapesOn(aSD1, aS2);
748 if (myShapesIn.IsBound(aF1)) {
749 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aF1);
750 aItMS.Initialize(aMSIn);
751 for (; aItMS.More(); aItMS.Next()) {
752 const TopoDS_Shape& aS2=aItMS.Key();
753 FillShapesOn(aSD1, aS2);
756 }//for (j=1; j<=aNbF; ++j) {
757 }//for (i=1; i<=aNbS; ++i) {
759 //=======================================================================
760 //function : PerformZF
762 //=======================================================================
763 void GEOMAlgo_GetInPlace::PerformZF()
765 Standard_Boolean bFound, bHasOnF;
766 TopTools_MapOfShape aMSX;
771 myIterator.Initialize(TopAbs_SOLID, TopAbs_FACE);
772 for (; myIterator.More(); myIterator.Next()) {
773 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
774 const TopoDS_Shape& aSo1=aCS.Shape1();
775 const TopoDS_Shape& aF2=aCS.Shape2();
777 bHasOnF=myShapesOn.IsBound(aSo1);
778 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aSo1) : aMSX;
779 bFound=aMSOnF.Contains(aF2);
783 //------------------------------
784 bFound=CheckCoincidence(aSo1, aF2);
789 FillShapesIn(aSo1, aF2);
793 //=======================================================================
794 //function : PerformZZ
796 //=======================================================================
797 void GEOMAlgo_GetInPlace::PerformZZ()
799 Standard_Boolean bFound, bHasOn, bHasIn;
800 Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
801 TopTools_MapOfShape aMSX;
802 TopTools_IndexedMapOfShape aMS2;
807 myIterator.Initialize(TopAbs_SOLID, TopAbs_SOLID);
808 for (; myIterator.More(); myIterator.Next()) {
809 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
810 const TopoDS_Shape& aSo1=aCS.Shape1();
811 const TopoDS_Shape& aSo2=aCS.Shape2();
813 bHasOn=myShapesOn.IsBound(aSo1);
814 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX;
816 bHasIn=myShapesIn.IsBound(aSo1);
817 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX;
820 TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2);
825 bFound=Standard_False;
827 for (i=1; i<=aNbS2; ++i) {
828 const TopoDS_Shape& aF2=aMS2(i);
830 if (aMSIn.Contains(aF2)) {
832 bFound=Standard_True;
835 else if (!aMSOn.Contains(aF2)) {
837 bFound=Standard_False;// out
845 if (!bFound && iCntOut) {
850 bFound=CheckCoincidence(aSo1, aSo2);
856 FillShapesIn(aSo1, aSo2);
858 }// for (; myIterator.More(); myIterator.Next()) {
860 //=======================================================================
861 //function : FillImages
863 //=======================================================================
864 void GEOMAlgo_GetInPlace::FillImages()
866 Standard_Integer i, aNbS, aNbSx, aNbSi;
867 TopAbs_ShapeEnum aType;
869 TopTools_ListOfShape aLSx;
870 TopTools_ListIteratorOfListOfShape aItLS;
871 TopTools_IndexedMapOfShape aMS;
872 TopTools_MapIteratorOfMapOfShape aItMS;
881 TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS);
883 for (i=1; i<=aNbS; ++i) {
884 const TopoDS_Shape& aV=aMS(i);
885 if (myShapesOn.IsBound(aV)) {
886 const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV);
890 aItMS.Initialize(aMSx);
891 for (; aItMS.More(); aItMS.Next()) {
892 const TopoDS_Shape& aVx=aItMS.Key();
896 myImages.Bind(aV, aLSx);
902 TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS);
904 for (i=1; i<=aNbS; ++i) {
905 const TopoDS_Shape& aE=aMS(i);
906 if (myShapesIn.IsBound(aE)) {
907 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE);
911 aItMS.Initialize(aMSx);
912 for (; aItMS.More(); aItMS.Next()) {
913 const TopoDS_Shape& aEx=aItMS.Key();
914 aType=aEx.ShapeType();
915 if (aType==TopAbs_EDGE){
920 myImages.Bind(aE, aLSx);
926 TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS);
928 for (i=1; i<=aNbS; ++i) {
929 const TopoDS_Shape& aW=aMS(i);
932 for(; aIt.More(); aIt.Next()) {
933 const TopoDS_Shape& aE=aIt.Value();
934 if (myImages.IsBound(aE)) {
935 const TopTools_ListOfShape& aLSi=myImages.Find(aE);
938 aItLS.Initialize(aLSi);
939 for (; aItLS.More(); aItLS.Next()) {
940 const TopoDS_Shape& aEi=aItLS.Value();
945 myImages.Bind(aW, aLSx);
950 TopExp::MapShapes(myArgument, TopAbs_FACE, aMS);
952 for (i=1; i<=aNbS; ++i) {
953 const TopoDS_Shape& aF=aMS(i);
954 if (myShapesIn.IsBound(aF)) {
955 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF);
959 aItMS.Initialize(aMSx);
960 for (; aItMS.More(); aItMS.Next()) {
961 const TopoDS_Shape& aFx=aItMS.Key();
962 aType=aFx.ShapeType();
963 if (aType==TopAbs_FACE){
968 myImages.Bind(aF, aLSx);
974 TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS);
976 for (i=1; i<=aNbS; ++i) {
977 const TopoDS_Shape& aSh=aMS(i);
980 for(; aIt.More(); aIt.Next()) {
981 const TopoDS_Shape& aF=aIt.Value();
982 if (myImages.IsBound(aF)) {
983 const TopTools_ListOfShape& aLSi=myImages.Find(aF);
986 aItLS.Initialize(aLSi);
987 for (; aItLS.More(); aItLS.Next()) {
988 const TopoDS_Shape& aFi=aItLS.Value();
993 myImages.Bind(aSh, aLSx);
998 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
1000 for (i=1; i<=aNbS; ++i) {
1001 const TopoDS_Shape& aZ=aMS(i);
1002 if (myShapesIn.IsBound(aZ)) {
1003 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ);
1004 aNbSx=aMSx.Extent();
1007 aItMS.Initialize(aMSx);
1008 for (; aItMS.More(); aItMS.Next()) {
1009 const TopoDS_Shape& aZx=aItMS.Key();
1010 aType=aZx.ShapeType();
1011 if (aType==TopAbs_SOLID){
1016 myImages.Bind(aZ, aLSx);
1022 TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS);
1024 for (i=1; i<=aNbS; ++i) {
1025 const TopoDS_Shape& aCs=aMS(i);
1027 aIt.Initialize(aCs);
1028 for(; aIt.More(); aIt.Next()) {
1029 const TopoDS_Shape& aZ=aIt.Value();
1030 if (myImages.IsBound(aZ)) {
1031 const TopTools_ListOfShape& aLSi=myImages.Find(aZ);
1032 aNbSi=aLSi.Extent();
1034 aItLS.Initialize(aLSi);
1035 for (; aItLS.More(); aItLS.Next()) {
1036 const TopoDS_Shape& aZi=aItLS.Value();
1041 myImages.Bind(aCs, aLSx);
1045 aType=myArgument.ShapeType();
1046 if (aType==TopAbs_COMPOUND) {
1047 FillImagesCompound(myArgument);
1050 //=======================================================================
1051 //function : FillImagesCompound
1053 //=======================================================================
1054 void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS)
1056 TopAbs_ShapeEnum aType;
1057 TopoDS_Iterator aIt;
1058 TopTools_ListOfShape aLSx;
1059 TopTools_ListIteratorOfListOfShape aItLS;
1062 for(; aIt.More(); aIt.Next()) {
1063 const TopoDS_Shape& aSx=aIt.Value();
1064 aType=aSx.ShapeType();
1066 if (aType==TopAbs_COMPOUND) {
1067 FillImagesCompound(aSx);
1070 if (myImages.IsBound(aSx)) {
1071 const TopTools_ListOfShape& aLSi=myImages.Find(aSx);
1072 aItLS.Initialize(aLSi);
1073 for (; aItLS.More(); aItLS.Next()) {
1074 const TopoDS_Shape& aSi=aItLS.Value();
1079 myImages.Bind(aS, aLSx);
1082 //=======================================================================
1083 //function : FillShapesIn
1085 //=======================================================================
1086 void GEOMAlgo_GetInPlace::FillShapesIn(const TopoDS_Shape& aS1,
1087 const TopoDS_Shape& aS2)
1089 if (myShapesIn.IsBound(aS1)) {
1090 TopTools_MapOfShape& aMS=myShapesIn.ChangeFind(aS1);
1094 TopTools_MapOfShape aMS;
1097 myShapesIn.Bind(aS1, aMS);
1100 //=======================================================================
1101 //function : FillShapesOn
1103 //=======================================================================
1104 void GEOMAlgo_GetInPlace::FillShapesOn(const TopoDS_Shape& aS1,
1105 const TopoDS_Shape& aS2)
1107 if (myShapesOn.IsBound(aS1)) {
1108 TopTools_MapOfShape& aMS=myShapesOn.ChangeFind(aS1);
1112 TopTools_MapOfShape aMS;
1115 myShapesOn.Bind(aS1, aMS);
1118 //=======================================================================
1119 //function : MapBRepShapes
1121 //=======================================================================
1122 void MapBRepShapes(const TopoDS_Shape& aS,
1123 TopTools_IndexedMapOfShape& aM)
1125 Standard_Boolean bDegenerated;
1126 TopAbs_ShapeEnum aType;
1127 TopoDS_Iterator aIt;
1129 aType=aS.ShapeType();
1130 if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
1131 aType==TopAbs_FACE || aType==TopAbs_SOLID) {
1132 bDegenerated=Standard_False;
1133 if (aType==TopAbs_EDGE) {
1134 TopoDS_Edge *pE=(TopoDS_Edge*)&aS;
1135 bDegenerated=BRep_Tool::Degenerated(*pE);
1137 if (!bDegenerated) {
1143 for(; aIt.More(); aIt.Next()) {
1144 const TopoDS_Shape& aSx=aIt.Value();
1145 aType=aSx.ShapeType();
1146 MapBRepShapes(aSx, aM);