--- /dev/null
+# 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()
Test20247.py
Test22847.py
TestPointCoordinates.py
+ TestPointCloud_Cone.py
TestPointCloud.py
TestGeometryCalculation.py
TestBoundingBox.py
#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>
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++)
{
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
}
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
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;
#include <ShapeUpgrade_ShapeDivideArea.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <ShapeFix.hxx>
#include <GEOMAlgo_PassKeyShape.hxx>
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;
{
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++)
{
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
}
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