]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Provide compatibility with old OCCT versions jgv/29470
authorjfa <jfa@opencascade.com>
Wed, 17 Aug 2022 13:37:01 +0000 (16:37 +0300)
committerjfa <jfa@opencascade.com>
Wed, 17 Aug 2022 13:37:01 +0000 (16:37 +0300)
src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx
src/GEOMImpl/GEOMImpl_PointDriver.cxx
test/test_point_cloud_on_face.py

index 9eada6310fca079191ff84dfbea4cdf1dd9f6caf..7965b41a5abcd1ed6f72bcbcf847ceaaf275c97f 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <GEOMAlgo_AlgoTools.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Dir2d.hxx>
@@ -87,7 +89,6 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_DataMapOfShapeReal.hxx>
-//#include <TColgp_Array1OfPnt.hxx>
 #include <TColgp_SequenceOfPnt2d.hxx>
 
 #include <TopTools_ListIteratorOfListOfShape.hxx>
@@ -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<TopoDS_Shape, Standard_Real>& 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;
index 313661168085ebe23c5d4e9fc0068f76cee6d2fb..e7c2516e3948f0699f0bc8fb54853eca5186a430 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <Standard_Stream.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <GEOMImpl_PointDriver.hxx>
 #include <GEOMImpl_IPoint.hxx>
 #include <GEOMImpl_Types.hxx>
@@ -57,6 +59,7 @@
 #include <Precision.hxx>
 
 #include <Standard_NullObject.hxx>
+#include <Standard_NotImplemented.hxx>
 
 //=======================================================================
 //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) {
index d31d6536a59267214666524ad6c80d0b5dfbb6ca..490a83cdf163f26938068ffdd3bf82e8ebc486c0 100644 (file)
@@ -12,11 +12,15 @@ Sphere = geompy.MakeSphereR(10, "Sphere")
 [Face] = geompy.ExtractShapes(Sphere, geompy.ShapeType["FACE"], True, "Sphere_face")\r
 \r
 # make a cloud of 100 points on the spherical face\r
-CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices")\r
-\r
-# check result\r
-nb_vert = geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"])\r
-assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100)\r
+try:\r
+    CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices")\r
+except Exception as err:\r
+    print(err)\r
+    # this test should not fail in case of "Improper OCCT version"\r
+    assert("Improper OCCT version" in str(err))\r
+else:\r
+    # check result\r
+    assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100)\r
 \r
 # test point cloud on a "Horse saddle"\r
 OX = geompy.MakeVectorDXDYDZ(1, 0, 0, 'OX')\r
@@ -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])\r
 geompy.addToStudy(Filling_1, 'Filling_1')\r
 \r
-PointCloudOnFilling = geompy.MakeVertexInsideFace(Face, 30, "PointCloudOnFilling")\r
-assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30)\r
+try:\r
+    PointCloudOnFilling = geompy.MakeVertexInsideFace(Filling_1, 30, "PointCloudOnFilling")\r
+except Exception as err:\r
+    print(err)\r
+    # this test should not fail in case of "Improper OCCT version"\r
+    assert("Improper OCCT version" in str(err))\r
+else:\r
+    assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30)\r