break;
case PrimitiveType::Cylinder:
isMatching = fabs(areas->getAdimKdiff0(areaId) -
- nodes->getAdimKdiff0(nodeId)) < EPSILON_PROP;
+ nodes->getAdimKdiff0(nodeId)) < TOL_MATCH_CYLINDER;
break;
case PrimitiveType::Cone:
case PrimitiveType::Unknown:
double distanceToCenter = distanceToSphere(
nodes->getCoordinates(nodeId),
areas->getCenter(areaId));
- isClose = fabs(distanceToCenter - areas->getRadius(areaId)) < DELTA_SPHERE;
+ double radius = areas->getRadius(areaId);
+ isClose = fabs((distanceToCenter - radius) / radius) < DELTA_SPHERE;
}
break;
case PrimitiveType::Cylinder:
break;
case PrimitiveType::Cone:
{
+ double radius = areas->getRadius(areaId);
isClose = distanceToCone(
nodes->getCoordinates(nodeId),
areas->getAxis(areaId),
areas->getApex(areaId),
- areas->getAngle(areaId),
- areas->getRadius(areaId)) < DELTA_CONE;
+ areas->getAngle(areaId)) /
+ fabs(radius) <
+ DELTA_CONE;
}
break;
case PrimitiveType::Torus:
const std::array<double, 3> &nodeCoords,
const std::array<double, 3> &axis,
const std::array<double, 3> &apex,
- double angle,
- double radius)
+ double angle)
{
std::array<double, 3> ps{
apex[0] - nodeCoords[0],
double a = MathOps::computeNorm(
MathOps::cross(ps, v));
double b = MathOps::dot(ps, v);
- return fabs(a * cos(angle) - b * sin(angle)) / fabs(radius);
+ return fabs(a * cos(angle) - b * sin(angle));
}
const std::array<double, 3> &nodeCoords,
const std::array<double, 3> &axis,
const std::array<double, 3> &apex,
- double angle,
- double radius);
+ double angle);
const Nodes *nodes;
Areas *areas;
PrimitiveType NodeCurvatureCalculator::findPrimitiveType(double k1, double k2, double kdiff0, double kis0) const
{
- if ((fabs(k1 - k2) < EPSILON_SC) && (fabs((k1 + k2) / 2) < EPSILON_PL))
+ if ((fabs(k1 - k2) < EPSILON_PRIMITIVE) && (fabs((k1 + k2) / 2) < EPSILON_PRIMITIVE))
return PrimitiveType::Plane;
- else if ((fabs(k1 - k2) < EPSILON_SC) && (fabs((k1 + k2) / 2) > EPSILON_PL))
+ else if ((fabs(k1 - k2) < EPSILON_PRIMITIVE) && (fabs((k1 + k2) / 2) > EPSILON_PRIMITIVE))
return PrimitiveType::Sphere;
- else if ((fabs(kdiff0) > EPSILON_CY) && (fabs(kis0) < EPSILON_CY))
+ else if ((fabs(kdiff0) > EPSILON_PRIMITIVE) && (fabs(kis0) < EPSILON_PRIMITIVE))
return PrimitiveType::Cylinder;
- else if ((fabs(k1) > EPSILON_CY) && (fabs(k2) > EPSILON_CY))
+ else if ((fabs(k1) > EPSILON_PRIMITIVE) && (fabs(k2) > EPSILON_PRIMITIVE))
return PrimitiveType::Torus;
else
return PrimitiveType::Unknown;
namespace MEDCoupling
{
// Nodes
- constexpr double EPSILON_SC = 0.005; // For |k1 - k2|
- constexpr double EPSILON_PL = 0.001; // For |k1 + k2| / 2 = 1 / R
- constexpr double EPSILON_CY = 0.005; // For k1 or k2
+ constexpr double EPSILON_PRIMITIVE = 0.05;
// Areas
- constexpr double EPSILON_PROP = 0.05;
- constexpr double DELTA_PLANE = 0.01;
- constexpr double DELTA_SPHERE = 0.1;
- constexpr double DELTA_CYLINDER = 0.02;
+ // - Match
+ constexpr double TOL_MATCH_CYLINDER = 0.05;
+ constexpr double TOL_MATCH_SPHERE = 0.05;
+ // - Relative distance
+ constexpr double DELTA_PLANE = 0.05;
+ constexpr double DELTA_SPHERE = 0.05;
+ constexpr double DELTA_CYLINDER = 0.05;
constexpr double DELTA_CONE = 0.05;
+ // - Invalid Zones
constexpr double THETA_MAX_CYLINDER = 0.05;
- constexpr double TOL_MATCH_SPHERE = 0.1;
+ // - Thresholds
constexpr int THRESHOLD_MIN_NB_NODES = 5;
constexpr int THRESHOLD_MAX_NB_AREAS = 500;
};