Salome HOME
Porting to OCCT development version: Standard_PI -> M_PI
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ShellSolid.cxx
index cd53db7fe0ab69e0c982cb6ffa52ee392d35ed19..535d0056f559f435d49459ac78cae9886ceee477 100644 (file)
@@ -1,33 +1,55 @@
-// File:       GEOMAlgo_ShellSolid.cxx
-// Created:    Wed Jan 12 12:49:45 2005
-// Author:     Peter KURNEV
-//             <pkv@irinox>
-
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
+// File:        GEOMAlgo_ShellSolid.cxx
+// Created:     Wed Jan 12 12:49:45 2005
+// Author:      Peter KURNEV
+//              <pkv@irinox>
+//
 #include <GEOMAlgo_ShellSolid.ixx>
 
 #include <Standard_Failure.hxx>
 
 #include <gp_Pnt2d.hxx>
 #include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
 
+#include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Edge.hxx>
-#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Solid.hxx>
 
 #include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
 
+#include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopExp_Explorer.hxx>
 
-#include <BOPTColStd_Dump.hxx>
-
 #include <BRepClass3d_SolidClassifier.hxx>
 
 #include <IntTools_Context.hxx>
-
+#include <BOPTColStd_Dump.hxx>
 #include <BooleanOperations_ShapesDataStructure.hxx>
 
 #include <BOPTools_PaveFiller.hxx>
 #include <BOPTools_SplitShapesPool.hxx>
 #include <BOPTools_Tools3D.hxx>
 #include <BOPTools_DSFiller.hxx>
-//
-#include <gp_Dir.hxx>
-#include <BOPTools_SSInterference.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS.hxx>
-#include <BOPTools_ListOfPaveBlock.hxx>
-#include <TopoDS_Edge.hxx>
-#include <BOPTools_Tools3D.hxx>
+
 #include <BOP_WireEdgeSet.hxx>
 #include <BOP_SDFWESFiller.hxx>
 #include <BOP_FaceBuilder.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <BRepTools.hxx>
-#include <IntTools_Context.hxx>
-#include <Geom_Surface.hxx>
-#include <TopExp_Explorer.hxx>
-#include <GeomAPI_ProjectPointOnSurf.hxx>
-
-static
-  Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
-                                            const TopoDS_Face& theFace2); 
 
 //=======================================================================
 //function : GEOMAlgo_ShellSolid
@@ -214,7 +218,7 @@ void GEOMAlgo_ShellSolid::BuildResult()
       const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks();
       aNbS=aSectEdges.Extent();
       if (aNbS) {
-       break;
+        break;
       }
     }
     //
@@ -226,7 +230,7 @@ void GEOMAlgo_ShellSolid::BuildResult()
     for (; anExp.More(); anExp.Next()) {
       const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
       if (BRep_Tool::Degenerated(aE)) {
-       continue;
+        continue;
       }
       //
       nE=aDS.ShapeIndex(aE, myRank);
@@ -234,46 +238,46 @@ void GEOMAlgo_ShellSolid::BuildResult()
       aNbPB=aLPB.Extent();
       //
       if (aNbPB<2) {
-       nSp=nE;
-       if (aNbPB) {
-         const BOPTools_PaveBlock& aPB=aLPB.First();
-         nSp=aPB.Edge();
-       }
-       const TopoDS_Shape& aSp=aDS.Shape(nSp);
-       //
-       aState=aDS.GetState(nSp);
-       if (aState==BooleanOperations_IN) {
-         myLSIN.Append(aF1);
-       }
-       else if (aState==BooleanOperations_OUT) {
-         myLSOUT.Append(aF1);
-       }
-       else if (aState==BooleanOperations_ON) {
-         Standard_Real aTol;
-         TopAbs_State aSt;
-         //
-         //const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape((iRank1==myRank)? nF2 : nF1));
-         //aTol=BRep_Tool::Tolerance(aF2);
-         aTol=1.e-7;
-         //
-         BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP3D);
-         const TopoDS_Solid& aRefSolid=(myRank==1) ? 
-           TopoDS::Solid(aDS.Tool()) : TopoDS::Solid(aDS.Object());
-         //
-         BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)& aPaveFiller;
-         IntTools_Context& aCtx=pPF->ChangeContext();
-         //
-         BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aRefSolid);
-         aSC.Perform(aP3D, aTol);
-         aSt=aSC.State();
-         if (aSt==TopAbs_IN) {
-           myLSIN.Append(aF1);
-         }
-         else if (aSt==TopAbs_OUT) {
-           myLSOUT.Append(aF1);
-         }
-       } 
-       break; 
+        nSp=nE;
+        if (aNbPB) {
+          const BOPTools_PaveBlock& aPB=aLPB.First();
+          nSp=aPB.Edge();
+        }
+        /*const TopoDS_Shape& aSp=*/aDS.Shape(nSp);
+        //
+        aState=aDS.GetState(nSp);
+        if (aState==BooleanOperations_IN) {
+          myLSIN.Append(aF1);
+        }
+        else if (aState==BooleanOperations_OUT) {
+          myLSOUT.Append(aF1);
+        }
+        else if (aState==BooleanOperations_ON) {
+          Standard_Real aTol;
+          TopAbs_State aSt;
+          //
+          //const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape((iRank1==myRank)? nF2 : nF1));
+          //aTol=BRep_Tool::Tolerance(aF2);
+          aTol=1.e-7;
+          //
+          BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP3D);
+          const TopoDS_Solid& aRefSolid=(myRank==1) ? 
+            TopoDS::Solid(aDS.Tool()) : TopoDS::Solid(aDS.Object());
+          //
+          BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)& aPaveFiller;
+          IntTools_Context& aCtx=pPF->ChangeContext();
+          //
+          BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aRefSolid);
+          aSC.Perform(aP3D, aTol);
+          aSt=aSC.State();
+          if (aSt==TopAbs_IN) {
+            myLSIN.Append(aF1);
+          }
+          else if (aSt==TopAbs_OUT) {
+            myLSOUT.Append(aF1);
+          }
+        
+        break; 
       } // if (aNbPB<2) { 
     } //for (; anExp.More(); anExp.Next())
   } 
