From 6f7a37a47b9b5d5afdef7625f7577ae95092e305 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 15 Jun 2022 18:34:27 +0300 Subject: [PATCH] Debug --- doc/salome/examples/curvature_face.py | 12 +++--------- src/GEOMImpl/GEOMImpl_MeasureDriver.cxx | 5 +++-- src/GEOM_SWIG/GEOM_TestAll.py | 7 +++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/doc/salome/examples/curvature_face.py b/doc/salome/examples/curvature_face.py index d3962204d..327a70750 100644 --- a/doc/salome/examples/curvature_face.py +++ b/doc/salome/examples/curvature_face.py @@ -29,11 +29,14 @@ Sphere_1 = geompy.MakeSphereR(R, 'Sphere_1') curvature_1 = geompy.CurvatureOnFace(Sph, pXYZ, OX, 'curvature_sph_pXYZ_OX') curvature_2 = geompy.CurvatureOnFace(Sph, pXYZ, vZ_XY, 'curvature_sph_pXYZ_vt') curvature_3 = geompy.CurvatureOnFace(Sph, pY, OX, 'curvature_sph_pY_OX') +# Pole +curvature_p = geompy.CurvatureOnFace(Sph, pZ, OX, 'curvature_sph_pZ_OX') # All sphere curvature radiuces = R assert(abs(geompy.BasicProperties(curvature_1)[0] - R) < 1e-07) assert(abs(geompy.BasicProperties(curvature_2)[0] - R) < 1e-07) assert(abs(geompy.BasicProperties(curvature_3)[0] - R) < 1e-07) +assert(abs(geompy.BasicProperties(curvature_p)[0] - R) < 1e-07) # Normal direction isExcept = False @@ -43,15 +46,6 @@ except: isExcept = True assert(isExcept) -# Pole (min and max curvatures are not defined, find via line projection?) -isExcept = False -try: - geompy.CurvatureOnFace(Sph, pZ, OX, 'curvature_sph_pZ_OX') -except: - isExcept = True - print(geompy.MeasuOp.GetErrorCode()) -assert(isExcept) - # II. Curvature of a Cylinder Cylinder_1 = geompy.MakeCylinderRH(R, 300, 'Cylinder_1') [Face_1,Face_2,Face_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["FACE"], True, "Face") diff --git a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx index 059c891da..4a5780999 100644 --- a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx @@ -113,8 +113,9 @@ TopoDS_Shape EvaluateAlongCurvature(const TopoDS_Shape& theFace, // Calculate differential properties BRepAdaptor_Surface aSurfAdapt (aFace); BRepLProp_SLProps Props (aSurfAdapt, UV.X(), UV.Y(), 2, 1e-7); - if (!Props.IsCurvatureDefined()) - Standard_ConstructionError::Raise("Curvature calculation failed"); + if (!Props.IsNormalDefined()) + Standard_ConstructionError::Raise + ("Curvature calculation failed: normal direction is not defined"); // Get differential properties gp_Vec Xu = Props.D1U(); diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index a6457d4a2..a182836db 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -600,12 +600,15 @@ def TestAll (geompy, math): [Face_1,Face_2,Face_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["FACE"], True, "Face") curvature_1 = geompy.CurvatureOnFace(Face_2, px, vy, 'curvature_cyl_px_vy') assert(abs(geompy.BasicProperties(curvature_1)[0] - 100) < 1e-07) + curvature_zero = geompy.CurvatureOnFace(Face_2, px, vz) + assert(geompy.MeasuOp.GetErrorCode() == "ZERO_CURVATURE") + assert(not curvature_zero) isExcept = False try: - geompy.CurvatureOnFace(Face_2, px, vz) + # p0 is on cylinder axis, projection should fail + geompy.CurvatureOnFace(Face_2, p0, vy) except: isExcept = True - assert(geompy.MeasuOp.GetErrorCode() == "Curvature radius is infinite") assert(isExcept) print("DONE") -- 2.39.2