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;
200 // Initialize the context
201 GEOMAlgo_GluerAlgo::Perform();
273 //=======================================================================
274 //function : CheckData
276 //=======================================================================
277 void GEOMAlgo_GetInPlace::CheckData()
282 if (myArgument.IsNull()) {
287 if (myShapeWhere.IsNull()) {
292 //=======================================================================
293 //function : Intersect
295 //=======================================================================
296 void GEOMAlgo_GetInPlace::Intersect()
298 Standard_Integer i, j, aNbS1, aNbS2, aNbSD;
299 TColStd_ListIteratorOfListOfInteger aItLI;
300 TopTools_IndexedMapOfShape aMS1, aMS2;
301 TopTools_DataMapOfShapeListOfShape aDMSLS;
302 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS;
303 TopTools_ListIteratorOfListOfShape aItLS;
304 NMTTools_CoupleOfShape aCS;
306 NMTDS_BoxBndTreeSelector aSelector;
307 NMTDS_BoxBndTree aBBTree;
308 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
315 MapBRepShapes(myArgument, aMS1);
317 for (i=1; i<=aNbS1; ++i) {
320 const TopoDS_Shape& aS1=aMS1(i);
321 BRepBndLib::Add(aS1, aBox1);
322 //modified by NIZNHY-PKV Fri Jun 10 08:20:03 2011f
323 //aBox1.SetGap(myTolerance);
324 aBox1.Enlarge(myTolerance);
325 //modified by NIZNHY-PKV Fri Jun 10 08:20:06 2011t
327 aTreeFiller.Add(i, aBox1);
332 MapBRepShapes(myShapeWhere, aMS2);
334 for (j=1; j<=aNbS2; ++j) {
337 const TopoDS_Shape& aS2=aMS2(j);
338 BRepBndLib::Add(aS2, aBox2);
339 //modified by NIZNHY-PKV Fri Jun 10 08:20:23 2011f
340 //aBox2.SetGap(myTolerance);
341 aBox2.Enlarge(myTolerance);
342 //modified by NIZNHY-PKV Fri Jun 10 08:20:25 2011t
345 aSelector.SetBox(aBox2);
346 aNbSD=aBBTree.Select(aSelector);
348 continue; // it should not be
351 const TColStd_ListOfInteger& aLI=aSelector.Indices();
352 aItLI.Initialize(aLI);
353 for (; aItLI.More(); aItLI.Next()) {
355 const TopoDS_Shape& aS1=aMS1(i);
357 if (aDMSLS.IsBound(aS1)) {
358 TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aS1);
362 TopTools_ListOfShape aLS;
365 aDMSLS.Bind(aS1, aLS);
368 }// for (j=1; j<=aNbS2; ++j) {
370 aItDMSLS.Initialize(aDMSLS);
371 for (; aItDMSLS.More(); aItDMSLS.Next()) {
372 const TopoDS_Shape& aS1=aItDMSLS.Key();
373 const TopTools_ListOfShape& aLS2=aItDMSLS.Value();
375 aItLS.Initialize(aLS2);
376 for (; aItLS.More(); aItLS.Next()) {
377 const TopoDS_Shape& aS2=aItLS.Value();
379 myIterator.AppendPair(aCS);
383 //=======================================================================
384 //function : PerformVV
386 //=======================================================================
387 void GEOMAlgo_GetInPlace::PerformVV()
392 myIterator.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
393 for (; myIterator.More(); myIterator.Next()) {
394 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
395 const TopoDS_Shape& aV1=aCS.Shape1();
396 const TopoDS_Shape& aV2=aCS.Shape2();
398 FillShapesOn(aV1, aV2);
401 //=======================================================================
402 //function : FillEdgesOn
404 //=======================================================================
405 void GEOMAlgo_GetInPlace::FillEdgesOn()
407 Standard_Integer i, aNbE;
409 TopTools_IndexedMapOfShape aME;
410 TopTools_MapIteratorOfMapOfShape aItMS;
412 TopExp::MapShapes(myArgument, TopAbs_EDGE, aME);
414 for (i=1; i<=aNbE; ++i) {
415 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
416 if (BRep_Tool::Degenerated(aE1)) {
421 for (; aIt.More(); aIt.Next()) {
422 const TopoDS_Shape& aV1=aIt.Value();
423 if (myShapesOn.IsBound(aV1)) {
424 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aV1);
425 //aNbSOn=aMSOn.Extent();
426 aItMS.Initialize(aMSOn);
427 for (; aItMS.More(); aItMS.Next()) {
428 const TopoDS_Shape& aV2=aItMS.Key();
429 FillShapesOn(aE1, aV2);
435 //=======================================================================
436 //function : PerformVE
438 //=======================================================================
439 void GEOMAlgo_GetInPlace::PerformVE()
441 Standard_Boolean bFound;
447 myIterator.Initialize(TopAbs_EDGE, TopAbs_VERTEX);
448 for (; myIterator.More(); myIterator.Next()) {
449 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
450 const TopoDS_Shape& aE1=aCS.Shape1();
451 const TopoDS_Shape& aV2=aCS.Shape2();
453 if (myShapesOn.IsBound(aE1)) {
454 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
455 if (aMSOn.Contains(aV2)) {
460 bFound=CheckCoincidence(aE1, aV2);
465 FillShapesIn(aE1, aV2);
469 //=======================================================================
470 //function : PerformEE
472 //=======================================================================
473 void GEOMAlgo_GetInPlace::PerformEE()
475 Standard_Boolean bHasOn, bHasIn, bFound;
477 TopTools_MapOfShape aMSX;
482 myIterator.Initialize(TopAbs_EDGE, TopAbs_EDGE);
483 for (; myIterator.More(); myIterator.Next()) {
484 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
485 const TopoDS_Shape& aE1=aCS.Shape1();
486 const TopoDS_Shape& aE2=aCS.Shape2();
488 bHasOn=myShapesOn.IsBound(aE1);
489 bHasIn=myShapesIn.IsBound(aE1);
490 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
491 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
493 bFound=Standard_True;
495 for (; aIt.More(); aIt.Next()) {
496 const TopoDS_Shape& aV2=aIt.Value();
497 if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
506 bFound=CheckCoincidence(aE1, aE2);
511 FillShapesIn(aE1, aE2);
515 //=======================================================================
516 //function : PerformVF
518 //=======================================================================
519 void GEOMAlgo_GetInPlace::PerformVF()
521 Standard_Boolean bHasOn, bHasIn, bFound;
522 Standard_Integer i, aNbE;
523 TopTools_MapOfShape aMSX;
524 TopTools_IndexedMapOfShape aME;
529 myIterator.Initialize(TopAbs_FACE, TopAbs_VERTEX);
530 for (; myIterator.More(); myIterator.Next()) {
531 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
532 const TopoDS_Shape& aF1=aCS.Shape1();
533 const TopoDS_Shape& aV2=aCS.Shape2();
536 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
538 bFound=Standard_False;
540 for (i=1; i<=aNbE; ++i) {
541 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
542 if (BRep_Tool::Degenerated(aE1)) {
546 bHasOn=myShapesOn.IsBound(aE1);
547 bHasIn=myShapesIn.IsBound(aE1);
548 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
549 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
550 bFound= (aMSOn.Contains(aV2) || aMSIn.Contains(aV2));
560 bFound=CheckCoincidence(aF1, aV2);
565 FillShapesIn(aF1, aV2);
569 //=======================================================================
570 //function : FillFacesOn
572 //=======================================================================
573 void GEOMAlgo_GetInPlace::FillFacesOn()
575 Standard_Integer i, j, aNbF, aNbE;
577 TopTools_IndexedMapOfShape aMF, aME;
578 TopTools_MapIteratorOfMapOfShape aItMS;
580 TopExp::MapShapes(myArgument, TopAbs_FACE, aMF);
582 for (i=1; i<=aNbF; ++i) {
583 const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i));
586 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
588 for (j=1; j<=aNbE; ++j) {
589 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(j));
590 if (BRep_Tool::Degenerated(aE1)) {
594 if (myShapesOn.IsBound(aE1)) {
595 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
596 aItMS.Initialize(aMSOn);
597 for (; aItMS.More(); aItMS.Next()) {
598 const TopoDS_Shape& aS2=aItMS.Key();
599 FillShapesOn(aF1, aS2);
603 if (myShapesIn.IsBound(aE1)) {
604 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aE1);
605 aItMS.Initialize(aMSIn);
606 for (; aItMS.More(); aItMS.Next()) {
607 const TopoDS_Shape& aS2=aItMS.Key();
608 FillShapesOn(aF1, aS2);
611 }//for (j=1; j<=aNbE; ++j) {
612 }//for (i=1; i<=aNbF; ++i) {
614 //=======================================================================
615 //function : PerformEF
617 //=======================================================================
618 void GEOMAlgo_GetInPlace::PerformEF()
620 Standard_Boolean bFound, bHasOnF, bHasInF;
622 TopTools_MapOfShape aMSX;
627 myIterator.Initialize(TopAbs_FACE, TopAbs_EDGE);
628 for (; myIterator.More(); myIterator.Next()) {
629 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
630 const TopoDS_Shape& aF1=aCS.Shape1();
631 const TopoDS_Shape& aE2=aCS.Shape2();
634 bHasOnF=myShapesOn.IsBound(aF1);
635 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
636 bFound=aMSOnF.Contains(aE2);
642 bHasInF=myShapesIn.IsBound(aF1);
643 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
646 for (; aIt.More(); aIt.Next()) {
647 const TopoDS_Shape& aV2=aIt.Value();
648 bFound=(aMSOnF.Contains(aV2) || aMSInF.Contains(aV2));
656 //------------------------------
657 bFound=CheckCoincidence(aF1, aE2);
662 FillShapesIn(aF1, aE2);
666 //=======================================================================
667 //function : PerformFF
669 //=======================================================================
670 void GEOMAlgo_GetInPlace::PerformFF()
672 Standard_Boolean bFound, bHasOnF, bHasInF;
673 Standard_Integer i, aNbS2;
674 TopTools_MapOfShape aMSX;
675 TopTools_IndexedMapOfShape aMS2;
680 myIterator.Initialize(TopAbs_FACE, TopAbs_FACE);
681 for (; myIterator.More(); myIterator.Next()) {
682 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
683 const TopoDS_Shape& aF1=aCS.Shape1();
684 const TopoDS_Shape& aF2=aCS.Shape2();
686 bHasOnF=myShapesOn.IsBound(aF1);
687 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
689 bHasInF=myShapesIn.IsBound(aF1);
690 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
693 MapBRepShapes(aF2, aMS2);
695 bFound=Standard_False;
697 for (i=1; i<=aNbS2; ++i) {
698 const TopoDS_Shape& aS2=aMS2(i);
699 if (aS2.IsSame(aF2)) {
702 bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
711 bFound=CheckCoincidence(aF1, aF2);
716 FillShapesIn(aF1, aF2);
720 //=======================================================================
721 //function : FillSolidsOn
723 //=======================================================================
724 void GEOMAlgo_GetInPlace::FillSolidsOn()
726 Standard_Integer i, j, aNbS, aNbF;
727 TopTools_IndexedMapOfShape aMS, aMF;
728 TopTools_MapIteratorOfMapOfShape aItMS;
730 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
733 for (i=1; i<=aNbS; ++i) {
734 const TopoDS_Shape& aSD1=aMS(i);
737 TopExp::MapShapes(aSD1, TopAbs_FACE, aMF);
739 for (j=1; j<=aNbF; ++j) {
740 const TopoDS_Shape& aF1=aMF(j);
742 if (myShapesOn.IsBound(aF1)) {
743 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aF1);
744 aItMS.Initialize(aMSOn);
745 for (; aItMS.More(); aItMS.Next()) {
746 const TopoDS_Shape& aS2=aItMS.Key();
747 FillShapesOn(aSD1, aS2);
751 if (myShapesIn.IsBound(aF1)) {
752 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aF1);
753 aItMS.Initialize(aMSIn);
754 for (; aItMS.More(); aItMS.Next()) {
755 const TopoDS_Shape& aS2=aItMS.Key();
756 FillShapesOn(aSD1, aS2);
759 }//for (j=1; j<=aNbF; ++j) {
760 }//for (i=1; i<=aNbS; ++i) {
762 //=======================================================================
763 //function : PerformZF
765 //=======================================================================
766 void GEOMAlgo_GetInPlace::PerformZF()
768 Standard_Boolean bFound, bHasOnF;
769 TopTools_MapOfShape aMSX;
774 myIterator.Initialize(TopAbs_SOLID, TopAbs_FACE);
775 for (; myIterator.More(); myIterator.Next()) {
776 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
777 const TopoDS_Shape& aSo1=aCS.Shape1();
778 const TopoDS_Shape& aF2=aCS.Shape2();
780 bHasOnF=myShapesOn.IsBound(aSo1);
781 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aSo1) : aMSX;
782 bFound=aMSOnF.Contains(aF2);
786 //------------------------------
787 bFound=CheckCoincidence(aSo1, aF2);
792 FillShapesIn(aSo1, aF2);
796 //=======================================================================
797 //function : PerformZZ
799 //=======================================================================
800 void GEOMAlgo_GetInPlace::PerformZZ()
802 Standard_Boolean bFound, bHasOn, bHasIn;
803 Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
804 TopTools_MapOfShape aMSX;
805 TopTools_IndexedMapOfShape aMS2;
810 myIterator.Initialize(TopAbs_SOLID, TopAbs_SOLID);
811 for (; myIterator.More(); myIterator.Next()) {
812 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
813 const TopoDS_Shape& aSo1=aCS.Shape1();
814 const TopoDS_Shape& aSo2=aCS.Shape2();
816 bHasOn=myShapesOn.IsBound(aSo1);
817 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX;
819 bHasIn=myShapesIn.IsBound(aSo1);
820 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX;
823 TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2);
828 bFound=Standard_False;
830 for (i=1; i<=aNbS2; ++i) {
831 const TopoDS_Shape& aF2=aMS2(i);
833 if (aMSIn.Contains(aF2)) {
835 bFound=Standard_True;
838 else if (!aMSOn.Contains(aF2)) {
840 bFound=Standard_False;// out
848 if (!bFound && iCntOut) {
853 bFound=CheckCoincidence(aSo1, aSo2);
859 FillShapesIn(aSo1, aSo2);
861 }// for (; myIterator.More(); myIterator.Next()) {
863 //=======================================================================
864 //function : FillImages
866 //=======================================================================
867 void GEOMAlgo_GetInPlace::FillImages()
869 Standard_Integer i, aNbS, aNbSx, aNbSi;
870 TopAbs_ShapeEnum aType;
872 TopTools_ListOfShape aLSx;
873 TopTools_ListIteratorOfListOfShape aItLS;
874 TopTools_IndexedMapOfShape aMS;
875 TopTools_MapIteratorOfMapOfShape aItMS;
884 TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS);
886 for (i=1; i<=aNbS; ++i) {
887 const TopoDS_Shape& aV=aMS(i);
888 if (myShapesOn.IsBound(aV)) {
889 const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV);
893 aItMS.Initialize(aMSx);
894 for (; aItMS.More(); aItMS.Next()) {
895 const TopoDS_Shape& aVx=aItMS.Key();
899 myImages.Bind(aV, aLSx);
905 TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS);
907 for (i=1; i<=aNbS; ++i) {
908 const TopoDS_Shape& aE=aMS(i);
909 if (myShapesIn.IsBound(aE)) {
910 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE);
914 aItMS.Initialize(aMSx);
915 for (; aItMS.More(); aItMS.Next()) {
916 const TopoDS_Shape& aEx=aItMS.Key();
917 aType=aEx.ShapeType();
918 if (aType==TopAbs_EDGE){
923 myImages.Bind(aE, aLSx);
929 TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS);
931 for (i=1; i<=aNbS; ++i) {
932 const TopoDS_Shape& aW=aMS(i);
935 for(; aIt.More(); aIt.Next()) {
936 const TopoDS_Shape& aE=aIt.Value();
937 if (myImages.IsBound(aE)) {
938 const TopTools_ListOfShape& aLSi=myImages.Find(aE);
941 aItLS.Initialize(aLSi);
942 for (; aItLS.More(); aItLS.Next()) {
943 const TopoDS_Shape& aEi=aItLS.Value();
948 myImages.Bind(aW, aLSx);
953 TopExp::MapShapes(myArgument, TopAbs_FACE, aMS);
955 for (i=1; i<=aNbS; ++i) {
956 const TopoDS_Shape& aF=aMS(i);
957 if (myShapesIn.IsBound(aF)) {
958 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF);
962 aItMS.Initialize(aMSx);
963 for (; aItMS.More(); aItMS.Next()) {
964 const TopoDS_Shape& aFx=aItMS.Key();
965 aType=aFx.ShapeType();
966 if (aType==TopAbs_FACE){
971 myImages.Bind(aF, aLSx);
977 TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS);
979 for (i=1; i<=aNbS; ++i) {
980 const TopoDS_Shape& aSh=aMS(i);
983 for(; aIt.More(); aIt.Next()) {
984 const TopoDS_Shape& aF=aIt.Value();
985 if (myImages.IsBound(aF)) {
986 const TopTools_ListOfShape& aLSi=myImages.Find(aF);
989 aItLS.Initialize(aLSi);
990 for (; aItLS.More(); aItLS.Next()) {
991 const TopoDS_Shape& aFi=aItLS.Value();
996 myImages.Bind(aSh, aLSx);
1001 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
1003 for (i=1; i<=aNbS; ++i) {
1004 const TopoDS_Shape& aZ=aMS(i);
1005 if (myShapesIn.IsBound(aZ)) {
1006 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ);
1007 aNbSx=aMSx.Extent();
1010 aItMS.Initialize(aMSx);
1011 for (; aItMS.More(); aItMS.Next()) {
1012 const TopoDS_Shape& aZx=aItMS.Key();
1013 aType=aZx.ShapeType();
1014 if (aType==TopAbs_SOLID){
1019 myImages.Bind(aZ, aLSx);
1025 TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS);
1027 for (i=1; i<=aNbS; ++i) {
1028 const TopoDS_Shape& aCs=aMS(i);
1030 aIt.Initialize(aCs);
1031 for(; aIt.More(); aIt.Next()) {
1032 const TopoDS_Shape& aZ=aIt.Value();
1033 if (myImages.IsBound(aZ)) {
1034 const TopTools_ListOfShape& aLSi=myImages.Find(aZ);
1035 aNbSi=aLSi.Extent();
1037 aItLS.Initialize(aLSi);
1038 for (; aItLS.More(); aItLS.Next()) {
1039 const TopoDS_Shape& aZi=aItLS.Value();
1044 myImages.Bind(aCs, aLSx);
1048 aType=myArgument.ShapeType();
1049 if (aType==TopAbs_COMPOUND) {
1050 FillImagesCompound(myArgument);
1053 //=======================================================================
1054 //function : FillImagesCompound
1056 //=======================================================================
1057 void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS)
1059 TopAbs_ShapeEnum aType;
1060 TopoDS_Iterator aIt;
1061 TopTools_ListOfShape aLSx;
1062 TopTools_ListIteratorOfListOfShape aItLS;
1065 for(; aIt.More(); aIt.Next()) {
1066 const TopoDS_Shape& aSx=aIt.Value();
1067 aType=aSx.ShapeType();
1069 if (aType==TopAbs_COMPOUND) {
1070 FillImagesCompound(aSx);
1073 if (myImages.IsBound(aSx)) {
1074 const TopTools_ListOfShape& aLSi=myImages.Find(aSx);
1075 aItLS.Initialize(aLSi);
1076 for (; aItLS.More(); aItLS.Next()) {
1077 const TopoDS_Shape& aSi=aItLS.Value();
1082 myImages.Bind(aS, aLSx);
1085 //=======================================================================
1086 //function : FillShapesIn
1088 //=======================================================================
1089 void GEOMAlgo_GetInPlace::FillShapesIn(const TopoDS_Shape& aS1,
1090 const TopoDS_Shape& aS2)
1092 if (myShapesIn.IsBound(aS1)) {
1093 TopTools_MapOfShape& aMS=myShapesIn.ChangeFind(aS1);
1097 TopTools_MapOfShape aMS;
1100 myShapesIn.Bind(aS1, aMS);
1103 //=======================================================================
1104 //function : FillShapesOn
1106 //=======================================================================
1107 void GEOMAlgo_GetInPlace::FillShapesOn(const TopoDS_Shape& aS1,
1108 const TopoDS_Shape& aS2)
1110 if (myShapesOn.IsBound(aS1)) {
1111 TopTools_MapOfShape& aMS=myShapesOn.ChangeFind(aS1);
1115 TopTools_MapOfShape aMS;
1118 myShapesOn.Bind(aS1, aMS);
1121 //=======================================================================
1122 //function : MapBRepShapes
1124 //=======================================================================
1125 void MapBRepShapes(const TopoDS_Shape& aS,
1126 TopTools_IndexedMapOfShape& aM)
1128 Standard_Boolean bDegenerated;
1129 TopAbs_ShapeEnum aType;
1130 TopoDS_Iterator aIt;
1132 aType=aS.ShapeType();
1133 if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
1134 aType==TopAbs_FACE || aType==TopAbs_SOLID) {
1135 bDegenerated=Standard_False;
1136 if (aType==TopAbs_EDGE) {
1137 TopoDS_Edge *pE=(TopoDS_Edge*)&aS;
1138 bDegenerated=BRep_Tool::Degenerated(*pE);
1140 if (!bDegenerated) {
1146 for(; aIt.More(); aIt.Next()) {
1147 const TopoDS_Shape& aSx=aIt.Value();
1148 aType=aSx.ShapeType();
1149 MapBRepShapes(aSx, aM);