Salome HOME
Merge from BR_new_bop4 (porting to new OCCT BOP) 13/09/2013
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_VertexSolid.cxx
index d16b84fa680bbd9d393c24630ef170bd93886998..71760aa183193c652a8492af0230644befcd0669 100644 (file)
 
 #include <BRep_Tool.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
-
-#include <BOPTColStd_Dump.hxx>
-
-#include <IntTools_Context.hxx>
-
-#include <BooleanOperations_StateOfShape.hxx>
-#include <BooleanOperations_ShapesDataStructure.hxx>
-
-#include <BOPTools_InterferencePool.hxx>
-#include <BOPTools_CArray1OfVVInterference.hxx>
-#include <BOPTools_VVInterference.hxx>
-#include <BOPTools_PaveFiller.hxx>
-#include <BOPTools_DSFiller.hxx>
+//
+#include <BOPCol_ListOfShape.hxx>
+#include <BOPInt_Context.hxx>
+//
+#include <BOPDS_DS.hxx>
+#include <BOPDS_IndexRange.hxx>
+#include <BOPDS_VectorOfInterfVV.hxx>
+#include <BOPDS_VectorOfInterfVE.hxx>
+#include <BOPDS_VectorOfInterfVF.hxx>
+#include <BOPDS_Interf.hxx>
 
 //=======================================================================
 //function : GEOMAlgo_VertexSolid
@@ -87,28 +84,28 @@ void GEOMAlgo_VertexSolid::Perform()
       myErrorStatus=10;
       return;
     }
-    if(!myDSFiller->IsDone()) {
+    if(myDSFiller->ErrorStatus()) {
       myErrorStatus=11;
       return;
     }
     //
-    Standard_Boolean bIsNewFiller;
-    Standard_Integer aNbF;
+    Standard_Integer aNbF, aNbArgs;
     TopTools_IndexedMapOfShape aM;
     //
-    const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
-    const TopoDS_Shape& aObj=aDS.Object();
+    const BOPDS_DS& aDS=myDSFiller->DS();
+    const BOPCol_ListOfShape& aLS=aDS.Arguments();
+    aNbArgs=aLS.Extent();
+    if (aNbArgs!=2) {
+      myErrorStatus=14;
+      return;
+    }
+    
+    const TopoDS_Shape& aObj=aLS.First();
     //
     TopExp::MapShapes(aObj, TopAbs_FACE, aM);
     aNbF=aM.Extent();
-    myRank=(aNbF) ? 2 : 1;
+    myRank=(aNbF) ? 1 : 0;
     //
-    bIsNewFiller=myDSFiller->IsNewFiller();
-
-    if (bIsNewFiller) {
-      Prepare();
-      myDSFiller->SetNewFiller(!bIsNewFiller);
-    }
     BuildResult();
   }
   //
@@ -117,123 +114,102 @@ void GEOMAlgo_VertexSolid::Perform()
   }
 }
 //=======================================================================
-// function: Prepare
+// function: BuildResult
 // purpose:
 //=======================================================================
-void GEOMAlgo_VertexSolid::Prepare()
+void GEOMAlgo_VertexSolid::BuildResult()
 {
-  Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound;
+  Standard_Integer i, iBeg, iEnd, aNbVV, aNbVE, aNbVF, j, iFound, aNbRanges;
   Standard_Real aTol;
   TopAbs_State aSt;
   TopAbs_ShapeEnum aType;
-  BooleanOperations_StateOfShape aState;
   gp_Pnt aP3D;
   //
-  const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
-  BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS;
-  const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool();
-  BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP;
-  BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences();
-  const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller();
-  BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
-  const Handle(IntTools_Context)& aCtx=pPF->Context();
+  myLSIN.Clear();
+  myLSOUT.Clear();
+  myLSON.Clear();
+  //
+  const BOPDS_DS& aDS=myDSFiller->DS();
+  BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
   //
-  const TopoDS_Shape& aObj=aDS.Object();
-  const TopoDS_Shape& aTool=aDS.Tool();
+  BOPDS_VectorOfInterfVV& aVVs=pDS->InterfVV();
+  BOPDS_VectorOfInterfVE& aVEs=pDS->InterfVE();
+  BOPDS_VectorOfInterfVF& aVFs=pDS->InterfVF();
   //
-  const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
+  const BOPCol_ListOfShape& aLS=aDS.Arguments();
+  const TopoDS_Shape& aObj=aLS.First();
   //
+  const TopoDS_Shape& aTool=aLS.Last();
+  const TopoDS_Solid& aSolid=(myRank==0) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
+  //
+  Handle(BOPInt_Context) aCtx=myDSFiller->Context();
   BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
   //
-  iBeg=1;
-  iEnd=aDS.NumberOfShapesOfTheObject();
-  if (myRank==2) {
-    iBeg=iEnd+1;
-    iEnd=aDS.NumberOfSourceShapes();
-  }
+  aNbRanges=aDS.NbRanges();
+  const BOPDS_IndexRange& aRange=aDS.Range(myRank);
+  aRange.Indices(iBeg, iEnd);
   //
   for (i=iBeg; i<=iEnd; ++i) {
-    aType=aDS.GetShapeType(i);
+    const TopoDS_Shape& aS=aDS.Shape(i);
+    aType=aS.ShapeType();
     if (aType!=TopAbs_VERTEX) {
-      continue;
+      continue; 
     }
     //
-    const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i));
-    //
-    aState=aDS.GetState(i);
-    if (aState==BooleanOperations_ON ||
-        aState==BooleanOperations_IN ||
-        aState==BooleanOperations_OUT) {
-      continue;
-    }
+    const TopoDS_Vertex& aV=TopoDS::Vertex(aS);
     //
     iFound=0;
