%shared_ptr(FiltersAPI_Feature)
%shared_ptr(FiltersAPI_Filter)
-%shared_ptr(ModelHighAPI_Interface)
-
// function with named parameters
%feature("kwargs") addFilter;
} 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");
theDumper << "model.selection()"; // mySelectionAttr;
}
else if (mySelection.variantType() == ModelHighAPI_Selection::VT_Empty) {
- if (myDouble.value() > -100000000000 ) {
+ if (myDouble.value() > std::numeric_limits<double>::lowest() ) {
theDumper << myDouble.value();
}
else if (myValue.empty()) {
#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Selection.h>
+#include <limits>
+
/**\class FiltersAPI_Argument
* \ingroup CPPHighAPI
* \brief Argument of the Filter
private:
bool myBoolean;
- ModelHighAPI_Double myDouble = -100000000000;
+ ModelHighAPI_Double myDouble = std::numeric_limits<double>::lowest() ;
std::string myValue;
ModelHighAPI_Selection mySelection;
AttributeSelectionPtr mySelectionAttr;
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<double>::lowest()) {
theDoubleArgs.push_back(anIt->dble());
}
else if (anIt->string().empty()) {
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Wire.h>
-#include <GeomAlgoAPI_ContinuousFaces.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <map>
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);
}
}
if (myCachedShapes.empty()) {
- ResultBodyPtr aBaseResult = ModelAPI_Tools::bodyOwner(aList->value(0)->context(), true);
- if (!aBaseResult.get()) {
- aBaseResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(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<ModelAPI_ResultBody>(aList->value(i)->context());
+ if (!aBaseResult.get())
+ return false;
+ }
+ cacheContinuousFaces(aBaseResult->shape(),
+ const_cast<FiltersPlugin_ContinuousFaces*>(this)->myFaces,
+ const_cast<FiltersPlugin_ContinuousFaces*>(this)->myCachedShapes,anAngle);
}
- cacheContinuousFaces(aBaseResult->shape(),
- const_cast<FiltersPlugin_ContinuousFaces*>(this)->myFaces,
- const_cast<FiltersPlugin_ContinuousFaces*>(this)->myCachedShapes,anAngle);
}
return myCachedShapes.find(theShape) != myCachedShapes.end();
}
#include <GeomAlgoAPI_ShapeTools.h>
-#include <Precision.hxx>
-
#include <map>
-#include <iostream>
+#include <cmath>
bool FiltersPlugin_EdgeSize::isSupported(GeomAPI_Shape::ShapeType theType) const
{
default:
return false;
}
+
+ double aTolerance = 0.0001;
double aLength = anEdge->length();
anAttr = theArgs.argument("comparatorType");
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;
}
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeDouble.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <ModelAPI_Tools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Wire.h>
-#include <GeomAlgoAPI_BasicProperties.h>
-#include <GeomAlgoAPI_ShapeTools.h>
-
-#include <Precision.hxx>
-
#include <map>
-#include <iostream>
+#include <cmath>
bool FiltersPlugin_FaceSize::isSupported(GeomAPI_Shape::ShapeType theType) const
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<ModelAPI_AttributeString>(anAttr);
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;
}
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Wire.h>
-#include <GeomAlgoAPI_ContinuousFaces.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <map>
#include <math.h>
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);
}
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeDouble.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <ModelAPI_Tools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Wire.h>
-#include <GeomAlgoAPI_BasicProperties.h>
-#include <GeomAlgoAPI_ShapeTools.h>
-
-#include <Precision.hxx>
-
#include <map>
-#include <iostream>
-
+#include <cmath>
bool FiltersPlugin_VolumeSize::isSupported(GeomAPI_Shape::ShapeType theType) const
{
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<ModelAPI_AttributeString>(anAttr);
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;
}
GeomAlgoAPI_Prism.h
GeomAlgoAPI_Revolution.h
GeomAlgoAPI_Boolean.h
- GeomAlgoAPI_BasicProperties.h
GeomAlgoAPI_ThroughAll.h
GeomAlgoAPI_Rotation.h
GeomAlgoAPI_Translation.h
GeomAlgoAPI_XAOImport.h
GeomAlgoAPI_Copy.h
GeomAlgoAPI_ConeSegment.h
- GeomAlgoAPI_ContinuousFaces.h
GeomAlgoAPI_Ellipsoid.h
GeomAlgoAPI_Symmetry.h
GeomAlgoAPI_Scale.h
GeomAlgoAPI_Prism.cpp
GeomAlgoAPI_Revolution.cpp
GeomAlgoAPI_Boolean.cpp
- GeomAlgoAPI_BasicProperties.cpp
GeomAlgoAPI_ThroughAll.cpp
GeomAlgoAPI_Rotation.cpp
GeomAlgoAPI_Translation.cpp
GeomAlgoAPI_XAOImport.cpp
GeomAlgoAPI_Copy.cpp
GeomAlgoAPI_ConeSegment.cpp
- GeomAlgoAPI_ContinuousFaces.cpp
GeomAlgoAPI_Ellipsoid.cpp
GeomAlgoAPI_Symmetry.cpp
GeomAlgoAPI_Scale.cpp
+++ /dev/null
-// 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 <GProp_GProps.hxx>
-#include <TopoDS_Shape.hxx>
-#include <BRepGProp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <Standard_ErrorHandler.hxx>
-
-//=================================================================================================
-bool GetBasicProperties(const std::shared_ptr<GeomAPI_Shape>& 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<TopoDS_Shape>();
-
- //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;
-}
+++ /dev/null
-// 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 <GeomAlgoAPI.h>
-#include <GeomAPI_Shape.h>
-#include <Standard_TypeDef.hxx>
-
-/// 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<GeomAPI_Shape>& theShape,
- const Standard_Real theTolerance,
- Standard_Real& theLength,
- Standard_Real& theSurfArea,
- Standard_Real& theVolume,
- std::string& theError);
-
-#endif
+++ /dev/null
-// 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 <TopoDS_Shape.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-#include <LocalAnalysis_SurfaceContinuity.hxx>
-#include <ShapeAnalysis_Surface.hxx>
-#include <gp_Pnt.hxx>
-
-#include <Standard_ErrorHandler.hxx>
-
-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<gp_Pnt>();
-
- // Getting base shape.
- if (!theFace1.get()) {
- theError = "isContinuousFaces : An invalid argument";
- return false;
- }
-
- TopoDS_Shape aShape1 = theFace1->impl<TopoDS_Shape>();
-
- 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<TopoDS_Shape>();
-
- 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;
-}
+++ /dev/null
-// 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 <GeomAlgoAPI.h>
-#include <GeomAPI_Shape.h>
-#include <Standard_TypeDef.hxx>
-#include <GeomAPI_Pnt.h>
-
-/// 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_
#include <NCollection_Vector.hxx>
+#include <LocalAnalysis_SurfaceContinuity.hxx>
+
//==================================================================================================
static GProp_GProps props(const TopoDS_Shape& theShape)
{
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<gp_Pnt>();
+
+ // Getting base shape.
+ if (!theFace1.get()) {
+ theError = "isContinuousFaces : An invalid argument";
+ return false;
+ }
+
+ TopoDS_Shape aShape1 = theFace1->impl<TopoDS_Shape>();
+
+ 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<TopoDS_Shape>();
+
+ 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<GeomAPI_Pnt>
GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape)
#include <GeomAPI_Shape.h>
#include <GeomAPI_Vertex.h>
+#include <GeomAPI_Pnt.h>
#include <map>
#include <set>
#ifdef WIN32
/// \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<GeomAPI_Shape> 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.