Part: Use std::numeric_limits and std::numbers instead of defines
This commit is contained in:
@@ -1622,7 +1622,8 @@ private:
|
||||
}
|
||||
Py::Object makeRevolution(const Py::Tuple& args)
|
||||
{
|
||||
double vmin = DBL_MAX, vmax=-DBL_MAX;
|
||||
constexpr double doubleMax = std::numeric_limits<double>::max();
|
||||
double vmin = doubleMax, vmax=-doubleMax;
|
||||
double angle=360;
|
||||
PyObject *pPnt=nullptr, *pDir=nullptr, *pCrv;
|
||||
Handle(Geom_Curve) curve;
|
||||
@@ -1641,10 +1642,10 @@ private:
|
||||
if (curve.IsNull()) {
|
||||
throw Py::Exception(PyExc_TypeError, "geometry is not a curve");
|
||||
}
|
||||
if (vmin == DBL_MAX)
|
||||
if (vmin == doubleMax)
|
||||
vmin = curve->FirstParameter();
|
||||
|
||||
if (vmax == -DBL_MAX)
|
||||
if (vmax == -doubleMax)
|
||||
vmax = curve->LastParameter();
|
||||
break;
|
||||
}
|
||||
@@ -1675,9 +1676,9 @@ private:
|
||||
throw Py::Exception(PartExceptionOCCError, "invalid curve in edge");
|
||||
}
|
||||
|
||||
if (vmin == DBL_MAX)
|
||||
if (vmin == doubleMax)
|
||||
vmin = adapt.FirstParameter();
|
||||
if (vmax == -DBL_MAX)
|
||||
if (vmax == -doubleMax)
|
||||
vmax = adapt.LastParameter();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1912,7 +1912,7 @@ AttachEngine3D::_calculateAttachedPlacement(const std::vector<App::DocumentObjec
|
||||
Base::Vector3d(dirs[2].X(), dirs[2].Y(), dirs[2].Z()),
|
||||
orderString);
|
||||
if (this->mapReverse) {
|
||||
rot = rot * Base::Rotation(Base::Vector3d(0, 1, 0), D_PI);
|
||||
rot = rot * Base::Rotation(Base::Vector3d(0, 1, 0), std::numbers::pi);
|
||||
}
|
||||
|
||||
Base::Placement plm = Base::Placement(
|
||||
|
||||
@@ -200,6 +200,8 @@ bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector
|
||||
|
||||
ExtrusionParameters Extrusion::computeFinalParameters()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
ExtrusionParameters result;
|
||||
Base::Vector3d dir;
|
||||
switch (this->DirMode.getValue()) {
|
||||
@@ -244,11 +246,11 @@ ExtrusionParameters Extrusion::computeFinalParameters()
|
||||
|
||||
result.solid = this->Solid.getValue();
|
||||
|
||||
result.taperAngleFwd = this->TaperAngle.getValue() * M_PI / 180.0;
|
||||
if (fabs(result.taperAngleFwd) > M_PI * 0.5 - Precision::Angular())
|
||||
result.taperAngleFwd = this->TaperAngle.getValue() * pi / 180.0;
|
||||
if (fabs(result.taperAngleFwd) > pi * 0.5 - Precision::Angular())
|
||||
throw Base::ValueError("Magnitude of taper angle matches or exceeds 90 degrees. That is too much.");
|
||||
result.taperAngleRev = this->TaperAngleRev.getValue() * M_PI / 180.0;
|
||||
if (fabs(result.taperAngleRev) > M_PI * 0.5 - Precision::Angular())
|
||||
result.taperAngleRev = this->TaperAngleRev.getValue() * pi / 180.0;
|
||||
if (fabs(result.taperAngleRev) > pi * 0.5 - Precision::Angular())
|
||||
throw Base::ValueError("Magnitude of taper angle matches or exceeds 90 degrees. That is too much.");
|
||||
|
||||
result.faceMakerClass = this->FaceMakerClass.getValue();
|
||||
|
||||
@@ -143,7 +143,7 @@ App::DocumentObjectExecReturn *Revolution::execute()
|
||||
gp_Ax1 revAx(pnt, dir);
|
||||
|
||||
//read out revolution angle
|
||||
double angle = Angle.getValue()/180.0f*M_PI;
|
||||
double angle = Angle.getValue()/180.0f * std::numbers::pi;
|
||||
if (fabs(angle) < Precision::Angular())
|
||||
angle = angle_edge;
|
||||
|
||||
|
||||
@@ -2640,7 +2640,7 @@ GeomCurve* GeomCircle::createArc(double first, double last) const
|
||||
GeomBSplineCurve* GeomCircle::toNurbs(double first, double last) const
|
||||
{
|
||||
// for an arc of circle use the generic method
|
||||
if (first != 0 || last != 2*M_PI) {
|
||||
if (first != 0 || last != 2 * std::numbers::pi) {
|
||||
return GeomConic::toNurbs(first, last);
|
||||
}
|
||||
|
||||
@@ -2674,8 +2674,8 @@ GeomBSplineCurve* GeomCircle::toNurbs(double first, double last) const
|
||||
|
||||
TColStd_Array1OfReal knots(1, 3);
|
||||
knots(1) = 0;
|
||||
knots(2) = M_PI;
|
||||
knots(3) = 2*M_PI;
|
||||
knots(2) = std::numbers::pi;
|
||||
knots(3) = 2 * std::numbers::pi;
|
||||
|
||||
Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles, weights,knots, mults, 3,
|
||||
Standard_False, Standard_True);
|
||||
@@ -2906,9 +2906,9 @@ void GeomArcOfCircle::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
}
|
||||
|
||||
if (v < u)
|
||||
v += 2*M_PI;
|
||||
if (v-u > 2*M_PI)
|
||||
v -= 2*M_PI;
|
||||
v += 2 * std::numbers::pi;
|
||||
if (v-u > 2 * std::numbers::pi)
|
||||
v -= 2 * std::numbers::pi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3086,7 +3086,7 @@ GeomCurve* GeomEllipse::createArc(double first, double last) const
|
||||
GeomBSplineCurve* GeomEllipse::toNurbs(double first, double last) const
|
||||
{
|
||||
// for an arc of ellipse use the generic method
|
||||
if (first != 0 || last != 2*M_PI) {
|
||||
if (first != 0 || last != 2 * std::numbers::pi) {
|
||||
return GeomConic::toNurbs(first, last);
|
||||
}
|
||||
|
||||
@@ -3465,9 +3465,9 @@ void GeomArcOfEllipse::getRange(double& u, double& v, bool emulateCCWXY) const
|
||||
std::swap(u,v);
|
||||
u = -u; v = -v;
|
||||
if (v < u)
|
||||
v += 2*M_PI;
|
||||
if (v-u > 2*M_PI)
|
||||
v -= 2*M_PI;
|
||||
v += 2 * std::numbers::pi;
|
||||
if (v-u > 2 * std::numbers::pi)
|
||||
v -= 2 * std::numbers::pi;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4683,11 +4683,12 @@ void GeomLineSegment::Restore (Base::XMLReader &reader)
|
||||
// for other objects, the best effort may be just to leave default values.
|
||||
reader.setPartialRestore(true);
|
||||
|
||||
constexpr double increment{std::numeric_limits<double>::epsilon()};
|
||||
if(start.x == 0) {
|
||||
end = start + Base::Vector3d(DBL_EPSILON,0,0);
|
||||
end = start + Base::Vector3d(increment, 0, 0);
|
||||
}
|
||||
else {
|
||||
end = start + Base::Vector3d(start.x*DBL_EPSILON,0,0);
|
||||
end = start + Base::Vector3d(start.x * increment, 0, 0);
|
||||
}
|
||||
|
||||
setPoints(start, end);
|
||||
@@ -5409,7 +5410,7 @@ gp_Vec GeomCone::getDN(double u, double v, int Nu, int Nv) const
|
||||
{
|
||||
gp_XYZ Xdir = Pos.XDirection().XYZ();
|
||||
gp_XYZ Ydir = Pos.YDirection().XYZ();
|
||||
Standard_Real Um = U + Nu * M_PI_2; // M_PI * 0.5
|
||||
Standard_Real Um = U + Nu * std::numbers::pi/2;
|
||||
Xdir.Multiply(cos(Um));
|
||||
Ydir.Multiply(sin(Um));
|
||||
Xdir.Add(Ydir);
|
||||
@@ -6228,11 +6229,11 @@ GeomArcOfCircle *createFilletGeometry(const GeomLineSegment *lineSeg1, const Geo
|
||||
if (endAngle < startAngle)
|
||||
std::swap(startAngle, endAngle);
|
||||
|
||||
if (endAngle > 2*M_PI )
|
||||
endAngle -= 2*M_PI;
|
||||
if (endAngle > 2 * std::numbers::pi)
|
||||
endAngle -= 2 * std::numbers::pi;
|
||||
|
||||
if (startAngle < 0 )
|
||||
endAngle += 2*M_PI;
|
||||
if (startAngle < 0)
|
||||
endAngle += 2 * std::numbers::pi;
|
||||
|
||||
// Create Arc Segment
|
||||
GeomArcOfCircle *arc = new GeomArcOfCircle();
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <limits>
|
||||
|
||||
// STL
|
||||
#include <array>
|
||||
@@ -52,6 +53,7 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <numbers>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
# include <limits>
|
||||
# include <BRepBuilderAPI_GTransform.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
@@ -57,7 +57,7 @@ namespace Part {
|
||||
const App::PropertyQuantityConstraint::Constraints torusRangeV = {-180.0, 180.0, 1.0};
|
||||
const App::PropertyQuantityConstraint::Constraints angleRangeU = {0.0, 360.0, 1.0};
|
||||
const App::PropertyQuantityConstraint::Constraints angleRangeV = {-90.0, 90.0, 1.0};
|
||||
const App::PropertyQuantityConstraint::Constraints quantityRange = {0.0, FLT_MAX, 0.1};
|
||||
const App::PropertyQuantityConstraint::Constraints quantityRange = {0.0, std::numeric_limits<float>::max(), 0.1};
|
||||
}
|
||||
|
||||
using namespace Part;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
size_t operator()(const TopoDS_Shape& theShape) const
|
||||
{
|
||||
#if OCC_VERSION_HEX < 0x070800
|
||||
return theShape.HashCode(INT_MAX);
|
||||
return theShape.HashCode(std::numeric_limits<int>::max());
|
||||
#else
|
||||
return std::hash<TopoDS_Shape>{}(theShape);
|
||||
#endif
|
||||
|
||||
@@ -773,9 +773,9 @@ bool Part::Tools::isConcave(const TopoDS_Face &face, const gp_Pnt &pointOfVue, c
|
||||
|
||||
// check normals orientation
|
||||
gp_Dir dirdU(dU);
|
||||
result = (dirdU.Angle(direction) - M_PI_2) <= Precision::Confusion();
|
||||
result = (dirdU.Angle(direction) - std::numbers::pi/2) <= Precision::Confusion();
|
||||
gp_Dir dirdV(dV);
|
||||
result = result || ((dirdV.Angle(direction) - M_PI_2) <= Precision::Confusion());
|
||||
result = result || ((dirdV.Angle(direction) - std::numbers::pi/2) <= Precision::Confusion());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2004,7 +2004,7 @@ TopoDS_Shape TopoShape::makeTube(double radius, double tol, int cont, int maxdeg
|
||||
|
||||
//circular profile
|
||||
Handle(Geom_Circle) aCirc = new Geom_Circle (gp::XOY(), theRadius);
|
||||
aCirc->Rotate (gp::OZ(), M_PI/2.);
|
||||
aCirc->Rotate (gp::OZ(), std::numbers::pi/2.);
|
||||
|
||||
//perpendicular section
|
||||
Handle(Law_Function) myEvol = ::CreateBsFunction (myPath->FirstParameter(), myPath->LastParameter(), theRadius);
|
||||
@@ -2116,6 +2116,8 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
|
||||
Standard_Boolean leftHanded,
|
||||
Standard_Boolean newStyle) const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (fabs(pitch) < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch of helix too small");
|
||||
|
||||
@@ -2140,24 +2142,24 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
|
||||
}
|
||||
|
||||
gp_Pnt2d aPnt(0, 0);
|
||||
gp_Dir2d aDir(2. * M_PI, pitch);
|
||||
gp_Dir2d aDir(2. * pi, pitch);
|
||||
Standard_Real coneDir = 1.0;
|
||||
if (leftHanded) {
|
||||
aDir.SetCoord(-2. * M_PI, pitch);
|
||||
aDir.SetCoord(-2. * pi, pitch);
|
||||
coneDir = -1.0;
|
||||
}
|
||||
gp_Ax2d aAx2d(aPnt, aDir);
|
||||
|
||||
Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d);
|
||||
gp_Pnt2d beg = line->Value(0);
|
||||
gp_Pnt2d end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*(height/pitch));
|
||||
gp_Pnt2d end = line->Value(sqrt(4.0*pi*pi+pitch*pitch)*(height/pitch));
|
||||
|
||||
if (newStyle) {
|
||||
// See discussion at 0001247: Part Conical Helix Height/Pitch Incorrect
|
||||
if (angle >= Precision::Confusion()) {
|
||||
// calculate end point for conical helix
|
||||
Standard_Real v = height / cos(angle);
|
||||
Standard_Real u = coneDir * (height/pitch) * 2.0 * M_PI;
|
||||
Standard_Real u = coneDir * (height/pitch) * 2.0 * pi;
|
||||
gp_Pnt2d cend(u, v);
|
||||
end = cend;
|
||||
}
|
||||
@@ -2179,6 +2181,8 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
|
||||
Standard_Real radius, Standard_Real angle,
|
||||
Standard_Boolean leftHanded) const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (pitch < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch of helix too small");
|
||||
|
||||
@@ -2206,10 +2210,10 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
|
||||
Standard_Real partTurn = turns - wholeTurns;
|
||||
|
||||
gp_Pnt2d aPnt(0, 0);
|
||||
gp_Dir2d aDir(2. * M_PI, pitch);
|
||||
gp_Dir2d aDir(2. * pi, pitch);
|
||||
Standard_Real coneDir = 1.0;
|
||||
if (leftHanded) {
|
||||
aDir.SetCoord(-2. * M_PI, pitch);
|
||||
aDir.SetCoord(-2. * pi, pitch);
|
||||
coneDir = -1.0;
|
||||
}
|
||||
gp_Ax2d aAx2d(aPnt, aDir);
|
||||
@@ -2223,10 +2227,10 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
|
||||
|
||||
for (unsigned long i = 0; i < wholeTurns; i++) {
|
||||
if (isCylinder) {
|
||||
end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*(i+1));
|
||||
end = line->Value(sqrt(4.0*pi*pi+pitch*pitch)*(i+1));
|
||||
}
|
||||
else {
|
||||
u = coneDir * (i+1) * 2.0 * M_PI;
|
||||
u = coneDir * (i+1) * 2.0 * pi;
|
||||
v = ((i+1) * pitch) / cos(angle);
|
||||
end = gp_Pnt2d(u, v);
|
||||
}
|
||||
@@ -2238,10 +2242,10 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
|
||||
|
||||
if (partTurn > Precision::Confusion()) {
|
||||
if (isCylinder) {
|
||||
end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*turns);
|
||||
end = line->Value(sqrt(4.0*pi*pi+pitch*pitch)*turns);
|
||||
}
|
||||
else {
|
||||
u = coneDir * turns * 2.0 * M_PI;
|
||||
u = coneDir * turns * 2.0 * pi;
|
||||
v = height / cos(angle);
|
||||
end = gp_Pnt2d(u, v);
|
||||
}
|
||||
@@ -2283,9 +2287,9 @@ TopoDS_Shape TopoShape::makeSpiralHelix(Standard_Real radiusbottom, Standard_Rea
|
||||
|
||||
gp_Pnt2d beg(0, 0);
|
||||
gp_Pnt2d end(0, 0);
|
||||
gp_Vec2d dir(breakperiod * 2.0 * M_PI, 1 / nbPeriods);
|
||||
gp_Vec2d dir(breakperiod * 2.0 * std::numbers::pi, 1 / nbPeriods);
|
||||
if (leftHanded == Standard_True)
|
||||
dir = gp_Vec2d(-breakperiod * 2.0 * M_PI, 1 / nbPeriods);
|
||||
dir = gp_Vec2d(-breakperiod * 2.0 * std::numbers::pi, 1 / nbPeriods);
|
||||
Handle(Geom2d_TrimmedCurve) segm;
|
||||
TopoDS_Edge edgeOnSurf;
|
||||
BRepBuilderAPI_MakeWire mkWire;
|
||||
@@ -2314,6 +2318,7 @@ TopoDS_Shape TopoShape::makeThread(Standard_Real pitch,
|
||||
Standard_Real height,
|
||||
Standard_Real radius) const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
if (pitch < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch of thread too small");
|
||||
|
||||
@@ -2332,21 +2337,21 @@ TopoDS_Shape TopoShape::makeThread(Standard_Real pitch,
|
||||
Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(cylAx2 , radius+depth);
|
||||
|
||||
//Threading : Define 2D Curves
|
||||
gp_Pnt2d aPnt(2. * M_PI , height / 2.);
|
||||
gp_Dir2d aDir(2. * M_PI , height / 4.);
|
||||
gp_Pnt2d aPnt(2. * pi , height / 2.);
|
||||
gp_Dir2d aDir(2. * pi , height / 4.);
|
||||
gp_Ax2d aAx2d(aPnt , aDir);
|
||||
|
||||
Standard_Real aMajor = 2. * M_PI;
|
||||
Standard_Real aMajor = 2. * pi;
|
||||
Standard_Real aMinor = pitch;
|
||||
|
||||
Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor);
|
||||
Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor / 4);
|
||||
|
||||
Handle(Geom2d_TrimmedCurve) aArc1 = new Geom2d_TrimmedCurve(anEllipse1 , 0 , M_PI);
|
||||
Handle(Geom2d_TrimmedCurve) aArc2 = new Geom2d_TrimmedCurve(anEllipse2 , 0 , M_PI);
|
||||
Handle(Geom2d_TrimmedCurve) aArc1 = new Geom2d_TrimmedCurve(anEllipse1 , 0 , pi);
|
||||
Handle(Geom2d_TrimmedCurve) aArc2 = new Geom2d_TrimmedCurve(anEllipse2 , 0 , pi);
|
||||
|
||||
gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0);
|
||||
gp_Pnt2d anEllipsePnt2 = anEllipse1->Value(M_PI);
|
||||
gp_Pnt2d anEllipsePnt2 = anEllipse1->Value(pi);
|
||||
|
||||
Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment(anEllipsePnt1 , anEllipsePnt2);
|
||||
|
||||
|
||||
@@ -126,7 +126,8 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear();
|
||||
PyObject *pcObj, *pcObj2;
|
||||
double first=DBL_MAX, last=DBL_MAX;
|
||||
double first = std::numeric_limits<double>::max();
|
||||
double last = std::numeric_limits<double>::max();
|
||||
if (PyArg_ParseTuple(args, "O!|dd", &(Part::GeometryPy::Type), &pcObj, &first, &last)) {
|
||||
Geometry* geom = static_cast<GeometryPy*>(pcObj)->getGeometryPtr();
|
||||
Handle(Geom_Curve) curve = Handle(Geom_Curve)::DownCast(geom->handle());
|
||||
@@ -135,9 +136,9 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (first==DBL_MAX)
|
||||
if (first == std::numeric_limits<double>::max())
|
||||
first = curve->FirstParameter();
|
||||
if (last==DBL_MAX)
|
||||
if (last == std::numeric_limits<double>::max())
|
||||
last = curve->LastParameter();
|
||||
|
||||
try {
|
||||
|
||||
@@ -1611,6 +1611,7 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
bool delayed = false;
|
||||
|
||||
while (true) {
|
||||
constexpr int intMin = std::numeric_limits<int>::min();
|
||||
|
||||
// Construct the names for modification/generation info collected in
|
||||
// the previous step
|
||||
@@ -1632,7 +1633,7 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
const auto& first_key = names.begin()->first;
|
||||
auto& first_info = names.begin()->second;
|
||||
|
||||
if (!delayed && first_key.shapetype >= 3 && first_info.index > INT_MIN + 1) {
|
||||
if (!delayed && first_key.shapetype >= 3 && first_info.index > intMin + 1) {
|
||||
// This name is mapped from high level (shell, solid, etc.)
|
||||
// Delay till next round.
|
||||
//
|
||||
@@ -1680,10 +1681,10 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
// 'K' marks the additional source shape of this
|
||||
// generate (or modified) shape.
|
||||
ss2 << elementMapPrefix() << 'K';
|
||||
if (other_info.index == INT_MIN) {
|
||||
if (other_info.index == intMin) {
|
||||
ss2 << '0';
|
||||
}
|
||||
else if (other_info.index == INT_MIN + 1) {
|
||||
else if (other_info.index == intMin + 1) {
|
||||
ss2 << "00";
|
||||
}
|
||||
else {
|
||||
@@ -1740,10 +1741,10 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
else {
|
||||
ss << modgenPostfix();
|
||||
}
|
||||
if (first_info.index == INT_MIN) {
|
||||
if (first_info.index == intMin) {
|
||||
ss << '0';
|
||||
}
|
||||
else if (first_info.index == INT_MIN + 1) {
|
||||
else if (first_info.index == intMin + 1) {
|
||||
ss << "00";
|
||||
}
|
||||
else if (abs(first_info.index) > 1) {
|
||||
|
||||
@@ -46,7 +46,7 @@ struct ShapeHasher
|
||||
#if OCC_VERSION_HEX >= 0x070800
|
||||
return std::hash<TopoDS_Shape> {}(s.getShape());
|
||||
#else
|
||||
return s.getShape().HashCode(INT_MAX);
|
||||
return s.getShape().HashCode(std::numeric_limits<int>::max());
|
||||
#endif
|
||||
}
|
||||
inline size_t operator()(const TopoDS_Shape& s) const
|
||||
@@ -54,7 +54,7 @@ struct ShapeHasher
|
||||
#if OCC_VERSION_HEX >= 0x070800
|
||||
return std::hash<TopoDS_Shape> {}(s);
|
||||
#else
|
||||
return s.HashCode(INT_MAX);
|
||||
return s.HashCode(std::numeric_limits<int>::max());
|
||||
#endif
|
||||
}
|
||||
inline bool operator()(const TopoShape& a, const TopoShape& b) const
|
||||
@@ -78,8 +78,8 @@ struct ShapeHasher
|
||||
size_t res = std::hash<TopoDS_Shape> {}(s.first.getShape());
|
||||
hash_combine(res, std::hash<TopoDS_Shape> {}(s.second.getShape()));
|
||||
#else
|
||||
size_t res = s.first.getShape().HashCode(INT_MAX);
|
||||
hash_combine(res, s.second.getShape().HashCode(INT_MAX));
|
||||
size_t res = s.first.getShape().HashCode(std::numeric_limits<int>::max());
|
||||
hash_combine(res, s.second.getShape().HashCode(std::numeric_limits<int>::max()));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
@@ -89,8 +89,8 @@ struct ShapeHasher
|
||||
size_t res = std::hash<TopoDS_Shape> {}(s.first);
|
||||
hash_combine(res, std::hash<TopoDS_Shape> {}(s.second));
|
||||
#else
|
||||
size_t res = s.first.HashCode(INT_MAX);
|
||||
hash_combine(res, s.second.HashCode(INT_MAX));
|
||||
size_t res = s.first.HashCode(std::numeric_limits<int>::max());
|
||||
hash_combine(res, s.second.HashCode(std::numeric_limits<int>::max()));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ static Py_hash_t _TopoShapeHash(PyObject* self)
|
||||
#if OCC_VERSION_HEX >= 0x070800
|
||||
return std::hash<TopoDS_Shape> {}(static_cast<TopoShapePy*>(self)->getTopoShapePtr()->getShape());
|
||||
#else
|
||||
return static_cast<TopoShapePy*>(self)->getTopoShapePtr()->getShape().HashCode(INT_MAX);
|
||||
return static_cast<TopoShapePy*>(self)->getTopoShapePtr()->getShape().HashCode(
|
||||
std::numeric_limits<int>::max());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -784,11 +784,12 @@ public:
|
||||
const bool isLinear)
|
||||
{
|
||||
std::unique_ptr<Geometry> geo;
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(p1, INT_MAX)); vit != vmap.qend(); ++vit) {
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(p1, max)); vit != vmap.qend(); ++vit) {
|
||||
auto& vinfo = *vit;
|
||||
if (canShowShape()) {
|
||||
#if OCC_VERSION_HEX < 0x070800
|
||||
FC_MSG("addcheck " << vinfo.edge().HashCode(INT_MAX));
|
||||
FC_MSG("addcheck " << vinfo.edge().HashCode(max));
|
||||
#else
|
||||
FC_MSG("addcheck " << std::hash<TopoDS_Edge> {}(vinfo.edge()));
|
||||
#endif
|
||||
@@ -1568,7 +1569,8 @@ public:
|
||||
}
|
||||
info.iEnd[ic] = info.iStart[ic] = (int)adjacentList.size();
|
||||
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(pt[ic], INT_MAX)); vit != vmap.qend();
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(pt[ic], max)); vit != vmap.qend();
|
||||
++vit) {
|
||||
auto& vinfo = *vit;
|
||||
if (vinfo.pt().SquareDistance(pt[ic]) > myTol2) {
|
||||
@@ -2717,7 +2719,8 @@ public:
|
||||
FC_MSG("init:");
|
||||
for (const auto& shape : sourceEdges) {
|
||||
#if OCC_VERSION_HEX < 0x070800
|
||||
FC_MSG(shape.getShape().TShape().get() << ", " << shape.getShape().HashCode(INT_MAX));
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
FC_MSG(shape.getShape().TShape().get() << ", " << shape.getShape().HashCode(max));
|
||||
#else
|
||||
FC_MSG(shape.getShape().TShape().get()
|
||||
<< ", " << std::hash<TopoDS_Shape> {}(shape.getShape()));
|
||||
@@ -2736,7 +2739,8 @@ public:
|
||||
for (int i = 1; i <= wireData->NbEdges(); ++i) {
|
||||
auto shape = wireData->Edge(i);
|
||||
#if OCC_VERSION_HEX < 0x070800
|
||||
FC_MSG(shape.TShape().get() << ", " << shape.HashCode(INT_MAX));
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
FC_MSG(shape.TShape().get() << ", " << shape.HashCode(max));
|
||||
#else
|
||||
FC_MSG(shape.TShape().get() << ", " << std::hash<TopoDS_Edge> {}(shape));
|
||||
#endif
|
||||
@@ -2800,9 +2804,10 @@ public:
|
||||
for (TopTools_ListIteratorOfListOfShape it(hist->Modified(shape.getShape())); it.More();
|
||||
it.Next()) {
|
||||
#if OCC_VERSION_HEX < 0x070800
|
||||
FC_MSG(shape.getShape().TShape().get()
|
||||
<< ", " << shape.getShape().HashCode(INT_MAX) << " -> "
|
||||
<< it.Value().TShape().get() << ", " << it.Value().HashCode(INT_MAX));
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
FC_MSG(shape.getShape().TShape().get()
|
||||
<< ", " << shape.getShape().HashCode(max) << " -> "
|
||||
<< it.Value().TShape().get() << ", " << it.Value().HashCode(max));
|
||||
#else
|
||||
FC_MSG(shape.getShape().TShape().get()
|
||||
<< ", " << std::hash<TopoDS_Shape> {}(shape.getShape()) << " -> "
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <numbers>
|
||||
# include <iterator>
|
||||
# include <Bnd_Box.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
@@ -613,8 +614,8 @@ bool wireEncirclesAxis(const TopoDS_Wire& wire, const Handle(Geom_CylindricalSur
|
||||
|
||||
// For an exact calculation, only two results would be possible:
|
||||
// totalArc = 0.0: The wire does not encircle the axis
|
||||
// totalArc = 2 * M_PI * radius: The wire encircles the axis
|
||||
return (fabs(totalArc) > M_PI * radius);
|
||||
// totalArc = 2 * std::numbers::pi * radius: The wire encircles the axis
|
||||
return (fabs(totalArc) > std::numbers::pi * radius);
|
||||
}
|
||||
|
||||
TopoDS_Face FaceTypedCylinder::buildFace(const FaceVectorType &faces) const
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
# include <QFuture>
|
||||
# include <QKeyEvent>
|
||||
|
||||
@@ -126,9 +125,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);
|
||||
vp = new ViewProviderCrossSections();
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ QWidget *FilletRadiusDelegate::createEditor(QWidget *parent, const QStyleOptionV
|
||||
Gui::QuantitySpinBox *editor = new Gui::QuantitySpinBox(parent);
|
||||
editor->setUnit(Base::Unit::Length);
|
||||
editor->setMinimum(0.0);
|
||||
editor->setMaximum(INT_MAX);
|
||||
editor->setMaximum(std::numeric_limits<int>::max());
|
||||
editor->setSingleStep(0.1);
|
||||
|
||||
return editor;
|
||||
@@ -234,11 +234,11 @@ DlgFilletEdges::DlgFilletEdges(FilletType type, Part::FilletBase* fillet, QWidge
|
||||
ui->setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
ui->filletStartRadius->setMaximum(INT_MAX);
|
||||
ui->filletStartRadius->setMaximum(std::numeric_limits<int>::max());
|
||||
ui->filletStartRadius->setMinimum(0);
|
||||
ui->filletStartRadius->setUnit(Base::Unit::Length);
|
||||
|
||||
ui->filletEndRadius->setMaximum(INT_MAX);
|
||||
ui->filletEndRadius->setMaximum(std::numeric_limits<int>::max());
|
||||
ui->filletEndRadius->setMinimum(0);
|
||||
ui->filletEndRadius->setUnit(Base::Unit::Length);
|
||||
|
||||
|
||||
@@ -239,8 +239,8 @@ PlanePrimitive::PlanePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Plane
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->planeLength->setRange(0, INT_MAX);
|
||||
ui->planeWidth->setRange(0, INT_MAX);
|
||||
ui->planeLength->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->planeWidth->setRange(0, std::numeric_limits<int>::max());
|
||||
|
||||
if (feature) {
|
||||
ui->planeLength->setValue(feature->Length.getQuantityValue());
|
||||
@@ -308,9 +308,9 @@ BoxPrimitive::BoxPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Box* feat
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->boxLength->setRange(0, INT_MAX);
|
||||
ui->boxWidth->setRange(0, INT_MAX);
|
||||
ui->boxHeight->setRange(0, INT_MAX);
|
||||
ui->boxLength->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->boxWidth->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->boxHeight->setRange(0, std::numeric_limits<int>::max());
|
||||
|
||||
if (feature) {
|
||||
ui->boxLength->setValue(feature->Length.getQuantityValue());
|
||||
@@ -388,8 +388,8 @@ CylinderPrimitive::CylinderPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part:
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->cylinderRadius->setRange(0, INT_MAX);
|
||||
ui->cylinderHeight->setRange(0, INT_MAX);
|
||||
ui->cylinderRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->cylinderHeight->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->cylinderAngle->setRange(0, 360);
|
||||
|
||||
if (feature) {
|
||||
@@ -488,9 +488,9 @@ ConePrimitive::ConePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Cone* f
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->coneRadius1->setRange(0, INT_MAX);
|
||||
ui->coneRadius2->setRange(0, INT_MAX);
|
||||
ui->coneHeight->setRange(0, INT_MAX);
|
||||
ui->coneRadius1->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->coneRadius2->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->coneHeight->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->coneAngle->setRange(0, 360);
|
||||
|
||||
if (feature) {
|
||||
@@ -579,7 +579,7 @@ SpherePrimitive::SpherePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Sph
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->sphereRadius->setRange(0, INT_MAX);
|
||||
ui->sphereRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->sphereAngle1->setRange(-90, 90);
|
||||
ui->sphereAngle2->setRange(-90, 90);
|
||||
ui->sphereAngle3->setRange(0, 360);
|
||||
@@ -670,9 +670,9 @@ EllipsoidPrimitive::EllipsoidPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Par
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->ellipsoidRadius1->setRange(0, INT_MAX);
|
||||
ui->ellipsoidRadius2->setRange(0, INT_MAX);
|
||||
ui->ellipsoidRadius3->setRange(0, INT_MAX);
|
||||
ui->ellipsoidRadius1->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->ellipsoidRadius2->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->ellipsoidRadius3->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->ellipsoidAngle1->setRange(-90, 90);
|
||||
ui->ellipsoidAngle2->setRange(-90, 90);
|
||||
ui->ellipsoidAngle3->setRange(0, 360);
|
||||
@@ -784,8 +784,8 @@ TorusPrimitive::TorusPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Torus
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->torusRadius1->setRange(0, INT_MAX);
|
||||
ui->torusRadius2->setRange(0, INT_MAX);
|
||||
ui->torusRadius1->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->torusRadius2->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->torusAngle1->setRange(-180, 180);
|
||||
ui->torusAngle2->setRange(-180, 180);
|
||||
ui->torusAngle3->setRange(0, 360);
|
||||
@@ -886,8 +886,8 @@ PrismPrimitive::PrismPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Prism
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->prismCircumradius->setRange(0, INT_MAX);
|
||||
ui->prismHeight->setRange(0, INT_MAX);
|
||||
ui->prismCircumradius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->prismHeight->setRange(0, std::numeric_limits<int>::max());
|
||||
|
||||
if (feature) {
|
||||
ui->prismPolygon->setValue(feature->Polygon.getValue());
|
||||
@@ -984,26 +984,28 @@ WedgePrimitive::WedgePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Wedge
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->wedgeXmin->setMinimum(INT_MIN);
|
||||
ui->wedgeXmin->setMaximum(INT_MAX);
|
||||
ui->wedgeYmin->setMinimum(INT_MIN);
|
||||
ui->wedgeYmin->setMaximum(INT_MAX);
|
||||
ui->wedgeZmin->setMinimum(INT_MIN);
|
||||
ui->wedgeZmin->setMaximum(INT_MAX);
|
||||
ui->wedgeX2min->setMinimum(INT_MIN);
|
||||
ui->wedgeX2min->setMaximum(INT_MAX);
|
||||
ui->wedgeZ2min->setMinimum(INT_MIN);
|
||||
ui->wedgeZ2min->setMaximum(INT_MAX);
|
||||
ui->wedgeXmax->setMinimum(INT_MIN);
|
||||
ui->wedgeXmax->setMaximum(INT_MAX);
|
||||
ui->wedgeYmax->setMinimum(INT_MIN);
|
||||
ui->wedgeYmax->setMaximum(INT_MAX);
|
||||
ui->wedgeZmax->setMinimum(INT_MIN);
|
||||
ui->wedgeZmax->setMaximum(INT_MAX);
|
||||
ui->wedgeX2max->setMinimum(INT_MIN);
|
||||
ui->wedgeX2max->setMaximum(INT_MAX);
|
||||
ui->wedgeZ2max->setMinimum(INT_MIN);
|
||||
ui->wedgeZ2max->setMaximum(INT_MAX);
|
||||
constexpr int min = std::numeric_limits<int>::min();
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
ui->wedgeXmin->setMinimum(min);
|
||||
ui->wedgeXmin->setMaximum(max);
|
||||
ui->wedgeYmin->setMinimum(min);
|
||||
ui->wedgeYmin->setMaximum(max);
|
||||
ui->wedgeZmin->setMinimum(min);
|
||||
ui->wedgeZmin->setMaximum(max);
|
||||
ui->wedgeX2min->setMinimum(min);
|
||||
ui->wedgeX2min->setMaximum(max);
|
||||
ui->wedgeZ2min->setMinimum(min);
|
||||
ui->wedgeZ2min->setMaximum(max);
|
||||
ui->wedgeXmax->setMinimum(min);
|
||||
ui->wedgeXmax->setMaximum(max);
|
||||
ui->wedgeYmax->setMinimum(min);
|
||||
ui->wedgeYmax->setMaximum(max);
|
||||
ui->wedgeZmax->setMinimum(min);
|
||||
ui->wedgeZmax->setMaximum(max);
|
||||
ui->wedgeX2max->setMinimum(min);
|
||||
ui->wedgeX2max->setMaximum(max);
|
||||
ui->wedgeZ2max->setMinimum(min);
|
||||
ui->wedgeZ2max->setMaximum(max);
|
||||
|
||||
if (feature) {
|
||||
ui->wedgeXmin->setValue(feature->Xmin.getQuantityValue());
|
||||
@@ -1151,9 +1153,9 @@ HelixPrimitive::HelixPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Helix
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->helixPitch->setRange(0, INT_MAX);
|
||||
ui->helixHeight->setRange(0, INT_MAX);
|
||||
ui->helixRadius->setRange(0, INT_MAX);
|
||||
ui->helixPitch->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->helixHeight->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->helixRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->helixAngle->setRange(-89.9, 89.9);
|
||||
|
||||
if (feature) {
|
||||
@@ -1252,9 +1254,9 @@ SpiralPrimitive::SpiralPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Spi
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->spiralGrowth->setRange(0, INT_MAX);
|
||||
ui->spiralRotation->setRange(0, INT_MAX);
|
||||
ui->spiralRadius->setRange(0, INT_MAX);
|
||||
ui->spiralGrowth->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->spiralRotation->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->spiralRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
|
||||
if (feature) {
|
||||
ui->spiralGrowth->setValue(feature->Growth.getQuantityValue());
|
||||
@@ -1331,7 +1333,7 @@ CirclePrimitive::CirclePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Cir
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->circleRadius->setRange(0, INT_MAX);
|
||||
ui->circleRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->circleAngle1->setRange(0, 360);
|
||||
ui->circleAngle2->setRange(0, 360);
|
||||
|
||||
@@ -1411,8 +1413,8 @@ EllipsePrimitive::EllipsePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::E
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->ellipseMajorRadius->setRange(0, INT_MAX);
|
||||
ui->ellipseMinorRadius->setRange(0, INT_MAX);
|
||||
ui->ellipseMajorRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->ellipseMinorRadius->setRange(0, std::numeric_limits<int>::max());
|
||||
ui->ellipseAngle1->setRange(0, 360);
|
||||
ui->ellipseAngle2->setRange(0, 360);
|
||||
|
||||
@@ -1502,7 +1504,7 @@ PolygonPrimitive::PolygonPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::R
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->regularPolygonCircumradius->setRange(0, INT_MAX);
|
||||
ui->regularPolygonCircumradius->setRange(0, std::numeric_limits<int>::max());
|
||||
|
||||
if (feature) {
|
||||
ui->regularPolygonPolygon->setValue(feature->Polygon.getValue());
|
||||
@@ -1569,18 +1571,20 @@ LinePrimitive::LinePrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Line* f
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->edgeX1->setMaximum(INT_MAX);
|
||||
ui->edgeX1->setMinimum(INT_MIN);
|
||||
ui->edgeY1->setMaximum(INT_MAX);
|
||||
ui->edgeY1->setMinimum(INT_MIN);
|
||||
ui->edgeZ1->setMaximum(INT_MAX);
|
||||
ui->edgeZ1->setMinimum(INT_MIN);
|
||||
ui->edgeX2->setMaximum(INT_MAX);
|
||||
ui->edgeX2->setMinimum(INT_MIN);
|
||||
ui->edgeY2->setMaximum(INT_MAX);
|
||||
ui->edgeY2->setMinimum(INT_MIN);
|
||||
ui->edgeZ2->setMaximum(INT_MAX);
|
||||
ui->edgeZ2->setMinimum(INT_MIN);
|
||||
constexpr int min = std::numeric_limits<int>::min();
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
ui->edgeX1->setMaximum(max);
|
||||
ui->edgeX1->setMinimum(min);
|
||||
ui->edgeY1->setMaximum(max);
|
||||
ui->edgeY1->setMinimum(min);
|
||||
ui->edgeZ1->setMaximum(max);
|
||||
ui->edgeZ1->setMinimum(min);
|
||||
ui->edgeX2->setMaximum(max);
|
||||
ui->edgeX2->setMinimum(min);
|
||||
ui->edgeY2->setMaximum(max);
|
||||
ui->edgeY2->setMinimum(min);
|
||||
ui->edgeZ2->setMaximum(max);
|
||||
ui->edgeZ2->setMinimum(min);
|
||||
|
||||
if (feature) {
|
||||
ui->edgeX1->setValue(feature->X1.getQuantityValue());
|
||||
@@ -1688,12 +1692,14 @@ VertexPrimitive::VertexPrimitive(std::shared_ptr<Ui_DlgPrimitives> ui, Part::Ver
|
||||
: AbstractPrimitive(feature)
|
||||
, ui(ui)
|
||||
{
|
||||
ui->vertexX->setMaximum(INT_MAX);
|
||||
ui->vertexY->setMaximum(INT_MAX);
|
||||
ui->vertexZ->setMaximum(INT_MAX);
|
||||
ui->vertexX->setMinimum(INT_MIN);
|
||||
ui->vertexY->setMinimum(INT_MIN);
|
||||
ui->vertexZ->setMinimum(INT_MIN);
|
||||
constexpr int min = std::numeric_limits<int>::min();
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
ui->vertexX->setMaximum(max);
|
||||
ui->vertexY->setMaximum(max);
|
||||
ui->vertexZ->setMaximum(max);
|
||||
ui->vertexX->setMinimum(min);
|
||||
ui->vertexY->setMinimum(min);
|
||||
ui->vertexZ->setMinimum(min);
|
||||
|
||||
if (feature) {
|
||||
ui->vertexX->setValue(feature->X.getQuantityValue());
|
||||
|
||||
@@ -103,16 +103,17 @@ DlgRevolution::DlgRevolution(QWidget* parent, Qt::WindowFlags fl)
|
||||
ui->setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
ui->xPos->setRange(-DBL_MAX,DBL_MAX);
|
||||
ui->yPos->setRange(-DBL_MAX,DBL_MAX);
|
||||
ui->zPos->setRange(-DBL_MAX,DBL_MAX);
|
||||
constexpr double max = std::numeric_limits<double>::max();
|
||||
ui->xPos->setRange(-max, max);
|
||||
ui->yPos->setRange(-max, max);
|
||||
ui->zPos->setRange(-max, max);
|
||||
ui->xPos->setUnit(Base::Unit::Length);
|
||||
ui->yPos->setUnit(Base::Unit::Length);
|
||||
ui->zPos->setUnit(Base::Unit::Length);
|
||||
|
||||
ui->xDir->setRange(-DBL_MAX,DBL_MAX);
|
||||
ui->yDir->setRange(-DBL_MAX,DBL_MAX);
|
||||
ui->zDir->setRange(-DBL_MAX,DBL_MAX);
|
||||
ui->xDir->setRange(-max, max);
|
||||
ui->yDir->setRange(-max, max);
|
||||
ui->zDir->setRange(-max, max);
|
||||
ui->xDir->setUnit(Base::Unit());
|
||||
ui->yDir->setUnit(Base::Unit());
|
||||
ui->zDir->setUnit(Base::Unit());
|
||||
@@ -307,7 +308,7 @@ bool DlgRevolution::validate()
|
||||
|
||||
//check angle
|
||||
if (!axisLinkHasAngle){
|
||||
if (fabs(this->getAngle() / 180.0 * M_PI) < Precision::Angular()) {
|
||||
if (fabs(this->getAngle() / 180.0 * std::numbers::pi) < Precision::Angular()) {
|
||||
QMessageBox::critical(this, windowTitle(),
|
||||
tr("Revolution angle span is zero. It must be non-zero."));
|
||||
ui->angle->setFocus();
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
|
||||
// to avoid compiler warnings of redefining contents of basic.h
|
||||
// later by #include <Gui/ViewProvider.h>
|
||||
# define _USE_MATH_DEFINES
|
||||
# include <cmath>
|
||||
|
||||
# include <gp_Ax2.hxx>
|
||||
@@ -40,7 +37,6 @@
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
|
||||
# include <cfloat>
|
||||
# include <QMessageBox>
|
||||
# include <QRegularExpression>
|
||||
# include <QTreeWidget>
|
||||
@@ -182,9 +178,10 @@ Mirroring::Mirroring(QWidget* parent)
|
||||
: QWidget(parent), ui(new Ui_Mirroring)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->baseX->setRange(-DBL_MAX, DBL_MAX);
|
||||
ui->baseY->setRange(-DBL_MAX, DBL_MAX);
|
||||
ui->baseZ->setRange(-DBL_MAX, DBL_MAX);
|
||||
constexpr double max = std::numeric_limits<double>::max();
|
||||
ui->baseX->setRange(-max, max);
|
||||
ui->baseY->setRange(-max, max);
|
||||
ui->baseZ->setRange(-max, max);
|
||||
ui->baseX->setUnit(Base::Unit::Length);
|
||||
ui->baseY->setUnit(Base::Unit::Length);
|
||||
ui->baseZ->setUnit(Base::Unit::Length);
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
// STL
|
||||
|
||||
@@ -24,10 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# ifdef _MSC_VER
|
||||
# define _USE_MATH_DEFINES
|
||||
# include <cmath>
|
||||
# endif //_MSC_VER
|
||||
# include <cmath>
|
||||
#endif // _PreComp_
|
||||
|
||||
#include <Gui/Application.h>
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
|
||||
// to avoid compiler warnings of redefining contents of basic.h
|
||||
// later by #include <Gui/ViewProviderGeometryObject.h>
|
||||
# define _USE_MATH_DEFINES // NOLINT
|
||||
# include <cmath>
|
||||
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
@@ -136,9 +132,10 @@ SectionCut::SectionCut(QWidget* parent)
|
||||
|
||||
void SectionCut::initSpinBoxes()
|
||||
{
|
||||
ui->cutX->setRange(-INT_MAX, INT_MAX);
|
||||
ui->cutY->setRange(-INT_MAX, INT_MAX);
|
||||
ui->cutZ->setRange(-INT_MAX, INT_MAX);
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
ui->cutX->setRange(-max, max);
|
||||
ui->cutY->setRange(-max, max);
|
||||
ui->cutZ->setRange(-max, max);
|
||||
}
|
||||
|
||||
void SectionCut::initControls(const Base::BoundBox3d& BoundCompound)
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/SoPrimitiveVertex.h>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
@@ -85,7 +84,7 @@ void SoBrepEdgeSet::GLRender(SoGLRenderAction *action)
|
||||
selContext2->sl.push_back(-1);
|
||||
}else if(ctx)
|
||||
selContext2->sl = ctx->sl;
|
||||
if(selContext2->highlightIndex==INT_MAX) {
|
||||
if(selContext2->highlightIndex == std::numeric_limits<int>::max()) {
|
||||
selContext2->hl.clear();
|
||||
selContext2->hl.push_back(-1);
|
||||
}else if(ctx)
|
||||
@@ -93,7 +92,7 @@ void SoBrepEdgeSet::GLRender(SoGLRenderAction *action)
|
||||
ctx = selContext2;
|
||||
}
|
||||
|
||||
if(ctx && ctx->highlightIndex==INT_MAX) {
|
||||
if(ctx && ctx->highlightIndex == std::numeric_limits<int>::max()) {
|
||||
if(ctx->selectionIndex.empty() || ctx->isSelectAll()) {
|
||||
if(ctx2) {
|
||||
ctx2->selectionColor = ctx->highlightColor;
|
||||
@@ -329,7 +328,7 @@ void SoBrepEdgeSet::doAction(SoAction* action)
|
||||
if (!detail) {
|
||||
SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext);
|
||||
ctx->highlightColor = hlaction->getColor();
|
||||
ctx->highlightIndex = INT_MAX;
|
||||
ctx->highlightIndex = std::numeric_limits<int>::max();
|
||||
ctx->hl.clear();
|
||||
ctx->hl.push_back(-1);
|
||||
touch();
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <map>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/SoPrimitiveVertex.h>
|
||||
@@ -194,7 +193,7 @@ void SoBrepFaceSet::doAction(SoAction* action)
|
||||
const SoDetail* detail = hlaction->getElement();
|
||||
if (!detail) {
|
||||
SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext);
|
||||
ctx->highlightIndex = INT_MAX;
|
||||
ctx->highlightIndex = std::numeric_limits<int>::max();
|
||||
ctx->highlightColor = hlaction->getColor();
|
||||
touch();
|
||||
}else {
|
||||
@@ -549,7 +548,7 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action)
|
||||
// Transparency complicates stuff even more, but not here. It will be handled inside
|
||||
// overrideMaterialBinding()
|
||||
//
|
||||
if(ctx && ctx->highlightIndex==INT_MAX) {
|
||||
if(ctx && ctx->highlightIndex == std::numeric_limits<int>::max()) {
|
||||
if(ctx->selectionIndex.empty() || ctx->isSelectAll()) {
|
||||
if(ctx2) {
|
||||
ctx2->selectionColor = ctx->highlightColor;
|
||||
@@ -1222,7 +1221,7 @@ void SoBrepFaceSet::renderHighlight(SoGLRenderAction *action, SelContextPtr ctx)
|
||||
mb.sendFirst(); // make sure we have the correct material
|
||||
|
||||
int id = ctx->highlightIndex;
|
||||
if (id!=INT_MAX && id >= this->partIndex.getNum()) {
|
||||
if (id != std::numeric_limits<int>::max() && id >= this->partIndex.getNum()) {
|
||||
SoDebugError::postWarning("SoBrepFaceSet::renderHighlight", "highlightIndex out of range");
|
||||
}
|
||||
else {
|
||||
@@ -1234,7 +1233,7 @@ void SoBrepFaceSet::renderHighlight(SoGLRenderAction *action, SelContextPtr ctx)
|
||||
// coords
|
||||
int start=0;
|
||||
int length;
|
||||
if(id==INT_MAX) {
|
||||
if(id == std::numeric_limits<int>::max()) {
|
||||
length = numindices;
|
||||
id = 0;
|
||||
} else {
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
@@ -82,7 +81,7 @@ void SoBrepPointSet::GLRender(SoGLRenderAction *action)
|
||||
if(selContext2->checkGlobal(ctx))
|
||||
ctx = selContext2;
|
||||
|
||||
if(ctx && ctx->highlightIndex==INT_MAX) {
|
||||
if(ctx && ctx->highlightIndex == std::numeric_limits<int>::max()) {
|
||||
if(ctx->selectionIndex.empty() || ctx->isSelectAll()) {
|
||||
if(ctx2) {
|
||||
ctx2->selectionColor = ctx->highlightColor;
|
||||
@@ -192,7 +191,7 @@ void SoBrepPointSet::renderHighlight(SoGLRenderAction *action, SelContextPtr ctx
|
||||
int id = ctx->highlightIndex;
|
||||
const SbVec3f * coords3d = coords->getArrayPtr3();
|
||||
if(coords3d) {
|
||||
if(id == INT_MAX) {
|
||||
if(id == std::numeric_limits<int>::max()) {
|
||||
glBegin(GL_POINTS);
|
||||
for(int idx=startIndex.getValue();idx<coords->getNum();++idx)
|
||||
glVertex3fv((const GLfloat*) (coords3d + idx));
|
||||
@@ -269,7 +268,7 @@ void SoBrepPointSet::doAction(SoAction* action)
|
||||
SelContextPtr ctx = Gui::SoFCSelectionRoot::getActionContext(action,this,selContext);
|
||||
const SoDetail* detail = hlaction->getElement();
|
||||
if (!detail) {
|
||||
ctx->highlightIndex = INT_MAX;
|
||||
ctx->highlightIndex = std::numeric_limits<int>::max();
|
||||
ctx->highlightColor = hlaction->getColor();
|
||||
touch();
|
||||
return;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
@@ -160,9 +159,10 @@ void SoFCControlPoints::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &cen
|
||||
const SbVec3f * points = coords->getArrayPtr3();
|
||||
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();
|
||||
if (len > 0) {
|
||||
for (int32_t i=0; i<len; i++) {
|
||||
|
||||
@@ -63,7 +63,8 @@ OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
|
||||
setupConnections();
|
||||
|
||||
d->ui.spinOffset->setUnit(Base::Unit::Length);
|
||||
d->ui.spinOffset->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.spinOffset->setRange(-std::numeric_limits<int>::max(),
|
||||
std::numeric_limits<int>::max());
|
||||
d->ui.spinOffset->setSingleStep(0.1);
|
||||
d->ui.facesButton->hide();
|
||||
|
||||
|
||||
@@ -91,7 +91,8 @@ ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent)
|
||||
d->ui.fillOffset->hide();
|
||||
|
||||
QSignalBlocker blockOffset(d->ui.spinOffset);
|
||||
d->ui.spinOffset->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.spinOffset->setRange(-std::numeric_limits<int>::max(),
|
||||
std::numeric_limits<int>::max());
|
||||
d->ui.spinOffset->setSingleStep(0.1);
|
||||
d->ui.spinOffset->setValue(d->thickness->Value.getValue());
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
|
||||
|
||||
# include <Inventor/nodes/SoAnnotation.h>
|
||||
@@ -57,7 +56,8 @@ using namespace std;
|
||||
// Construction/Destruction
|
||||
|
||||
const char* ViewProvider2DObjectGrid::GridStyleEnums[]= {"Dashed","Light",nullptr};
|
||||
App::PropertyQuantityConstraint::Constraints ViewProvider2DObjectGrid::GridSizeRange = {0.001,DBL_MAX,1.0};
|
||||
App::PropertyQuantityConstraint::Constraints ViewProvider2DObjectGrid::GridSizeRange = {
|
||||
0.001, std::numeric_limits<double>::max(), 1.0};
|
||||
|
||||
PROPERTY_SOURCE(PartGui::ViewProvider2DObjectGrid, PartGui::ViewProvider2DObject)
|
||||
|
||||
@@ -106,10 +106,11 @@ SoSeparator* ViewProvider2DObjectGrid::createGrid()
|
||||
else {
|
||||
// make sure that nine of the numbers are exactly zero because log(0)
|
||||
// is not defined
|
||||
float xMin = std::abs(MinX) < FLT_EPSILON ? 0.01f : MinX;
|
||||
float xMax = std::abs(MaxX) < FLT_EPSILON ? 0.01f : MaxX;
|
||||
float yMin = std::abs(MinY) < FLT_EPSILON ? 0.01f : MinY;
|
||||
float yMax = std::abs(MaxY) < FLT_EPSILON ? 0.01f : MaxY;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
float xMin = std::abs(MinX) < floatEpsilon ? 0.01f : MinX;
|
||||
float xMax = std::abs(MaxX) < floatEpsilon ? 0.01f : MaxX;
|
||||
float yMin = std::abs(MinY) < floatEpsilon ? 0.01f : MinY;
|
||||
float yMax = std::abs(MaxY) < floatEpsilon ? 0.01f : MaxY;
|
||||
MiX = -exp(ceil(log(std::abs(xMin))));
|
||||
MiX = std::min<float>(MiX,(float)-exp(ceil(log(std::abs(0.1f*xMax)))));
|
||||
MaX = exp(ceil(log(std::abs(xMax))));
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# ifdef _MSC_VER
|
||||
# define _USE_MATH_DEFINES
|
||||
# include <cmath>
|
||||
# endif
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
||||
@@ -976,7 +976,7 @@ void ViewProviderPartExt::updateVisual()
|
||||
//deflection = std::min(deflection, 20.0);
|
||||
|
||||
// create or use the mesh on the data structure
|
||||
Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI;
|
||||
Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * std::numbers::pi;
|
||||
|
||||
IMeshTools_Parameters meshParams;
|
||||
meshParams.Deflection = deflection;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
|
||||
# include <Inventor/nodes/SoDepthBuffer.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
@@ -60,7 +59,8 @@ using namespace std;
|
||||
|
||||
EXTENSION_PROPERTY_SOURCE(PartGui::ViewProviderGridExtension, Gui::ViewProviderExtension)
|
||||
|
||||
App::PropertyQuantityConstraint::Constraints ViewProviderGridExtension::GridSizeRange = { 0.001,DBL_MAX,1.0 };
|
||||
App::PropertyQuantityConstraint::Constraints ViewProviderGridExtension::GridSizeRange = {
|
||||
0.001, std::numeric_limits<double>::max(), 1.0 };
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
// to avoid compiler warnings of redefining contents of basic.h
|
||||
// later by #include "ViewProvider.h"
|
||||
# define _USE_MATH_DEFINES
|
||||
# include <cmath>
|
||||
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
|
||||
@@ -172,7 +172,7 @@ TEST_F(FeatureExtrusionTest, testExecuteAngled)
|
||||
{
|
||||
// Arrange
|
||||
const double ang = 30;
|
||||
const double tangent = tan(ang / 180.0 * M_PI);
|
||||
const double tangent = tan(ang / 180.0 * std::numbers::pi);
|
||||
|
||||
// The shape is a truncated pyramid elongated by a truncated triangular prism in the middle.
|
||||
// Calc the volume of full size pyramid and prism, and subtract top volumes to truncate.
|
||||
@@ -209,7 +209,7 @@ TEST_F(FeatureExtrusionTest, testExecuteAngledRev)
|
||||
{
|
||||
// Arrange
|
||||
const double ang = 30;
|
||||
const double tangent = tan(ang / 180.0 * M_PI);
|
||||
const double tangent = tan(ang / 180.0 * std::numbers::pi);
|
||||
// The shape is a truncated pyramid elongated by a truncated triangular prism in the middle,
|
||||
// plus a rectangular prism.
|
||||
// Calc the volume of full size pyramid and prism, and subtract top volumes to truncate.
|
||||
@@ -249,7 +249,7 @@ TEST_F(FeatureExtrusionTest, testExecuteEdge)
|
||||
{
|
||||
// Arrange
|
||||
const double ang = 30;
|
||||
const double tangent = tan(ang / 180.0 * M_PI);
|
||||
const double tangent = tan(ang / 180.0 * std::numbers::pi);
|
||||
BRepBuilderAPI_MakeEdge e1(gp_Pnt(0, 0, 0), gp_Pnt(ext1, ext1, ext1));
|
||||
auto edge = _doc->addObject<Part::Feature>("Edge");
|
||||
edge->Shape.setValue(e1);
|
||||
@@ -270,7 +270,7 @@ TEST_F(FeatureExtrusionTest, testExecuteEdge)
|
||||
TEST_F(FeatureExtrusionTest, testExecuteDir)
|
||||
{
|
||||
// Arrange
|
||||
const double sin45 = sin(45 / 180.0 * M_PI);
|
||||
const double sin45 = sin(45 / 180.0 * std::numbers::pi);
|
||||
_extrusion->Dir.setValue(Base::Vector3d(0, 1, 1));
|
||||
_extrusion->DirMode.setValue((long)0);
|
||||
// Act
|
||||
@@ -319,8 +319,10 @@ TEST_F(FeatureExtrusionTest, testFaceWithHoles)
|
||||
double volume = PartTestHelpers::getVolume(ts.getShape());
|
||||
Base::BoundBox3d bb = ts.getBoundBox();
|
||||
// Assert
|
||||
EXPECT_FLOAT_EQ(volume, len * wid * ext1 - radius * radius * M_PI * ext1);
|
||||
EXPECT_FLOAT_EQ(volume, len * wid * ext1 - radius * radius * std::numbers::pi * ext1);
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0, 0, 0, len, wid, ext1)));
|
||||
EXPECT_FLOAT_EQ(PartTestHelpers::getArea(face1), len * wid + radius * radius * M_PI);
|
||||
EXPECT_FLOAT_EQ(PartTestHelpers::getArea(face2), len * wid - radius * radius * M_PI);
|
||||
EXPECT_FLOAT_EQ(PartTestHelpers::getArea(face1),
|
||||
len * wid + radius * radius * std::numbers::pi);
|
||||
EXPECT_FLOAT_EQ(PartTestHelpers::getArea(face2),
|
||||
len * wid - radius * radius * std::numbers::pi);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
TEST_F(FeatureRevolutionTest, testExecute)
|
||||
{
|
||||
// Arrange
|
||||
double puckVolume = len * len * M_PI * wid; // Area is PIr2; apply height
|
||||
double puckVolume = len * len * std::numbers::pi * wid; // Area is PIr2; apply height
|
||||
// Act
|
||||
_revolution->execute();
|
||||
Part::TopoShape ts = _revolution->Shape.getValue();
|
||||
@@ -62,8 +62,8 @@ TEST_F(FeatureRevolutionTest, testExecuteBase)
|
||||
// Arrange
|
||||
double rad = len + 1.0;
|
||||
double rad2 = 1.0;
|
||||
double outerPuckVolume = rad * rad * M_PI * wid; // Area is PIr2; apply height
|
||||
double innerPuckVolume = rad2 * rad2 * M_PI * wid; // Area is PIr2; apply height
|
||||
double outerPuckVolume = rad * rad * std::numbers::pi * wid; // Area is PIr2; apply height
|
||||
double innerPuckVolume = rad2 * rad2 * std::numbers::pi * wid; // Area is PIr2; apply height
|
||||
_revolution->Base.setValue(Base::Vector3d(len + 1, 0, 0));
|
||||
// Act
|
||||
_revolution->execute();
|
||||
@@ -79,7 +79,7 @@ TEST_F(FeatureRevolutionTest, testExecuteBase)
|
||||
TEST_F(FeatureRevolutionTest, testAxis)
|
||||
{
|
||||
// Arrange
|
||||
double puckVolume = wid * wid * M_PI * len; // Area is PIr2 times height
|
||||
double puckVolume = wid * wid * std::numbers::pi * len; // Area is PIr2 times height
|
||||
_revolution->Axis.setValue(Base::Vector3d(1, 0, 0));
|
||||
// Act
|
||||
_revolution->execute();
|
||||
@@ -98,7 +98,7 @@ TEST_F(FeatureRevolutionTest, testAxisLink)
|
||||
auto edge = _doc->addObject<Part::Feature>("Edge");
|
||||
edge->Shape.setValue(e1);
|
||||
_revolution->AxisLink.setValue(edge);
|
||||
// double puckVolume = wid * wid * M_PI * len; // Area is PIr2; apply height
|
||||
// double puckVolume = wid * wid * std::numbers::pi * len; // Area is PIr2; apply height
|
||||
// Act
|
||||
_revolution->execute();
|
||||
Part::TopoShape ts = _revolution->Shape.getValue();
|
||||
@@ -115,7 +115,7 @@ TEST_F(FeatureRevolutionTest, testAxisLink)
|
||||
TEST_F(FeatureRevolutionTest, testSymmetric)
|
||||
{
|
||||
// Arrange
|
||||
double puckVolume = len * len * M_PI * wid; // Area is PIr2 times height
|
||||
double puckVolume = len * len * std::numbers::pi * wid; // Area is PIr2 times height
|
||||
_revolution->Symmetric.setValue(true);
|
||||
// Act
|
||||
_revolution->execute();
|
||||
@@ -130,8 +130,8 @@ TEST_F(FeatureRevolutionTest, testSymmetric)
|
||||
TEST_F(FeatureRevolutionTest, testAngle)
|
||||
{
|
||||
// Arrange
|
||||
double puckVolume = len * len * M_PI * wid; // Area is PIr2 times height
|
||||
_revolution->Angle.setValue(90); // NOLINT magic number
|
||||
double puckVolume = len * len * std::numbers::pi * wid; // Area is PIr2 times height
|
||||
_revolution->Angle.setValue(90); // NOLINT magic number
|
||||
// Act
|
||||
_revolution->execute();
|
||||
Part::TopoShape ts = _revolution->Shape.getValue();
|
||||
|
||||
@@ -608,10 +608,10 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceNull)
|
||||
double area3 = getArea(topoShape.getShape());
|
||||
// Assert
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid - M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid - std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
}
|
||||
|
||||
@@ -632,8 +632,8 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceSimple)
|
||||
// Assert
|
||||
EXPECT_TRUE(newFace.getShape().IsEqual(topoShape.getShape())); // topoShape was altered
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
@@ -656,8 +656,8 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceParams)
|
||||
// Assert
|
||||
EXPECT_TRUE(newFace.getShape().IsEqual(topoShape.getShape())); // topoShape was altered
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
@@ -680,10 +680,10 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceFromFace)
|
||||
// Assert
|
||||
EXPECT_TRUE(newFace.getShape().IsEqual(topoShape.getShape())); // topoShape was altered
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid - M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid - M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid - std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid - std::numbers::pi * Rad * Rad);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
}
|
||||
|
||||
@@ -705,8 +705,8 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceOpenWire)
|
||||
// Assert
|
||||
EXPECT_TRUE(newFace.getShape().IsEqual(topoShape.getShape())); // topoShape was altered
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, 0); // Len * Wid - M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, 0); // Len * Wid - std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, Len * Wid);
|
||||
EXPECT_DOUBLE_EQ(area3, Len * Wid);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
@@ -730,10 +730,10 @@ TEST_F(TopoShapeExpansionTest, makeElementFaceClosedWire)
|
||||
// Assert
|
||||
EXPECT_TRUE(newFace.getShape().IsEqual(topoShape.getShape())); // topoShape was altered
|
||||
EXPECT_FALSE(face1.IsEqual(newFace.getShape()));
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, 0); // Len * Wid - M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, M_PI * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area, Len * Wid + std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area1, 0); // Len * Wid - std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area2, std::numbers::pi * Rad * Rad);
|
||||
EXPECT_DOUBLE_EQ(area3, std::numbers::pi * Rad * Rad);
|
||||
EXPECT_STREQ(newFace.shapeName().c_str(), "Face");
|
||||
}
|
||||
|
||||
@@ -837,7 +837,7 @@ TEST_F(TopoShapeExpansionTest, splitWires)
|
||||
// Assert
|
||||
EXPECT_EQ(inner.size(), 1);
|
||||
EXPECT_DOUBLE_EQ(getLength(wire.getShape()), 2 + 2 + 3 + 3);
|
||||
EXPECT_DOUBLE_EQ(getLength(inner.front().getShape()), M_PI * Rad * 2);
|
||||
EXPECT_DOUBLE_EQ(getLength(inner.front().getShape()), std::numbers::pi * Rad * 2);
|
||||
EXPECT_EQ(wire.getShape().Orientation(), TopAbs_REVERSED);
|
||||
for (TopoShape& shape : inner) {
|
||||
EXPECT_EQ(shape.getShape().Orientation(), TopAbs_FORWARD);
|
||||
@@ -1284,7 +1284,7 @@ TEST_F(TopoShapeExpansionTest, makeElementShellOpen)
|
||||
const float Wid = 2;
|
||||
auto [face1, wire1, edge1, edge2, edge3, edge4] = CreateRectFace(Len, Wid);
|
||||
auto transform {gp_Trsf()};
|
||||
transform.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), M_PI / 2);
|
||||
transform.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), std::numbers::pi / 2);
|
||||
auto face2 = face1; // Shallow copy
|
||||
face2.Move(TopLoc_Location(transform));
|
||||
TopoDS_Compound compound1;
|
||||
@@ -1562,7 +1562,7 @@ TEST_F(TopoShapeExpansionTest, makeElementDraft)
|
||||
std::vector<TopoShape> subShapes = cube1TS.getSubTopoShapes(TopAbs_FACE);
|
||||
std::vector<TopoShape> faces {subShapes[0], subShapes[1], subShapes[2], subShapes[3]};
|
||||
const gp_Dir pullDirection {0, 0, 1};
|
||||
double angle {M_PI * 10
|
||||
double angle {std::numbers::pi * 10
|
||||
/ 8}; // Angle should be between Pi and Pi * 1.5 ( 180 and 270 degrees )
|
||||
const gp_Pln plane {};
|
||||
// Act
|
||||
@@ -1580,7 +1580,7 @@ TEST_F(TopoShapeExpansionTest, makeElementDraftTopoShapes)
|
||||
// Arrange
|
||||
auto [cube1TS, cube2TS] = CreateTwoTopoShapeCubes();
|
||||
const gp_Dir pullDirection {0, 0, 1};
|
||||
double angle {M_PI * 10
|
||||
double angle {std::numbers::pi * 10
|
||||
/ 8}; // Angle should be between Pi and Pi * 1.5 ( 180 and 270 degrees )
|
||||
const gp_Pln plane {};
|
||||
// Act
|
||||
|
||||
Reference in New Issue
Block a user