Salome HOME
0023361: EDF - Partition by plane fails
authorskv <skv@opencascade.com>
Tue, 18 Oct 2016 10:00:19 +0000 (13:00 +0300)
committerskv <skv@opencascade.com>
Tue, 18 Oct 2016 10:00:19 +0000 (13:00 +0300)
idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOMUtils/GEOMUtils.cxx
src/GEOMUtils/GEOMUtils.hxx
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/geomBuilder.py

index 31e6491a6d6bc93b2c4927896e35fc306d463472..1d275720c0aba1863762816261991223d78913ed 100644 (file)
@@ -4548,6 +4548,14 @@ module GEOM
                                        in double      theTolerance,
                                        out ListOfLong theIntersections);
 
+    /*!
+     *  \brief Check boolean and partition operations agruments.
+     *  \param theShape the agrument of an operation to be checked.
+     *  \return TRUE if the agrument is valid for a boolean or partition
+     *          operation; FALSE otherwise.
+     */
+    boolean CheckBOPArguments (in GEOM_Object theShape);
+
     /*!
      *  \brief Detect intersections of the given shapes with algorithm based on mesh intersections.
      *  \param theShape1 First source object
index 080d8b858fdfb53d59928de740eb7eaeae84198f..6cebe14bc5f862e7511d442db4d62130683f91f4 100644 (file)
@@ -1672,6 +1672,40 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersectionsFast
   return theIntersections->IsEmpty();
 }
 
+//=============================================================================
+/*!
+ *  CheckBOPArguments
+ */
+//=============================================================================
+bool GEOMImpl_IMeasureOperations::CheckBOPArguments
+                                      (const Handle(GEOM_Object) &theShape)
+{
+  SetErrorCode(KO);
+
+  if (theShape.IsNull()) {
+    return false;
+  }
+
+  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+
+  if (aRefShape.IsNull()) {
+    return false;
+  }
+
+  TopoDS_Shape aShape = aRefShape->GetValue();
+
+  if (aShape.IsNull()) {
+    return false;
+  }
+
+  //Compute the parameters
+  bool isValid = GEOMUtils::CheckBOPArguments(aShape);
+
+  SetErrorCode(OK);
+
+  return isValid;
+}
+
 //=============================================================================
 /*!
  *  FastIntersect
index 3ee2311289e49c8f97db87604286d00dca4f3ed3..6943814dd590842bdf6e19b5feede871bc221263 100644 (file)
@@ -164,6 +164,8 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                                   float  deflection, 
                                                   double tolerance,
                                                   Handle(TColStd_HSequenceOfInteger)& theIntersections);
+
+  Standard_EXPORT bool CheckBOPArguments (const Handle(GEOM_Object) &theShape);
   
   Standard_EXPORT bool FastIntersect (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2,
                                       double tolerance, float deflection,
index 91abe5bf2204cde196846be4927cf052acd5a5d9..ab91abb4c3d6dd60ef87ca84eb97064aa1114f1a 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <Bnd_Box.hxx>
 
+#include <BOPAlgo_ArgumentAnalyzer.hxx>
 #include <BOPTools_AlgoTools.hxx>
 
 #include <TopAbs.hxx>
@@ -1098,6 +1099,29 @@ bool GEOMUtils::CheckShape( TopoDS_Shape& shape,
   return analyzer.IsValid();
 }
 
+bool GEOMUtils::CheckBOPArguments(const TopoDS_Shape &theShape)
+{
+  BOPAlgo_ArgumentAnalyzer aChecker;
+
+  aChecker.SetShape1(theShape);
+
+  // Set default options
+  aChecker.ArgumentTypeMode()   = Standard_True;
+  aChecker.SelfInterMode()      = Standard_True;
+  aChecker.SmallEdgeMode()      = Standard_True;
+  aChecker.RebuildFaceMode()    = Standard_True;
+  aChecker.ContinuityMode()     = Standard_True;
+  aChecker.CurveOnSurfaceMode() = Standard_True;
+
+  aChecker.StopOnFirstFaulty() = Standard_True;
+  aChecker.Perform();
+
+  // process result of checking
+  const bool isValid = !aChecker.HasFaulty();
+
+  return isValid;
+}
+
 bool GEOMUtils::FixShapeTolerance( TopoDS_Shape& shape,
                                    TopAbs_ShapeEnum type,
                                    Standard_Real tolerance,
index 11e58890aa75128acdeb99a8a65c4f6212e73863..8bee52fadb369fbd0d11604e9626e52a73f39ea9 100644 (file)
@@ -252,6 +252,15 @@ namespace GEOMUtils
    * \return \c true if shape is valid or \c false otherwise
    */
   Standard_EXPORT bool CheckShape( TopoDS_Shape& shape, bool checkGeometry = false );
+
+  /*!
+   * \brief Check boolean and partition operations agruments
+   *
+   * \param theShape the agrument of an operation to be checked
+   * \return \c true if the agrument is valid for a boolean or partition
+   *         operation or \c false otherwise
+   */
+  Standard_EXPORT bool CheckBOPArguments(const TopoDS_Shape &theShape);
   
   /*!
    * \brief Limit shape tolerance to the given value
index 63cb07d15da8f20441b3dc4cef3f9287f85d51e8..7babefba88f35b746feacf08c9defe206724ca12 100644 (file)
@@ -808,6 +808,29 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersectionsFast
   return isGood;
 }
 
+//=============================================================================
+/*!
+ *  CheckBOPArguments
+ */
+//=============================================================================
+CORBA::Boolean GEOM_IMeasureOperations_i::CheckBOPArguments
+                                      (GEOM::GEOM_Object_ptr theShape)
+{
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the reference shape
+  HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
+  bool isGood = false;
+
+  if (!aShape.IsNull()) {
+    // Check BOP agruments
+    isGood = GetOperations()->CheckBOPArguments(aShape);
+  }
+
+  return isGood;
+}
+
 //=============================================================================
 /*!
  *  FastIntersect
index 428ae93b860489fadc9f14e2ecd00e58b1775390..9311fb9461ed8c73ae663777e2ed6d27059a0fa8 100644 (file)
@@ -105,6 +105,8 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
                                             CORBA::Double         theTolerance,
                                             GEOM::ListOfLong_out  theIntersections);
 
+  CORBA::Boolean CheckBOPArguments (GEOM::GEOM_Object_ptr theShape);
+
   CORBA::Boolean FastIntersect (GEOM::GEOM_Object_ptr theShape1,
                                 GEOM::GEOM_Object_ptr theShape2,
                                 CORBA::Double         theTolerance,
index a7fced187856d4366aca7d31d24459f6f7e21777..29161717f77029422e77f11272c1e86609e59d30 100644 (file)
@@ -11443,6 +11443,24 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             RaiseIfFailed("CheckSelfIntersectionsFast", self.MeasuOp)
             return IsValid
 
+        ## Check boolean and partition operations agruments.
+        #  @param theShape the agrument of an operation to be checked
+        #  @return TRUE if the agrument is valid for a boolean or partition
+        #          operation; FALSE otherwise.
+        @ManageTransactions("MeasuOp")
+        def CheckBOPArguments(self, theShape):
+            """
+            Check boolean and partition operations agruments.
+
+            Parameters:
+                theShape the agrument of an operation to be checked
+
+            Returns:
+                TRUE if the agrument is valid for a boolean or partition
+                operation; FALSE otherwise.
+            """
+            return self.MeasuOp.CheckBOPArguments(theShape)
+
         ## Detect intersections of the given shapes with algorithm based on mesh intersections.
         #  @param theShape1 First source object
         #  @param theShape2 Second source object