mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-15 21:13:07 +05:00
Fix a problem with wrong curvature values
This commit is contained in:
parent
6f7a37a47b
commit
55e7a4baa5
@ -29,14 +29,19 @@ Sphere_1 = geompy.MakeSphereR(R, 'Sphere_1')
|
|||||||
curvature_1 = geompy.CurvatureOnFace(Sph, pXYZ, OX, 'curvature_sph_pXYZ_OX')
|
curvature_1 = geompy.CurvatureOnFace(Sph, pXYZ, OX, 'curvature_sph_pXYZ_OX')
|
||||||
curvature_2 = geompy.CurvatureOnFace(Sph, pXYZ, vZ_XY, 'curvature_sph_pXYZ_vt')
|
curvature_2 = geompy.CurvatureOnFace(Sph, pXYZ, vZ_XY, 'curvature_sph_pXYZ_vt')
|
||||||
curvature_3 = geompy.CurvatureOnFace(Sph, pY, OX, 'curvature_sph_pY_OX')
|
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
|
# All sphere curvature radiuces = R
|
||||||
assert(abs(geompy.BasicProperties(curvature_1)[0] - R) < 1e-07)
|
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_2)[0] - R) < 1e-07)
|
||||||
assert(abs(geompy.BasicProperties(curvature_3)[0] - R) < 1e-07)
|
assert(abs(geompy.BasicProperties(curvature_3)[0] - R) < 1e-07)
|
||||||
assert(abs(geompy.BasicProperties(curvature_p)[0] - R) < 1e-07)
|
|
||||||
|
# Pole
|
||||||
|
isExcept = False
|
||||||
|
try:
|
||||||
|
geompy.CurvatureOnFace(Sph, pZ, OX)
|
||||||
|
except:
|
||||||
|
isExcept = True
|
||||||
|
assert(isExcept)
|
||||||
|
|
||||||
# Normal direction
|
# Normal direction
|
||||||
isExcept = False
|
isExcept = False
|
||||||
|
@ -118,49 +118,47 @@ TopoDS_Shape EvaluateAlongCurvature(const TopoDS_Shape& theFace,
|
|||||||
("Curvature calculation failed: normal direction is not defined");
|
("Curvature calculation failed: normal direction is not defined");
|
||||||
|
|
||||||
// Get differential properties
|
// Get differential properties
|
||||||
gp_Vec Xu = Props.D1U();
|
gp_Vec n = Props.Normal();
|
||||||
gp_Vec Xv = Props.D1V();
|
if (aV.IsParallel(n, Precision::Angular()))
|
||||||
gp_Vec Xuu = Props.D2U();
|
|
||||||
gp_Vec Xuv = Props.DUV();
|
|
||||||
gp_Vec Xvv = Props.D2V();
|
|
||||||
gp_Vec n = Props.Normal();
|
|
||||||
|
|
||||||
// Direction in 2d
|
|
||||||
gp_Dir aDirU (Xu);
|
|
||||||
gp_Dir aDirV (Xv);
|
|
||||||
gp_Vec2d T (aV.Dot(aDirU), aV.Dot(aDirV));
|
|
||||||
if (Abs(T.X()) < Precision::Confusion() &&
|
|
||||||
Abs(T.Y()) < Precision::Confusion())
|
|
||||||
Standard_ConstructionError::Raise
|
Standard_ConstructionError::Raise
|
||||||
("Curvature calculation failed: direction is normal to the face");
|
("Curvature calculation failed: direction is normal to the face");
|
||||||
|
|
||||||
// Coefficients of the FFF
|
if (!Props.IsCurvatureDefined())
|
||||||
double E = Xu.Dot(Xu);
|
Standard_ConstructionError::Raise
|
||||||
double F = Xu.Dot(Xv);
|
("Curvature calculation failed: curvature is not defined");
|
||||||
double G = Xv.Dot(Xv);
|
|
||||||
|
|
||||||
// Coefficients of the SFF
|
// Curvature
|
||||||
double L = n.Dot(Xuu);
|
Standard_Real k = 0.;
|
||||||
double M = n.Dot(Xuv);
|
|
||||||
double N = n.Dot(Xvv);
|
|
||||||
|
|
||||||
// Calculate radius (or -radius) of curvature
|
if (Props.IsUmbilic()) {
|
||||||
// using the coefficients of both fundamental forms
|
k = Props.MaxCurvature();
|
||||||
double r = 0.;
|
|
||||||
if (Abs(T.X()) < Precision::Confusion()) {
|
|
||||||
if (Abs(N) < Precision::Confusion())
|
|
||||||
Standard_Failure::Raise("ZERO_CURVATURE");
|
|
||||||
r = G / N;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double lambda = T.Y() / T.X();
|
gp_Dir aMaxDir, aMinDir;
|
||||||
double detE = E + 2*F*lambda + G*lambda*lambda;
|
Props.CurvatureDirections(aMaxDir, aMinDir);
|
||||||
double detL = L + 2*M*lambda + N*lambda*lambda;
|
|
||||||
if (Abs(detL) < Precision::Confusion())
|
gp_Vec2d T (aV.Dot(aMinDir), aV.Dot(aMaxDir));
|
||||||
Standard_Failure::Raise("ZERO_CURVATURE");
|
if (Abs(T.X()) < Precision::Confusion() &&
|
||||||
r = detE / detL;
|
Abs(T.Y()) < Precision::Confusion())
|
||||||
|
Standard_ConstructionError::Raise
|
||||||
|
("Curvature calculation failed: direction is normal to the face");
|
||||||
|
gp_Dir2d aDirT (T);
|
||||||
|
Standard_Real cosAlpha = aDirT.X();
|
||||||
|
|
||||||
|
Standard_Real aMinCurv = Props.MinCurvature();
|
||||||
|
Standard_Real aMaxCurv = Props.MaxCurvature();
|
||||||
|
|
||||||
|
// Euler formula: k = k1 * cos^2(alpha) + k2 * sin^2(alpha)
|
||||||
|
// k = k2 + (k1 - k2) * cos^2(alpha)
|
||||||
|
k = aMaxCurv + (aMinCurv - aMaxCurv) * cosAlpha * cosAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Abs(k) < Precision::Confusion())
|
||||||
|
Standard_Failure::Raise("ZERO_CURVATURE");
|
||||||
|
|
||||||
|
// Radius or -radius of curvature
|
||||||
|
Standard_Real r = 1.0 / k;
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
gp_Dir aNormal (n);
|
gp_Dir aNormal (n);
|
||||||
gp_Pnt aPntEnd (aPnt.XYZ() + aNormal.XYZ() * r);
|
gp_Pnt aPntEnd (aPnt.XYZ() + aNormal.XYZ() * r);
|
||||||
|
Loading…
Reference in New Issue
Block a user