]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMImpl/GEOMImpl_PartitionDriver.cxx
Salome HOME
Merge remote branch 'origin/gdd/translations'
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PartitionDriver.cxx
index 97625c539c359cfb8109191eea93beab05cec1f7..fa7526643c15f17d42a06e51100b76cf32cb8e05 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  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
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Standard_Stream.hxx>
-
 #include <GEOMImpl_PartitionDriver.hxx>
 #include <GEOMImpl_IPartition.hxx>
 #include <GEOMImpl_Types.hxx>
-
+#include <GEOMUtils.hxx>
 #include <GEOM_Object.hxx>
 #include <GEOM_Function.hxx>
-
 #include <GEOMAlgo_Splitter.hxx>
 
 #include <TDataStd_IntegerArray.hxx>
 #include <TNaming_CopyShape.hxx>
 
-//#include <BRepBuilderAPI_Copy.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAlgo.hxx>
-#include <BRepTools.hxx>
-
 #include <TopAbs.hxx>
 #include <TopExp.hxx>
-#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Wire.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_DataMapOfShapeShape.hxx>
 
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_ListOfInteger.hxx>
 #include <Standard_NullObject.hxx>
 #include <StdFail_NotDone.hxx>
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
 #include <BOPAlgo_CheckerSI.hxx>
 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
 #include <BOPCol_ListOfShape.hxx>
@@ -174,7 +156,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
       }
 
       // Check self-intersection.
-      if (isCheckSelfInte) {
+      if (isCheckSelfInte && aType == PARTITION_NO_SELF_INTERSECTIONS) {
         CheckSelfIntersection(aShape_i);
       }
 
@@ -216,7 +198,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
       }
 
       // Check self-intersection.
-      if (isCheckSelfInte) {
+      if (isCheckSelfInte && aType == PARTITION_NO_SELF_INTERSECTIONS) {
         CheckSelfIntersection(aShape_i);
       }
 
@@ -359,12 +341,6 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
       Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
     }
 
-    // Check self-intersection.
-    if (isCheckSelfInte) {
-      CheckSelfIntersection(aShapeArg);
-      CheckSelfIntersection(aPlaneArg);
-    }
-
     TopoDS_Shape aShapeArg_copy;
     TopoDS_Shape aPlaneArg_copy;
     {
@@ -405,8 +381,20 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
     }
 
     // add object shapes that are in ListShapes;
-    PS.AddArgument(aShapeArg_copy);
-    //PS.AddShape(aShapeArg);
+    TopTools_ListOfShape aSimpleShapes;
+    TopTools_MapOfShape aShapesMap;
+
+    PrepareShapes(aShapeArg_copy, aType, aSimpleShapes);
+
+    TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
+
+    for (; aSimpleIter.More(); aSimpleIter.Next()) {
+      const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
+
+      if (aShapesMap.Add(aSimpleSh)) {
+        PS.AddArgument(aSimpleSh);
+      }
+    }
 
     // add tool shapes that are in ListTools and not in ListShapes;
     PS.AddTool(aPlaneArg_copy);
@@ -438,17 +426,8 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
     Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
   //end of IPAL21418
 
-  if (!BRepAlgo::IsValid(aShape)) {
-    // 08.07.2008 added by skl during fixing bug 19761 from Mantis
-    ShapeFix_ShapeTolerance aSFT;
-    aSFT.LimitTolerance(aShape, Precision::Confusion(),
-                        Precision::Confusion(), TopAbs_SHAPE);
-    Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
-    aSfs->Perform();
-    aShape = aSfs->Shape();
-    if (!BRepAlgo::IsValid(aShape))
-      Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
-  }
+  if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+    Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
 
   aFunction->SetValue(aShape);
 
@@ -560,6 +539,10 @@ GetCreationInformation(std::string&             theOperationName,
     AddParam( theParams, "Resulting type", (TopAbs_ShapeEnum) aCI.GetLimit());
     AddParam( theParams, "Keep shapes of lower type", aCI.GetKeepNonlimitShapes());
     AddParam( theParams, "No object intersections", ( aType == PARTITION_NO_SELF_INTERSECTIONS ));
+
+    if (aType == PARTITION_NO_SELF_INTERSECTIONS) {
+      AddParam( theParams, "Check self-intersections", aCI.GetCheckSelfIntersection());
+    }
     break;
   case PARTITION_HALF:
     AddParam( theParams, "Object", aCI.GetShape() );