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 aBox1.SetGap(myTolerance);
321 aTreeFiller.Add(i, aBox1);
326 MapBRepShapes(myShapeWhere, aMS2);
328 for (j=1; j<=aNbS2; ++j) {
331 const TopoDS_Shape& aS2=aMS2(j);
332 BRepBndLib::Add(aS2, aBox2);
333 aBox2.SetGap(myTolerance);
336 aSelector.SetBox(aBox2);
337 aNbSD=aBBTree.Select(aSelector);
339 continue; // it should not be
342 const TColStd_ListOfInteger& aLI=aSelector.Indices();
343 aItLI.Initialize(aLI);
344 for (; aItLI.More(); aItLI.Next()) {
346 const TopoDS_Shape& aS1=aMS1(i);
348 if (aDMSLS.IsBound(aS1)) {
349 TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aS1);
353 TopTools_ListOfShape aLS;
356 aDMSLS.Bind(aS1, aLS);
359 }// for (j=1; j<=aNbS2; ++j) {
361 aItDMSLS.Initialize(aDMSLS);
362 for (; aItDMSLS.More(); aItDMSLS.Next()) {
363 const TopoDS_Shape& aS1=aItDMSLS.Key();
364 const TopTools_ListOfShape& aLS2=aItDMSLS.Value();
366 aItLS.Initialize(aLS2);
367 for (; aItLS.More(); aItLS.Next()) {
368 const TopoDS_Shape& aS2=aItLS.Value();
370 myIterator.AppendPair(aCS);
374 //=======================================================================
375 //function : PerformVV
377 //=======================================================================
378 void GEOMAlgo_GetInPlace::PerformVV()
383 myIterator.Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
384 for (; myIterator.More(); myIterator.Next()) {
385 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
386 const TopoDS_Shape& aV1=aCS.Shape1();
387 const TopoDS_Shape& aV2=aCS.Shape2();
389 FillShapesOn(aV1, aV2);
392 //=======================================================================
393 //function : FillEdgesOn
395 //=======================================================================
396 void GEOMAlgo_GetInPlace::FillEdgesOn()
398 Standard_Integer i, aNbE, aNbSOn;
400 TopTools_IndexedMapOfShape aME;
401 TopTools_MapIteratorOfMapOfShape aItMS;
403 TopExp::MapShapes(myArgument, TopAbs_EDGE, aME);
405 for (i=1; i<=aNbE; ++i) {
406 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
407 if (BRep_Tool::Degenerated(aE1)) {
412 for (; aIt.More(); aIt.Next()) {
413 const TopoDS_Shape& aV1=aIt.Value();
414 if (myShapesOn.IsBound(aV1)) {
415 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aV1);
416 aNbSOn=aMSOn.Extent();
417 aItMS.Initialize(aMSOn);
418 for (; aItMS.More(); aItMS.Next()) {
419 const TopoDS_Shape& aV2=aItMS.Key();
420 FillShapesOn(aE1, aV2);
426 //=======================================================================
427 //function : PerformVE
429 //=======================================================================
430 void GEOMAlgo_GetInPlace::PerformVE()
432 Standard_Boolean bFound;
438 myIterator.Initialize(TopAbs_EDGE, TopAbs_VERTEX);
439 for (; myIterator.More(); myIterator.Next()) {
440 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
441 const TopoDS_Shape& aE1=aCS.Shape1();
442 const TopoDS_Shape& aV2=aCS.Shape2();
444 if (myShapesOn.IsBound(aE1)) {
445 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
446 if (aMSOn.Contains(aV2)) {
451 bFound=CheckCoincidence(aE1, aV2);
456 FillShapesIn(aE1, aV2);
460 //=======================================================================
461 //function : PerformEE
463 //=======================================================================
464 void GEOMAlgo_GetInPlace::PerformEE()
466 Standard_Boolean bHasOn, bHasIn, bFound;
468 TopTools_MapOfShape aMSX;
473 myIterator.Initialize(TopAbs_EDGE, TopAbs_EDGE);
474 for (; myIterator.More(); myIterator.Next()) {
475 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
476 const TopoDS_Shape& aE1=aCS.Shape1();
477 const TopoDS_Shape& aE2=aCS.Shape2();
479 bHasOn=myShapesOn.IsBound(aE1);
480 bHasIn=myShapesIn.IsBound(aE1);
481 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
482 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
484 bFound=Standard_True;
486 for (; aIt.More(); aIt.Next()) {
487 const TopoDS_Shape& aV2=aIt.Value();
488 if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) {
497 bFound=CheckCoincidence(aE1, aE2);
502 FillShapesIn(aE1, aE2);
506 //=======================================================================
507 //function : PerformVF
509 //=======================================================================
510 void GEOMAlgo_GetInPlace::PerformVF()
512 Standard_Boolean bHasOn, bHasIn, bFound;
513 Standard_Integer i, aNbE;
514 TopTools_MapOfShape aMSX;
515 TopTools_IndexedMapOfShape aME;
520 myIterator.Initialize(TopAbs_FACE, TopAbs_VERTEX);
521 for (; myIterator.More(); myIterator.Next()) {
522 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
523 const TopoDS_Shape& aF1=aCS.Shape1();
524 const TopoDS_Shape& aV2=aCS.Shape2();
527 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
529 bFound=Standard_False;
531 for (i=1; i<=aNbE; ++i) {
532 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i));
533 if (BRep_Tool::Degenerated(aE1)) {
537 bHasOn=myShapesOn.IsBound(aE1);
538 bHasIn=myShapesIn.IsBound(aE1);
539 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX;
540 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX;
541 bFound= (aMSOn.Contains(aV2) || aMSIn.Contains(aV2));
551 bFound=CheckCoincidence(aF1, aV2);
556 FillShapesIn(aF1, aV2);
560 //=======================================================================
561 //function : FillFacesOn
563 //=======================================================================
564 void GEOMAlgo_GetInPlace::FillFacesOn()
566 Standard_Integer i, j, aNbF, aNbE, aNbSOn;
568 TopTools_IndexedMapOfShape aMF, aME;
569 TopTools_MapIteratorOfMapOfShape aItMS;
571 TopExp::MapShapes(myArgument, TopAbs_FACE, aMF);
573 for (i=1; i<=aNbF; ++i) {
574 const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i));
577 TopExp::MapShapes(aF1, TopAbs_EDGE, aME);
579 for (j=1; j<=aNbE; ++j) {
580 const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(j));
581 if (BRep_Tool::Degenerated(aE1)) {
585 if (myShapesOn.IsBound(aE1)) {
586 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1);
587 aItMS.Initialize(aMSOn);
588 for (; aItMS.More(); aItMS.Next()) {
589 const TopoDS_Shape& aS2=aItMS.Key();
590 FillShapesOn(aF1, aS2);
594 if (myShapesIn.IsBound(aE1)) {
595 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aE1);
596 aItMS.Initialize(aMSIn);
597 for (; aItMS.More(); aItMS.Next()) {
598 const TopoDS_Shape& aS2=aItMS.Key();
599 FillShapesOn(aF1, aS2);
602 }//for (j=1; j<=aNbE; ++j) {
603 }//for (i=1; i<=aNbF; ++i) {
605 //=======================================================================
606 //function : PerformEF
608 //=======================================================================
609 void GEOMAlgo_GetInPlace::PerformEF()
611 Standard_Boolean bFound, bHasOnF, bHasInF;
612 Standard_Integer i, aNbE;
614 TopTools_MapOfShape aMSX;
619 myIterator.Initialize(TopAbs_FACE, TopAbs_EDGE);
620 for (; myIterator.More(); myIterator.Next()) {
621 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
622 const TopoDS_Shape& aF1=aCS.Shape1();
623 const TopoDS_Shape& aE2=aCS.Shape2();
626 bHasOnF=myShapesOn.IsBound(aF1);
627 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
628 bFound=aMSOnF.Contains(aE2);
634 bHasInF=myShapesIn.IsBound(aF1);
635 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
638 for (; aIt.More(); aIt.Next()) {
639 const TopoDS_Shape& aV2=aIt.Value();
640 bFound=(aMSOnF.Contains(aV2) || aMSInF.Contains(aV2));
648 //------------------------------
649 bFound=CheckCoincidence(aF1, aE2);
654 FillShapesIn(aF1, aE2);
658 //=======================================================================
659 //function : PerformFF
661 //=======================================================================
662 void GEOMAlgo_GetInPlace::PerformFF()
664 Standard_Boolean bFound, bHasOnF, bHasInF;
665 Standard_Integer i, aNbS2;
666 TopTools_MapOfShape aMSX;
667 TopTools_IndexedMapOfShape aMS2;
672 myIterator.Initialize(TopAbs_FACE, TopAbs_FACE);
673 for (; myIterator.More(); myIterator.Next()) {
674 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
675 const TopoDS_Shape& aF1=aCS.Shape1();
676 const TopoDS_Shape& aF2=aCS.Shape2();
678 bHasOnF=myShapesOn.IsBound(aF1);
679 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX;
681 bHasInF=myShapesIn.IsBound(aF1);
682 const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX;
685 MapBRepShapes(aF2, aMS2);
687 bFound=Standard_False;
689 for (i=1; i<=aNbS2; ++i) {
690 const TopoDS_Shape& aS2=aMS2(i);
691 if (aS2.IsSame(aF2)) {
694 bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2));
703 bFound=CheckCoincidence(aF1, aF2);
708 FillShapesIn(aF1, aF2);
712 //=======================================================================
713 //function : FillSolidsOn
715 //=======================================================================
716 void GEOMAlgo_GetInPlace::FillSolidsOn()
718 Standard_Integer i, j, aNbS, aNbF, aNbSOn;
719 TopTools_IndexedMapOfShape aMS, aMF;
720 TopTools_MapIteratorOfMapOfShape aItMS;
722 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
725 for (i=1; i<=aNbS; ++i) {
726 const TopoDS_Shape& aSD1=aMS(i);
729 TopExp::MapShapes(aSD1, TopAbs_FACE, aMF);
731 for (j=1; j<=aNbF; ++j) {
732 const TopoDS_Shape& aF1=aMF(j);
734 if (myShapesOn.IsBound(aF1)) {
735 const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aF1);
736 aItMS.Initialize(aMSOn);
737 for (; aItMS.More(); aItMS.Next()) {
738 const TopoDS_Shape& aS2=aItMS.Key();
739 FillShapesOn(aSD1, aS2);
743 if (myShapesIn.IsBound(aF1)) {
744 const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aF1);
745 aItMS.Initialize(aMSIn);
746 for (; aItMS.More(); aItMS.Next()) {
747 const TopoDS_Shape& aS2=aItMS.Key();
748 FillShapesOn(aSD1, aS2);
751 }//for (j=1; j<=aNbF; ++j) {
752 }//for (i=1; i<=aNbS; ++i) {
754 //=======================================================================
755 //function : PerformZF
757 //=======================================================================
758 void GEOMAlgo_GetInPlace::PerformZF()
760 Standard_Boolean bFound, bHasOnF, bHasInF;
761 Standard_Integer i, aNbE;
762 TopTools_MapOfShape aMSX;
767 myIterator.Initialize(TopAbs_SOLID, TopAbs_FACE);
768 for (; myIterator.More(); myIterator.Next()) {
769 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
770 const TopoDS_Shape& aSo1=aCS.Shape1();
771 const TopoDS_Shape& aF2=aCS.Shape2();
773 bHasOnF=myShapesOn.IsBound(aSo1);
774 const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aSo1) : aMSX;
775 bFound=aMSOnF.Contains(aF2);
779 //------------------------------
780 bFound=CheckCoincidence(aSo1, aF2);
785 FillShapesIn(aSo1, aF2);
789 //=======================================================================
790 //function : PerformZZ
792 //=======================================================================
793 void GEOMAlgo_GetInPlace::PerformZZ()
795 Standard_Boolean bFound, bHasOn, bHasIn;
796 Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut;
797 TopTools_MapOfShape aMSX;
798 TopTools_IndexedMapOfShape aMS2;
803 myIterator.Initialize(TopAbs_SOLID, TopAbs_SOLID);
804 for (; myIterator.More(); myIterator.Next()) {
805 const NMTTools_CoupleOfShape& aCS=myIterator.Value();
806 const TopoDS_Shape& aSo1=aCS.Shape1();
807 const TopoDS_Shape& aSo2=aCS.Shape2();
809 bHasOn=myShapesOn.IsBound(aSo1);
810 const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX;
812 bHasIn=myShapesIn.IsBound(aSo1);
813 const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX;
816 TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2);
821 bFound=Standard_False;
823 for (i=1; i<=aNbS2; ++i) {
824 const TopoDS_Shape& aF2=aMS2(i);
826 if (aMSIn.Contains(aF2)) {
828 bFound=Standard_True;
831 else if (!aMSOn.Contains(aF2)) {
833 bFound=Standard_False;// out
841 if (!bFound && iCntOut) {
846 bFound=CheckCoincidence(aSo1, aSo2);
852 FillShapesIn(aSo1, aSo2);
854 }// for (; myIterator.More(); myIterator.Next()) {
856 //=======================================================================
857 //function : FillImages
859 //=======================================================================
860 void GEOMAlgo_GetInPlace::FillImages()
862 Standard_Integer i, aNbS, aNbSx, aNbSi;
863 TopAbs_ShapeEnum aType;
865 TopTools_ListOfShape aLSx;
866 TopTools_ListIteratorOfListOfShape aItLS;
867 TopTools_IndexedMapOfShape aMS;
868 TopTools_MapIteratorOfMapOfShape aItMS;
877 TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS);
879 for (i=1; i<=aNbS; ++i) {
880 const TopoDS_Shape& aV=aMS(i);
881 if (myShapesOn.IsBound(aV)) {
882 const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV);
886 aItMS.Initialize(aMSx);
887 for (; aItMS.More(); aItMS.Next()) {
888 const TopoDS_Shape& aVx=aItMS.Key();
892 myImages.Bind(aV, aLSx);
898 TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS);
900 for (i=1; i<=aNbS; ++i) {
901 const TopoDS_Shape& aE=aMS(i);
902 if (myShapesIn.IsBound(aE)) {
903 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE);
907 aItMS.Initialize(aMSx);
908 for (; aItMS.More(); aItMS.Next()) {
909 const TopoDS_Shape& aEx=aItMS.Key();
910 aType=aEx.ShapeType();
911 if (aType==TopAbs_EDGE){
916 myImages.Bind(aE, aLSx);
922 TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS);
924 for (i=1; i<=aNbS; ++i) {
925 const TopoDS_Shape& aW=aMS(i);
928 for(; aIt.More(); aIt.Next()) {
929 const TopoDS_Shape& aE=aIt.Value();
930 if (myImages.IsBound(aE)) {
931 const TopTools_ListOfShape& aLSi=myImages.Find(aE);
934 aItLS.Initialize(aLSi);
935 for (; aItLS.More(); aItLS.Next()) {
936 const TopoDS_Shape& aEi=aItLS.Value();
941 myImages.Bind(aW, aLSx);
946 TopExp::MapShapes(myArgument, TopAbs_FACE, aMS);
948 for (i=1; i<=aNbS; ++i) {
949 const TopoDS_Shape& aF=aMS(i);
950 if (myShapesIn.IsBound(aF)) {
951 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF);
955 aItMS.Initialize(aMSx);
956 for (; aItMS.More(); aItMS.Next()) {
957 const TopoDS_Shape& aFx=aItMS.Key();
958 aType=aFx.ShapeType();
959 if (aType==TopAbs_FACE){
964 myImages.Bind(aF, aLSx);
970 TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS);
972 for (i=1; i<=aNbS; ++i) {
973 const TopoDS_Shape& aSh=aMS(i);
976 for(; aIt.More(); aIt.Next()) {
977 const TopoDS_Shape& aF=aIt.Value();
978 if (myImages.IsBound(aF)) {
979 const TopTools_ListOfShape& aLSi=myImages.Find(aF);
982 aItLS.Initialize(aLSi);
983 for (; aItLS.More(); aItLS.Next()) {
984 const TopoDS_Shape& aFi=aItLS.Value();
989 myImages.Bind(aSh, aLSx);
994 TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS);
996 for (i=1; i<=aNbS; ++i) {
997 const TopoDS_Shape& aZ=aMS(i);
998 if (myShapesIn.IsBound(aZ)) {
999 const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ);
1000 aNbSx=aMSx.Extent();
1003 aItMS.Initialize(aMSx);
1004 for (; aItMS.More(); aItMS.Next()) {
1005 const TopoDS_Shape& aZx=aItMS.Key();
1006 aType=aZx.ShapeType();
1007 if (aType==TopAbs_SOLID){
1012 myImages.Bind(aZ, aLSx);
1018 TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS);
1020 for (i=1; i<=aNbS; ++i) {
1021 const TopoDS_Shape& aCs=aMS(i);
1023 aIt.Initialize(aCs);
1024 for(; aIt.More(); aIt.Next()) {
1025 const TopoDS_Shape& aZ=aIt.Value();
1026 if (myImages.IsBound(aZ)) {
1027 const TopTools_ListOfShape& aLSi=myImages.Find(aZ);
1028 aNbSi=aLSi.Extent();
1030 aItLS.Initialize(aLSi);
1031 for (; aItLS.More(); aItLS.Next()) {
1032 const TopoDS_Shape& aZi=aItLS.Value();
1037 myImages.Bind(aCs, aLSx);
1041 aType=myArgument.ShapeType();
1042 if (aType==TopAbs_COMPOUND) {
1043 FillImagesCompound(myArgument);
1046 //=======================================================================
1047 //function : FillImagesCompound
1049 //=======================================================================
1050 void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS)
1052 TopAbs_ShapeEnum aType;
1053 TopoDS_Iterator aIt;
1054 TopTools_ListOfShape aLSx;
1055 TopTools_ListIteratorOfListOfShape aItLS;
1058 for(; aIt.More(); aIt.Next()) {
1059 const TopoDS_Shape& aSx=aIt.Value();
1060 aType=aSx.ShapeType();
1062 if (aType==TopAbs_COMPOUND) {
1063 FillImagesCompound(aSx);
1066 if (myImages.IsBound(aSx)) {
1067 const TopTools_ListOfShape& aLSi=myImages.Find(aSx);
1068 aItLS.Initialize(aLSi);
1069 for (; aItLS.More(); aItLS.Next()) {
1070 const TopoDS_Shape& aSi=aItLS.Value();
1075 myImages.Bind(aS, aLSx);
1078 //=======================================================================
1079 //function : FillShapesIn
1081 //=======================================================================
1082 void GEOMAlgo_GetInPlace::FillShapesIn(const TopoDS_Shape& aS1,
1083 const TopoDS_Shape& aS2)
1085 if (myShapesIn.IsBound(aS1)) {
1086 TopTools_MapOfShape& aMS=myShapesIn.ChangeFind(aS1);
1090 TopTools_MapOfShape aMS;
1093 myShapesIn.Bind(aS1, aMS);
1096 //=======================================================================
1097 //function : FillShapesOn
1099 //=======================================================================
1100 void GEOMAlgo_GetInPlace::FillShapesOn(const TopoDS_Shape& aS1,
1101 const TopoDS_Shape& aS2)
1103 if (myShapesOn.IsBound(aS1)) {
1104 TopTools_MapOfShape& aMS=myShapesOn.ChangeFind(aS1);
1108 TopTools_MapOfShape aMS;
1111 myShapesOn.Bind(aS1, aMS);
1114 //=======================================================================
1115 //function : MapBRepShapes
1117 //=======================================================================
1118 void MapBRepShapes(const TopoDS_Shape& aS,
1119 TopTools_IndexedMapOfShape& aM)
1121 Standard_Boolean bHasBRep, bDegenerated;
1122 TopAbs_ShapeEnum aType;
1123 TopoDS_Iterator aIt;
1125 aType=aS.ShapeType();
1126 if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
1127 aType==TopAbs_FACE || aType==TopAbs_SOLID) {
1128 bDegenerated=Standard_False;
1129 if (aType==TopAbs_EDGE) {
1130 TopoDS_Edge *pE=(TopoDS_Edge*)&aS;
1131 bDegenerated=BRep_Tool::Degenerated(*pE);
1133 if (!bDegenerated) {
1139 for(; aIt.More(); aIt.Next()) {
1140 const TopoDS_Shape& aSx=aIt.Value();
1141 aType=aSx.ShapeType();
1142 MapBRepShapes(aSx, aM);