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

This commit is contained in:
Benjamin Nauck
2025-03-27 19:00:50 +01:00
parent e2da3bce46
commit c1c14a6817
12 changed files with 9 additions and 20 deletions

View File

@@ -27,7 +27,6 @@
#ifndef _PreComp_
#include <boost/algorithm/string/predicate.hpp>
#include <boost/range/adaptor/indexed.hpp>
#include <climits>
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextra-semi"

View File

@@ -36,7 +36,6 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_Location.hxx>
#include <climits>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Pln.hxx> // for Precision::Confusion()

View File

@@ -23,7 +23,6 @@
#ifndef IMPORT_EXPORTOCAF_H
#define IMPORT_EXPORTOCAF_H
#include <climits>
#include <map>
#include <set>
#include <string>

View File

@@ -42,7 +42,6 @@
#include <TopoDS_Iterator.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_Location.hxx>
#include <climits>
#include <gp_Pln.hxx> // for Precision::Confusion()
#include <gp_Trsf.hxx>
#endif

View File

@@ -23,7 +23,6 @@
#ifndef IMPORT_IMPORTOCAF_H
#define IMPORT_IMPORTOCAF_H
#include <climits>
#include <map>
#include <set>
#include <string>

View File

@@ -23,7 +23,6 @@
#ifndef IMPORT_IMPORTOCAF2_H
#define IMPORT_IMPORTOCAF2_H
#include <climits>
#include <map>
#include <set>
#include <string>

View File

@@ -37,7 +37,6 @@
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_Location.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <climits>
#include <sstream>
#endif

View File

@@ -23,7 +23,6 @@
#ifndef IMPORT_ImportOCAFAssembly_H
#define IMPORT_ImportOCAFAssembly_H
#include <climits>
#include <map>
#include <set>
#include <string>

View File

@@ -41,7 +41,7 @@ struct ShapeHasher
#if OCC_VERSION_HEX >= 0x070800
return std::hash<TopoDS_Shape> {}(shape);
#else
return shape.HashCode(INT_MAX);
return shape.HashCode(std::numeric_limits<int>::max());
#endif
}
};
@@ -53,7 +53,7 @@ struct LabelHasher
#if OCC_VERSION_HEX >= 0x070800
return std::hash<TDF_Label> {}(label);
#else
return TDF_LabelMapHasher::HashCode(label, INT_MAX);
return TDF_LabelMapHasher::HashCode(label, std::numeric_limits<int>::max());
#endif
}
};

View File

@@ -977,8 +977,8 @@ void ImpExpDxfWrite::exportEllipse(BRepAdaptor_Curve& c)
// rotation appears to be the clockwise(?) angle between major & +Y??
double rotation = xaxis.AngleWithRef(gp_Dir(0, 1, 0), gp_Dir(0, 0, 1));
// 2*M_PI = 6.28319 is invalid(doesn't display in LibreCAD), but 2PI = 6.28318 is valid!
// writeEllipse(center, major, minor, rotation, 0.0, 2 * M_PI, true );
// 2*pi = 6.28319 is invalid(doesn't display in LibreCAD), but 2PI = 6.28318 is valid!
// writeEllipse(center, major, minor, rotation, 0.0, 2 * std::numbers::pi, true );
writeEllipse(center, major, minor, rotation, 0.0, 6.28318, true);
}
@@ -1036,8 +1036,8 @@ void ImpExpDxfWrite::exportEllipseArc(BRepAdaptor_Curve& c)
// a > 0 ==> v2 is CCW from v1 (righthanded)?
// a < 0 ==> v2 is CW from v1 (lefthanded)?
double startAngle = fmod(f, 2.0 * M_PI); // revolutions
double endAngle = fmod(l, 2.0 * M_PI);
double startAngle = fmod(f, 2.0 * std::numbers::pi); // revolutions
double endAngle = fmod(l, 2.0 * std::numbers::pi);
bool endIsCW = (a < 0) ? true : false; // if !endIsCW swap(start,end)
// not sure if this is a hack or not. seems to make valid arcs.
if (!endIsCW) {

View File

@@ -5,8 +5,6 @@
#include "PreCompiled.h"
// required by windows for M_PI definition
#define _USE_MATH_DEFINES
#include <cmath>
#include <fstream>
#include <iomanip>
@@ -1584,10 +1582,10 @@ void CDxfWrite::writeAngularDimBlock(const double* textMidPoint,
double span = fabs(endAngle - startAngle);
double offset = span * 0.10;
if (startAngle < 0) {
startAngle += 2 * M_PI;
startAngle += 2 * std::numbers::pi;
}
if (endAngle < 0) {
endAngle += 2 * M_PI;
endAngle += 2 * std::numbers::pi;
}
Base::Vector3d startOff(cos(startAngle + offset), sin(startAngle + offset), 0.0);
Base::Vector3d endOff(cos(endAngle - offset), sin(endAngle - offset), 0.0);
@@ -2130,7 +2128,7 @@ bool CDxfRead::ReadEllipse()
Base::Vector3d majorAxisEnd; // relative to centre
double eccentricity = 0;
double startAngleRadians = 0;
double endAngleRadians = 2 * M_PI;
double endAngleRadians = 2 * std::numbers::pi;
Setup3DVectorAttribute(ePrimaryPoint, centre);
Setup3DVectorAttribute(ePoint2, majorAxisEnd);

View File

@@ -25,7 +25,6 @@
#define WNT // avoid conflict with GUID
#endif
#ifndef _PreComp_
#include <climits>
#include <iostream>
#include <QString>