MeshPart: Use std::numeric_limits and std::numbers instead of defines

This commit is contained in:
Benjamin Nauck
2025-03-27 19:01:33 +01:00
parent 99bb999deb
commit 1301b58296
7 changed files with 18 additions and 20 deletions

View File

@@ -180,7 +180,7 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
/ ((cP1 - cP0) * (cP1 - cP0));
// is the Point on the Edge of the facet?
if (l < 0.0 || l > 1.0) {
PointOnEdge[i] = Base::Vector3f(FLOAT_MAX, 0, 0);
PointOnEdge[i] = Base::Vector3f(std::numeric_limits<float>::max(), 0, 0);
}
else {
cSplitPoint = (1 - l) * cP0 + l * cP1;
@@ -191,11 +191,11 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
// no intersection
}
else if (Alg.NbPoints() == 0) {
PointOnEdge[i] = Base::Vector3f(FLOAT_MAX, 0, 0);
PointOnEdge[i] = Base::Vector3f(std::numeric_limits<float>::max(), 0, 0);
// more the one intersection (@ToDo)
}
else if (Alg.NbPoints() > 1) {
PointOnEdge[i] = Base::Vector3f(FLOAT_MAX, 0, 0);
PointOnEdge[i] = Base::Vector3f(std::numeric_limits<float>::max(), 0, 0);
Base::Console().Log("MeshAlgos::projectCurve(): More then one intersection in "
"Facet %lu, Edge %d\n",
uCurFacetIdx,
@@ -234,7 +234,7 @@ bool CurveProjectorShape::findStartPoint(const MeshKernel& MeshK,
MeshCore::FacetIndex& FaceIndex)
{
Base::Vector3f TempResultPoint;
float MinLength = FLOAT_MAX;
float MinLength = std::numeric_limits<float>::max();
bool bHit = false;
// go through the whole Mesh
@@ -363,7 +363,7 @@ bool CurveProjectorSimple::findStartPoint(const MeshKernel& MeshK,
MeshCore::FacetIndex& FaceIndex)
{
Base::Vector3f TempResultPoint;
float MinLength = FLOAT_MAX;
float MinLength = std::numeric_limits<float>::max();
bool bHit = false;
// go through the whole Mesh
@@ -465,11 +465,11 @@ void CurveProjectorWithToolMesh::makeToolMesh(const TopoDS_Edge& aEdge,
// build up the new mesh
Base::Vector3f lp(FLOAT_MAX, 0, 0), ln, p1, p2, p3, p4, p5, p6;
Base::Vector3f lp(std::numeric_limits<float>::max(), 0, 0), ln, p1, p2, p3, p4, p5, p6;
float ToolSize = 0.2f;
for (const auto& It2 : LineSegs) {
if (lp.x != FLOAT_MAX) {
if (lp.x != std::numeric_limits<float>::max()) {
p1 = lp + (ln * (-ToolSize));
p2 = lp + (ln * ToolSize);
p3 = lp;

View File

@@ -66,7 +66,8 @@ public:
std::hash<T> hasher;
return hasher(x) < hasher(y);
#else
return x.HashCode(INT_MAX - 1) < y.HashCode(INT_MAX - 1);
constexpr int max = std::numeric_limits<int>::max();
return x.HashCode(max - 1) < y.HashCode(max - 1);
#endif
}
};

View File

@@ -26,14 +26,11 @@
#include <cmath>
#include <iostream>
#include <map>
#include <numbers>
#include <set>
#include <vector>
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846f
#endif
#include <Eigen/SparseCholesky>
#include "MeshFlatteningLscmRelax.h"
@@ -649,7 +646,7 @@ void LscmRelax::rotate_by_min_bound_area()
// rotate vector by 90 degree and find min area
for (int i = 0; i < n + 1; i++ )
{
phi = i * M_PI / n;
phi = i * std::numbers::pi / n;
Eigen::VectorXd x_proj = this->flat_vertices.transpose() * Vector2(std::cos(phi), std::sin(phi));
Eigen::VectorXd y_proj = this->flat_vertices.transpose() * Vector2(-std::sin(phi), std::cos(phi));
double x_distance = x_proj.maxCoeff() - x_proj.minCoeff();
@@ -663,7 +660,7 @@ void LscmRelax::rotate_by_min_bound_area()
}
}
Eigen::Matrix<double, 2, 2> rot;
min_phi += x_dominant * M_PI / 2;
min_phi += x_dominant * std::numbers::pi / 2;
rot << std::cos(min_phi), std::sin(min_phi), -std::sin(min_phi), std::cos(min_phi);
this->flat_vertices = rot * this->flat_vertices;
}

View File

@@ -43,6 +43,7 @@
#include <array>
#include <map>
#include <memory>
#include <numbers>
#include <set>
#include <sstream>
#include <stdexcept>

View File

@@ -22,7 +22,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cfloat>
#include <sstream>
#include <BRepBuilderAPI_MakePolygon.hxx>
@@ -179,9 +178,10 @@ CrossSections::CrossSections(const Base::BoundBox3d& bb, QWidget* parent, Qt::Wi
ui->setupUi(this);
setupConnections();
ui->position->setRange(-DBL_MAX, DBL_MAX);
constexpr double max = std::numeric_limits<double>::max();
ui->position->setRange(-max, max);
ui->position->setUnit(Base::Unit::Length);
ui->distance->setRange(0, DBL_MAX);
ui->distance->setRange(0, max);
ui->distance->setUnit(Base::Unit::Length);
ui->spinEpsilon->setMinimum(0.0001);
vp = new ViewProviderCrossSections();

View File

@@ -34,7 +34,6 @@
#ifdef _PreComp_
// STL
#include <cfloat>
#include <sstream>
// Qt Toolkit

View File

@@ -71,11 +71,11 @@ Tessellation::Tessellation(QWidget* parent)
relative = handle->GetBool("RelativeLinearDeflection", relative);
ui->relativeDeviation->setChecked(relative);
ui->spinSurfaceDeviation->setMaximum(INT_MAX);
ui->spinSurfaceDeviation->setMaximum(std::numeric_limits<int>::max());
ui->spinSurfaceDeviation->setValue(value);
ui->spinAngularDeviation->setValue(angle);
ui->spinMaximumEdgeLength->setRange(0, INT_MAX);
ui->spinMaximumEdgeLength->setRange(0, std::numeric_limits<int>::max());
ui->comboFineness->setCurrentIndex(2);
onComboFinenessCurrentIndexChanged(2);