@@ -337,26 +341,26 @@ void GEOMAlgo_ShellSolid::DetectSDFaces()
       iZone=0;
       TopTools_ListIteratorOfListOfShape anIt(aLF);
       for (; anIt.More(); anIt.Next()) {
-       const TopoDS_Shape& aFR=anIt.Value();
+        const TopoDS_Shape& aFR=anIt.Value();
 
-       if (aFR.ShapeType()==TopAbs_FACE) {
-         const TopoDS_Face& aFaceResult=TopoDS::Face(aFR);
-         //
-         Standard_Boolean bIsValidIn2D, bNegativeFlag;
-         bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag);
-         if (bIsValidIn2D) { 
-           if(CheckSameDomainFaceInside(aFaceResult, aF2)) {
-             iZone=1;
-             break;
-           }
-         }
-         //
-       }
+        if (aFR.ShapeType()==TopAbs_FACE) {
+          const TopoDS_Face& aFaceResult=TopoDS::Face(aFR);
+          //
+          Standard_Boolean bIsValidIn2D, bNegativeFlag;
+          bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag);
+          if (bIsValidIn2D) { 
+            //if(CheckSameDomainFaceInside(aFaceResult, aF2)) {
+            iZone=1;
+            break;
+            //}
+          }
+          //
+        }
       }
       
       if (iZone) { 
-       bFlag=Standard_True;
-       aFF.SetStatesMap(aWESFiller.StatesMap());
+        bFlag=Standard_True;
+        aFF.SetStatesMap(aWESFiller.StatesMap());
       }
       
     }// if (iSenseFlag)
@@ -365,52 +369,3 @@ void GEOMAlgo_ShellSolid::DetectSDFaces()
   aFF.SetSenseFlag (iSenseFlag);
   }// end of for (i=1; i<=aNb; i++) 
 }
-//=======================================================================
-//function : CheckSameDomainFaceInside
-//purpose  : 
-//=======================================================================
-Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
-                                          const TopoDS_Face& theFace2) 
-{
-  Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.;
-  BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax);
-  IntTools_Context aContext;
-  Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1);
-  Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1);
-
-  TopExp_Explorer anExpE(theFace1, TopAbs_EDGE);
-
-  for(; anExpE.More(); anExpE.Next()) {
-    const TopoDS_Edge& anEdge = TopoDS::Edge(anExpE.Current());
-    Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge);
-    aTolerance = (aTolerance < anEdgeTol) ? anEdgeTol : aTolerance;
-  }
-  aTolerance += BRep_Tool::Tolerance(theFace2);
-
-  Standard_Integer nbpoints = 5;
-  Standard_Real adeltau = (umax - umin) / (nbpoints + 1);
-  Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1);
-  Standard_Real U = umin + adeltau;
-  GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2);
-
-  for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) {
-    Standard_Real V = vmin + adeltav;
-
-    for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) {
-      gp_Pnt2d aPoint(U,V);
-
-      if(aContext.IsPointInFace(theFace1, aPoint)) {
-       gp_Pnt aP3d = aSurface->Value(U, V);
-       aProjector.Perform(aP3d);
-
-       if(aProjector.IsDone()) {
-
-         if(aProjector.LowerDistance() > aTolerance)
-           return Standard_False;
-       }
-      }
-    }
-  }
-
-  return Standard_True;
-}