From ad427fadef9559a6b53589a28060c67bb2811321 Mon Sep 17 00:00:00 2001 From: Konstantin Leontev Date: Fri, 25 Oct 2024 16:41:33 +0100 Subject: [PATCH] [bos #43278][EDF 25230] MakeVertexInsideFace too long. Added ShapeFix for result created by ShapeUpgrade_ShapeDivideArea. --- src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx | 19 +++++++++++++++++++ test/test_point_cloud_on_face_cone.py | 27 +++++++++++++++++++++++++++ test/tests.set | 1 + 3 files changed, 47 insertions(+) create mode 100644 test/test_point_cloud_on_face_cone.py diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx index 7e9cc0b1b..19ef49b49 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx @@ -101,6 +101,7 @@ #include #include +#include #include @@ -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 index 000000000..dffe8ca45 --- /dev/null +++ b/test/test_point_cloud_on_face_cone.py @@ -0,0 +1,27 @@ +# Point Cloud on Face Cone + +from salome.geom import geomBuilder +geompy = geomBuilder.New() + +# Create one closed cone face +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cone_1 = geompy.MakeConeR1R2H(50, 100, 50) +[Face_1] = geompy.SubShapes(Cone_1, [3]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cone_1, 'Cone_1' ) +geompy.addToStudyInFather( Cone_1, Face_1, 'Face_1' ) + +# Make a cloud of given number of points in range 1-30 on the cone face +try: + for i in range(1, 31): + PointCloudOnFilling = geompy.MakeVertexInsideFace(Face_1, i, "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)) diff --git a/test/tests.set b/test/tests.set index 417fe1771..43b912ab2 100644 --- a/test/tests.set +++ b/test/tests.set @@ -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 -- 2.39.2