This commit is contained in:
jfa 2022-06-15 18:34:27 +03:00
parent 2d6c2bb07d
commit 6f7a37a47b
3 changed files with 11 additions and 13 deletions

View File

@ -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")

View File

@ -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();

View File

@ -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")