1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2012 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 // This file is part of Open CASCADE Technology software library.
10 // This library is free software; you can redistribute it and/or modify it under
11 // the terms of the GNU Lesser General Public License version 2.1 as published
12 // by the Free Software Foundation, with special exception defined in the file
13 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
14 // distribution for complete text of the license and disclaimer of any warranty.
16 // Alternatively, this file may be used under the terms of Open CASCADE
17 // commercial license or contractual agreement.
19 #include <Bnd_Box.hxx>
20 #include <BOPAlgo_BuilderFace.hxx>
21 #include <BOPAlgo_WireEdgeSet.hxx>
22 #include <BOPAlgo_WireSplitter.hxx>
23 #include <BOPAlgo_Alerts.hxx>
24 #include <BOPCol_Box2DBndTree.hxx>
25 #include <BOPCol_DataMapOfShapeListOfShape.hxx>
26 #include <BOPCol_DataMapOfShapeShape.hxx>
27 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
28 #include <BOPCol_ListOfShape.hxx>
29 #include <BOPCol_MapOfShape.hxx>
30 #include <BOPCol_MapOfOrientedShape.hxx>
31 #include <BOPTools.hxx>
32 #include <BOPTools_AlgoTools.hxx>
33 #include <BOPTools_AlgoTools2D.hxx>
34 #include <BRep_Builder.hxx>
35 #include <BRep_Tool.hxx>
36 #include <BRepBndLib.hxx>
37 #include <BRepTools.hxx>
38 #include <Geom_Surface.hxx>
42 #include <gp_Pnt2d.hxx>
44 #include <IntTools_Context.hxx>
45 #include <IntTools_FClass2d.hxx>
46 #include <NCollection_DataMap.hxx>
47 #include <NCollection_UBTreeFiller.hxx>
48 #include <TColStd_MapIntegerHasher.hxx>
51 #include <TopExp_Explorer.hxx>
52 #include <TopLoc_Location.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Face.hxx>
55 #include <TopoDS_Iterator.hxx>
56 #include <TopoDS_Shape.hxx>
57 #include <TopoDS_Vertex.hxx>
58 #include <TopoDS_Wire.hxx>
62 Standard_Boolean IsGrowthWire(const TopoDS_Shape& ,
63 const BOPCol_IndexedMapOfShape& );
66 Standard_Boolean IsInside(const TopoDS_Shape& ,
68 Handle(IntTools_Context)& );
70 void MakeInternalWires(const BOPCol_IndexedMapOfShape& ,
71 BOPCol_ListOfShape& );
73 void GetWire(const TopoDS_Shape& ,
78 //=======================================================================
79 //class : BOPAlgo_ShapeBox2D
80 //purpose : Auxiliary class
81 //=======================================================================
82 class BOPAlgo_ShapeBox2D {
84 BOPAlgo_ShapeBox2D() {
85 myIsHole=Standard_False;
88 ~BOPAlgo_ShapeBox2D() {
91 void SetShape(const TopoDS_Shape& aS) {
95 const TopoDS_Shape& Shape()const {
99 void SetBox2D(const Bnd_Box2d& aBox2D) {
103 const Bnd_Box2d& Box2D()const {
107 void SetIsHole(const Standard_Boolean bFlag) {
111 Standard_Boolean IsHole()const {
116 Standard_Boolean myIsHole;
117 TopoDS_Shape myShape;
121 typedef NCollection_IndexedDataMap
124 TColStd_MapIntegerHasher> BOPAlgo_IndexedDataMapOfIntegerShapeBox2D;
126 typedef NCollection_IndexedDataMap
129 TopTools_ShapeMapHasher> BOPCol_IndexedDataMapOfShapeShape;
131 //=======================================================================
134 //=======================================================================
135 BOPAlgo_BuilderFace::BOPAlgo_BuilderFace()
137 BOPAlgo_BuilderArea()
139 myOrientation=TopAbs_EXTERNAL;
141 //=======================================================================
144 //=======================================================================
145 BOPAlgo_BuilderFace::BOPAlgo_BuilderFace
146 (const Handle(NCollection_BaseAllocator)& theAllocator)
148 BOPAlgo_BuilderArea(theAllocator)
150 myOrientation=TopAbs_EXTERNAL;
152 //=======================================================================
155 //=======================================================================
156 BOPAlgo_BuilderFace::~BOPAlgo_BuilderFace()
159 //=======================================================================
162 //=======================================================================
163 void BOPAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace)
165 myOrientation=theFace.Orientation();
167 myFace.Orientation(TopAbs_FORWARD);
169 //=======================================================================
170 //function : Orientation
172 //=======================================================================
173 TopAbs_Orientation BOPAlgo_BuilderFace::Orientation()const
175 return myOrientation;
177 //=======================================================================
180 //=======================================================================
181 const TopoDS_Face& BOPAlgo_BuilderFace::Face()const
185 //=======================================================================
186 //function : CheckData
188 //=======================================================================
189 void BOPAlgo_BuilderFace::CheckData()
191 if (myFace.IsNull()) {
192 AddError (new BOPAlgo_AlertNullInputShapes);
195 if (myContext.IsNull()) {
196 myContext = new IntTools_Context;
199 //=======================================================================
202 //=======================================================================
203 void BOPAlgo_BuilderFace::Perform()
205 GetReport()->Clear();
214 PerformShapesToAvoid();
235 PerformInternalShapes();
240 //=======================================================================
241 //function :PerformShapesToAvoid
243 //=======================================================================
244 void BOPAlgo_BuilderFace::PerformShapesToAvoid()
246 Standard_Boolean bFound;
247 Standard_Integer i, iCnt, aNbV, aNbE;
248 BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
249 BOPCol_ListIteratorOfListOfShape aIt;
251 myShapesToAvoid.Clear();
256 bFound=Standard_False;
260 aIt.Initialize (myShapes);
261 for (; aIt.More(); aIt.Next()) {
262 const TopoDS_Shape& aE=aIt.Value();
263 if (!myShapesToAvoid.Contains(aE)) {
264 BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
270 for (i=1; i<=aNbV; ++i) {
271 const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&aMVE.FindKey(i)));
273 BOPCol_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
279 const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aLE.First()));
281 if (BRep_Tool::Degenerated(aE1)) {
284 if (aV.Orientation()==TopAbs_INTERNAL) {
287 bFound=Standard_True;
288 myShapesToAvoid.Add(aE1);
291 const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aLE.Last()));
292 if (aE2.IsSame(aE1)) {
293 TopoDS_Vertex aV1x, aV2x;
295 TopExp::Vertices(aE1, aV1x, aV2x);
296 if (aV1x.IsSame(aV2x)) {
299 bFound=Standard_True;
300 myShapesToAvoid.Add(aE1);
301 myShapesToAvoid.Add(aE2);
304 }// for (i=1; i<=aNbE; ++i) {
311 //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
313 //=======================================================================
314 //function : PerformLoops
316 //=======================================================================
317 void BOPAlgo_BuilderFace::PerformLoops()
319 Standard_Boolean bFlag;
320 Standard_Integer i, aNbEA;
321 BOPCol_ListIteratorOfListOfShape aIt;
322 BOPCol_IndexedDataMapOfShapeListOfShape aVEMap;
323 BOPCol_MapOfOrientedShape aMAdded;
324 TopoDS_Iterator aItW;
326 BOPAlgo_WireEdgeSet aWES(myAllocator);
327 BOPAlgo_WireSplitter aWSp(myAllocator);
331 aWES.SetFace(myFace);
333 aIt.Initialize(myShapes);
334 for (; aIt.More(); aIt.Next()) {
335 const TopoDS_Shape& aE=aIt.Value();
336 if (!myShapesToAvoid.Contains(aE)) {
337 aWES.AddStartElement(aE);
342 aWSp.SetRunParallel(myRunParallel);
343 aWSp.SetContext(myContext);
345 if (aWSp.HasErrors()) {
349 const BOPCol_ListOfShape& aLW=aWES.Shapes();
350 aIt.Initialize (aLW);
351 for (; aIt.More(); aIt.Next()) {
352 const TopoDS_Shape& aW=aIt.Value();
356 BOPCol_MapOfOrientedShape aMEP;
358 // a. collect all edges that are in loops
359 aIt.Initialize (myLoops);
360 for (; aIt.More(); aIt.Next()) {
361 const TopoDS_Shape& aW=aIt.Value();
363 for (; aItW.More(); aItW.Next()) {
364 const TopoDS_Shape& aE=aItW.Value();
369 // b. collect all edges that are to avoid
370 aNbEA = myShapesToAvoid.Extent();
371 for (i = 1; i <= aNbEA; ++i) {
372 const TopoDS_Shape& aE = myShapesToAvoid(i);
376 // c. add all edges that are not processed to myShapesToAvoid
377 aIt.Initialize (myShapes);
378 for (; aIt.More(); aIt.Next()) {
379 const TopoDS_Shape& aE=aIt.Value();
380 if (!aMEP.Contains(aE)) {
381 myShapesToAvoid.Add(aE);
386 myLoopsInternal.Clear();
388 aNbEA = myShapesToAvoid.Extent();
389 for (i = 1; i <= aNbEA; ++i) {
390 const TopoDS_Shape& aEE = myShapesToAvoid(i);
391 BOPTools::MapShapesAndAncestors(aEE,
398 for (i = 1; (i <= aNbEA) && bFlag; ++i) {
399 const TopoDS_Shape& aEE = myShapesToAvoid(i);
400 if (!aMAdded.Add(aEE)) {
410 for (; aItW.More()&&bFlag; aItW.Next()) {
411 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aItW.Value()));
413 TopoDS_Iterator aItE(aE);
414 for (; aItE.More()&&bFlag; aItE.Next()) {
415 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&aItE.Value()));
416 const BOPCol_ListOfShape& aLE=aVEMap.FindFromKey(aV);
418 for (; aIt.More()&&bFlag; aIt.Next()) {
419 const TopoDS_Shape& aEx=aIt.Value();
420 if (aMAdded.Add(aEx)) {
422 if(aMAdded.Extent()==aNbEA) {
426 }//for (; aIt.More(); aIt.Next()) {
427 }//for (; aItE.More(); aItE.Next()) {
428 }//for (; aItW.More(); aItW.Next()) {
429 aW.Closed(BRep_Tool::IsClosed(aW));
430 myLoopsInternal.Append(aW);
431 }//for (i = 1; (i <= aNbEA) && bFlag; ++i) {
433 //=======================================================================
434 //function : PerformAreas
436 //=======================================================================
437 void BOPAlgo_BuilderFace::PerformAreas()
439 Standard_Boolean bIsGrowth, bIsHole;
440 Standard_Integer k, aNbS, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap;
442 TopLoc_Location aLoc;
443 Handle(Geom_Surface) aS;
446 BOPCol_ListIteratorOfListOfInteger aItLI;
447 BOPCol_IndexedMapOfShape aMHE;
448 BOPCol_ListIteratorOfListOfShape aIt1;
449 BOPCol_IndexedDataMapOfShapeListOfShape aMSH;
450 BOPCol_IndexedDataMapOfShapeShape aInOutMap;
451 BOPAlgo_IndexedDataMapOfIntegerShapeBox2D aDMISB(100);
453 BOPCol_Box2DBndTreeSelector aSelector;
454 BOPCol_Box2DBndTree aBBTree;
455 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
459 aTol=BRep_Tool::Tolerance(myFace);
460 aS=BRep_Tool::Surface(myFace, aLoc);
464 if (myLoops.IsEmpty()) {
465 if (myContext->IsInfiniteFace(myFace)) {
466 aBB.MakeFace(aFace, aS, aLoc, aTol);
467 if (BRep_Tool::NaturalRestriction(myFace)) {
468 aBB.NaturalRestriction(aFace, Standard_True);
470 myAreas.Append(aFace);
475 // 1. Growthes and Holes -> aDMISB: [Index/ShapeBox2D]
476 aIt1.Initialize(myLoops);
477 for (k=0 ; aIt1.More(); aIt1.Next(), ++k) {
480 const TopoDS_Shape& aWire=aIt1.Value();
482 aBB.MakeFace(aFace, aS, aLoc, aTol);
483 aBB.Add (aFace, aWire);
484 BRepTools::AddUVBounds(aFace, aBox2D);
486 bIsGrowth=IsGrowthWire(aWire, aMHE);
488 bIsHole=Standard_False;
491 // check if a wire is a hole
492 IntTools_FClass2d& aClsf=myContext->FClass2d(aFace);
493 aClsf.Init(aFace, aTol);
495 bIsHole=aClsf.IsHole();
497 BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE);
499 bIsHole=Standard_True;
502 bIsHole=Standard_False;
506 BOPAlgo_ShapeBox2D aSB2D;
508 aSB2D.SetShape(aFace);
509 aSB2D.SetBox2D(aBox2D);
510 aSB2D.SetIsHole(bIsHole);
512 aDMISB.Add(k, aSB2D);
513 }// for (k=0 ; aIt1.More(); aIt1.Next(), ++k) {
515 // 2. Prepare TreeFiller
516 aNbDMISB=aDMISB.Extent();
517 for (m=1; m<=aNbDMISB; ++m) {
519 const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
521 bIsHole=aSB2D.IsHole();
523 const Bnd_Box2d& aBox2D=aSB2D.Box2D();
524 aTreeFiller.Add(k, aBox2D);
529 // 3. Shake TreeFiller
532 // 4. Find outer growth shell that is most close
533 // to each hole shell
534 for (m=1; m<=aNbDMISB; ++m) {
535 const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
536 bIsHole=aSB2D.IsHole();
541 const Bnd_Box2d& aBox2DF=aSB2D.Box2D();
542 const TopoDS_Shape aF=aSB2D.Shape();
545 aSelector.SetBox(aBox2DF);
547 aNbS = aBBTree.Select(aSelector);
552 const BOPCol_ListOfInteger& aLI=aSelector.Indices();
554 aItLI.Initialize(aLI);
555 for (; aItLI.More(); aItLI.Next()) {
557 const BOPAlgo_ShapeBox2D& aSB2Dk=aDMISB.FindFromKey(k);
558 const TopoDS_Shape& aHole=aSB2Dk.Shape();
560 if (!IsInside(aHole, aF, myContext)){
564 if (aInOutMap.Contains(aHole)){
565 TopoDS_Shape& aF2=aInOutMap.ChangeFromKey(aHole);
566 if (IsInside(aF, aF2, myContext)) {
571 aInOutMap.Add(aHole, aF);
574 }// for (m=1; m<=aNbDMISB; ++m)
576 // 5.1 Map [Face/Holes] -> aMSH
577 aNbInOutMap=aInOutMap.Extent();
578 for (m=1; m<=aNbInOutMap; ++m) {
579 const TopoDS_Shape& aHole=aInOutMap.FindKey(m);
580 const TopoDS_Shape& aF=aInOutMap.FindFromIndex(m);
582 if (aMSH.Contains(aF)) {
583 BOPCol_ListOfShape& aLH=aMSH.ChangeFromKey(aF);
587 BOPCol_ListOfShape aLH;
593 // 5.2. Add unused holes to the original face
594 if (aNbHoles != aNbInOutMap) {
596 BRepBndLib::Add(myFace, aBoxF);
597 if (aBoxF.IsOpenXmin() || aBoxF.IsOpenXmax() ||
598 aBoxF.IsOpenYmin() || aBoxF.IsOpenYmax() ||
599 aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax()) {
601 BOPCol_ListOfShape anUnUsedHoles;
602 for (m = 1; m <= aNbDMISB; ++m) {
603 const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
604 if (aSB2D.IsHole()) {
605 const TopoDS_Shape& aHole = aSB2D.Shape();
606 if (!aInOutMap.Contains(aHole)) {
607 anUnUsedHoles.Append(aHole);
612 if (anUnUsedHoles.Extent()) {
613 aBB.MakeFace(aFace, aS, aLoc, aTol);
614 aMSH.Add(aFace, anUnUsedHoles);
616 BOPAlgo_ShapeBox2D aSB2D;
618 aSB2D.SetShape(aFace);
619 aSB2D.SetIsHole(Standard_False);
621 aDMISB.Add(aNbDMISB, aSB2D);
627 // 6. Add aHoles to Faces
628 aNbMSH=aMSH.Extent();
629 for (m=1; m<=aNbMSH; ++m) {
630 TopoDS_Face aF=(*(TopoDS_Face *)(&aMSH.FindKey(m)));
631 const BOPCol_ListOfShape& aLH=aMSH.FindFromIndex(m);
633 aIt1.Initialize(aLH);
634 for (; aIt1.More(); aIt1.Next()) {
637 const TopoDS_Shape& aFHole=aIt1.Value();
638 GetWire(aFHole, aWHole);
639 aBB.Add (aF, aWHole);
643 aTol=BRep_Tool::Tolerance(aF);
644 IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
645 aClsf.Init(aF, aTol);
649 // NB:These aNewFaces are draft faces that
650 // do not contain any internal shapes
651 for (m=1; m<=aNbDMISB; ++m) {
652 const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
653 bIsHole=aSB2D.IsHole();
655 const TopoDS_Shape aF=aSB2D.Shape();
660 //=======================================================================
663 //=======================================================================
664 void GetWire(const TopoDS_Shape& aF, TopoDS_Shape& aW)
670 for (; aIt.More(); aIt.Next()) {
674 //=======================================================================
675 //function : PerformInternalShapes
677 //=======================================================================
678 void BOPAlgo_BuilderFace::PerformInternalShapes()
680 if (myAvoidInternalShapes) {
684 Standard_Integer aNbWI=myLoopsInternal.Extent();
685 if (!aNbWI) {// nothing to do
689 //Standard_Real aTol;
692 BOPCol_ListIteratorOfListOfShape aIt1, aIt2;
694 BOPCol_IndexedMapOfShape aME1, aME2, aMEP;
695 BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
696 BOPCol_ListOfShape aLSI;
698 // 1. All internal edges
699 aIt1.Initialize(myLoopsInternal);
700 for (; aIt1.More(); aIt1.Next()) {
701 const TopoDS_Shape& aWire=aIt1.Value();
702 aIt.Initialize(aWire);
703 for (; aIt.More(); aIt.Next()) {
704 const TopoDS_Shape& aE=aIt.Value();
710 aIt2.Initialize(myAreas);
711 for ( ; aIt2.More(); aIt2.Next()) {
712 TopoDS_Face& aF=(*(TopoDS_Face *)(&aIt2.Value()));
715 BOPTools::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
717 // 2.1 Separate faces to process aMEP
720 aNbWI = aME1.Extent();
721 for (i = 1; i <= aNbWI; ++i) {
722 const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aME1(i)));
723 if (IsInside(aE, aF, myContext)) {
731 // 2.2 Make Internal Wires
733 MakeInternalWires(aMEP, aLSI);
735 // 2.3 Add them to aF
736 aIt1.Initialize(aLSI);
737 for (; aIt1.More(); aIt1.Next()) {
738 const TopoDS_Shape& aSI=aIt1.Value();
742 // 2.4 Remove faces aMFP from aMF
745 aNbWI = aME1.Extent();
749 } //for ( ; aIt2.More(); aIt2.Next()) {
751 //=======================================================================
752 //function : MakeInternalWires
754 //=======================================================================
755 void MakeInternalWires(const BOPCol_IndexedMapOfShape& theME,
756 BOPCol_ListOfShape& theWires)
758 Standard_Integer i, aNbE;
759 BOPCol_MapOfShape aAddedMap;
760 BOPCol_ListIteratorOfListOfShape aItE;
761 BOPCol_IndexedDataMapOfShapeListOfShape aMVE;
764 aNbE = theME.Extent();
765 for (i = 1; i <= aNbE; ++i) {
766 const TopoDS_Shape& aE = theME(i);
767 BOPTools::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
770 for (i = 1; i <= aNbE; ++i) {
771 TopoDS_Shape aEE = theME(i);
772 if (!aAddedMap.Add(aEE)) {
779 aEE.Orientation(TopAbs_INTERNAL);
782 TopoDS_Iterator aItAdded (aW);
783 for (; aItAdded.More(); aItAdded.Next()) {
784 const TopoDS_Shape& aE =aItAdded.Value();
786 TopExp_Explorer aExp(aE, TopAbs_VERTEX);
787 for (; aExp.More(); aExp.Next()) {
788 const TopoDS_Shape& aV =aExp.Current();
789 const BOPCol_ListOfShape& aLE=aMVE.FindFromKey(aV);
790 aItE.Initialize(aLE);
791 for (; aItE.More(); aItE.Next()) {
792 TopoDS_Shape aEL=aItE.Value();
793 if (aAddedMap.Add(aEL)){
794 aEL.Orientation(TopAbs_INTERNAL);
800 aW.Closed(BRep_Tool::IsClosed(aW));
804 //=======================================================================
805 //function : IsInside
807 //=======================================================================
808 Standard_Boolean IsInside(const TopoDS_Shape& theHole,
809 const TopoDS_Shape& theF2,
810 Handle(IntTools_Context)& theContext)
812 Standard_Boolean bRet;
813 Standard_Real aT, aU, aV;
816 TopExp_Explorer aExp;
817 BOPCol_IndexedMapOfShape aME2;
821 aState=TopAbs_UNKNOWN;
822 const TopoDS_Face& aF2=(*(TopoDS_Face *)(&theF2));
824 BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);//AA
826 aExp.Init(theHole, TopAbs_EDGE);
828 const TopoDS_Edge& aE =(*(TopoDS_Edge *)(&aExp.Current()));
829 if (aME2.Contains(aE)) {
832 if (!BRep_Tool::Degenerated(aE)) {
834 aT=BOPTools_AlgoTools2D::IntermediatePoint(aE);
835 BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV, theContext);
836 aP2D.SetCoord(aU, aV);
838 IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
839 aState=aClsf.Perform(aP2D);
840 bRet=(aState==TopAbs_IN);
847 //=======================================================================
848 //function : IsGrowthWire
850 //=======================================================================
851 Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
852 const BOPCol_IndexedMapOfShape& theMHE)
854 Standard_Boolean bRet;
858 if (theMHE.Extent()) {
859 aIt.Initialize(theWire);
860 for(; aIt.More(); aIt.Next()) {
861 const TopoDS_Shape& aE=aIt.Value();
862 if (theMHE.Contains(aE)) {