Mesh: Use std::numeric_limits and std::numbers instead of defines
This commit is contained in:
@@ -295,7 +295,7 @@ float MeshAlgorithm::GetAverageEdgeLength() const
|
||||
|
||||
float MeshAlgorithm::GetMinimumEdgeLength() const
|
||||
{
|
||||
float fLen = FLOAT_MAX;
|
||||
float fLen = std::numeric_limits<float>::max();
|
||||
MeshFacetIterator cF(_rclMesh);
|
||||
for (cF.Init(); cF.More(); cF.Next()) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -785,19 +785,20 @@ bool MeshAlgorithm::FillupHole(const std::vector<PointIndex>& boundary,
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
// Get the new neighbour to our reference facet
|
||||
MeshFacet facet;
|
||||
unsigned short ref_side = rFace.Side(refPoint0, refPoint1);
|
||||
unsigned short tri_side = USHRT_MAX;
|
||||
unsigned short tri_side = max;
|
||||
if (cTria.NeedsReindexing()) {
|
||||
// the referenced indices of the polyline
|
||||
refPoint0 = 0;
|
||||
refPoint1 = 1;
|
||||
}
|
||||
if (ref_side < USHRT_MAX) {
|
||||
if (ref_side < max) {
|
||||
for (const auto& face : faces) {
|
||||
tri_side = face.Side(refPoint0, refPoint1);
|
||||
if (tri_side < USHRT_MAX) {
|
||||
if (tri_side < max) {
|
||||
facet = face;
|
||||
break;
|
||||
}
|
||||
@@ -805,7 +806,7 @@ bool MeshAlgorithm::FillupHole(const std::vector<PointIndex>& boundary,
|
||||
}
|
||||
|
||||
// in case the reference facet has not an open edge print a log message
|
||||
if (ref_side == USHRT_MAX || tri_side == USHRT_MAX) {
|
||||
if (ref_side == max || tri_side == max) {
|
||||
Base::Console().Log(
|
||||
"MeshAlgorithm::FillupHole: Expected open edge for facet <%d, %d, %d>\n",
|
||||
rFace._aulPoints[0],
|
||||
@@ -1461,7 +1462,7 @@ bool MeshAlgorithm::NearestPointFromPoint(const Base::Vector3f& rclPt,
|
||||
}
|
||||
|
||||
// calc each facet
|
||||
float fMinDist = FLOAT_MAX;
|
||||
float fMinDist = std::numeric_limits<float>::max();
|
||||
FacetIndex ulInd = FACET_INDEX_MAX;
|
||||
MeshFacetIterator pF(_rclMesh);
|
||||
for (pF.Init(); pF.More(); pF.Next()) {
|
||||
|
||||
@@ -143,7 +143,7 @@ float PlaneFit::Fit()
|
||||
{
|
||||
_bIsFitted = true;
|
||||
if (CountPoints() < 3) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
double sxx {0.0};
|
||||
@@ -207,7 +207,7 @@ float PlaneFit::Fit()
|
||||
akMat.EigenDecomposition(rkRot, rkDiag);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
// We know the Eigenvalues are ordered
|
||||
@@ -215,7 +215,7 @@ float PlaneFit::Fit()
|
||||
//
|
||||
// points describe a line or even are identical
|
||||
if (rkDiag(1, 1) <= 0) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
Wm4::Vector3<double> U = rkRot.GetColumn(1);
|
||||
@@ -225,7 +225,7 @@ float PlaneFit::Fit()
|
||||
// It may happen that the result have nan values
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (boost::math::isnan(W[i])) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ float PlaneFit::Fit()
|
||||
|
||||
// In case sigma is nan
|
||||
if (boost::math::isnan(sigma)) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
// This must be caused by some round-off errors. Theoretically it's impossible
|
||||
@@ -318,7 +318,7 @@ Base::Vector3f PlaneFit::GetNormal() const
|
||||
|
||||
float PlaneFit::GetDistanceToPlane(const Base::Vector3f& rcPoint) const
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
if (_bIsFitted) {
|
||||
fResult = (rcPoint - _vBase) * _vDirW;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ float PlaneFit::GetStdDeviation() const
|
||||
// Standard deviation: SD=SQRT(VAR)
|
||||
// Standard error of the mean: SE=SD/SQRT(N)
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
float fSumXi = 0.0F, fSumXi2 = 0.0F, fMean = 0.0F, fDist = 0.0F;
|
||||
@@ -356,11 +356,11 @@ float PlaneFit::GetSignedStdDeviation() const
|
||||
// of normal direction the value will be
|
||||
// positive otherwise negative
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
float fSumXi = 0.0F, fSumXi2 = 0.0F, fMean = 0.0F, fDist = 0.0F;
|
||||
float fMinDist = FLOAT_MAX;
|
||||
float fMinDist = std::numeric_limits<float>::max();
|
||||
float fFactor = 0.0F;
|
||||
|
||||
float ulPtCt = float(CountPoints());
|
||||
@@ -426,7 +426,7 @@ void PlaneFit::Dimension(float& length, float& width) const
|
||||
std::vector<Base::Vector3f> PlaneFit::GetLocalPoints() const
|
||||
{
|
||||
std::vector<Base::Vector3f> localPoints;
|
||||
if (_bIsFitted && _fLastResult < FLOAT_MAX) {
|
||||
if (_bIsFitted && _fLastResult < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3d bs = Base::convertTo<Base::Vector3d>(this->_vBase);
|
||||
Base::Vector3d ex = Base::convertTo<Base::Vector3d>(this->_vDirU);
|
||||
Base::Vector3d ey = Base::convertTo<Base::Vector3d>(this->_vDirV);
|
||||
@@ -507,12 +507,12 @@ double QuadraticFit::GetCoeff(std::size_t ulIndex) const
|
||||
return _fCoeff[ulIndex];
|
||||
}
|
||||
|
||||
return double(FLOAT_MAX);
|
||||
return double(std::numeric_limits<float>::max());
|
||||
}
|
||||
|
||||
float QuadraticFit::Fit()
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
|
||||
if (CountPoints() > 0) {
|
||||
std::vector<Wm4::Vector3<double>> cPts;
|
||||
@@ -595,14 +595,14 @@ void QuadraticFit::CalcZValues(double x, double y, double& dZ1, double& dZ2) con
|
||||
- 4 * _fCoeff[6] * _fCoeff[4] * x * x - 4 * _fCoeff[6] * _fCoeff[5] * y * y;
|
||||
|
||||
if (fabs(_fCoeff[6]) < 0.000005) {
|
||||
dZ1 = double(FLOAT_MAX);
|
||||
dZ2 = double(FLOAT_MAX);
|
||||
dZ1 = double(std::numeric_limits<float>::max());
|
||||
dZ2 = double(std::numeric_limits<float>::max());
|
||||
return;
|
||||
}
|
||||
|
||||
if (dDisk < 0.0) {
|
||||
dZ1 = double(FLOAT_MAX);
|
||||
dZ2 = double(FLOAT_MAX);
|
||||
dZ1 = double(std::numeric_limits<float>::max());
|
||||
dZ2 = double(std::numeric_limits<float>::max());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ SurfaceFit::SurfaceFit()
|
||||
|
||||
float SurfaceFit::Fit()
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
|
||||
if (CountPoints() > 0) {
|
||||
fResult = float(PolynomFit());
|
||||
@@ -671,8 +671,8 @@ bool SurfaceFit::GetCurvatureInfo(double x, double y, double z, double& rfCurv0,
|
||||
|
||||
double SurfaceFit::PolynomFit()
|
||||
{
|
||||
if (PlaneFit::Fit() >= FLOAT_MAX) {
|
||||
return double(FLOAT_MAX);
|
||||
if (PlaneFit::Fit() >= std::numeric_limits<float>::max()) {
|
||||
return double(std::numeric_limits<float>::max());
|
||||
}
|
||||
|
||||
Base::Vector3d bs = Base::convertTo<Base::Vector3d>(this->_vBase);
|
||||
@@ -1165,7 +1165,7 @@ void CylinderFit::SetInitialValues(const Base::Vector3f& b, const Base::Vector3f
|
||||
float CylinderFit::Fit()
|
||||
{
|
||||
if (CountPoints() < 7) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
_bIsFitted = true;
|
||||
|
||||
@@ -1180,7 +1180,7 @@ float CylinderFit::Fit()
|
||||
}
|
||||
|
||||
float result = cylFit.Fit();
|
||||
if (result < FLOAT_MAX) {
|
||||
if (result < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3d base = cylFit.GetBase();
|
||||
Base::Vector3d dir = cylFit.GetAxis();
|
||||
|
||||
@@ -1284,7 +1284,7 @@ Base::Vector3f CylinderFit::GetAxis() const
|
||||
|
||||
float CylinderFit::GetDistanceToCylinder(const Base::Vector3f& rcPoint) const
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
if (_bIsFitted) {
|
||||
fResult = rcPoint.DistanceToLine(_vBase, _vAxis) - _fRadius;
|
||||
}
|
||||
@@ -1298,7 +1298,7 @@ float CylinderFit::GetStdDeviation() const
|
||||
// Standard deviation: SD=SQRT(VAR)
|
||||
// Standard error of the mean: SE=SD/SQRT(N)
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
float fSumXi = 0.0F, fSumXi2 = 0.0F, fMean = 0.0F, fDist = 0.0F;
|
||||
@@ -1318,8 +1318,8 @@ float CylinderFit::GetStdDeviation() const
|
||||
|
||||
void CylinderFit::GetBounding(Base::Vector3f& bottom, Base::Vector3f& top) const
|
||||
{
|
||||
float distMin = FLT_MAX;
|
||||
float distMax = FLT_MIN;
|
||||
float distMin = std::numeric_limits<float>::max();
|
||||
float distMax = std::numeric_limits<float>::min();
|
||||
|
||||
std::list<Base::Vector3f>::const_iterator cIt;
|
||||
for (cIt = _vPoints.begin(); cIt != _vPoints.end(); ++cIt) {
|
||||
@@ -1384,7 +1384,7 @@ float SphereFit::GetRadius() const
|
||||
return _fRadius;
|
||||
}
|
||||
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
Base::Vector3f SphereFit::GetCenter() const
|
||||
@@ -1400,7 +1400,7 @@ float SphereFit::Fit()
|
||||
{
|
||||
_bIsFitted = true;
|
||||
if (CountPoints() < 4) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
std::vector<Wm4::Vector3d> input;
|
||||
@@ -1433,7 +1433,7 @@ float SphereFit::Fit()
|
||||
sphereFit.AddPoints(_vPoints);
|
||||
sphereFit.ComputeApproximations();
|
||||
float result = sphereFit.Fit();
|
||||
if (result < FLOAT_MAX) {
|
||||
if (result < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3d center = sphereFit.GetCenter();
|
||||
#if defined(_DEBUG)
|
||||
Base::Console().Message("MeshCoreFit::Sphere Fit: Center: (%0.4f, %0.4f, %0.4f), Radius: "
|
||||
@@ -1455,7 +1455,7 @@ float SphereFit::Fit()
|
||||
|
||||
float SphereFit::GetDistanceToSphere(const Base::Vector3f& rcPoint) const
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
if (_bIsFitted) {
|
||||
fResult = Base::Vector3f(rcPoint - _vCenter).Length() - _fRadius;
|
||||
}
|
||||
@@ -1469,7 +1469,7 @@ float SphereFit::GetStdDeviation() const
|
||||
// Standard deviation: SD=SQRT(VAR)
|
||||
// Standard error of the mean: SE=SD/SQRT(N)
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
float fSumXi = 0.0F, fSumXi2 = 0.0F, fMean = 0.0F, fDist = 0.0F;
|
||||
@@ -1533,7 +1533,7 @@ float PolynomialFit::Fit()
|
||||
}
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
|
||||
@@ -201,7 +201,8 @@ protected:
|
||||
// NOLINTBEGIN
|
||||
std::list<Base::Vector3f> _vPoints; /**< Holds the points for the fit algorithm. */
|
||||
bool _bIsFitted {false}; /**< Flag, whether the fit has been called. */
|
||||
float _fLastResult {FLOAT_MAX}; /**< Stores the last result of the fit */
|
||||
float _fLastResult {
|
||||
std::numeric_limits<float>::max()}; /**< Stores the last result of the fit */
|
||||
// NOLINTEND
|
||||
};
|
||||
|
||||
|
||||
@@ -423,14 +423,14 @@ CurvatureInfo FacetCurvature::Compute(FacetIndex index) const
|
||||
fMax = (float)dMax;
|
||||
}
|
||||
else {
|
||||
fMin = FLT_MAX;
|
||||
fMax = FLT_MAX;
|
||||
fMin = std::numeric_limits<float>::max();
|
||||
fMax = std::numeric_limits<float>::max();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// too few points => cannot calc any properties
|
||||
fMin = FLT_MAX;
|
||||
fMax = FLT_MAX;
|
||||
fMin = std::numeric_limits<float>::max();
|
||||
fMax = std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
CurvatureInfo info;
|
||||
|
||||
@@ -81,7 +81,7 @@ void CylinderFit::SetApproximations(double radius,
|
||||
const Base::Vector3d& axis)
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
_dRadius = radius;
|
||||
_vBase = base;
|
||||
@@ -94,7 +94,7 @@ void CylinderFit::SetApproximations(double radius,
|
||||
void CylinderFit::SetApproximations(const Base::Vector3d& base, const Base::Vector3d& axis)
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
_vBase = base;
|
||||
_vAxis = axis;
|
||||
@@ -168,7 +168,7 @@ int CylinderFit::GetNumIterations() const
|
||||
|
||||
float CylinderFit::GetDistanceToCylinder(const Base::Vector3f& rcPoint) const
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
if (_bIsFitted) {
|
||||
Base::Vector3d pt(rcPoint.x, rcPoint.y, rcPoint.z);
|
||||
fResult = static_cast<float>(pt.DistanceToLine(_vBase, _vAxis) - _dRadius);
|
||||
@@ -182,7 +182,7 @@ float CylinderFit::GetStdDeviation() const
|
||||
// Variance: VAR=(N/N-1)*[(1/N)*SUM(Xi^2)-M^2]
|
||||
// Standard deviation: SD=SQRT(VAR)
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
double sumXi = 0.0;
|
||||
@@ -239,7 +239,7 @@ void CylinderFit::ProjectToCylinder()
|
||||
void CylinderFit::ComputeApproximationsLine()
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
_vBase.Set(0.0, 0.0, 0.0);
|
||||
_vAxis.Set(0.0, 0.0, 0.0);
|
||||
@@ -266,13 +266,13 @@ void CylinderFit::ComputeApproximationsLine()
|
||||
float CylinderFit::Fit()
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
|
||||
// A minimum of 5 surface points is needed to define a cylinder
|
||||
const int minPts = 5;
|
||||
if (CountPoints() < minPts) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
// If approximations have not been set/computed then compute some now using the line fit method
|
||||
@@ -308,7 +308,7 @@ float CylinderFit::Fit()
|
||||
// Solve the equations for the unknown corrections
|
||||
Eigen::LLT<Matrix5x5> llt(atpa);
|
||||
if (llt.info() != Eigen::Success) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
Eigen::VectorXd x = llt.solve(atpl);
|
||||
|
||||
@@ -327,7 +327,7 @@ float CylinderFit::Fit()
|
||||
// convergence
|
||||
bool vConverged {};
|
||||
if (!computeResiduals(solDir, x, residuals, sigma0, _vConvLimit, vConverged)) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
if (!vConverged) {
|
||||
cont = true;
|
||||
@@ -335,13 +335,13 @@ float CylinderFit::Fit()
|
||||
|
||||
// Update the parameters
|
||||
if (!updateParameters(solDir, x)) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
}
|
||||
|
||||
// Check for convergence
|
||||
if (cont) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
_bIsFitted = true;
|
||||
|
||||
@@ -123,7 +123,7 @@ void MeshSimplify::simplify(int targetSize)
|
||||
}
|
||||
|
||||
// Simplification starts
|
||||
alg.simplify_mesh(targetSize, FLT_MAX);
|
||||
alg.simplify_mesh(targetSize, std::numeric_limits<float>::max());
|
||||
|
||||
// Simplification done
|
||||
MeshPointArray new_points;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <Mod/Mesh/MeshGlobal.h>
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
#include <limits>
|
||||
|
||||
// default values
|
||||
#define MESH_MIN_PT_DIST 1.0e-6F
|
||||
@@ -36,33 +36,16 @@
|
||||
#define MESH_REMOVE_MIN_LEN true
|
||||
#define MESH_REMOVE_G3_EDGES true
|
||||
|
||||
/*
|
||||
* general constant definitions
|
||||
*/
|
||||
#define FLOAT_EPS 1.0e-4F
|
||||
|
||||
#ifndef FLOAT_MAX
|
||||
#define FLOAT_MAX 1e30F
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_MAX
|
||||
#define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_MIN
|
||||
#define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
namespace MeshCore
|
||||
{
|
||||
|
||||
// type definitions
|
||||
using ElementIndex = unsigned long;
|
||||
const ElementIndex ELEMENT_INDEX_MAX = ULONG_MAX;
|
||||
const ElementIndex ELEMENT_INDEX_MAX = std::numeric_limits<unsigned long>::max();
|
||||
using FacetIndex = ElementIndex;
|
||||
const FacetIndex FACET_INDEX_MAX = ULONG_MAX;
|
||||
const FacetIndex FACET_INDEX_MAX = std::numeric_limits<unsigned long>::max();
|
||||
using PointIndex = ElementIndex;
|
||||
const PointIndex POINT_INDEX_MAX = ULONG_MAX;
|
||||
const PointIndex POINT_INDEX_MAX = std::numeric_limits<unsigned long>::max();
|
||||
|
||||
template<class Prec>
|
||||
class Math
|
||||
|
||||
@@ -1309,9 +1309,9 @@ unsigned short MeshGeomFacet::NearestEdgeToPoint(const Base::Vector3f& rclPt) co
|
||||
const Base::Vector3f& rcP2 = _aclPoints[1];
|
||||
const Base::Vector3f& rcP3 = _aclPoints[2];
|
||||
|
||||
float fD1 = FLOAT_MAX;
|
||||
float fD2 = FLOAT_MAX;
|
||||
float fD3 = FLOAT_MAX;
|
||||
float fD1 = std::numeric_limits<float>::max();
|
||||
float fD2 = std::numeric_limits<float>::max();
|
||||
float fD3 = std::numeric_limits<float>::max();
|
||||
|
||||
// 1st edge
|
||||
Base::Vector3f clDir = rcP2 - rcP1;
|
||||
@@ -1383,9 +1383,9 @@ void MeshGeomFacet::NearestEdgeToPoint(const Base::Vector3f& rclPt,
|
||||
const Base::Vector3f& rcP2 = _aclPoints[1];
|
||||
const Base::Vector3f& rcP3 = _aclPoints[2];
|
||||
|
||||
float fD1 = FLOAT_MAX;
|
||||
float fD2 = FLOAT_MAX;
|
||||
float fD3 = FLOAT_MAX;
|
||||
float fD1 = std::numeric_limits<float>::max();
|
||||
float fD2 = std::numeric_limits<float>::max();
|
||||
float fD3 = std::numeric_limits<float>::max();
|
||||
|
||||
// 1st edge
|
||||
Base::Vector3f clDir = rcP2 - rcP1;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef MESH_ELEMENTS_H
|
||||
#define MESH_ELEMENTS_H
|
||||
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
@@ -1147,7 +1146,7 @@ inline unsigned short MeshFacet::Side(FacetIndex ulNIndex) const
|
||||
return 2;
|
||||
}
|
||||
|
||||
return USHRT_MAX;
|
||||
return std::numeric_limits<unsigned short>::max();
|
||||
}
|
||||
|
||||
inline unsigned short MeshFacet::Side(PointIndex ulP0, PointIndex ulP1) const
|
||||
@@ -1177,7 +1176,7 @@ inline unsigned short MeshFacet::Side(PointIndex ulP0, PointIndex ulP1) const
|
||||
}
|
||||
}
|
||||
|
||||
return USHRT_MAX;
|
||||
return std::numeric_limits<unsigned short>::max();
|
||||
}
|
||||
|
||||
inline unsigned short MeshFacet::Side(const MeshFacet& rFace) const
|
||||
@@ -1185,12 +1184,12 @@ inline unsigned short MeshFacet::Side(const MeshFacet& rFace) const
|
||||
unsigned short side {};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
side = Side(rFace._aulPoints[i], rFace._aulPoints[(i + 1) % 3]);
|
||||
if (side != USHRT_MAX) {
|
||||
if (side != std::numeric_limits<unsigned short>::max()) {
|
||||
return side;
|
||||
}
|
||||
}
|
||||
|
||||
return USHRT_MAX;
|
||||
return std::numeric_limits<unsigned short>::max();
|
||||
}
|
||||
|
||||
inline bool MeshFacet::IsEqual(const MeshFacet& rcFace) const
|
||||
|
||||
@@ -639,7 +639,7 @@ unsigned long
|
||||
MeshGrid::GetIndexToPosition(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
|
||||
{
|
||||
if (!CheckPos(ulX, ulY, ulZ)) {
|
||||
return ULONG_MAX;
|
||||
return std::numeric_limits<unsigned long>::max();
|
||||
}
|
||||
return (ulZ * _ulCtGridsY + ulY) * _ulCtGridsX + ulX;
|
||||
}
|
||||
@@ -654,9 +654,9 @@ bool MeshGrid::GetPositionToIndex(unsigned long id,
|
||||
ulZ = id / (_ulCtGridsX * _ulCtGridsY);
|
||||
|
||||
if (!CheckPos(ulX, ulY, ulZ)) {
|
||||
ulX = ULONG_MAX;
|
||||
ulY = ULONG_MAX;
|
||||
ulZ = ULONG_MAX;
|
||||
ulX = std::numeric_limits<unsigned long>::max();
|
||||
ulY = std::numeric_limits<unsigned long>::max();
|
||||
ulZ = std::numeric_limits<unsigned long>::max();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ void MeshFacetGrid::RebuildGrid()
|
||||
unsigned long MeshFacetGrid::SearchNearestFromPoint(const Base::Vector3f& rclPt) const
|
||||
{
|
||||
ElementIndex ulFacetInd = ELEMENT_INDEX_MAX;
|
||||
float fMinDist = FLOAT_MAX;
|
||||
float fMinDist = std::numeric_limits<float>::max();
|
||||
Base::BoundBox3f clBB = GetBoundBox();
|
||||
|
||||
if (clBB.IsInBox(rclPt)) { // Point lies within
|
||||
@@ -1154,7 +1154,7 @@ bool MeshGridIterator::InitOnRay(const Base::Vector3f& rclPt,
|
||||
// needed in NextOnRay() to avoid an infinite loop
|
||||
_cSearchPositions.clear();
|
||||
|
||||
_fMaxSearchArea = FLOAT_MAX;
|
||||
_fMaxSearchArea = std::numeric_limits<float>::max();
|
||||
|
||||
raulElements.clear();
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ private:
|
||||
Base::Vector3f _clPt; /**< Base point of search ray. */
|
||||
Base::Vector3f _clDir; /**< Direction of search ray. */
|
||||
bool _bValidRay {false}; /**< Search ray ok? */
|
||||
float _fMaxSearchArea {FLOAT_MAX};
|
||||
float _fMaxSearchArea {std::numeric_limits<float>::max()};
|
||||
/** Checks if a grid position is already visited by NextOnRay(). */
|
||||
struct GridElement
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef MESH_ITERATOR_H
|
||||
#define MESH_ITERATOR_H
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <Base/Matrix.h>
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet>& rclFAry, bool
|
||||
|
||||
if (ulF0 != FACET_INDEX_MAX) {
|
||||
unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1);
|
||||
assert(usSide != USHRT_MAX);
|
||||
assert(usSide != std::numeric_limits<unsigned short>::max());
|
||||
_aclFacetArray[ulF0]._aulNeighbours[usSide] = FACET_INDEX_MAX;
|
||||
}
|
||||
}
|
||||
@@ -342,13 +342,13 @@ unsigned long MeshKernel::AddFacets(const std::vector<MeshFacet>& rclFAry, bool
|
||||
|
||||
if (ulF0 != FACET_INDEX_MAX) {
|
||||
unsigned short usSide = _aclFacetArray[ulF0].Side(ulP0, ulP1);
|
||||
assert(usSide != USHRT_MAX);
|
||||
assert(usSide != std::numeric_limits<unsigned short>::max());
|
||||
_aclFacetArray[ulF0]._aulNeighbours[usSide] = ulF1;
|
||||
}
|
||||
|
||||
if (ulF1 != FACET_INDEX_MAX) {
|
||||
unsigned short usSide = _aclFacetArray[ulF1].Side(ulP0, ulP1);
|
||||
assert(usSide != USHRT_MAX);
|
||||
assert(usSide != std::numeric_limits<unsigned short>::max());
|
||||
_aclFacetArray[ulF1]._aulNeighbours[usSide] = ulF0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ bool MeshProjection::connectLines(std::list<std::pair<Base::Vector3f, Base::Vect
|
||||
const Base::Vector3f& endPoint,
|
||||
std::vector<Base::Vector3f>& polyline) const
|
||||
{
|
||||
const float fMaxDist = float(std::sqrt(FLOAT_MAX)); // max. length of a gap
|
||||
const float fMaxDist = std::sqrt(std::numeric_limits<float>::max()); // max. length of a gap
|
||||
const float fMinEps = 1.0e-4F;
|
||||
|
||||
polyline.clear();
|
||||
|
||||
@@ -201,7 +201,7 @@ std::vector<float> PlaneSurfaceFit::Parameters() const
|
||||
// --------------------------------------------------------
|
||||
|
||||
CylinderSurfaceFit::CylinderSurfaceFit()
|
||||
: radius(FLOAT_MAX)
|
||||
: radius(std::numeric_limits<float>::max())
|
||||
, fitter(new CylinderFit)
|
||||
{
|
||||
axis.Set(0, 0, 0);
|
||||
@@ -266,7 +266,7 @@ float CylinderSurfaceFit::Fit()
|
||||
}
|
||||
|
||||
float fit = fitter->Fit();
|
||||
if (fit < FLOAT_MAX) {
|
||||
if (fit < std::numeric_limits<float>::max()) {
|
||||
basepoint = fitter->GetBase();
|
||||
axis = fitter->GetAxis();
|
||||
radius = fitter->GetRadius();
|
||||
@@ -309,7 +309,7 @@ std::vector<float> CylinderSurfaceFit::Parameters() const
|
||||
// --------------------------------------------------------
|
||||
|
||||
SphereSurfaceFit::SphereSurfaceFit()
|
||||
: radius(FLOAT_MAX)
|
||||
: radius(std::numeric_limits<float>::max())
|
||||
, fitter(new SphereFit)
|
||||
{
|
||||
center.Set(0, 0, 0);
|
||||
@@ -367,7 +367,7 @@ float SphereSurfaceFit::Fit()
|
||||
}
|
||||
|
||||
float fit = fitter->Fit();
|
||||
if (fit < FLOAT_MAX) {
|
||||
if (fit < std::numeric_limits<float>::max()) {
|
||||
center = fitter->GetCenter();
|
||||
radius = fitter->GetRadius();
|
||||
}
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifndef _USE_MATH_DEFINES
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
|
||||
using vec3f = Base::Vector3f;
|
||||
|
||||
class SymmetricMatrix {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef MESH_SMOOTHING_H
|
||||
#define MESH_SMOOTHING_H
|
||||
|
||||
#include <cfloat>
|
||||
#include <vector>
|
||||
|
||||
#include "Definitions.h"
|
||||
@@ -88,7 +87,7 @@ public:
|
||||
void SmoothPoints(unsigned int, const std::vector<PointIndex>&) override;
|
||||
|
||||
private:
|
||||
float maximum {FLT_MAX};
|
||||
float maximum {std::numeric_limits<float>::max()};
|
||||
};
|
||||
|
||||
class MeshExport LaplaceSmoothing: public AbstractSmoothing
|
||||
|
||||
@@ -41,7 +41,7 @@ SphereFit::SphereFit()
|
||||
void SphereFit::SetApproximations(double radius, const Base::Vector3d& center)
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
_dRadius = radius;
|
||||
_vCenter = center;
|
||||
@@ -92,7 +92,7 @@ int SphereFit::GetNumIterations() const
|
||||
|
||||
float SphereFit::GetDistanceToSphere(const Base::Vector3f& rcPoint) const
|
||||
{
|
||||
float fResult = FLOAT_MAX;
|
||||
float fResult = std::numeric_limits<float>::max();
|
||||
if (_bIsFitted) {
|
||||
fResult = Base::Vector3d((double)rcPoint.x - _vCenter.x,
|
||||
(double)rcPoint.y - _vCenter.y,
|
||||
@@ -109,7 +109,7 @@ float SphereFit::GetStdDeviation() const
|
||||
// Variance: VAR=(N/N-1)*[(1/N)*SUM(Xi^2)-M^2]
|
||||
// Standard deviation: SD=SQRT(VAR)
|
||||
if (!_bIsFitted) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
double sumXi = 0.0, sumXi2 = 0.0, dist = 0.0;
|
||||
@@ -156,7 +156,7 @@ void SphereFit::ProjectToSphere()
|
||||
void SphereFit::ComputeApproximations()
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
_vCenter.Set(0.0, 0.0, 0.0);
|
||||
_dRadius = 0.0;
|
||||
@@ -182,12 +182,12 @@ void SphereFit::ComputeApproximations()
|
||||
float SphereFit::Fit()
|
||||
{
|
||||
_bIsFitted = false;
|
||||
_fLastResult = FLOAT_MAX;
|
||||
_fLastResult = std::numeric_limits<float>::max();
|
||||
_numIter = 0;
|
||||
|
||||
// A minimum of 4 surface points is needed to define a sphere
|
||||
if (CountPoints() < 4) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
// If approximations have not been set/computed then compute some now
|
||||
@@ -212,7 +212,7 @@ float SphereFit::Fit()
|
||||
// Solve the equations for the unknown corrections
|
||||
Eigen::LLT<Matrix4x4> llt(atpa);
|
||||
if (llt.info() != Eigen::Success) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
Eigen::VectorXd x = llt.solve(atpl);
|
||||
|
||||
@@ -227,7 +227,7 @@ float SphereFit::Fit()
|
||||
// convergence
|
||||
bool vConverged {};
|
||||
if (!computeResiduals(x, residuals, sigma0, _vConvLimit, vConverged)) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
if (!vConverged) {
|
||||
cont = true;
|
||||
@@ -242,7 +242,7 @@ float SphereFit::Fit()
|
||||
|
||||
// Check for convergence
|
||||
if (cont) {
|
||||
return FLOAT_MAX;
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
_bIsFitted = true;
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
|
||||
// NOLINTBEGIN
|
||||
Index nearest_index;
|
||||
float nearest_dist {FLOAT_MAX};
|
||||
float nearest_dist {std::numeric_limits<float>::max()};
|
||||
// NOLINTEND
|
||||
|
||||
private:
|
||||
|
||||
@@ -121,7 +121,7 @@ bool MeshTopoAlgorithm::SnapVertex(FacetIndex ulFacetPos, const Base::Vector3f&
|
||||
float fTV = (rP - rPt1) * (rPt2 - rPt1);
|
||||
|
||||
// Point is on the edge
|
||||
if (cNo3.Length() < FLOAT_EPS) {
|
||||
if (cNo3.Length() < std::numeric_limits<float>::epsilon()) {
|
||||
return SplitOpenEdge(ulFacetPos, i, rP);
|
||||
}
|
||||
if ((rP - rPt1) * cNo2 > 0.0F && fD2 >= fTV && fTV >= 0.0F) {
|
||||
@@ -290,7 +290,7 @@ float MeshTopoAlgorithm::SwapEdgeBenefit(FacetIndex f, int e) const
|
||||
PointIndex v2 = faces[f]._aulPoints[(e + 1) % 3];
|
||||
PointIndex v3 = faces[f]._aulPoints[(e + 2) % 3];
|
||||
unsigned short s = faces[n].Side(faces[f]);
|
||||
if (s == USHRT_MAX) {
|
||||
if (s == std::numeric_limits<unsigned short>::max()) {
|
||||
std::cerr << "MeshTopoAlgorithm::SwapEdgeBenefit: error in neighbourhood "
|
||||
<< "of faces " << f << " and " << n << std::endl;
|
||||
return 0.0F; // topological error
|
||||
@@ -600,7 +600,8 @@ bool MeshTopoAlgorithm::IsSwapEdgeLegal(FacetIndex ulFacetPos, FacetIndex ulNeig
|
||||
unsigned short uFSide = rclF.Side(rclN);
|
||||
unsigned short uNSide = rclN.Side(rclF);
|
||||
|
||||
if (uFSide == USHRT_MAX || uNSide == USHRT_MAX) {
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
if (uFSide == max || uNSide == max) {
|
||||
return false; // not neighbours
|
||||
}
|
||||
|
||||
@@ -686,7 +687,8 @@ void MeshTopoAlgorithm::SwapEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbour)
|
||||
unsigned short uFSide = rclF.Side(rclN);
|
||||
unsigned short uNSide = rclN.Side(rclF);
|
||||
|
||||
if (uFSide == USHRT_MAX || uNSide == USHRT_MAX) {
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
if (uFSide == max || uNSide == max) {
|
||||
return; // not neighbours
|
||||
}
|
||||
|
||||
@@ -720,7 +722,8 @@ bool MeshTopoAlgorithm::SplitEdge(FacetIndex ulFacetPos,
|
||||
unsigned short uFSide = rclF.Side(rclN);
|
||||
unsigned short uNSide = rclN.Side(rclF);
|
||||
|
||||
if (uFSide == USHRT_MAX || uNSide == USHRT_MAX) {
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
if (uFSide == max || uNSide == max) {
|
||||
return false; // not neighbours
|
||||
}
|
||||
|
||||
@@ -816,13 +819,13 @@ bool MeshTopoAlgorithm::SplitOpenEdge(FacetIndex ulFacetPos,
|
||||
bool MeshTopoAlgorithm::Vertex_Less::operator()(const Base::Vector3f& u,
|
||||
const Base::Vector3f& v) const
|
||||
{
|
||||
if (std::fabs(u.x - v.x) > FLOAT_EPS) {
|
||||
if (std::fabs(u.x - v.x) > std::numeric_limits<float>::epsilon()) {
|
||||
return u.x < v.x;
|
||||
}
|
||||
if (std::fabs(u.y - v.y) > FLOAT_EPS) {
|
||||
if (std::fabs(u.y - v.y) > std::numeric_limits<float>::epsilon()) {
|
||||
return u.y < v.y;
|
||||
}
|
||||
if (std::fabs(u.z - v.z) > FLOAT_EPS) {
|
||||
if (std::fabs(u.z - v.z) > std::numeric_limits<float>::epsilon()) {
|
||||
return u.z < v.z;
|
||||
}
|
||||
return false;
|
||||
@@ -980,7 +983,8 @@ bool MeshTopoAlgorithm::CollapseEdge(FacetIndex ulFacetPos, FacetIndex ulNeighbo
|
||||
unsigned short uFSide = rclF.Side(rclN);
|
||||
unsigned short uNSide = rclN.Side(rclF);
|
||||
|
||||
if (uFSide == USHRT_MAX || uNSide == USHRT_MAX) {
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
if (uFSide == max || uNSide == max) {
|
||||
return false; // not neighbours
|
||||
}
|
||||
|
||||
@@ -1214,7 +1218,7 @@ void MeshTopoAlgorithm::SplitFacet(FacetIndex ulFacetPos,
|
||||
MeshPoint& rVertex2 = _rclMesh._aclPointArray[rFace._aulPoints[2]];
|
||||
|
||||
auto pointIndex = [=](const Base::Vector3f& rP) {
|
||||
unsigned short equalP = USHRT_MAX;
|
||||
unsigned short equalP = std::numeric_limits<unsigned short>::max();
|
||||
if (Base::Distance(rVertex0, rP) < fEps) {
|
||||
equalP = 0;
|
||||
}
|
||||
@@ -1230,16 +1234,17 @@ void MeshTopoAlgorithm::SplitFacet(FacetIndex ulFacetPos,
|
||||
unsigned short equalP1 = pointIndex(rP1);
|
||||
unsigned short equalP2 = pointIndex(rP2);
|
||||
|
||||
constexpr auto max = std::numeric_limits<unsigned short>::max();
|
||||
// both points are coincident with the corner points
|
||||
if (equalP1 != USHRT_MAX && equalP2 != USHRT_MAX) {
|
||||
if (equalP1 != max && equalP2 != max) {
|
||||
return; // must not split the facet
|
||||
}
|
||||
|
||||
if (equalP1 != USHRT_MAX) {
|
||||
if (equalP1 != max) {
|
||||
// get the edge to the second given point and perform a split edge operation
|
||||
SplitFacetOnOneEdge(ulFacetPos, rP2);
|
||||
}
|
||||
else if (equalP2 != USHRT_MAX) {
|
||||
else if (equalP2 != max) {
|
||||
// get the edge to the first given point and perform a split edge operation
|
||||
SplitFacetOnOneEdge(ulFacetPos, rP1);
|
||||
}
|
||||
@@ -1250,8 +1255,8 @@ void MeshTopoAlgorithm::SplitFacet(FacetIndex ulFacetPos,
|
||||
|
||||
void MeshTopoAlgorithm::SplitFacetOnOneEdge(FacetIndex ulFacetPos, const Base::Vector3f& rP)
|
||||
{
|
||||
float fMinDist = FLOAT_MAX;
|
||||
unsigned short iEdgeNo = USHRT_MAX;
|
||||
float fMinDist = std::numeric_limits<float>::max();
|
||||
unsigned short iEdgeNo = std::numeric_limits<unsigned short>::max();
|
||||
MeshFacet& rFace = _rclMesh._aclFacetArray[ulFacetPos];
|
||||
|
||||
for (unsigned short i = 0; i < 3; i++) {
|
||||
@@ -1281,8 +1286,10 @@ void MeshTopoAlgorithm::SplitFacetOnTwoEdges(FacetIndex ulFacetPos,
|
||||
const Base::Vector3f& rP2)
|
||||
{
|
||||
// search for the matching edges
|
||||
unsigned short iEdgeNo1 = USHRT_MAX, iEdgeNo2 = USHRT_MAX;
|
||||
float fMinDist1 = FLOAT_MAX, fMinDist2 = FLOAT_MAX;
|
||||
unsigned short iEdgeNo1 = std::numeric_limits<unsigned short>::max();
|
||||
unsigned short iEdgeNo2 = std::numeric_limits<unsigned short>::max();
|
||||
float fMinDist1 = std::numeric_limits<float>::max();
|
||||
float fMinDist2 = std::numeric_limits<float>::max();
|
||||
MeshFacet& rFace = _rclMesh._aclFacetArray[ulFacetPos];
|
||||
|
||||
for (unsigned short i = 0; i < 3; i++) {
|
||||
@@ -1392,7 +1399,7 @@ void MeshTopoAlgorithm::SplitFacet(FacetIndex ulFacetPos,
|
||||
{
|
||||
MeshFacet& rFace = _rclMesh._aclFacetArray[ulFacetPos];
|
||||
unsigned short side = rFace.Side(P1, P2);
|
||||
if (side != USHRT_MAX) {
|
||||
if (side != std::numeric_limits<unsigned short>::max()) {
|
||||
PointIndex V1 = rFace._aulPoints[(side + 1) % 3];
|
||||
PointIndex V2 = rFace._aulPoints[(side + 2) % 3];
|
||||
FacetIndex size = _rclMesh._aclFacetArray.size();
|
||||
@@ -1455,12 +1462,12 @@ void MeshTopoAlgorithm::HarmonizeNeighbours(FacetIndex facet1, FacetIndex facet2
|
||||
MeshFacet& rFace2 = _rclMesh._aclFacetArray[facet2];
|
||||
|
||||
unsigned short side = rFace1.Side(rFace2);
|
||||
if (side != USHRT_MAX) {
|
||||
if (side != std::numeric_limits<unsigned short>::max()) {
|
||||
rFace1._aulNeighbours[side] = facet2;
|
||||
}
|
||||
|
||||
side = rFace2.Side(rFace1);
|
||||
if (side != USHRT_MAX) {
|
||||
if (side != std::numeric_limits<unsigned short>::max()) {
|
||||
rFace2._aulNeighbours[side] = facet1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ Base::Matrix4D AbstractPolygonTriangulator::GetTransformToFitPlane() const
|
||||
planeFit.AddPoint(point);
|
||||
}
|
||||
|
||||
if (planeFit.Fit() >= FLOAT_MAX) {
|
||||
if (planeFit.Fit() >= std::numeric_limits<float>::max()) {
|
||||
throw Base::RuntimeError("Plane fit failed");
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ void AbstractPolygonTriangulator::PostProcessing(const std::vector<Base::Vector3
|
||||
polyFit.AddPoint(pt);
|
||||
}
|
||||
|
||||
if (polyFit.CountPoints() >= uMinPts && polyFit.Fit() < FLOAT_MAX) {
|
||||
if (polyFit.CountPoints() >= uMinPts && polyFit.Fit() < std::numeric_limits<float>::max()) {
|
||||
for (auto& newpoint : _newpoints) {
|
||||
newpoint.z = static_cast<float>(polyFit.Value(newpoint.x, newpoint.y));
|
||||
}
|
||||
@@ -377,7 +377,9 @@ bool EarClippingTriangulator::Triangulate::InsideTriangle(float Ax,
|
||||
cCROSSap = cx * apy - cy * apx;
|
||||
bCROSScp = bx * cpy - by * cpx;
|
||||
|
||||
return ((aCROSSbp >= FLOAT_EPS) && (bCROSScp >= FLOAT_EPS) && (cCROSSap >= FLOAT_EPS));
|
||||
return ((aCROSSbp >= std::numeric_limits<float>::epsilon())
|
||||
&& (bCROSScp >= std::numeric_limits<float>::epsilon())
|
||||
&& (cCROSSap >= std::numeric_limits<float>::epsilon()));
|
||||
}
|
||||
|
||||
bool EarClippingTriangulator::Triangulate::Snip(const std::vector<Base::Vector3f>& contour,
|
||||
@@ -399,7 +401,8 @@ bool EarClippingTriangulator::Triangulate::Snip(const std::vector<Base::Vector3f
|
||||
Cx = contour[V[w]].x;
|
||||
Cy = contour[V[w]].y;
|
||||
|
||||
if (FLOAT_EPS > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) {
|
||||
constexpr float eps = std::numeric_limits<float>::epsilon();
|
||||
if (eps > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ App::DocumentObjectExecReturn* SegmentByMesh::execute()
|
||||
// now we have too many facets since we have (invisible) facets near to the back clipping
|
||||
// plane, so we need the nearest facet to the front clipping plane
|
||||
//
|
||||
float fDist = FLOAT_MAX;
|
||||
float fDist = std::numeric_limits<float>::max();
|
||||
MeshCore::FacetIndex uIdx = MeshCore::FACET_INDEX_MAX;
|
||||
MeshFacetIterator cFIt(rMeshKernel);
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
namespace Mesh
|
||||
{
|
||||
const App::PropertyIntegerConstraint::Constraints intSampling = {0, INT_MAX, 1};
|
||||
const App::PropertyLength::Constraints floatRange = {0.0, FLT_MAX, 1.0};
|
||||
const App::PropertyIntegerConstraint::Constraints intSampling = {0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1};
|
||||
const App::PropertyLength::Constraints floatRange = {0.0, std::numeric_limits<float>::max(), 1.0};
|
||||
} // namespace Mesh
|
||||
|
||||
using namespace Mesh;
|
||||
|
||||
@@ -73,7 +73,7 @@ PyObject* MeshFeaturePy::harmonizeNormals(PyObject* args)
|
||||
PyObject* MeshFeaturePy::smooth(PyObject* args)
|
||||
{
|
||||
int iter = 1;
|
||||
float d_max = FLOAT_MAX;
|
||||
float d_max = std::numeric_limits<float>::max();
|
||||
if (!PyArg_ParseTuple(args, "|if", &iter, &d_max)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef MESH_MESHPOINT_H
|
||||
#define MESH_MESHPOINT_H
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/Handle.h>
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
/// simple constructor
|
||||
explicit MeshPoint(const Vector3d& vec = Vector3d(),
|
||||
const MeshObject* obj = nullptr,
|
||||
unsigned int index = UINT_MAX)
|
||||
unsigned int index = std::numeric_limits<unsigned>::max())
|
||||
: Vector3d(vec)
|
||||
, Index(index)
|
||||
, Mesh(obj)
|
||||
@@ -59,7 +58,7 @@ public:
|
||||
|
||||
bool isBound() const
|
||||
{
|
||||
return Index != UINT_MAX;
|
||||
return Index != std::numeric_limits<unsigned>::max();
|
||||
}
|
||||
|
||||
unsigned int Index;
|
||||
|
||||
@@ -86,7 +86,7 @@ PyObject* MeshPointPy::unbound(PyObject* args)
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
getMeshPointPtr()->Index = UINT_MAX;
|
||||
getMeshPointPtr()->Index = std::numeric_limits<unsigned>::max();
|
||||
getMeshPointPtr()->Mesh = nullptr;
|
||||
Py_Return;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ Py::Long MeshPointPy::getIndex() const
|
||||
|
||||
Py::Boolean MeshPointPy::getBound() const
|
||||
{
|
||||
return {getMeshPointPtr()->Index != UINT_MAX};
|
||||
return {getMeshPointPtr()->Index != std::numeric_limits<unsigned>::max()};
|
||||
}
|
||||
|
||||
Py::Object MeshPointPy::getNormal() const
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
// standard
|
||||
#include <cassert>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
namespace Wm4 {
|
||||
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::EPSILON = FLT_EPSILON;
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::EPSILON = std::numeric_limits<float>::epsilon();
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::ZERO_TOLERANCE = 1e-06f;
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::MAX_REAL = FLT_MAX;
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::MAX_REAL = std::numeric_limits<float>::max();
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::PI = (float)(4.0*atan(1.0));
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::TWO_PI = 2.0f*Math<float>::PI;
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::HALF_PI = 0.5f*Math<float>::PI;
|
||||
@@ -34,9 +34,9 @@ template<> WM4_FOUNDATION_ITEM const float Math<float>::LN_10 = Math<float>::Log
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::INV_LN_2 = 1.0f/Math<float>::LN_2;
|
||||
template<> WM4_FOUNDATION_ITEM const float Math<float>::INV_LN_10 = 1.0f/Math<float>::LN_10;
|
||||
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::EPSILON = DBL_EPSILON;
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::EPSILON = std::numeric_limits<double>::epsilon();
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::ZERO_TOLERANCE = 1e-08;
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::MAX_REAL = DBL_MAX;
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::MAX_REAL = std::numeric_limits<double>::max();
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::PI = 4.0*atan(1.0);
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::TWO_PI = 2.0*Math<double>::PI;
|
||||
template<> WM4_FOUNDATION_ITEM const double Math<double>::HALF_PI = 0.5*Math<double>::PI;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
// common standard library headers
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1798,7 +1798,7 @@ void CmdMeshScale::activated(int)
|
||||
QObject::tr("Enter scaling factor:"),
|
||||
1,
|
||||
0,
|
||||
DBL_MAX,
|
||||
std::numeric_limits<double>::max(),
|
||||
5,
|
||||
&ok,
|
||||
Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
#include <qmessagebox.h>
|
||||
#endif
|
||||
|
||||
@@ -55,45 +54,46 @@ DlgRegularSolidImp::DlgRegularSolidImp(QWidget* parent, Qt::WindowFlags fl)
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "import Mesh,BuildRegularGeoms");
|
||||
|
||||
// set limits
|
||||
constexpr double doubleMax = std::numeric_limits<double>::max();
|
||||
// Box
|
||||
ui->boxLength->setMaximum(DBL_MAX);
|
||||
ui->boxLength->setMaximum(doubleMax);
|
||||
ui->boxLength->setMinimum(0);
|
||||
ui->boxWidth->setMaximum(DBL_MAX);
|
||||
ui->boxWidth->setMaximum(doubleMax);
|
||||
ui->boxWidth->setMinimum(0);
|
||||
ui->boxHeight->setMaximum(DBL_MAX);
|
||||
ui->boxHeight->setMaximum(doubleMax);
|
||||
ui->boxHeight->setMinimum(0);
|
||||
// Cylinder
|
||||
ui->cylinderRadius->setMaximum(DBL_MAX);
|
||||
ui->cylinderRadius->setMaximum(doubleMax);
|
||||
ui->cylinderRadius->setMinimum(0);
|
||||
ui->cylinderLength->setMaximum(DBL_MAX);
|
||||
ui->cylinderLength->setMaximum(doubleMax);
|
||||
ui->cylinderLength->setMinimum(0);
|
||||
ui->cylinderEdgeLength->setMaximum(DBL_MAX);
|
||||
ui->cylinderEdgeLength->setMaximum(doubleMax);
|
||||
ui->cylinderEdgeLength->setMinimum(0);
|
||||
ui->cylinderCount->setMaximum(1000);
|
||||
// Cone
|
||||
ui->coneRadius1->setMaximum(DBL_MAX);
|
||||
ui->coneRadius1->setMaximum(doubleMax);
|
||||
ui->coneRadius1->setMinimum(0);
|
||||
ui->coneRadius2->setMaximum(DBL_MAX);
|
||||
ui->coneRadius2->setMaximum(doubleMax);
|
||||
ui->coneRadius2->setMinimum(0);
|
||||
ui->coneLength->setMaximum(DBL_MAX);
|
||||
ui->coneLength->setMaximum(doubleMax);
|
||||
ui->coneLength->setMinimum(0);
|
||||
ui->coneEdgeLength->setMaximum(DBL_MAX);
|
||||
ui->coneEdgeLength->setMaximum(doubleMax);
|
||||
ui->coneEdgeLength->setMinimum(0);
|
||||
ui->coneCount->setMaximum(1000);
|
||||
// Sphere
|
||||
ui->sphereRadius->setMaximum(DBL_MAX);
|
||||
ui->sphereRadius->setMaximum(doubleMax);
|
||||
ui->sphereRadius->setMinimum(0);
|
||||
ui->sphereCount->setMaximum(1000);
|
||||
// Ellipsoid
|
||||
ui->ellipsoidRadius1->setMaximum(DBL_MAX);
|
||||
ui->ellipsoidRadius1->setMaximum(doubleMax);
|
||||
ui->ellipsoidRadius1->setMinimum(0);
|
||||
ui->ellipsoidRadius2->setMaximum(DBL_MAX);
|
||||
ui->ellipsoidRadius2->setMaximum(doubleMax);
|
||||
ui->ellipsoidRadius2->setMinimum(0);
|
||||
ui->ellipsoidCount->setMaximum(1000);
|
||||
// Torus
|
||||
ui->toroidRadius1->setMaximum(DBL_MAX);
|
||||
ui->toroidRadius1->setMaximum(doubleMax);
|
||||
ui->toroidRadius1->setMinimum(0);
|
||||
ui->toroidRadius2->setMaximum(DBL_MAX);
|
||||
ui->toroidRadius2->setMaximum(doubleMax);
|
||||
ui->toroidRadius2->setMinimum(0);
|
||||
ui->toroidCount->setMaximum(1000);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
|
||||
}
|
||||
|
||||
int point_index = -1;
|
||||
float distance = FLT_MAX;
|
||||
float distance = std::numeric_limits<float>::max();
|
||||
Base::Vector3f pnt;
|
||||
SbVec3f face_pnt;
|
||||
|
||||
@@ -654,7 +654,7 @@ float MeshFillHole::findClosestPoint(const SbLine& ray,
|
||||
SbVec3f& closestPoint) const
|
||||
{
|
||||
// now check which vertex of the polygon is closest to the ray
|
||||
float minDist = FLT_MAX;
|
||||
float minDist = std::numeric_limits<float>::max();
|
||||
vertex_index = MeshCore::POINT_INDEX_MAX;
|
||||
|
||||
const MeshCore::MeshKernel& rMesh = myMesh->Mesh.getValue().getKernel();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <QBitmap>
|
||||
|
||||
#include <Inventor/SbBox2s.h>
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
// standard
|
||||
#include <ios>
|
||||
#include <cfloat>
|
||||
|
||||
// STL
|
||||
#include <algorithm>
|
||||
|
||||
@@ -41,9 +41,9 @@ RemoveComponents::RemoveComponents(QWidget* parent, Qt::WindowFlags fl)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setupConnections();
|
||||
ui->spSelectComp->setRange(1, INT_MAX);
|
||||
ui->spSelectComp->setRange(1, std::numeric_limits<int>::max());
|
||||
ui->spSelectComp->setValue(10);
|
||||
ui->spDeselectComp->setRange(1, INT_MAX);
|
||||
ui->spDeselectComp->setRange(1, std::numeric_limits<int>::max());
|
||||
ui->spDeselectComp->setValue(10);
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
@@ -44,18 +44,19 @@ Segmentation::Segmentation(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags
|
||||
, ui(new Ui_Segmentation)
|
||||
, myMesh(mesh)
|
||||
{
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
ui->setupUi(this);
|
||||
ui->numPln->setRange(1, INT_MAX);
|
||||
ui->numPln->setRange(1, max);
|
||||
ui->numPln->setValue(100);
|
||||
ui->crvCyl->setRange(0, INT_MAX);
|
||||
ui->numCyl->setRange(1, INT_MAX);
|
||||
ui->crvCyl->setRange(0, max);
|
||||
ui->numCyl->setRange(1, max);
|
||||
ui->numCyl->setValue(100);
|
||||
ui->crvSph->setRange(0, INT_MAX);
|
||||
ui->numSph->setRange(1, INT_MAX);
|
||||
ui->crvSph->setRange(0, max);
|
||||
ui->numSph->setRange(1, max);
|
||||
ui->numSph->setValue(100);
|
||||
ui->crv1Free->setRange(-INT_MAX, INT_MAX);
|
||||
ui->crv2Free->setRange(-INT_MAX, INT_MAX);
|
||||
ui->numFree->setRange(1, INT_MAX);
|
||||
ui->crv1Free->setRange(-max, max);
|
||||
ui->crv2Free->setRange(-max, max);
|
||||
ui->numFree->setRange(1, max);
|
||||
ui->numFree->setValue(100);
|
||||
|
||||
ui->checkBoxSmooth->setChecked(false);
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
std::vector<float> values;
|
||||
MeshCore::PlaneFit fit;
|
||||
fit.AddPoints(pts.points);
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
if (fit.Fit() < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3f base = fit.GetBase();
|
||||
Base::Vector3f axis = fit.GetNormal();
|
||||
values.push_back(base.x);
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
if (fit.Fit() < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3f base, top;
|
||||
fit.GetBounding(base, top);
|
||||
Base::Vector3f axis = fit.GetAxis();
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
std::vector<float> values;
|
||||
MeshCore::SphereFit fit;
|
||||
fit.AddPoints(pts.points);
|
||||
if (fit.Fit() < FLOAT_MAX) {
|
||||
if (fit.Fit() < std::numeric_limits<float>::max()) {
|
||||
Base::Vector3f base = fit.GetCenter();
|
||||
float radius = fit.GetRadius();
|
||||
values.push_back(base.x);
|
||||
@@ -228,7 +228,7 @@ ParametersDialog::ParametersDialog(std::vector<float>& val,
|
||||
|
||||
QDoubleSpinBox* doubleSpinBox = new QDoubleSpinBox(groupBox);
|
||||
doubleSpinBox->setObjectName(it.first);
|
||||
doubleSpinBox->setRange(-INT_MAX, INT_MAX);
|
||||
doubleSpinBox->setRange(-std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
|
||||
doubleSpinBox->setValue(it.second);
|
||||
layout->addWidget(doubleSpinBox, index, 1, 1, 1);
|
||||
spinBoxes.push_back(doubleSpinBox);
|
||||
@@ -335,11 +335,11 @@ SegmentationBestFit::SegmentationBestFit(Mesh::Feature* mesh, QWidget* parent, Q
|
||||
ui->setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
ui->numPln->setRange(1, INT_MAX);
|
||||
ui->numPln->setRange(1, std::numeric_limits<int>::max());
|
||||
ui->numPln->setValue(100);
|
||||
ui->numCyl->setRange(1, INT_MAX);
|
||||
ui->numCyl->setRange(1, std::numeric_limits<int>::max());
|
||||
ui->numCyl->setValue(100);
|
||||
ui->numSph->setRange(1, INT_MAX);
|
||||
ui->numSph->setRange(1, std::numeric_limits<int>::max());
|
||||
ui->numSph->setValue(100);
|
||||
|
||||
Gui::SelectionObject obj(myMesh);
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#ifdef FC_OS_MACOSX
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
@@ -459,7 +458,7 @@ void SoFCIndexedFaceSet::initClass()
|
||||
}
|
||||
|
||||
SoFCIndexedFaceSet::SoFCIndexedFaceSet()
|
||||
: renderTriangleLimit(UINT_MAX)
|
||||
: renderTriangleLimit(std::numeric_limits<unsigned>::max())
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCIndexedFaceSet);
|
||||
SO_NODE_ADD_FIELD(updateGLArray, (false));
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@@ -607,7 +606,7 @@ void SoFCMeshObjectShape::initClass()
|
||||
}
|
||||
|
||||
SoFCMeshObjectShape::SoFCMeshObjectShape()
|
||||
: renderTriangleLimit(UINT_MAX)
|
||||
: renderTriangleLimit(std::numeric_limits<unsigned>::max())
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCMeshObjectShape);
|
||||
setName(SoFCMeshObjectShape::getClassTypeId().getName());
|
||||
@@ -1235,7 +1234,7 @@ void SoFCMeshSegmentShape::initClass()
|
||||
}
|
||||
|
||||
SoFCMeshSegmentShape::SoFCMeshSegmentShape()
|
||||
: renderTriangleLimit(UINT_MAX)
|
||||
: renderTriangleLimit(std::numeric_limits<unsigned>::max())
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCMeshSegmentShape);
|
||||
SO_NODE_ADD_FIELD(index, (0));
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/bundles/SoMaterialBundle.h>
|
||||
@@ -145,8 +144,9 @@ void SoPolygon::computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center)
|
||||
if (!points) {
|
||||
return;
|
||||
}
|
||||
float maxX = -FLT_MAX, minX = FLT_MAX, maxY = -FLT_MAX, minY = FLT_MAX, maxZ = -FLT_MAX,
|
||||
minZ = FLT_MAX;
|
||||
constexpr float floatMax = std::numeric_limits<float>::max();
|
||||
float maxX = -floatMax, minX = floatMax, maxY = -floatMax, minY = floatMax, maxZ = -floatMax,
|
||||
minZ = floatMax;
|
||||
int32_t len = coords->getNum();
|
||||
int32_t beg = startIndex.getValue();
|
||||
int32_t cnt = numVertices.getValue();
|
||||
|
||||
Reference in New Issue
Block a user