+    //
+    // 1
     aNbVV=aVVs.Extent();
-    for (j=1; j<=aNbVV; ++j) {
-      BOPTools_VVInterference& aVV=aVVs(j);
-      aVV.Indices(n1, n2);
-      if (n1==i || n2==i) {
-        pDS->SetState (n1, BooleanOperations_ON);
-        pDS->SetState (n2, BooleanOperations_ON);
-        iFound=1;
-        break;
+    for (j=0; j<aNbVV; ++j) {
+      BOPDS_InterfVV& aVV=aVVs(j);
+      if (aVV.Contains(i)) {
+       myLSON.Append(aV);
+       iFound=1;
+       break;
+      }
+    }
+    if (iFound) {
+      continue; 
+    }
+    // 2
+    aNbVE=aVEs.Extent();
+    for (j=0; j<aNbVE; ++j) {
+      BOPDS_InterfVE& aVE=aVEs(j);
+      if (aVE.Contains(i)) {
+       myLSON.Append(aV);
+       iFound=1;
+       break;
+      }
+    }
+    if (iFound) {
+      continue; 
+    }
+    // 3
+    aNbVF=aVFs.Extent();
+    for (j=0; j<aNbVF; ++j) {
+      BOPDS_InterfVF& aVF=aVFs(j);
+      if (aVF.Contains(i)) {
+       myLSON.Append(aV);
+       iFound=1;
+       break;
       }
     }
     if (iFound) {
-      continue;
+      continue; 
     }
     //
+    // 4
     aP3D=BRep_Tool::Pnt(aV);
-    aTol=1.E-7;
+    aTol=1.e-7;
     aSC.Perform(aP3D, aTol);
     aSt=aSC.State();
     if (aSt==TopAbs_IN) {
-      pDS->SetState (i, BooleanOperations_IN);
-    }
-    else if (aSt==TopAbs_OUT) {
-      pDS->SetState (i, BooleanOperations_OUT);
-    }
-  }
-}
-//=======================================================================
-// function: BuildResult
-// purpose:
-//=======================================================================
-void GEOMAlgo_VertexSolid::BuildResult()
-{
-  const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
-  //
-  Standard_Integer i, iBeg, iEnd;
-  TopAbs_ShapeEnum aType;
-  BooleanOperations_StateOfShape aState;
-  //
-  myLSIN.Clear();
-  myLSOUT.Clear();
-  myLSON.Clear();
-  //
-  iBeg=1;
-  iEnd=aDS.NumberOfShapesOfTheObject();
-  if (myRank==2) {
-    iBeg=iEnd+1;
-    iEnd=aDS.NumberOfSourceShapes();
-  }
-  //
-  for (i=iBeg; i<=iEnd; ++i) {
-    aType=aDS.GetShapeType(i);
-    if (aType!=TopAbs_VERTEX) {
-      continue;
-    }
-    const TopoDS_Shape& aV=aDS.Shape(i);
-    aState=aDS.GetState(i);
-    //
-    if (aState==BooleanOperations_IN) {
       myLSIN.Append(aV);
     }
-    else if (aState==BooleanOperations_OUT) {
+    else if (aSt==TopAbs_OUT) {
       myLSOUT.Append(aV);
     }
-    else if (aState==BooleanOperations_ON) {
-      myLSON.Append(aV);
-    }
-  }
+  }//for (i=iBeg; i<iEnd; ++i) {
 }