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
23 // File: GEOMAlgo_BuilderSolid.cxx
25 // Author: Peter KURNEV
27 #include <GEOMAlgo_BuilderSolid.hxx>
29 #include <gp_Pnt2d.hxx>
35 #include <Geom_Curve.hxx>
36 #include <Geom_Surface.hxx>
37 #include <Geom2d_Curve.hxx>
41 #include <TopoDS_Iterator.hxx>
42 #include <TopoDS_Face.hxx>
44 #include <TopoDS_Shape.hxx>
45 #include <TopoDS_Shell.hxx>
46 #include <TopoDS_Edge.hxx>
47 #include <TopoDS_Solid.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <TopoDS_Compound.hxx>
51 #include <BRep_Builder.hxx>
52 #include <BRep_Tool.hxx>
53 #include <BRepTools.hxx>
54 #include <BRepClass3d_SolidClassifier.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopTools_MapOfShape.hxx>
60 #include <TopTools_MapIteratorOfMapOfShape.hxx>
61 #include <TopTools_MapOfOrientedShape.hxx>
62 #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
63 #include <TopTools_ListOfShape.hxx>
64 #include <TopTools_ListIteratorOfListOfShape.hxx>
65 #include <TopTools_DataMapOfShapeShape.hxx>
66 #include <TopTools_IndexedMapOfShape.hxx>
67 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
68 #include <TopTools_DataMapOfShapeListOfShape.hxx>
69 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
71 #include <IntTools_Context.hxx>
73 #include <BOPTools_Tools2D.hxx>
74 #include <BOPTools_Tools3D.hxx>
76 #include <NMTTools_ListOfCoupleOfShape.hxx>
77 #include <NMTTools_CoupleOfShape.hxx>
78 #include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
80 #include <GEOMAlgo_Tools3D.hxx>
81 #include <GEOMAlgo_BuilderTools.hxx>
85 Standard_Boolean IsGrowthShell(const TopoDS_Shape& ,
86 const TopTools_IndexedMapOfShape& );
88 Standard_Boolean IsHole(const TopoDS_Shape& ,
89 const Handle(IntTools_Context)& );
91 Standard_Boolean IsInside(const TopoDS_Shape& ,
93 const Handle(IntTools_Context)& );
95 void MakeInternalShells(const TopTools_MapOfShape& ,
96 TopTools_ListOfShape& );
99 Standard_Boolean IsClosedShell(const TopoDS_Shell& );
102 Standard_Boolean RefineShell(const TopoDS_Shell& ,
105 //=======================================================================
108 //=======================================================================
109 GEOMAlgo_BuilderSolid::GEOMAlgo_BuilderSolid()
111 GEOMAlgo_BuilderArea()
114 //=======================================================================
117 //=======================================================================
118 GEOMAlgo_BuilderSolid::~GEOMAlgo_BuilderSolid()
121 //=======================================================================
124 //=======================================================================
125 void GEOMAlgo_BuilderSolid::Perform()
129 // Initialize the context
130 GEOMAlgo_BuilderArea::Perform();
134 TopTools_ListIteratorOfListOfShape aIt;
136 aBB.MakeCompound(aC);
137 aIt.Initialize(myShapes);
138 for(; aIt.More(); aIt.Next()) {
139 const TopoDS_Shape& aF=aIt.Value();
143 PerformShapesToAvoid();
156 if (myComputeInternalShapes) {
157 PerformInternalShapes();
163 //=======================================================================
164 //function :PerformShapesToAvoid
166 //=======================================================================
167 void GEOMAlgo_BuilderSolid::PerformShapesToAvoid()
169 Standard_Boolean bFound;
170 Standard_Integer i, iCnt, aNbE, aNbF;
171 TopAbs_Orientation aOrE;
172 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
173 TopTools_ListIteratorOfListOfShape aIt;
175 myShapesToAvoid.Clear();
180 bFound=Standard_False;
184 aIt.Initialize (myShapes);
185 for (; aIt.More(); aIt.Next()) {
186 const TopoDS_Shape& aF=aIt.Value();
187 if (!myShapesToAvoid.Contains(aF)) {
188 TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
199 for (i=1; i<=aNbE; ++i) {
200 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
201 if (BRep_Tool::Degenerated(aE)) {
205 TopTools_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
212 aOrE=aE.Orientation();
214 const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
216 if (aOrE==TopAbs_INTERNAL) {
219 bFound=Standard_True;
220 myShapesToAvoid.Add(aF1);
223 const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
224 if (aF2.IsSame(aF1)) {
225 if (BRep_Tool::IsClosed(aE, aF1)) {
229 if (aOrE==TopAbs_INTERNAL) {
233 bFound=Standard_True;
234 myShapesToAvoid.Add(aF1);
235 myShapesToAvoid.Add(aF2);
240 TopTools_ListIteratorOfListOfShape aItLF;
242 aItLF.Initialize (aLF);
243 for (; aItLF.More(); aItLF.Next()) {
244 const TopoDS_Shape& aFx=aItLF.Value();
249 }// for (i=1; i<=aNbE; ++i) {
257 //=======================================================================
258 //function : PerformLoops
260 //=======================================================================
261 void GEOMAlgo_BuilderSolid::PerformLoops()
267 Standard_Integer aNbLF, aNbOff, aNbFP;
268 TopAbs_Orientation anOr;
271 NMTTools_CoupleOfShape aCSOff;
272 TopTools_MapOfOrientedShape AddedFacesMap;
273 TopTools_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP;
274 TopTools_ListIteratorOfListOfShape aItF, aIt;
275 TopTools_MapIteratorOfMapOfOrientedShape aItM;
276 TopoDS_Iterator aItS;
278 //=================================================
282 aItF.Initialize (myShapes);
283 for (; aItF.More(); aItF.Next()) {
284 const TopoDS_Shape& aFF = aItF.Value();
285 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
288 aItF.Initialize (myShapes);
289 for (; aItF.More(); aItF.Next()) {
290 const TopoDS_Shape& aFF = aItF.Value();
291 if (myShapesToAvoid.Contains(aFF)) {
294 if (!AddedFacesMap.Add(aFF)) {
300 aBB.MakeShell(aShell);
301 aBB.Add(aShell, aFF);
304 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
306 // loop on faces added to Shell; add their neighbor faces to Shell and so on
307 TopoDS_Iterator aItAddedF (aShell);
308 for (; aItAddedF.More(); aItAddedF.Next()) {
309 const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
311 // loop on edges of aF; find a good neighbor face of aF by aE
312 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
313 for (; aEdgeExp.More(); aEdgeExp.Next()) {
314 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aEdgeExp.Current()));
317 if (aMEFP.Contains(aE)) {
318 const TopTools_ListOfShape& aLFP=aMEFP.FindFromKey(aE);
325 anOr=aE.Orientation();
326 if (anOr==TopAbs_INTERNAL) {
330 if (BRep_Tool::Degenerated(aE)) {
334 // candidate faces list
335 const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
341 // try to select one of neighbors
342 // check if a face already added to Shell shares E
343 Standard_Boolean bFound;
344 TopTools_ListIteratorOfListOfShape aItLF;
345 NMTTools_ListOfCoupleOfShape aLCSOff;
347 aItLF.Initialize(aLF);
348 for (; aItLF.More(); aItLF.Next()) {
349 const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItLF.Value()));
350 if (myShapesToAvoid.Contains(aFL)) {
353 if (aF.IsSame(aFL)) {
356 if (AddedFacesMap.Contains(aFL)){
360 bFound=GEOMAlgo_Tools3D::GetEdgeOff(aE, aFL, aEL);
365 aCSOff.SetShape1(aEL);
366 aCSOff.SetShape2(aFL);
367 aLCSOff.Append(aCSOff);
368 }//for (; aItLF.More(); aItLF.Next()) {
370 aNbOff=aLCSOff.Extent();
377 aSelF=*((TopoDS_Face*)(&aLCSOff.First().Shape2()));
380 GEOMAlgo_Tools3D::GetFaceOff(aE, aF, aLCSOff, aSelF);
383 if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
384 aBB.Add(aShell, aSelF);
385 TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
387 } // for (; aEdgeExp.More(); aEdgeExp.Next()) {
388 } //for (; aItAddedF.More(); aItAddedF.Next()) {
390 if (IsClosedShell(aShell)) {
391 myLoops.Append(aShell);
394 Standard_Boolean bRefine;
397 bRefine=RefineShell(aShell, aShx);
399 myLoops.Append(aShx);
402 } // for (; aItF.More(); aItF.Next()) {
405 TopTools_MapOfOrientedShape aMP;
407 // a. collect all edges that are in loops
408 aIt.Initialize (myLoops);
409 for (; aIt.More(); aIt.Next()) {
410 const TopoDS_Shape& aS=aIt.Value();
412 for (; aItS.More(); aItS.Next()) {
413 const TopoDS_Shape& aF=aItS.Value();
418 // b. collect all faces that are to avoid
419 aItM.Initialize(myShapesToAvoid);
420 for (; aItM.More(); aItM.Next()) {
421 const TopoDS_Shape& aF=aItM.Key();
425 // c. add all faces that are not processed to myShapesToAvoid
426 aIt.Initialize (myShapes);
427 for (; aIt.More(); aIt.Next()) {
428 const TopoDS_Shape& aF=aIt.Value();
429 if (!aMP.Contains(aF)) {
430 myShapesToAvoid.Add(aF);
433 //=================================================
437 myLoopsInternal.Clear();
440 AddedFacesMap.Clear();
442 if (myComputeInternalShapes) {
443 aItM.Initialize(myShapesToAvoid);
444 for (; aItM.More(); aItM.Next()) {
445 const TopoDS_Shape& aFF=aItM.Key();
446 TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
449 aItM.Initialize(myShapesToAvoid);
450 for (; aItM.More(); aItM.Next()) {
451 const TopoDS_Shape& aFF=aItM.Key();
452 if (!AddedFacesMap.Add(aFF)) {
458 aBB.MakeShell(aShell);
459 aBB.Add(aShell, aFF);
461 TopoDS_Iterator aItAddedF (aShell);
462 for (; aItAddedF.More(); aItAddedF.Next()) {
463 const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
465 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
466 for (; aEdgeExp.More(); aEdgeExp.Next()) {
467 const TopoDS_Edge& aE = *((TopoDS_Edge*)(&aEdgeExp.Current()));
468 const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
469 aItF.Initialize(aLF);
470 for (; aItF.More(); aItF.Next()) {
471 const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItF.Value()));
472 if (AddedFacesMap.Add(aFL)){
473 aBB.Add(aShell, aFL);
478 myLoopsInternal.Append(aShell);
482 //=======================================================================
483 //function : PerformAreas
485 //=======================================================================
486 void GEOMAlgo_BuilderSolid::PerformAreas()
490 Standard_Boolean bIsGrowthShell, bIsHole;
491 TopTools_ListOfShape aNewSolids, aHoleShells;
492 TopoDS_Shape anInfinitePointShape;
493 TopTools_DataMapOfShapeShape aInOutMap;
494 TopTools_DataMapOfShapeListOfShape aMSH;
495 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
496 TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
497 TopTools_IndexedMapOfShape aMHF;
502 // Draft solids [aNewSolids]
503 aShellIt.Initialize(myLoops);
504 for ( ; aShellIt.More(); aShellIt.Next()) {
505 const TopoDS_Shape& aShell = aShellIt.Value();
507 bIsGrowthShell=IsGrowthShell(aShell, aMHF);
508 if (bIsGrowthShell) {
509 // make a growth solid from a shell
511 aBB.MakeSolid(Solid);
512 aBB.Add (Solid, aShell);
514 aNewSolids.Append (Solid);
517 // check if a shell is a hole
518 bIsHole=IsHole(aShell, myContext);
521 aHoleShells.Append(aShell);
522 TopExp::MapShapes(aShell, TopAbs_FACE, aMHF);
525 // make a growth solid from a shell
527 aBB.MakeSolid(Solid);
528 aBB.Add (Solid, aShell);
530 aNewSolids.Append (Solid);
535 // 2. Find outer growth shell that is most close to each hole shell
536 aShellIt.Initialize(aHoleShells);
537 for (; aShellIt.More(); aShellIt.Next()) {
538 const TopoDS_Shape& aHole = aShellIt.Value();
540 aSolidIt.Initialize(aNewSolids);
541 for ( ; aSolidIt.More(); aSolidIt.Next()) {
542 const TopoDS_Shape& aSolid = aSolidIt.Value();
544 if (!IsInside(aHole, aSolid, myContext)){
548 if ( aInOutMap.IsBound (aHole)){
549 const TopoDS_Shape& aSolid2 = aInOutMap(aHole);
550 if (IsInside(aSolid, aSolid2, myContext)) {
551 aInOutMap.UnBind(aHole);
552 aInOutMap.Bind (aHole, aSolid);
556 aInOutMap.Bind (aHole, aSolid);
560 // Add aHole to a map Solid/ListOfHoles [aMSH]
561 if (aInOutMap.IsBound(aHole)){
562 const TopoDS_Shape& aSolid=aInOutMap(aHole);
563 if (aMSH.IsBound(aSolid)) {
564 TopTools_ListOfShape& aLH=aMSH.ChangeFind(aSolid);
568 TopTools_ListOfShape aLH;
570 aMSH.Bind(aSolid, aLH);
572 //aBB.Add (aSolid, aHole);
574 }// for (; aShellIt.More(); aShellIt.Next()) {
576 // 3. Add aHoles to Solids
577 aItMSH.Initialize(aMSH);
578 for (; aItMSH.More(); aItMSH.Next()) {
579 TopoDS_Solid aSolid=*((TopoDS_Solid*)(&aItMSH.Key()));
581 const TopTools_ListOfShape& aLH=aItMSH.Value();
582 aShellIt.Initialize(aLH);
583 for (; aShellIt.More(); aShellIt.Next()) {
584 const TopoDS_Shape& aHole = aShellIt.Value();
585 aBB.Add (aSolid, aHole);
589 BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
594 // These aNewSolids are draft solids that
595 // do not contain any internal shapes
597 myAreas.Append(aNewSolids);
599 //=======================================================================
600 //function : PerformInternalShapes
602 //=======================================================================
603 void GEOMAlgo_BuilderSolid::PerformInternalShapes()
607 Standard_Integer aNbFI=myLoopsInternal.Extent();
608 if (!aNbFI) {// nothing to do
612 Standard_Integer bFlag;
614 TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
616 TopTools_MapOfShape aMF, aMFP, aMFS;
617 TopTools_MapIteratorOfMapOfShape aItMF;
618 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
619 TopTools_ListOfShape aLSI;
621 // 1. All internal faces
622 aShellIt.Initialize(myLoopsInternal);
623 for (; aShellIt.More(); aShellIt.Next()) {
624 const TopoDS_Shape& aShell=aShellIt.Value();
625 aIt.Initialize(aShell);
626 for (; aIt.More(); aIt.Next()) {
627 const TopoDS_Shape& aF=aIt.Value();
634 aSolidIt.Initialize(myAreas);
635 for ( ; aSolidIt.More(); aSolidIt.Next()) {
636 TopoDS_Solid& aSolid=*((TopoDS_Solid*)(&aSolidIt.Value()));
638 //modified by NIZNHY-PKV Wed Mar 07 08:52:18 2012f
641 TopExp_Explorer aExp(aSolid, TopAbs_FACE);
642 while (aExp.More()) {
643 aMFS.Add(aExp.Current());
647 //modified by NIZNHY-PKV Wed Mar 07 08:52:20 2012t
649 TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF);
651 // 2.1 Separate faces to process aMFP
653 aItMF.Initialize(aMF);
654 for (; aItMF.More(); aItMF.Next()) {
655 const TopoDS_Face& aF=*((TopoDS_Face*)(&aItMF.Key()));
656 //modified by NIZNHY-PKV Wed Mar 07 08:54:56 2012f
657 if (!aMFS.Contains(aF)) {
658 bFlag=GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext);
663 //if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) {
666 //modified by NIZNHY-PKV Wed Mar 07 08:56:07 2012t
669 // 2.2 Make Internal Shells
671 MakeInternalShells(aMFP, aLSI);
673 // 2.3 Add them to aSolid
674 aShellIt.Initialize(aLSI);
675 for (; aShellIt.More(); aShellIt.Next()) {
676 const TopoDS_Shape& aSI=aShellIt.Value();
677 aBB.Add (aSolid, aSI);
680 // 2.4 Remove faces aMFP from aMF
681 aItMF.Initialize(aMFP);
682 for (; aItMF.More(); aItMF.Next()) {
683 const TopoDS_Shape& aF=aItMF.Key();
691 } //for ( ; aSolidIt.More(); aSolidIt.Next()) {
694 //=======================================================================
695 //function : MakeInternalShells
697 //=======================================================================
698 void MakeInternalShells(const TopTools_MapOfShape& theMF,
699 TopTools_ListOfShape& theShells)
701 TopTools_MapIteratorOfMapOfShape aItM;
702 TopTools_MapOfShape aAddedFacesMap;
703 TopTools_ListIteratorOfListOfShape aItF;
704 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
707 aItM.Initialize(theMF);
708 for (; aItM.More(); aItM.Next()) {
709 const TopoDS_Shape& aF=aItM.Key();
710 TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
713 aItM.Initialize(theMF);
714 for (; aItM.More(); aItM.Next()) {
715 TopoDS_Shape aFF=aItM.Key();
716 if (!aAddedFacesMap.Add(aFF)) {
722 aBB.MakeShell(aShell);
723 aFF.Orientation(TopAbs_INTERNAL);
724 aBB.Add(aShell, aFF);
726 TopoDS_Iterator aItAddedF (aShell);
727 for (; aItAddedF.More(); aItAddedF.Next()) {
728 const TopoDS_Shape& aF =aItAddedF.Value();
730 TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
731 for (; aEdgeExp.More(); aEdgeExp.Next()) {
732 const TopoDS_Shape& aE =aEdgeExp.Current();
733 const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
734 aItF.Initialize(aLF);
735 for (; aItF.More(); aItF.Next()) {
736 TopoDS_Shape aFL=aItF.Value();
737 if (aAddedFacesMap.Add(aFL)){
738 aFL.Orientation(TopAbs_INTERNAL);
739 aBB.Add(aShell, aFL);
744 theShells.Append(aShell);
747 //=======================================================================
750 //=======================================================================
751 Standard_Boolean IsHole(const TopoDS_Shape& theS2,
752 const Handle(IntTools_Context)& theContext)
754 TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
755 BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
757 aClsf.PerformInfinitePoint(::RealSmall());
759 return (aClsf.State()==TopAbs_IN);
761 //=======================================================================
762 //function : IsInside
764 //=======================================================================
765 Standard_Boolean IsInside(const TopoDS_Shape& theS1,
766 const TopoDS_Shape& theS2,
767 const Handle(IntTools_Context)& theContext)
769 TopExp_Explorer aExp;
772 TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
774 aExp.Init(theS1, TopAbs_FACE);
776 BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
777 aClsf.PerformInfinitePoint(::RealSmall());
778 aState=aClsf.State();
781 TopTools_IndexedMapOfShape aBounds;
782 const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
783 aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext);
785 return (aState==TopAbs_IN);
787 //=======================================================================
788 //function : IsGrowthShell
790 //=======================================================================
791 Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell,
792 const TopTools_IndexedMapOfShape& theMHF)
794 Standard_Boolean bRet;
798 if (theMHF.Extent()) {
799 aIt.Initialize(theShell);
800 for(; aIt.More(); aIt.Next()) {
801 const TopoDS_Shape& aF=aIt.Value();
802 if (theMHF.Contains(aF)) {
809 //=======================================================================
810 //function : IsClosedShell
812 //=======================================================================
813 Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell)
815 Standard_Integer aNbE;
816 Standard_Boolean bRet;
818 TopExp_Explorer aExp;
819 TopTools_MapOfShape aM;
822 aIt.Initialize(theShell);
823 for(; aIt.More(); aIt.Next()) {
824 const TopoDS_Face& aF=TopoDS::Face(aIt.Value());
825 aExp.Init(aF, TopAbs_EDGE);
826 for (; aExp.More(); aExp.Next()) {
827 const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current()));
828 if (BRep_Tool::Degenerated(aE)) {
832 if (aE.Orientation()==TopAbs_INTERNAL) {
848 //=======================================================================
849 //function : RefineShell
851 //=======================================================================
852 Standard_Boolean RefineShell(const TopoDS_Shell& aShell,
856 Standard_Boolean bRet;
857 Standard_Integer i, aNbE, aNbF;
858 TopAbs_Orientation aOrE;
859 TopTools_IndexedDataMapOfShapeListOfShape aMEF;
860 TopTools_MapOfOrientedShape aMFx;
864 TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
866 for (i=1; i<=aNbE; ++i) {
867 const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
869 if (BRep_Tool::Degenerated(aE)) {
873 aOrE=aE.Orientation();
875 const TopTools_ListOfShape& aLF=aMEF(i);
881 const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
883 if (aOrE==TopAbs_INTERNAL) {
890 const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
891 if (aF2.IsSame(aF1)) {
892 if (BRep_Tool::IsClosed(aE, aF1)) {
895 if (aOrE==TopAbs_INTERNAL) {
914 aIt.Initialize(aShell);
915 for (; aIt.More(); aIt.Next()) {
916 const TopoDS_Shape& aF=aIt.Value();
917 if (!aMFx.Contains(aF)) {
924 bRet=IsClosedShell(aShx);