]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
[bos #43278][EDF 25230] MakeVertexInsideFace too long. Added ShapeFix for result... kleontev/43278_MakeVertexInsideFace_too_long master 28/head
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 25 Oct 2024 15:41:33 +0000 (16:41 +0100)
committerKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Mon, 4 Nov 2024 15:32:44 +0000 (15:32 +0000)
src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx
test/test_point_cloud_on_face_cone.py [new file with mode: 0644]
test/tests.set

index 7e9cc0b1b5a65eeb69b14724d56e7c91d4b1d1d2..19ef49b49b13aa5001fea5f335ef96cb59d3369e 100644 (file)
 
 #include <ShapeUpgrade_ShapeDivideArea.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <ShapeFix.hxx>
 
 #include <GEOMAlgo_PassKeyShape.hxx>
 
@@ -1015,6 +1016,13 @@ Standard_Integer GEOMAlgo_AlgoTools::PointCloudInFace(const TopoDS_Face& theFace
   tool.NbParts() = theNbPnts;
   tool.Perform();
   TopoDS_Shape res = tool.Result();
+  if (res.IsNull())
+    return -1;
+
+  // Splitting algorithm can produces invalid shapes that results in
+  // infinite loop on ShapeUpgrade_UnifySameDomain::build() call.
+  // Here is a fix from OCCT DRAW: SWDRAW_ShapeUpgrade: splitbynumber().
+  ShapeFix::SameParameter(res, Standard_False);
 
   BRep_Builder aBB;
   TopoDS_Compound aGlobalRes;
@@ -1528,6 +1536,12 @@ void ModifyFacesForGlobalResult(const TopoDS_Face&     theInputFace,
         aLocalTool.SetNumbersUVSplits (1, aNumberToSplit);
       aLocalTool.Perform();
       aLocalResult = aLocalTool.Result();
+
+      // Splitting algorithm can produces invalid shapes that results in
+      // infinite loop on ShapeUpgrade_UnifySameDomain::build() call.
+      // Here is a fix from OCCT DRAW: SWDRAW_ShapeUpgrade: splitbynumber().
+      ShapeFix::SameParameter(aLocalResult, Standard_False);
+
       aNbFacesInLocalResult = aNumberToSplit;
 #endif
     }
@@ -1608,6 +1622,11 @@ void ModifyFacesForGlobalResult(const TopoDS_Face&     theInputFace,
         aLocalTool.SetNumbersUVSplits (1, aNumberToSplit);
       aLocalTool.Perform();
       aLocalResult = aLocalTool.Result();
+
+      // Splitting algorithm can produces invalid shapes that results in
+      // infinite loop on ShapeUpgrade_UnifySameDomain::build() call.
+      // Here is a fix from OCCT DRAW: SWDRAW_ShapeUpgrade: splitbynumber().
+      ShapeFix::SameParameter(aLocalResult, Standard_False);
 #endif
     }
     else
diff --git a/test/test_point_cloud_on_face_cone.py b/test/test_point_cloud_on_face_cone.py
new file mode 100644 (file)
index 0000000..dffe8ca
--- /dev/null
@@ -0,0 +1,27 @@
+# Point Cloud on Face Cone\r
+\r
+from salome.geom import geomBuilder\r
+geompy = geomBuilder.New()\r
+\r
+# Create one closed cone face\r
+O = geompy.MakeVertex(0, 0, 0)\r
+OX = geompy.MakeVectorDXDYDZ(1, 0, 0)\r
+OY = geompy.MakeVectorDXDYDZ(0, 1, 0)\r
+OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)\r
+Cone_1 = geompy.MakeConeR1R2H(50, 100, 50)\r
+[Face_1] = geompy.SubShapes(Cone_1, [3])\r
+geompy.addToStudy( O, 'O' )\r
+geompy.addToStudy( OX, 'OX' )\r
+geompy.addToStudy( OY, 'OY' )\r
+geompy.addToStudy( OZ, 'OZ' )\r
+geompy.addToStudy( Cone_1, 'Cone_1' )\r
+geompy.addToStudyInFather( Cone_1, Face_1, 'Face_1' )\r
+\r
+# Make a cloud of given number of points in range 1-30 on the cone face\r
+try:\r
+    for i in range(1, 31):\r
+        PointCloudOnFilling = geompy.MakeVertexInsideFace(Face_1, i, "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
index 417fe17710e865a9932f91d0cf3a6244f094e643..43b912ab22d15dc38b8e6a9da5144d36803cd5b6 100644 (file)
@@ -24,6 +24,7 @@ SET(ALL_TESTS
 
 IF(${OpenCASCADE_VERSION}.${OpenCASCADE_SP_VERSION} VERSION_GREATER "7.5.3.3")
     LIST(APPEND ALL_TESTS
+      test_point_cloud_on_face_cone.py
       test_point_cloud_on_face.py
       test_CR.py
       test_conformity.py