From: jfa Date: Wed, 17 Aug 2022 13:37:01 +0000 (+0300) Subject: Provide compatibility with old OCCT versions X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4ce47452dea9c184a3f1fba286139408026d046c;p=modules%2Fgeom.git Provide compatibility with old OCCT versions --- diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx index 9eada6310..7965b41a5 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx @@ -25,6 +25,8 @@ #include +#include + #include #include #include @@ -87,7 +89,6 @@ #include #include #include -//#include #include #include @@ -1058,6 +1059,9 @@ Standard_Integer GEOMAlgo_AlgoTools::PointCloudInFace(const TopoDS_Face& theFace const int theNbPnts, TopoDS_Compound& theCompound) { +#if OCC_VERSION_LARGE < 0x07050304 + return -1; +#else ShapeUpgrade_ShapeDivideArea tool (theFace); tool.SetSplittingByNumber (Standard_True); tool.NbParts() = theNbPnts; @@ -1199,6 +1203,7 @@ Standard_Integer GEOMAlgo_AlgoTools::PointCloudInFace(const TopoDS_Face& theFace } return 0; +#endif } Standard_Boolean comp(const std::pair& theA, @@ -1531,6 +1536,9 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, Standard_Integer aNbFacesInLocalResult; if (aNumberToSplit > 1) { +#if OCC_VERSION_LARGE < 0x07050304 + aNbFacesInLocalResult = 0; +#else ShapeUpgrade_ShapeDivideArea aLocalTool (aUnifiedShape); aLocalTool.SetSplittingByNumber (Standard_True); aLocalTool.MaxArea() = -1; @@ -1541,6 +1549,7 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, aLocalTool.Perform(); aLocalResult = aLocalTool.Result(); aNbFacesInLocalResult = aNumberToSplit; +#endif } else { @@ -1605,6 +1614,9 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, Standard_Integer aNumberToSplit = (theIsToAddFaces)? aMaxNbFaces + (aDiff-aSum) : aMaxNbFaces - (aDiff-aSum); if (aNumberToSplit > 1) { +#if OCC_VERSION_LARGE < 0x07050304 + aNumberToSplit = 1; +#else ShapeUpgrade_ShapeDivideArea aLocalTool (aUnifiedShape); aLocalTool.SetSplittingByNumber (Standard_True); aLocalTool.MaxArea() = -1; @@ -1614,6 +1626,7 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, aLocalTool.SetNumbersUVSplits (1, aNumberToSplit); aLocalTool.Perform(); aLocalResult = aLocalTool.Result(); +#endif } else aNumberToSplit = 1; diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 313661168..e7c2516e3 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -22,6 +22,8 @@ #include +#include + #include #include #include @@ -57,6 +59,7 @@ #include #include +#include //======================================================================= //function : GetID @@ -318,8 +321,13 @@ Standard_Integer GEOMImpl_PointDriver::Execute(Handle(TFunction_Logbook)& log) c } else { - GEOMAlgo_AlgoTools::PointCloudInFace (F, aNbPnts, aCompound); +#if OCC_VERSION_LARGE < 0x07050304 + Standard_NotImplemented::Raise("Point cloud creation aborted. Improper OCCT version: please, use OCCT 7.5.3p4 or newer."); +#else + if (GEOMAlgo_AlgoTools::PointCloudInFace(F, aNbPnts, aCompound) < 0) + Standard_ConstructionError::Raise("Point cloud creation aborted : algorithm failed"); retCompound = true; +#endif } } else if (aType == POINT_LINES_INTERSECTION) { diff --git a/test/test_point_cloud_on_face.py b/test/test_point_cloud_on_face.py index d31d6536a..490a83cdf 100644 --- a/test/test_point_cloud_on_face.py +++ b/test/test_point_cloud_on_face.py @@ -12,11 +12,15 @@ Sphere = geompy.MakeSphereR(10, "Sphere") [Face] = geompy.ExtractShapes(Sphere, geompy.ShapeType["FACE"], True, "Sphere_face") # make a cloud of 100 points on the spherical face -CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices") - -# check result -nb_vert = geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) -assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100) +try: + CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices") +except Exception as err: + print(err) + # this test should not fail in case of "Improper OCCT version" + assert("Improper OCCT version" in str(err)) +else: + # check result + assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100) # test point cloud on a "Horse saddle" OX = geompy.MakeVectorDXDYDZ(1, 0, 0, 'OX') @@ -30,5 +34,11 @@ Translation_3 = geompy.MakeTranslation(Translation_2, 0, -200, 0, 'Translation_3 Filling_1 = geompy.MakeFilling([Translation_2, Edge_3, Translation_3]) geompy.addToStudy(Filling_1, 'Filling_1') -PointCloudOnFilling = geompy.MakeVertexInsideFace(Face, 30, "PointCloudOnFilling") -assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30) +try: + PointCloudOnFilling = geompy.MakeVertexInsideFace(Filling_1, 30, "PointCloudOnFilling") +except Exception as err: + print(err) + # this test should not fail in case of "Improper OCCT version" + assert("Improper OCCT version" in str(err)) +else: + assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30)