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_BuilderSolid.cxx
23 // Author: Peter KURNEV
25 #include <GEOMAlgo_BuilderSolid.ixx>
27 #include <GEOMAlgo_Tools3D.hxx>
28 #include <GEOMAlgo_BuilderTools.hxx>
30 #include <NMTTools_ListOfCoupleOfShape.hxx>
31 #include <NMTTools_CoupleOfShape.hxx>
32 #include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
34 #include <Basics_OCCTVersion.hxx>
36 #include <gp_Pnt2d.hxx>
42 #include <Geom_Curve.hxx>
43 #include <Geom_Surface.hxx>
44 #include <Geom2d_Curve.hxx>
48 #include <TopoDS_Iterator.hxx>
49 #include <TopoDS_Face.hxx>
51 #include <TopoDS_Shape.hxx>
52 #include <TopoDS_Shell.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Solid.hxx>
55 #include <TopoDS_Vertex.hxx>
56 #include <TopoDS_Compound.hxx>
58 #include <BRep_Builder.hxx>
59 #include <BRep_Tool.hxx>
60 #include <BRepTools.hxx>
61 #include <BRepClass3d_SolidClassifier.hxx>
64 #include <TopExp_Explorer.hxx>
66 #include <TopTools_MapOfShape.hxx>
67 #include <TopTools_MapIteratorOfMapOfShape.hxx>
68 #include <TopTools_MapOfOrientedShape.hxx>
69 #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
70 #include <TopTools_ListOfShape.hxx>
71 #include <TopTools_ListIteratorOfListOfShape.hxx>
72 #include <TopTools_DataMapOfShapeShape.hxx>
73 #include <TopTools_IndexedMapOfShape.hxx>
74 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
75 #include <TopTools_DataMapOfShapeListOfShape.hxx>
76 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
78 #include <IntTools_Context.hxx>
80 #include <BOPTools_Tools2D.hxx>
81 #include <BOPTools_Tools3D.hxx>
85 Standard_Boolean IsGrowthShell(const TopoDS_Shape& ,
86 const TopTools_IndexedMapOfShape& );
88 Standard_Boolean IsHole(const TopoDS_Shape& ,
89 #if OCC_VERSION_LARGE > 0x06050200
90 const Handle(IntTools_Context)& );
96 Standard_Boolean IsInside(const TopoDS_Shape& ,
98 #if OCC_VERSION_LARGE > 0x06050200
99 const Handle(IntTools_Context)& );
101 IntTools_PContext& );
105 void MakeInternalShells(const TopTools_MapOfShape& ,
106 TopTools_ListOfShape& );
109 Standard_Boolean IsClosedShell(const TopoDS_Shell& );
112 Standard_Boolean RefineShell(const TopoDS_Shell& ,
115 //=======================================================================
118 //=======================================================================
119 GEOMAlgo_BuilderSolid::GEOMAlgo_BuilderSolid()
121 GEOMAlgo_BuilderArea()
124 //=======================================================================
127 //=======================================================================
128 GEOMAlgo_BuilderSolid::~GEOMAlgo_BuilderSolid()
131 //=======================================================================
134 //=======================================================================
135 void GEOMAlgo_BuilderSolid::Perform()
139 #if OCC_VERSION_LARGE > 0x06050200
140 // Initialize the context
141 GEOMAlgo_BuilderArea::Perform();
146 TopTools_ListIteratorOfListOfShape aIt;
148 aBB.MakeCompound(aC);
149 aIt.Initialize(myShapes);
150 for(; aIt.More(); aIt.Next()) {
151 const TopoDS_Shape& aF=aIt.Value();
155 #if OCC_VERSION_LARGE <= 0x06050200
156 if (myContext==NULL) {
157 myErrorStatus=11;// Null Context
162 PerformShapesToAvoid();
175 if (myComputeInternalShapes) {
176 PerformInternalShapes();
182 //=======================================================================
183 //function :PerformShapesToAvoid
185 //=======================================================================
186 void GEOMAlgo_BuilderSolid::PerformShapesToAvoid()
188 Standard_Boolean bFound;
189 Standard_Integer i, iCnt, aNbE, aNbF;
190 TopAbs_Orientation aOrE;
191 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
192 TopTools_ListIteratorOfListOfShape aIt;
194 myShapesToAvoid.Clear();
199 bFound=Standard_False;
203 aIt.Initialize (myShapes);
204 for (; aIt.More(); aIt.Next()) {
205 const TopoDS_Shape& aF=aIt.Value();
206 if (!myShapesToAvoid.Contains(aF)) {
207 TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
218 for (i=1; i<=aNbE; ++i) {
219 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
220 if (BRep_Tool::Degenerated(aE)) {
224 TopTools_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
231 aOrE=aE.Orientation();
233 const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
235 if (aOrE==TopAbs_INTERNAL) {
238 bFound=Standard_True;
239 myShapesToAvoid.Add(aF1);
242 const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
243 if (aF2.IsSame(aF1)) {
244 if (BRep_Tool::IsClosed(aE, aF1)) {
248 if (aOrE==TopAbs_INTERNAL) {
252 bFound=Standard_True;
253 myShapesToAvoid.Add(aF1);
254 myShapesToAvoid.Add(aF2);
259 TopTools_ListIteratorOfListOfShape aItLF;
261 aItLF.Initialize (aLF);
262 for (; aItLF.More(); aItLF.Next()) {
263 const TopoDS_Shape& aFx=aItLF.Value();
268 }// for (i=1; i<=aNbE; ++i) {
276 //=======================================================================
277 //function : PerformLoops
279 //=======================================================================
280 void GEOMAlgo_BuilderSolid::PerformLoops()
286 Standard_Integer aNbLF, aNbOff, aNbFP;
287 TopAbs_Orientation anOr;
290 NMTTools_CoupleOfShape aCSOff;
291 TopTools_MapOfOrientedShape AddedFacesMap;
292 TopTools_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP;
293 TopTools_ListIteratorOfListOfShape aItF, aIt;
294 TopTools_MapIteratorOfMapOfOrientedShape aItM;
295 TopoDS_Iterator aItS;
297 //=================================================
301 aItF.Initialize (myShapes);
302 for (; aItF.More(); aItF.Next()) {
303 const TopoDS_Shape& aFF = aItF.Value();
304 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
307 aItF.Initialize (myShapes);
308 for (; aItF.More(); aItF.Next()) {
309 const TopoDS_Shape& aFF = aItF.Value();
310 if (myShapesToAvoid.Contains(aFF)) {
313 if (!AddedFacesMap.Add(aFF)) {
319 aBB.MakeShell(aShell);
320 aBB.Add(aShell, aFF);
323 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
325 // loop on faces added to Shell; add their neighbor faces to Shell and so on
326 TopoDS_Iterator aItAddedF (aShell);
327 for (; aItAddedF.More(); aItAddedF.Next()) {
328 const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
330 // loop on edges of aF; find a good neighbor face of aF by aE
331 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
332 for (; aEdgeExp.More(); aEdgeExp.Next()) {
333 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aEdgeExp.Current()));
336 if (aMEFP.Contains(aE)) {
337 const TopTools_ListOfShape& aLFP=aMEFP.FindFromKey(aE);
344 anOr=aE.Orientation();
345 if (anOr==TopAbs_INTERNAL) {
349 if (BRep_Tool::Degenerated(aE)) {
353 // candidate faces list
354 const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
360 // try to select one of neighbors
361 // check if a face already added to Shell shares E
362 Standard_Boolean bFound;
363 TopTools_ListIteratorOfListOfShape aItLF;
364 NMTTools_ListOfCoupleOfShape aLCSOff;
366 aItLF.Initialize(aLF);
367 for (; aItLF.More(); aItLF.Next()) {
368 const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItLF.Value()));
369 if (myShapesToAvoid.Contains(aFL)) {
372 if (aF.IsSame(aFL)) {
375 if (AddedFacesMap.Contains(aFL)){
379 bFound=GEOMAlgo_Tools3D::GetEdgeOff(aE, aFL, aEL);
384 aCSOff.SetShape1(aEL);
385 aCSOff.SetShape2(aFL);
386 aLCSOff.Append(aCSOff);
387 }//for (; aItLF.More(); aItLF.Next()) {
389 aNbOff=aLCSOff.Extent();
396 aSelF=*((TopoDS_Face*)(&aLCSOff.First().Shape2()));
399 GEOMAlgo_Tools3D::GetFaceOff(aE, aF, aLCSOff, aSelF);
402 if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
403 aBB.Add(aShell, aSelF);
404 TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
406 } // for (; aEdgeExp.More(); aEdgeExp.Next()) {
407 } //for (; aItAddedF.More(); aItAddedF.Next()) {
409 if (IsClosedShell(aShell)) {
410 myLoops.Append(aShell);
412 //modified by NIZNHY-PKV Wed Oct 27 07:10:41 2010f
414 Standard_Boolean bRefine;
417 bRefine=RefineShell(aShell, aShx);
419 myLoops.Append(aShx);
422 //modified by NIZNHY-PKV Wed Oct 27 07:10:44 2010t
423 } // for (; aItF.More(); aItF.Next()) {
426 TopTools_MapOfOrientedShape aMP;
428 // a. collect all edges that are in loops
429 aIt.Initialize (myLoops);
430 for (; aIt.More(); aIt.Next()) {
431 const TopoDS_Shape& aS=aIt.Value();
433 for (; aItS.More(); aItS.Next()) {
434 const TopoDS_Shape& aF=aItS.Value();
439 // b. collect all faces that are to avoid
440 aItM.Initialize(myShapesToAvoid);
441 for (; aItM.More(); aItM.Next()) {
442 const TopoDS_Shape& aF=aItM.Key();
446 // c. add all faces that are not processed to myShapesToAvoid
447 aIt.Initialize (myShapes);
448 for (; aIt.More(); aIt.Next()) {
449 const TopoDS_Shape& aF=aIt.Value();
450 if (!aMP.Contains(aF)) {
451 myShapesToAvoid.Add(aF);
454 //=================================================
458 myLoopsInternal.Clear();
461 AddedFacesMap.Clear();
463 if (myComputeInternalShapes) {
464 aItM.Initialize(myShapesToAvoid);
465 for (; aItM.More(); aItM.Next()) {
466 const TopoDS_Shape& aFF=aItM.Key();
467 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
470 aItM.Initialize(myShapesToAvoid);
471 for (; aItM.More(); aItM.Next()) {
472 const TopoDS_Shape& aFF=aItM.Key();
473 if (!AddedFacesMap.Add(aFF)) {
479 aBB.MakeShell(aShell);
480 aBB.Add(aShell, aFF);
482 TopoDS_Iterator aItAddedF (aShell);
483 for (; aItAddedF.More(); aItAddedF.Next()) {
484 const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
486 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
487 for (; aEdgeExp.More(); aEdgeExp.Next()) {
488 const TopoDS_Edge& aE = *((TopoDS_Edge*)(&aEdgeExp.Current()));
489 const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
490 aItF.Initialize(aLF);
491 for (; aItF.More(); aItF.Next()) {
492 const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItF.Value()));
493 if (AddedFacesMap.Add(aFL)){
494 aBB.Add(aShell, aFL);
499 myLoopsInternal.Append(aShell);
503 //=======================================================================
504 //function : PerformAreas
506 //=======================================================================
507 void GEOMAlgo_BuilderSolid::PerformAreas()
511 Standard_Boolean bIsGrowthShell, bIsHole;
512 TopTools_ListOfShape aNewSolids, aHoleShells;
513 TopoDS_Shape anInfinitePointShape;
514 TopTools_DataMapOfShapeShape aInOutMap;
515 TopTools_DataMapOfShapeListOfShape aMSH;
516 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
517 TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
518 TopTools_IndexedMapOfShape aMHF;
523 // Draft solids [aNewSolids]
524 aShellIt.Initialize(myLoops);
525 for ( ; aShellIt.More(); aShellIt.Next()) {
526 const TopoDS_Shape& aShell = aShellIt.Value();
528 bIsGrowthShell=IsGrowthShell(aShell, aMHF);
529 if (bIsGrowthShell) {
530 // make a growth solid from a shell
532 aBB.MakeSolid(Solid);
533 aBB.Add (Solid, aShell);
535 aNewSolids.Append (Solid);
538 // check if a shell is a hole
539 bIsHole=IsHole(aShell, myContext);
542 aHoleShells.Append(aShell);
543 TopExp::MapShapes(aShell, TopAbs_FACE, aMHF);
546 // make a growth solid from a shell
548 aBB.MakeSolid(Solid);
549 aBB.Add (Solid, aShell);
551 aNewSolids.Append (Solid);
556 // 2. Find outer growth shell that is most close to each hole shell
557 aShellIt.Initialize(aHoleShells);
558 for (; aShellIt.More(); aShellIt.Next()) {
559 const TopoDS_Shape& aHole = aShellIt.Value();
561 aSolidIt.Initialize(aNewSolids);
562 for ( ; aSolidIt.More(); aSolidIt.Next()) {
563 const TopoDS_Shape& aSolid = aSolidIt.Value();
565 if (!IsInside(aHole, aSolid, myContext)){
569 if ( aInOutMap.IsBound (aHole)){
570 const TopoDS_Shape& aSolid2 = aInOutMap(aHole);
571 if (IsInside(aSolid, aSolid2, myContext)) {
572 aInOutMap.UnBind(aHole);
573 aInOutMap.Bind (aHole, aSolid);
577 aInOutMap.Bind (aHole, aSolid);
581 // Add aHole to a map Solid/ListOfHoles [aMSH]
582 if (aInOutMap.IsBound(aHole)){
583 const TopoDS_Shape& aSolid=aInOutMap(aHole);
584 if (aMSH.IsBound(aSolid)) {
585 TopTools_ListOfShape& aLH=aMSH.ChangeFind(aSolid);
589 TopTools_ListOfShape aLH;
591 aMSH.Bind(aSolid, aLH);
593 //aBB.Add (aSolid, aHole);
595 }// for (; aShellIt.More(); aShellIt.Next()) {
597 // 3. Add aHoles to Solids
598 aItMSH.Initialize(aMSH);
599 for (; aItMSH.More(); aItMSH.Next()) {
600 TopoDS_Solid aSolid=*((TopoDS_Solid*)(&aItMSH.Key()));
602 const TopTools_ListOfShape& aLH=aItMSH.Value();
603 aShellIt.Initialize(aLH);
604 for (; aShellIt.More(); aShellIt.Next()) {
605 const TopoDS_Shape& aHole = aShellIt.Value();
606 aBB.Add (aSolid, aHole);
610 BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
615 // These aNewSolids are draft solids that
616 // do not contain any internal shapes
618 myAreas.Append(aNewSolids);
620 //=======================================================================
621 //function : PerformInternalShapes
623 //=======================================================================
624 void GEOMAlgo_BuilderSolid::PerformInternalShapes()
628 Standard_Integer aNbFI=myLoopsInternal.Extent();
629 if (!aNbFI) {// nothing to do
634 TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
636 TopTools_MapOfShape aMF, aMFP;
637 TopTools_MapIteratorOfMapOfShape aItMF;
638 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
639 TopTools_ListOfShape aLSI;
641 // 1. All internal faces
642 aShellIt.Initialize(myLoopsInternal);
643 for (; aShellIt.More(); aShellIt.Next()) {
644 const TopoDS_Shape& aShell=aShellIt.Value();
645 aIt.Initialize(aShell);
646 for (; aIt.More(); aIt.Next()) {
647 const TopoDS_Shape& aF=aIt.Value();
654 aSolidIt.Initialize(myAreas);
655 for ( ; aSolidIt.More(); aSolidIt.Next()) {
656 TopoDS_Solid& aSolid=*((TopoDS_Solid*)(&aSolidIt.Value()));
659 TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF);
661 // 2.1 Separate faces to process aMFP
663 aItMF.Initialize(aMF);
664 for (; aItMF.More(); aItMF.Next()) {
665 const TopoDS_Face& aF=*((TopoDS_Face*)(&aItMF.Key()));
666 #if OCC_VERSION_LARGE > 0x06050200
667 if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) {
669 if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, *myContext)) {
675 // 2.2 Make Internal Shells
677 MakeInternalShells(aMFP, aLSI);
679 // 2.3 Add them to aSolid
680 aShellIt.Initialize(aLSI);
681 for (; aShellIt.More(); aShellIt.Next()) {
682 const TopoDS_Shape& aSI=aShellIt.Value();
683 aBB.Add (aSolid, aSI);
686 // 2.4 Remove faces aMFP from aMF
687 aItMF.Initialize(aMFP);
688 for (; aItMF.More(); aItMF.Next()) {
689 const TopoDS_Shape& aF=aItMF.Key();
697 } //for ( ; aSolidIt.More(); aSolidIt.Next()) {
700 //=======================================================================
701 //function : MakeInternalShells
703 //=======================================================================
704 void MakeInternalShells(const TopTools_MapOfShape& theMF,
705 TopTools_ListOfShape& theShells)
707 TopTools_MapIteratorOfMapOfShape aItM;
708 TopTools_MapOfShape aAddedFacesMap;
709 TopTools_ListIteratorOfListOfShape aItF;
710 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
713 aItM.Initialize(theMF);
714 for (; aItM.More(); aItM.Next()) {
715 const TopoDS_Shape& aF=aItM.Key();
716 TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
719 aItM.Initialize(theMF);
720 for (; aItM.More(); aItM.Next()) {
721 TopoDS_Shape aFF=aItM.Key();
722 if (!aAddedFacesMap.Add(aFF)) {
728 aBB.MakeShell(aShell);
729 aFF.Orientation(TopAbs_INTERNAL);
730 aBB.Add(aShell, aFF);
732 TopoDS_Iterator aItAddedF (aShell);
733 for (; aItAddedF.More(); aItAddedF.Next()) {
734 const TopoDS_Shape& aF =aItAddedF.Value();
736 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
737 for (; aEdgeExp.More(); aEdgeExp.Next()) {
738 const TopoDS_Shape& aE =aEdgeExp.Current();
739 const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
740 aItF.Initialize(aLF);
741 for (; aItF.More(); aItF.Next()) {
742 TopoDS_Shape aFL=aItF.Value();
743 if (aAddedFacesMap.Add(aFL)){
744 aFL.Orientation(TopAbs_INTERNAL);
745 aBB.Add(aShell, aFL);
750 theShells.Append(aShell);
753 //=======================================================================
756 //=======================================================================
757 Standard_Boolean IsHole(const TopoDS_Shape& theS2,
758 #if OCC_VERSION_LARGE > 0x06050200
759 const Handle(IntTools_Context)& theContext)
761 IntTools_PContext& theContext)
764 TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
765 BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
767 aClsf.PerformInfinitePoint(::RealSmall());
769 return (aClsf.State()==TopAbs_IN);
771 //=======================================================================
772 //function : IsInside
774 //=======================================================================
775 Standard_Boolean IsInside(const TopoDS_Shape& theS1,
776 const TopoDS_Shape& theS2,
777 #if OCC_VERSION_LARGE > 0x06050200
778 const Handle(IntTools_Context)& theContext)
780 IntTools_PContext& theContext)
783 TopExp_Explorer aExp;
786 TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
788 aExp.Init(theS1, TopAbs_FACE);
790 BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
791 aClsf.PerformInfinitePoint(::RealSmall());
792 aState=aClsf.State();
795 TopTools_IndexedMapOfShape aBounds;
796 const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
797 #if OCC_VERSION_LARGE > 0x06050200
798 aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext);
800 aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, *theContext);
803 return (aState==TopAbs_IN);
805 //=======================================================================
806 //function : IsGrowthShell
808 //=======================================================================
809 Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell,
810 const TopTools_IndexedMapOfShape& theMHF)
812 Standard_Boolean bRet;
816 if (theMHF.Extent()) {
817 aIt.Initialize(theShell);
818 for(; aIt.More(); aIt.Next()) {
819 const TopoDS_Shape& aF=aIt.Value();
820 if (theMHF.Contains(aF)) {
827 //=======================================================================
828 //function : IsClosedShell
830 //=======================================================================
831 Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell)
833 Standard_Integer aNbE;
834 Standard_Boolean bRet;
836 TopExp_Explorer aExp;
837 TopTools_MapOfShape aM;
840 aIt.Initialize(theShell);
841 for(; aIt.More(); aIt.Next()) {
842 const TopoDS_Face& aF=TopoDS::Face(aIt.Value());
843 aExp.Init(aF, TopAbs_EDGE);
844 for (; aExp.More(); aExp.Next()) {
845 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current()));
846 if (BRep_Tool::Degenerated(aE)) {
850 if (aE.Orientation()==TopAbs_INTERNAL) {
867 //=======================================================================
868 //function : RefineShell
870 //=======================================================================
871 Standard_Boolean RefineShell (const TopoDS_Shell& aShell,
874 Standard_Boolean bRet;
875 Standard_Integer i, aNbE, aNbF;
876 TopAbs_Orientation aOrE;
877 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
878 TopTools_MapOfOrientedShape aMFx;
882 TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
884 for (i=1; i<=aNbE; ++i) {
885 const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
887 if (BRep_Tool::Degenerated(aE)) {
891 aOrE=aE.Orientation();
893 const TopTools_ListOfShape& aLF=aMEF(i);
899 const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
901 if (aOrE==TopAbs_INTERNAL) {
908 const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
909 if (aF2.IsSame(aF1)) {
910 if (BRep_Tool::IsClosed(aE, aF1)) {
913 if (aOrE==TopAbs_INTERNAL) {
932 aIt.Initialize(aShell);
933 for (; aIt.More(); aIt.Next()) {
934 const TopoDS_Shape& aF=aIt.Value();
935 if (!aMFx.Contains(aF)) {
942 bRet=IsClosedShell(aShx);