]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide compatibility with old OCCT versions jgv/29470
authorjfa <jfa@opencascade.com>
Wed, 17 Aug 2022 13:44:01 +0000 (16:44 +0300)
committerjfa <jfa@opencascade.com>
Wed, 17 Aug 2022 13:44:01 +0000 (16:44 +0300)
src/FeaturesPlugin/Test/TestPointCloud.py
src/GeomAlgoAPI/GeomAlgoAPI_PointCloudOnFace.cpp

index 74ed5073d22174a6c8451201b6a44fcd019a5c1b..69fb706553fd732609b81d9146853bfb1b137b79 100644 (file)
@@ -40,11 +40,17 @@ PC_1 = model.makeVertexInsideFace(Part_1_doc, model.selection("FACE", "Sphere_1_
 model.end()
 
 ### Check result
-model.testNbResults(PC_1, 1)
-model.testNbSubResults(PC_1, [0])
-model.testNbSubShapes(PC_1, GeomAPI_Shape.SOLID, [0])
-model.testNbSubShapes(PC_1, GeomAPI_Shape.FACE, [0])
-model.testNbSubShapes(PC_1, GeomAPI_Shape.EDGE, [0])
-model.testNbSubShapes(PC_1, GeomAPI_Shape.VERTEX, [100])
-
-assert(model.checkPythonDump())
+err = PC_1.feature().error()
+if err != "":
+    print(err)
+    # this test should not fail with old OCCT
+    assert("Improper OCCT version" in err)
+else:
+    model.testNbResults(PC_1, 1)
+    model.testNbSubResults(PC_1, [0])
+    model.testNbSubShapes(PC_1, GeomAPI_Shape.SOLID, [0])
+    model.testNbSubShapes(PC_1, GeomAPI_Shape.FACE, [0])
+    model.testNbSubShapes(PC_1, GeomAPI_Shape.EDGE, [0])
+    model.testNbSubShapes(PC_1, GeomAPI_Shape.VERTEX, [100])
+
+    assert(model.checkPythonDump())
index ed135f46745e6a43051e74f6c2752a321e2ef735..2e71f82a64003447443ac45c9e80e455bd9bb874 100644 (file)
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <TopTools_DataMapOfShapeReal.hxx>
 
+#include <Standard_Version.hxx>
+// code from KERNEL_SRC/src/Basics/Basics_OCCTVersion.hxx
+#ifdef OCC_VERSION_SERVICEPACK
+#  define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
+#else
+#  ifdef OCC_VERSION_DEVELOPMENT
+#    define OCC_VERSION_LARGE ((OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)-1)
+#  else
+#    define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
+#  endif
+#endif
+
 #include <algorithm>
 
 Standard_Boolean comp(const std::pair<TopoDS_Shape, Standard_Real>& theA,
@@ -377,9 +389,12 @@ void ModifyFacesForGlobalResult(const TopoDS_Face&     theInputFace,
     TopoDS_Shape aUnifiedShape = aUnifier.Shape();
     //Splitting
     TopoDS_Shape aLocalResult = aUnifiedShape;
-    Standard_Integer aNbFacesInLocalResult;
+    Standard_Integer aNbFacesInLocalResult = 1;
     if (aNumberToSplit > 1)
     {
+#if OCC_VERSION_LARGE < 0x07050304
+      aNbFacesInLocalResult = 1;
+#else
       ShapeUpgrade_ShapeDivideArea aLocalTool (aUnifiedShape);
       aLocalTool.SetSplittingByNumber (Standard_True);
       aLocalTool.MaxArea() = -1;
@@ -390,10 +405,10 @@ void ModifyFacesForGlobalResult(const TopoDS_Face&     theInputFace,
       aLocalTool.Perform();
       aLocalResult = aLocalTool.Result();
       aNbFacesInLocalResult = aNumberToSplit;
+#endif
     }
     else
     {
-      aNbFacesInLocalResult = 1;
       if (aNumberToSplit == 0)
       {
         theExtremalFaces.Add (theFacesAndAreas[theNbExtremalFaces].first);
@@ -454,6 +469,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;
@@ -463,6 +481,7 @@ void ModifyFacesForGlobalResult(const TopoDS_Face&     theInputFace,
         aLocalTool.SetNumbersUVSplits (1, aNumberToSplit);
       aLocalTool.Perform();
       aLocalResult = aLocalTool.Result();
+#endif
     }
     else
       aNumberToSplit = 1;
@@ -482,9 +501,14 @@ bool GeomAlgoAPI_PointCloudOnFace::PointCloud(GeomShapePtr theFace,
                                               GeomShapePtr thePoints,
                                               std::string& theError)
 {
-  #ifdef _DEBUG
+#ifdef _DEBUG
   std::cout << "GeomAlgoAPI_PointCloudOnFace::PointCloud" << std::endl;
-  #endif
+#endif
+
+#if OCC_VERSION_LARGE < 0x07050304
+  theError = "Improper OCCT version: please, use OCCT 7.5.3p4 or newer.";
+  return false;
+#else
 
   if (!theFace.get()) {
     theError = "Face for point cloud calculation is null";
@@ -644,4 +668,5 @@ bool GeomAlgoAPI_PointCloudOnFace::PointCloud(GeomShapePtr theFace,
   thePoints->setImpl(new TopoDS_Shape(aCompound));
 
   return true;
+#endif
 }