From afce74184aad364a58c4bfbe2d3156ba2dd3be89 Mon Sep 17 00:00:00 2001 From: skv Date: Tue, 18 Oct 2016 13:00:19 +0300 Subject: [PATCH] 0023361: EDF - Partition by plane fails --- idl/GEOM_Gen.idl | 8 +++++ src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx | 34 ++++++++++++++++++++ src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx | 2 ++ src/GEOMUtils/GEOMUtils.cxx | 24 ++++++++++++++ src/GEOMUtils/GEOMUtils.hxx | 9 ++++++ src/GEOM_I/GEOM_IMeasureOperations_i.cc | 23 +++++++++++++ src/GEOM_I/GEOM_IMeasureOperations_i.hh | 2 ++ src/GEOM_SWIG/geomBuilder.py | 18 +++++++++++ 8 files changed, 120 insertions(+) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 31e6491a6..1d275720c 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 080d8b858..6cebe14bc 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -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 diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index 3ee231128..6943814dd 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -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, diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index 91abe5bf2..ab91abb4c 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -49,6 +49,7 @@ #include +#include #include #include @@ -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, diff --git a/src/GEOMUtils/GEOMUtils.hxx b/src/GEOMUtils/GEOMUtils.hxx index 11e58890a..8bee52fad 100644 --- a/src/GEOMUtils/GEOMUtils.hxx +++ b/src/GEOMUtils/GEOMUtils.hxx @@ -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 diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 63cb07d15..7babefba8 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -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 diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh index 428ae93b8..9311fb946 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.hh +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -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, diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index a7fced187..29161717f 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -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