From: Nicolas Rechatin Date: Thu, 2 Sep 2021 06:38:27 +0000 (+0200) Subject: fix Integration feedbacks fixes X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=272ab77b229cf1b02f12376490ee6f9d3bb1a31e;p=modules%2Fshaper.git fix Integration feedbacks fixes --- diff --git a/src/FiltersAPI/FiltersAPI.i b/src/FiltersAPI/FiltersAPI.i index 99e680515..050375692 100644 --- a/src/FiltersAPI/FiltersAPI.i +++ b/src/FiltersAPI/FiltersAPI.i @@ -45,8 +45,6 @@ %shared_ptr(FiltersAPI_Feature) %shared_ptr(FiltersAPI_Filter) -%shared_ptr(ModelHighAPI_Interface) - // function with named parameters %feature("kwargs") addFilter; @@ -118,8 +116,8 @@ } else if (PyBool_Check(item)) { temp.push_back(FiltersAPI_Argument(item == Py_True)); - } else - if(PyFloat_Check(item) || PyLong_Check(item)) { + } else + if(PyFloat_Check(item) || PyLong_Check(item)) { temp.push_back(FiltersAPI_Argument(ModelHighAPI_Double(PyFloat_AsDouble(item)))); } else { PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.4"); diff --git a/src/FiltersAPI/FiltersAPI_Argument.cpp b/src/FiltersAPI/FiltersAPI_Argument.cpp index 182251e19..90a79bb5d 100644 --- a/src/FiltersAPI/FiltersAPI_Argument.cpp +++ b/src/FiltersAPI/FiltersAPI_Argument.cpp @@ -64,7 +64,7 @@ void FiltersAPI_Argument::dump(ModelHighAPI_Dumper& theDumper) const theDumper << "model.selection()"; // mySelectionAttr; } else if (mySelection.variantType() == ModelHighAPI_Selection::VT_Empty) { - if (myDouble.value() > -100000000000 ) { + if (myDouble.value() > std::numeric_limits::lowest() ) { theDumper << myDouble.value(); } else if (myValue.empty()) { diff --git a/src/FiltersAPI/FiltersAPI_Argument.h b/src/FiltersAPI/FiltersAPI_Argument.h index 050bacd14..dd5699894 100644 --- a/src/FiltersAPI/FiltersAPI_Argument.h +++ b/src/FiltersAPI/FiltersAPI_Argument.h @@ -28,6 +28,8 @@ #include #include +#include + /**\class FiltersAPI_Argument * \ingroup CPPHighAPI * \brief Argument of the Filter @@ -69,7 +71,7 @@ public: private: bool myBoolean; - ModelHighAPI_Double myDouble = -100000000000; + ModelHighAPI_Double myDouble = std::numeric_limits::lowest() ; std::string myValue; ModelHighAPI_Selection mySelection; AttributeSelectionPtr mySelectionAttr; diff --git a/src/FiltersAPI/FiltersAPI_Feature.cpp b/src/FiltersAPI/FiltersAPI_Feature.cpp index 0b5def82e..329eee72d 100644 --- a/src/FiltersAPI/FiltersAPI_Feature.cpp +++ b/src/FiltersAPI/FiltersAPI_Feature.cpp @@ -48,7 +48,7 @@ static void separateArguments(const std::list& theArguments for (; anIt != theArguments.end(); ++anIt) { if (anIt->selection().variantType() != ModelHighAPI_Selection::VT_Empty) theSelections.push_back(anIt->selection()); - else if (anIt->dble().value() > -100000000000) { + else if (anIt->dble().value() > std::numeric_limits::lowest()) { theDoubleArgs.push_back(anIt->dble()); } else if (anIt->string().empty()) { diff --git a/src/FiltersPlugin/FiltersPlugin_ContinuousFaces.cpp b/src/FiltersPlugin/FiltersPlugin_ContinuousFaces.cpp index 67726eaa1..d67d88ce6 100644 --- a/src/FiltersPlugin/FiltersPlugin_ContinuousFaces.cpp +++ b/src/FiltersPlugin/FiltersPlugin_ContinuousFaces.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -73,11 +72,11 @@ static void cacheContinuousFace(const GeomShapePtr theFace, std::string anError = ""; if (theCache.find(*aFIt) == theCache.end()) { GeomPointPtr aPoint = anEdge->middlePoint(); - if (isContinuousFaces(theFace, - *aFIt, - aPoint, - theAngle, - anError)) { + if (GeomAlgoAPI_ShapeTools::isContinuousFaces(theFace, + *aFIt, + aPoint, + theAngle, + anError)) { theCache.insert(*aFIt); cacheContinuousFace(*aFIt, theEdgeToFaces, theCache, theAngle); } @@ -166,15 +165,18 @@ bool FiltersPlugin_ContinuousFaces::isOk(const GeomShapePtr& theShape, const Res } if (myCachedShapes.empty()) { - ResultBodyPtr aBaseResult = ModelAPI_Tools::bodyOwner(aList->value(0)->context(), true); - if (!aBaseResult.get()) { - aBaseResult = std::dynamic_pointer_cast(aList->value(0)->context()); - if (!aBaseResult.get()) - return false; + for (size_t i = 0; i < aList->size(); i++) + { + ResultBodyPtr aBaseResult = ModelAPI_Tools::bodyOwner(aList->value(i)->context(), true); + if (!aBaseResult.get()) { + aBaseResult = std::dynamic_pointer_cast(aList->value(i)->context()); + if (!aBaseResult.get()) + return false; + } + cacheContinuousFaces(aBaseResult->shape(), + const_cast(this)->myFaces, + const_cast(this)->myCachedShapes,anAngle); } - cacheContinuousFaces(aBaseResult->shape(), - const_cast(this)->myFaces, - const_cast(this)->myCachedShapes,anAngle); } return myCachedShapes.find(theShape) != myCachedShapes.end(); } diff --git a/src/FiltersPlugin/FiltersPlugin_EdgeSize.cpp b/src/FiltersPlugin/FiltersPlugin_EdgeSize.cpp index 854636ab0..ed0a473ab 100644 --- a/src/FiltersPlugin/FiltersPlugin_EdgeSize.cpp +++ b/src/FiltersPlugin/FiltersPlugin_EdgeSize.cpp @@ -30,10 +30,8 @@ #include -#include - #include -#include +#include bool FiltersPlugin_EdgeSize::isSupported(GeomAPI_Shape::ShapeType theType) const { @@ -70,6 +68,8 @@ bool FiltersPlugin_EdgeSize::isOk(const GeomShapePtr& theShape, const ResultPtr& default: return false; } + + double aTolerance = 0.0001; double aLength = anEdge->length(); anAttr = theArgs.argument("comparatorType"); @@ -80,19 +80,21 @@ bool FiltersPlugin_EdgeSize::isOk(const GeomShapePtr& theShape, const ResultPtr& bool isOK = false; if (aCompString == "inf") - isOK = aLength < aVal && fabs(aLength - aVal) > Precision::Confusion(); + isOK = aLength < aVal && fabs(aLength - aVal) > aTolerance; else if (aCompString == "infEq") - isOK = aLength < aVal || fabs(aLength - aVal) < Precision::Confusion(); + isOK = aLength < aVal || fabs(aLength - aVal) < aTolerance; else if (aCompString == "sup") - isOK = aLength > aVal && fabs(aLength - aVal) > Precision::Confusion(); + isOK = aLength > aVal && fabs(aLength - aVal) > aTolerance; else if (aCompString == "supEq") - isOK = aLength > aVal || fabs(aLength - aVal) < Precision::Confusion(); + isOK = aLength > aVal || fabs(aLength - aVal) < aTolerance; else if (aCompString == "isBetween") - isOK = (aLength > aVal || fabs(aLength - aVal) < Precision::Confusion()) - && (aLength < aValMax || fabs(aLength - aVal) < Precision::Confusion()); + isOK = (aVal <= aValMax) + && (aLength > aVal || fabs(aLength - aVal) < aTolerance) + && (aLength < aValMax || fabs(aLength - aValMax) < aTolerance); else if (aCompString == "isStrictlyBetween") - isOK = (aLength > aVal && fabs(aLength - aVal) > Precision::Confusion()) - && (aLength < aValMax && fabs(aLength - aValMax) > Precision::Confusion()); + isOK = (aVal <= aValMax) + && (aLength > aVal && fabs(aLength - aVal) > aTolerance) + && (aLength < aValMax && fabs(aLength - aValMax) > aTolerance); return isOK; } diff --git a/src/FiltersPlugin/FiltersPlugin_FaceSize.cpp b/src/FiltersPlugin/FiltersPlugin_FaceSize.cpp index 8479c4a36..5dff8a306 100644 --- a/src/FiltersPlugin/FiltersPlugin_FaceSize.cpp +++ b/src/FiltersPlugin/FiltersPlugin_FaceSize.cpp @@ -21,19 +21,15 @@ #include #include +#include #include #include #include #include -#include -#include - -#include - #include -#include +#include bool FiltersPlugin_FaceSize::isSupported(GeomAPI_Shape::ShapeType theType) const @@ -60,17 +56,7 @@ bool FiltersPlugin_FaceSize::isOk(const GeomShapePtr& theShape, const ResultPtr& return false; double aTolerance = 0.0001; - double aLength; - double aSurfArea; - double aVolume; - std::string aError; - if (!GetBasicProperties(theShape, - aTolerance, - aLength, - aSurfArea, - aVolume, - aError)) - return false; + double aSurfArea = GeomAlgoAPI_ShapeTools::area(theShape); anAttr = theArgs.argument("comparatorType"); AttributeStringPtr aCompAttr = std::dynamic_pointer_cast(anAttr); @@ -80,19 +66,21 @@ bool FiltersPlugin_FaceSize::isOk(const GeomShapePtr& theShape, const ResultPtr& bool isOK = false; if (aCompString == "inf") - isOK = aSurfArea < aVal && fabs(aSurfArea - aVal) > Precision::Confusion(); + isOK = aSurfArea < aVal && fabs(aSurfArea - aVal) > aTolerance; else if (aCompString == "infEq") - isOK = aSurfArea < aVal || fabs(aSurfArea - aVal) < Precision::Confusion(); + isOK = aSurfArea < aVal || fabs(aSurfArea - aVal) < aTolerance; else if (aCompString == "sup") - isOK = aSurfArea > aVal && fabs(aSurfArea - aVal) > Precision::Confusion(); + isOK = aSurfArea > aVal && fabs(aSurfArea - aVal) > aTolerance; else if (aCompString == "supEq") - isOK = aSurfArea > aVal || fabs(aSurfArea - aVal) < Precision::Confusion(); + isOK = aSurfArea > aVal || fabs(aSurfArea - aVal) < aTolerance; else if (aCompString == "isBetween") - isOK = (aSurfArea > aVal || fabs(aSurfArea - aVal) < Precision::Confusion()) - && (aSurfArea < aValMax || fabs(aSurfArea - aVal) < Precision::Confusion()); + isOK = (aVal <= aValMax) + && (aSurfArea > aVal || fabs(aSurfArea - aVal) < aTolerance) + && (aSurfArea < aValMax || fabs(aSurfArea - aValMax) < aTolerance); else if (aCompString == "isStrictlyBetween") - isOK = (aSurfArea > aVal && fabs(aSurfArea - aVal) > Precision::Confusion()) - && (aSurfArea < aValMax && fabs(aSurfArea - aValMax) > Precision::Confusion()); + isOK = (aVal <= aValMax) + && (aSurfArea > aVal && fabs(aSurfArea - aVal) > aTolerance) + && (aSurfArea < aValMax && fabs(aSurfArea - aValMax) > aTolerance); return isOK; } diff --git a/src/FiltersPlugin/FiltersPlugin_FeatureEdges.cpp b/src/FiltersPlugin/FiltersPlugin_FeatureEdges.cpp index 1617be13b..d03abfb58 100644 --- a/src/FiltersPlugin/FiltersPlugin_FeatureEdges.cpp +++ b/src/FiltersPlugin/FiltersPlugin_FeatureEdges.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -72,11 +72,11 @@ static void cacheFeatureEdge(const GeomShapePtr theTopLevelShape, for (;aFIt2 != aIt->second.end(); ++aFIt2) { std::string anError; if (theCache.find(*aFIt) == theCache.end()) { - if (!isContinuousFaces(*aFIt, - *aFIt2, - anEdge->middlePoint(), - theAngle, - anError)) { + if (!GeomAlgoAPI_ShapeTools::isContinuousFaces(*aFIt, + *aFIt2, + anEdge->middlePoint(), + theAngle, + anError)) { if (anError.empty()) theCache.insert(anEdge); } diff --git a/src/FiltersPlugin/FiltersPlugin_VolumeSize.cpp b/src/FiltersPlugin/FiltersPlugin_VolumeSize.cpp index 2a4a961c2..b640fa660 100644 --- a/src/FiltersPlugin/FiltersPlugin_VolumeSize.cpp +++ b/src/FiltersPlugin/FiltersPlugin_VolumeSize.cpp @@ -21,20 +21,15 @@ #include #include +#include #include #include #include #include -#include -#include - -#include - #include -#include - +#include bool FiltersPlugin_VolumeSize::isSupported(GeomAPI_Shape::ShapeType theType) const { @@ -60,17 +55,7 @@ bool FiltersPlugin_VolumeSize::isOk(const GeomShapePtr& theShape, const ResultPt return false; double aTolerance = 0.0001; - double aLength; - double aSurfArea; - double aVolume; - std::string aError; - if (!GetBasicProperties(theShape, - aTolerance, - aLength, - aSurfArea, - aVolume, - aError)) - return false; + double aVolume = GeomAlgoAPI_ShapeTools::volume(theShape); anAttr = theArgs.argument("comparatorType"); AttributeStringPtr aCompAttr = std::dynamic_pointer_cast(anAttr); @@ -80,19 +65,21 @@ bool FiltersPlugin_VolumeSize::isOk(const GeomShapePtr& theShape, const ResultPt bool isOK = false; if (aCompString == "inf") - isOK = aVolume < aVal && fabs(aVolume - aVal) > Precision::Confusion(); + isOK = aVolume < aVal && fabs(aVolume - aVal) > aTolerance; else if (aCompString == "infEq") - isOK = aVolume < aVal || fabs(aVolume - aVal) < Precision::Confusion(); + isOK = aVolume < aVal || fabs(aVolume - aVal) < aTolerance; else if (aCompString == "sup") - isOK = aVolume > aVal && fabs(aVolume - aVal) > Precision::Confusion(); + isOK = aVolume > aVal && fabs(aVolume - aVal) > aTolerance; else if (aCompString == "supEq") - isOK = aVolume > aVal || fabs(aVolume - aVal) < Precision::Confusion(); + isOK = aVolume > aVal || fabs(aVolume - aVal) < aTolerance; else if (aCompString == "isBetween") - isOK = (aVolume > aVal || fabs(aVolume - aVal) < Precision::Confusion()) - && (aVolume < aValMax || fabs(aVolume - aVal) < Precision::Confusion()); + isOK = (aVal <= aValMax) + && (aVolume >= aVal || fabs(aVolume - aVal) < aTolerance) + && (aVolume <= aValMax || fabs(aVolume - aValMax) < aTolerance); else if (aCompString == "isStrictlyBetween") - isOK = (aVolume > aVal && fabs(aVolume - aVal) > Precision::Confusion()) - && (aVolume < aValMax && fabs(aVolume - aValMax) > Precision::Confusion()); + isOK = (aVal <= aValMax) + &&(aVolume > aVal && fabs(aVolume - aVal) > aTolerance) + && (aVolume < aValMax && fabs(aVolume - aValMax) > aTolerance); return isOK; } diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index d55d92608..0c549a45b 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -33,7 +33,6 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Prism.h GeomAlgoAPI_Revolution.h GeomAlgoAPI_Boolean.h - GeomAlgoAPI_BasicProperties.h GeomAlgoAPI_ThroughAll.h GeomAlgoAPI_Rotation.h GeomAlgoAPI_Translation.h @@ -74,7 +73,6 @@ SET(PROJECT_HEADERS GeomAlgoAPI_XAOImport.h GeomAlgoAPI_Copy.h GeomAlgoAPI_ConeSegment.h - GeomAlgoAPI_ContinuousFaces.h GeomAlgoAPI_Ellipsoid.h GeomAlgoAPI_Symmetry.h GeomAlgoAPI_Scale.h @@ -105,7 +103,6 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Prism.cpp GeomAlgoAPI_Revolution.cpp GeomAlgoAPI_Boolean.cpp - GeomAlgoAPI_BasicProperties.cpp GeomAlgoAPI_ThroughAll.cpp GeomAlgoAPI_Rotation.cpp GeomAlgoAPI_Translation.cpp @@ -146,7 +143,6 @@ SET(PROJECT_SOURCES GeomAlgoAPI_XAOImport.cpp GeomAlgoAPI_Copy.cpp GeomAlgoAPI_ConeSegment.cpp - GeomAlgoAPI_ContinuousFaces.cpp GeomAlgoAPI_Ellipsoid.cpp GeomAlgoAPI_Symmetry.cpp GeomAlgoAPI_Scale.cpp diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp deleted file mode 100644 index 123370f24..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D -// -// 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, or (at your option) any later version. -// -// 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 -// - -#include "GeomAlgoAPI_BasicProperties.h" - -#include -#include -#include -#include -#include - -//================================================================================================= -bool GetBasicProperties(const std::shared_ptr& theShape, - const double theTolerance, - Standard_Real& theLength, - Standard_Real& theSurfArea, - Standard_Real& theVolume, - std::string& theError) -{ - - #ifdef _DEBUG - std::cout << "GetBasicProperties " << std::endl; - #endif - - if (!theShape.get()) { - theError = "GetBasicProperties : An invalid argument"; - return false; - } - - TopoDS_Shape aShape = theShape->impl(); - - //Compute the parameters - GProp_GProps LProps, SProps; - Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6; - try { - OCC_CATCH_SIGNALS; - BRepGProp::LinearProperties(aShape, LProps, Standard_True); - theLength = LProps.Mass(); - - BRepGProp::SurfaceProperties(aShape, SProps, anEps, Standard_True); - theSurfArea = SProps.Mass(); - - theVolume = 0.0; - if (aShape.ShapeType() < TopAbs_SHELL) { - for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) { - GProp_GProps VProps; - BRepGProp::VolumeProperties(Exp.Current(), VProps, anEps, Standard_True); - theVolume += VProps.Mass(); - } - } - } - catch (Standard_Failure& aFail) { - theError = aFail.GetMessageString(); - return false; - } - return true; -} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h b/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h deleted file mode 100644 index e697dd090..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D -// -// 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, or (at your option) any later version. -// -// 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 -// - -#ifndef GeomAlgoAPI_BasicProperties_H_ -#define GeomAlgoAPI_BasicProperties_H_ - -#include -#include -#include - -/// Run chamfer operation with two distances or with a distance and an angle . - /// \param theShape the shape - /// \param theTolerance tolerance desirated - /// \param theLength lenght calculated - /// \param theSurfArea Surface Area calculated - /// \param theVolume Volume calculated - /// \param theError error -GEOMALGOAPI_EXPORT -bool GetBasicProperties( const std::shared_ptr& theShape, - const Standard_Real theTolerance, - Standard_Real& theLength, - Standard_Real& theSurfArea, - Standard_Real& theVolume, - std::string& theError); - -#endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.cpp deleted file mode 100644 index 436c64d85..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D -// -// 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, or (at your option) any later version. -// -// 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 -// - -#include "GeomAlgoAPI_ContinuousFaces.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -const double PI = 3.141592653589793238463; - -//======================================================================= -bool isContinuousFaces(const GeomShapePtr& theFace1, - const GeomShapePtr& theFace2, - const GeomPointPtr& thePoint, - const double & theAngle, - std::string& theError) -{ - - #ifdef _DEBUG - std::cout << "isContinuousFaces " << std::endl; - #endif - - if (!thePoint.get()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - const gp_Pnt& aPoint = thePoint->impl(); - - // Getting base shape. - if (!theFace1.get()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - TopoDS_Shape aShape1 = theFace1->impl(); - - if (aShape1.IsNull()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - // Getting base shape. - if (!theFace2.get()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - TopoDS_Shape aShape2 = theFace2->impl(); - - if (aShape2.IsNull()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - TopoDS_Face aFace1 = TopoDS::Face(aShape1); - if (aFace1.IsNull()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(aFace1); - if (aSurf1.IsNull()) { - theError = "isContinuousFaces : An invalid surface"; - return false; - } - - ShapeAnalysis_Surface aSAS1(aSurf1); - gp_Pnt2d aPointOnFace1 = aSAS1.ValueOfUV(aPoint, Precision::Confusion()); - - TopoDS_Face aFace2 = TopoDS::Face(aShape2); - if (aFace2.IsNull()) { - theError = "isContinuousFaces : An invalid argument"; - return false; - } - - Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(aFace2); - if (aSurf2.IsNull()) { - theError = "isContinuousFaces : An invalid surface"; - return false; - } - - ShapeAnalysis_Surface aSAS2(aSurf2); - gp_Pnt2d aPointOnFace2= aSAS2.ValueOfUV(aPoint, Precision::Confusion()); - - bool aRes = false; - try { - OCC_CATCH_SIGNALS; - LocalAnalysis_SurfaceContinuity aLocAnal(aSurf1, - aPointOnFace1.X(), - aPointOnFace1.Y(), - aSurf2, - aPointOnFace2.X(), - aPointOnFace2.Y(), - GeomAbs_Shape::GeomAbs_G1, // Order - 0.001, // EpsNul - 0.001, // EpsC0 - 0.001, // EpsC1 - 0.001, // EpsC2 - theAngle * PI/ 180.0); //EpsG1 - aRes = aLocAnal.IsG1(); - } - catch (Standard_Failure const& anException) { - theError = "LocalAnalysis_SurfaceContinuity error :"; - theError += anException.GetMessageString(); - } - - return aRes; -} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.h b/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.h deleted file mode 100644 index 0d0faade4..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ContinuousFaces.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D -// -// 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, or (at your option) any later version. -// -// 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 -// - -#ifndef GEOMALGOAPI_CONTINUOUSFACES_H_ -#define GEOMALGOAPI_CONTINUOUSFACES_H_ - -#include -#include -#include -#include - -/// indicate if two faces are continuous -/// with an angular tolerance used for G1 continuity to compare the angle between the normals -/// \param theFace1 the first face -/// \param theFace2 the second face -/// \param thePoint the point for the normal -/// \param theAngle the angular tolerance -/// \param theError error -GEOMALGOAPI_EXPORT -bool isContinuousFaces(const GeomShapePtr& theFace1, - const GeomShapePtr& theFace2, - const GeomPointPtr& thePoint, - const double & theAngle, - std::string& theError); - -#endif //GEOMALGOAPI_SHAREDFACES_H_ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index c4cdde252..cc7ac82ee 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -95,6 +95,8 @@ #include +#include + //================================================================================================== static GProp_GProps props(const TopoDS_Shape& theShape) { @@ -177,6 +179,105 @@ double GeomAlgoAPI_ShapeTools::area (const std::shared_ptr theSha return aGProps.Mass(); } +//================================================================================================== +bool GeomAlgoAPI_ShapeTools::isContinuousFaces(const GeomShapePtr& theFace1, + const GeomShapePtr& theFace2, + const GeomPointPtr& thePoint, + const double & theAngle, + std::string& theError) +{ + + #ifdef _DEBUG + std::cout << "isContinuousFaces " << std::endl; + #endif + + if (!thePoint.get()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + const gp_Pnt& aPoint = thePoint->impl(); + + // Getting base shape. + if (!theFace1.get()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + TopoDS_Shape aShape1 = theFace1->impl(); + + if (aShape1.IsNull()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + // Getting base shape. + if (!theFace2.get()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + TopoDS_Shape aShape2 = theFace2->impl(); + + if (aShape2.IsNull()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + TopoDS_Face aFace1 = TopoDS::Face(aShape1); + if (aFace1.IsNull()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(aFace1); + if (aSurf1.IsNull()) { + theError = "isContinuousFaces : An invalid surface"; + return false; + } + + ShapeAnalysis_Surface aSAS1(aSurf1); + gp_Pnt2d aPointOnFace1 = aSAS1.ValueOfUV(aPoint, Precision::Confusion()); + + TopoDS_Face aFace2 = TopoDS::Face(aShape2); + if (aFace2.IsNull()) { + theError = "isContinuousFaces : An invalid argument"; + return false; + } + + Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(aFace2); + if (aSurf2.IsNull()) { + theError = "isContinuousFaces : An invalid surface"; + return false; + } + + ShapeAnalysis_Surface aSAS2(aSurf2); + gp_Pnt2d aPointOnFace2= aSAS2.ValueOfUV(aPoint, Precision::Confusion()); + + bool aRes = false; + try { + OCC_CATCH_SIGNALS; + LocalAnalysis_SurfaceContinuity aLocAnal(aSurf1, + aPointOnFace1.X(), + aPointOnFace1.Y(), + aSurf2, + aPointOnFace2.X(), + aPointOnFace2.Y(), + GeomAbs_Shape::GeomAbs_G1, // Order + 0.001, // EpsNul + 0.001, // EpsC0 + 0.001, // EpsC1 + 0.001, // EpsC2 + theAngle * M_PI / 180.0); //EpsG1 + aRes = aLocAnal.IsG1(); + } + catch (Standard_Failure const& anException) { + theError = "LocalAnalysis_SurfaceContinuity error :"; + theError += anException.GetMessageString(); + } + + return aRes; +} + //================================================================================================== std::shared_ptr GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr theShape) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h index b1f154948..5f511d73c 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #ifdef WIN32 @@ -56,6 +57,19 @@ public: /// \return the total area of the faces of the current shape or 0.0 if it can be computed. GEOMALGOAPI_EXPORT static double area(const std::shared_ptr theShape); + /// indicate if two faces are continuous + /// with an angular tolerance used for G1 continuity to compare the angle between the normals + /// \param theFace1 the first face + /// \param theFace2 the second face + /// \param thePoint the point for the normal + /// \param theAngle the angular tolerance + /// \param theError error + GEOMALGOAPI_EXPORT static bool isContinuousFaces(const GeomShapePtr& theFace1, + const GeomShapePtr& theFace2, + const GeomPointPtr& thePoint, + const double & theAngle, + std::string& theError); + /// \return the center of mass of the current face. /// The coordinates returned for the center of mass /// are expressed in the absolute Cartesian coordinate system.