]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #43278][EDF 25230] MakeVertexInsideFace too long. Added ShapeFix for result... kleontev/43278_MakeVertexInsideFace_too_long V9_14_0a1 74/head
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 25 Oct 2024 15:44:53 +0000 (16:44 +0100)
committerKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Tue, 29 Oct 2024 11:03:10 +0000 (11:03 +0000)
src/FeaturesPlugin/Test/TestPointCloud_Cone.py [new file with mode: 0644]
src/FeaturesPlugin/tests.set
src/GeomAlgoAPI/GeomAlgoAPI_PointCloudOnFace.cpp
src/GeomAlgoImpl/GEOMAlgo_AlgoTools.cxx

diff --git a/src/FeaturesPlugin/Test/TestPointCloud_Cone.py b/src/FeaturesPlugin/Test/TestPointCloud_Cone.py
new file mode 100644 (file)
index 0000000..abe256a
--- /dev/null
@@ -0,0 +1,47 @@
+# Copyright (C) 2014-2024  CEA, EDF
+#
+# 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
+#
+
+"""
+      Unit test of makeVertexInsideFace with a cone
+"""
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 50, 100, 50)
+
+# Make a cloud of given number of points in range 1-30 on the cone face
+for i in range(1, 31):
+    model.do()
+    PC_1 = model.makeVertexInsideFace(Part_1_doc, model.selection("FACE", "Cone_1_1/Face_1"), i)
+
+    ### Check result
+    err = PC_1.feature().error()
+    if err != "":
+        print(err)
+        # this test should not fail with old OCCT
+        assert("Improper OCCT version" in err)
+        break
+    else:
+        assert(model.checkPythonDump())
+
+model.end()
index 2611fad2e9d75172be9a6152faf7a146ec602765..25a67737eec715f51497082786dfd83495113ddb 100644 (file)
@@ -525,6 +525,7 @@ SET(TEST_NAMES_PARA
                Test20247.py
                Test22847.py
                TestPointCoordinates.py
+               TestPointCloud_Cone.py
                TestPointCloud.py
                TestGeometryCalculation.py
                TestBoundingBox.py
index 8a49805cd920d852aaeb911c67e097d28c63f7b7..fefb1645bdb88cf5e41f2da207a0467d40f63e35 100644 (file)
@@ -41,6 +41,7 @@
 #include <ShapeAnalysis_Surface.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
 #include <ShapeUpgrade_ShapeDivideArea.hxx>
+#include <ShapeFix.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepAdaptor_Curve2d.hxx>
 #include <BRepBndLib.hxx>
@@ -145,6 +146,13 @@ gp_Pnt GetMidPnt2d(const TopoDS_Face&     theFace,
       const TopoDS_Edge& anEdge = aWexp.Current();
       if (!aUsedEmap.Add(anEdge)) continue;
       BRepAdaptor_Curve2d aBAcurve2d (anEdge, theFace);
+      // Initialization of curve could fail in constructor,
+      // so we need to check if we actually have a curve here.
+      if (!aBAcurve2d.Curve())
+      {
+        continue;
+      }
+
       Standard_Real aDelta = (aBAcurve2d.LastParameter() - aBAcurve2d.FirstParameter())/aNbSamples;
       for (Standard_Integer ii = 0; ii < aNbSamples; ii++)
       {
@@ -426,6 +434,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
     }
@@ -505,6 +519,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
@@ -553,6 +572,13 @@ bool GeomAlgoAPI_PointCloudOnFace::PointCloud(GeomShapePtr theFace,
   tool.NbParts() = theNumberOfPoints;
   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;
index e79ecdffbdeb2321dbb3d173e163d0346ef15846..c3eaf8edc4794f9d66c82f1c4a8dc8de81accefb 100644 (file)
 
 #include <ShapeUpgrade_ShapeDivideArea.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <ShapeFix.hxx>
 
 #include <GEOMAlgo_PassKeyShape.hxx>
 
@@ -1016,6 +1017,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;
@@ -1236,6 +1244,13 @@ gp_Pnt GetMidPnt2d(const TopoDS_Face&     theFace,
     {
       const TopoDS_Edge& anEdge = aWexp.Current();
       BRepAdaptor_Curve2d aBAcurve2d (anEdge, theFace);
+      // Initialization of curve could fail in constructor,
+      // so we need to check if we actually have a curve here.
+      if (!aBAcurve2d.Curve())
+      {
+        continue;
+      }
+
       Standard_Real aDelta = (aBAcurve2d.LastParameter() - aBAcurve2d.FirstParameter())/aNbSamples;
       for (Standard_Integer ii = 0; ii < aNbSamples; ii++)
       {
@@ -1497,6 +1512,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
     }
@@ -1575,6 +1596,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