diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index 9a0bfab347..c09aa683d2 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -35,6 +35,8 @@ # include #endif +#include + #include #include #include @@ -49,7 +51,7 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp) const char* ChamferTypeEnums[] = {"Equal distance", "Two distances", "Distance and Angle", nullptr}; -const App::PropertyQuantityConstraint::Constraints Chamfer::floatSize = {0.0, FLT_MAX, 0.1}; +const App::PropertyQuantityConstraint::Constraints Chamfer::floatSize = {0.0, std::numeric_limits::max(), 0.1}; const App::PropertyAngle::Constraints Chamfer::floatAngle = {0.0, 180.0, 1.0}; static App::DocumentObjectExecReturn *validateParameters(int chamferType, double size, double size2, double angle); diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 7b74b486fc..d317b77863 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -244,7 +244,7 @@ App::DocumentObjectExecReturn *Draft::execute() if (c.GetType() != GeomAbs_Line) throw Base::TypeError("Neutral plane reference edge must be linear"); double a = c.Line().Angle(gp_Lin(c.Value(c.FirstParameter()), pullDirection)); - if (std::fabs(a - M_PI_2) > Precision::Confusion()) + if (std::fabs(a - std::numbers::pi/2) > Precision::Confusion()) throw Base::ValueError("Neutral plane reference edge must be normal to pull direction"); neutralPlane = gp_Pln(c.Value(c.FirstParameter()), pullDirection); } else { diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index 73659cc6bd..fbe4560184 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -50,7 +50,8 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::FeatureExtrude, PartDesign::ProfileBased) -App::PropertyQuantityConstraint::Constraints FeatureExtrude::signedLengthConstraint = { -DBL_MAX, DBL_MAX, 1.0 }; +App::PropertyQuantityConstraint::Constraints FeatureExtrude::signedLengthConstraint = { + -std::numeric_limits::max(), std::numeric_limits::max(), 1.0 }; double FeatureExtrude::maxAngle = 90 - Base::toDegrees(Precision::Angular()); App::PropertyAngle::Constraints FeatureExtrude::floatAngle = { -maxAngle, maxAngle, 1.0 }; @@ -714,11 +715,13 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt } } else { + using std::numbers::pi; + Part::ExtrusionParameters params; params.dir = dir; params.solid = makeface; - params.taperAngleFwd = this->TaperAngle.getValue() * M_PI / 180.0; - params.taperAngleRev = this->TaperAngle2.getValue() * M_PI / 180.0; + params.taperAngleFwd = this->TaperAngle.getValue() * pi / 180.0; + params.taperAngleRev = this->TaperAngle2.getValue() * pi / 180.0; if (L2 == 0.0 && Midplane.getValue()) { params.lengthFwd = L / 2; params.lengthRev = L / 2; @@ -732,8 +735,8 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt } if (std::fabs(params.taperAngleFwd) >= Precision::Angular() || std::fabs(params.taperAngleRev) >= Precision::Angular()) { - if (fabs(params.taperAngleFwd) > M_PI * 0.5 - Precision::Angular() - || fabs(params.taperAngleRev) > M_PI * 0.5 - Precision::Angular()) { + if (fabs(params.taperAngleFwd) > pi * 0.5 - Precision::Angular() + || fabs(params.taperAngleRev) > pi * 0.5 - Precision::Angular()) { return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP( "Exception", "Magnitude of taper angle matches or exceeds 90 degrees")); diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 25d60c2778..c44653a76f 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -44,7 +44,7 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Fillet, PartDesign::DressUp) -const App::PropertyQuantityConstraint::Constraints floatRadius = {0.0,FLT_MAX,0.1}; +const App::PropertyQuantityConstraint::Constraints floatRadius = {0.0, std::numeric_limits::max(), 0.1}; Fillet::Fillet() { diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index 66f27fdcd3..3df6e019eb 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -270,7 +270,7 @@ void Groove::generateRevolution(TopoDS_Shape& revol, angleOffset = angle2 * -1.0; } else if (method == RevolMethod::ThroughAll) { - angleTotal = 2 * M_PI; + angleTotal = 2 * std::numbers::pi; } else if (midplane) { // Rotate the face by half the angle to get Groove symmetric to sketch plane diff --git a/src/Mod/PartDesign/App/FeatureHelix.cpp b/src/Mod/PartDesign/App/FeatureHelix.cpp index 94cfab1c86..7acc3f267b 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.cpp +++ b/src/Mod/PartDesign/App/FeatureHelix.cpp @@ -61,8 +61,8 @@ const char* Helix::ModeEnums[] = { "pitch-height-angle", "pitch-turns-angle", "h PROPERTY_SOURCE(PartDesign::Helix, PartDesign::ProfileBased) // we purposely use not FLT_MAX because this would not be computable -const App::PropertyFloatConstraint::Constraints Helix::floatTurns = { Precision::Confusion(), INT_MAX, 1.0 }; -const App::PropertyFloatConstraint::Constraints Helix::floatTolerance = { 0.1, INT_MAX, 1.0 }; +const App::PropertyFloatConstraint::Constraints Helix::floatTurns = { Precision::Confusion(), std::numeric_limits::max(), 1.0 }; +const App::PropertyFloatConstraint::Constraints Helix::floatTolerance = { 0.1, std::numeric_limits::max(), 1.0 }; const App::PropertyAngle::Constraints Helix::floatAngle = { -89.0, 89.0, 1.0 }; Helix::Helix() @@ -442,13 +442,13 @@ TopoDS_Shape Helix::generateHelixPath(double breakAtTurn) // because of the radius factor we used above, we must reverse after the // startOffset movement (that brings the path back to the desired position) if (reversed) { - mov.SetRotation(gp_Ax1(origo, dir_axis2), M_PI); + mov.SetRotation(gp_Ax1(origo, dir_axis2), std::numbers::pi); TopLoc_Location loc(mov); path.Move(loc); } if (turned) { // turn the helix so that the starting point aligns with the profile - mov.SetRotation(gp_Ax1(origo, dir_axis1), M_PI); + mov.SetRotation(gp_Ax1(origo, dir_axis1), std::numbers::pi); TopLoc_Location loc(mov); path.Move(loc); } @@ -495,7 +495,7 @@ double Helix::safePitch() } } - double angle = Angle.getValue() / 180.0 * M_PI; + double angle = Angle.getValue() / 180.0 * std::numbers::pi; gp_Dir direction(axisVec.x, axisVec.y, axisVec.z); gp_Dir directionStart(startVec.x, startVec.y, startVec.z); TopoDS_Shape sketchshape = getVerifiedFace(); diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 18dbb723ec..d3fc78e2f9 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -732,7 +732,7 @@ PROPERTY_SOURCE(PartDesign::Hole, PartDesign::ProfileBased) const App::PropertyAngle::Constraints Hole::floatAngle = { Base::toDegrees(Precision::Angular()), 180.0 - Base::toDegrees(Precision::Angular()), 1.0 }; // OCC can only create holes with a min diameter of 10 times the Precision::Confusion() -const App::PropertyQuantityConstraint::Constraints diameterRange = { 10 * Precision::Confusion(), FLT_MAX, 1.0 }; +const App::PropertyQuantityConstraint::Constraints diameterRange = { 10 * Precision::Confusion(), std::numeric_limits::max(), 1.0 }; Hole::Hole() { @@ -2244,7 +2244,7 @@ TopoDS_Shape Hole::makeThread(const gp_Vec& xDir, const gp_Vec& zDir, double len // | base-sharpV Rmaj H // the little adjustment of p1 and p4 is here to prevent coincidencies - double marginX = std::tan(62.5 * M_PI / 180.0) * marginZ; + double marginX = std::tan(62.5 * std::numbers::pi / 180.0) * marginZ; gp_Pnt p1 = toPnt( (RmajC - 5 * H / 6 + marginX) * xDir @@ -2281,7 +2281,7 @@ TopoDS_Shape Hole::makeThread(const gp_Vec& xDir, const gp_Vec& zDir, double len // | base-sharpV Rmaj // the little adjustment of p1 and p4 is here to prevent coincidencies - double marginX = std::tan(60.0 * M_PI / 180.0) * marginZ; + double marginX = std::tan(60.0 * std::numbers::pi / 180.0) * marginZ; gp_Pnt p1 = toPnt( (RmajC - h + marginX) * xDir + marginZ * zDir @@ -2343,7 +2343,7 @@ TopoDS_Shape Hole::makeThread(const gp_Vec& xDir, const gp_Vec& zDir, double len // Reverse the direction of the helix. So that it goes into the material gp_Trsf mov; - mov.SetRotation(gp_Ax1(origo, dir_axis2), M_PI); + mov.SetRotation(gp_Ax1(origo, dir_axis2), std::numbers::pi); TopLoc_Location loc1(mov); helix.Move(loc1); diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index 58455b4624..9d01fc33ab 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -49,7 +49,8 @@ namespace PartDesign { PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed) -const App::PropertyIntegerConstraint::Constraints LinearPattern::intOccurrences = { 1, INT_MAX, 1 }; +const App::PropertyIntegerConstraint::Constraints LinearPattern::intOccurrences = { + 1, std::numeric_limits::max(), 1 }; const char* LinearPattern::ModeEnums[] = { "length", "offset", nullptr }; diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index 0647a3ee17..7272147711 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -48,7 +48,8 @@ namespace PartDesign { PROPERTY_SOURCE(PartDesign::PolarPattern, PartDesign::Transformed) -const App::PropertyIntegerConstraint::Constraints PolarPattern::intOccurrences = { 1, INT_MAX, 1 }; +const App::PropertyIntegerConstraint::Constraints PolarPattern::intOccurrences = { + 1, std::numeric_limits::max(), 1 }; const App::PropertyAngle::Constraints PolarPattern::floatAngle = { Base::toDegrees(Precision::Angular()), 360.0, 1.0 }; const char* PolarPattern::ModeEnums[] = {"angle", "offset", nullptr}; diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index 21cc034d8d..72e772765a 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -56,8 +56,8 @@ const App::PropertyQuantityConstraint::Constraints angleRangeU = { 0.0, 360.0, 1 const App::PropertyQuantityConstraint::Constraints angleRangeV = { -90.0, 90.0, 1.0 }; // it turned out that OCC cannot e.g. create a box with a width of Precision::Confusion() // with two times Precision::Confusion() all geometric primitives can be created -const App::PropertyQuantityConstraint::Constraints quantityRange = { 2 * Precision::Confusion(), FLT_MAX, 0.1 }; -const App::PropertyQuantityConstraint::Constraints quantityRangeZero = { 0.0, FLT_MAX, 0.1 }; +const App::PropertyQuantityConstraint::Constraints quantityRange = { 2 * Precision::Confusion(), std::numeric_limits::max(), 0.1 }; +const App::PropertyQuantityConstraint::Constraints quantityRangeZero = { 0.0, std::numeric_limits::max(), 0.1 }; PROPERTY_SOURCE_WITH_EXTENSIONS(PartDesign::FeaturePrimitive, PartDesign::FeatureAddSub) diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp index 539ed47128..a6d37a9362 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp @@ -222,26 +222,26 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->wedgeZ2max->bind(getObject()->Z2max); ui->wedgeZ2min->setValue(getObject()->Z2min.getValue()); ui->wedgeZ2min->bind(getObject()->Z2min); - ui->wedgeXmin->setMinimum(INT_MIN); + ui->wedgeXmin->setMinimum(std::numeric_limits::min()); ui->wedgeXmin->setMaximum(ui->wedgeXmax->rawValue()); // must be < than wedgeXmax - ui->wedgeYmin->setMinimum(INT_MIN); + ui->wedgeYmin->setMinimum(std::numeric_limits::min()); ui->wedgeYmin->setMaximum(ui->wedgeYmax->rawValue()); // must be < than wedgeYmax - ui->wedgeZmin->setMinimum(INT_MIN); + ui->wedgeZmin->setMinimum(std::numeric_limits::min()); ui->wedgeZmin->setMaximum(ui->wedgeZmax->rawValue()); // must be < than wedgeZmax - ui->wedgeX2min->setMinimum(INT_MIN); + ui->wedgeX2min->setMinimum(std::numeric_limits::min());; ui->wedgeX2min->setMaximum(ui->wedgeX2max->rawValue()); // must be <= than wedgeXmax - ui->wedgeZ2min->setMinimum(INT_MIN); + ui->wedgeZ2min->setMinimum(std::numeric_limits::min());; ui->wedgeZ2min->setMaximum(ui->wedgeZ2max->rawValue()); // must be <= than wedgeXmax ui->wedgeXmax->setMinimum(ui->wedgeXmin->rawValue()); - ui->wedgeXmax->setMaximum(INT_MAX); + ui->wedgeXmax->setMaximum(std::numeric_limits::max()); ui->wedgeYmax->setMinimum(ui->wedgeYmin->rawValue()); - ui->wedgeYmax->setMaximum(INT_MAX); + ui->wedgeYmax->setMaximum(std::numeric_limits::max()); ui->wedgeZmax->setMinimum(ui->wedgeZmin->rawValue()); - ui->wedgeZmax->setMaximum(INT_MAX); + ui->wedgeZmax->setMaximum(std::numeric_limits::max()); ui->wedgeX2max->setMinimum(ui->wedgeX2min->rawValue()); - ui->wedgeX2max->setMaximum(INT_MAX); + ui->wedgeX2max->setMaximum(std::numeric_limits::max()); ui->wedgeZ2max->setMinimum(ui->wedgeZ2min->rawValue()); - ui->wedgeZ2max->setMaximum(INT_MAX); + ui->wedgeZ2max->setMaximum(std::numeric_limits::max()); break; } diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp index c6b30c4b75..ffb399a6ed 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.cpp @@ -78,7 +78,7 @@ void TaskScaledParameters::setupParameterUI(QWidget* widget) auto pcScaled = getObject(); ui->spinFactor->bind(pcScaled->Factor); - ui->spinOccurrences->setMaximum(INT_MAX); + ui->spinOccurrences->setMaximum(std::numeric_limits::max()); ui->spinOccurrences->bind(pcScaled->Occurrences); ui->spinFactor->setEnabled(true); ui->spinOccurrences->setEnabled(true); diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 3976f848cf..09346de5d7 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -327,7 +327,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch) // Offset to base plane // Find out which direction we need to offset double a = sketchVector.GetAngle(pnt); - if ((a < -M_PI_2) || (a > M_PI_2)) + if ((a < -std::numbers::pi/2) || (a > std::numbers::pi/2)) offset *= -1.0; std::string Datum = doc->getUniqueObjectName("DatumPlane"); diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp index 8f44733ad8..66ad7b123d 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp @@ -121,7 +121,7 @@ void ViewProviderAddSub::updateAddSubShapeIndicator() { Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 * Deviation.getValue(); // 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; BRepMesh_IncrementalMesh(cShape, deflection, Standard_False, AngDeflectionRads, Standard_True); // We must reset the location here because the transformation data diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp index 2961cc4a4e..6c7f7f77c3 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp @@ -45,8 +45,10 @@ using namespace PartDesignGui; PROPERTY_SOURCE(PartDesignGui::ViewProviderDatumCoordinateSystem,PartDesignGui::ViewProviderDatum) -const App::PropertyFloatConstraint::Constraints ZoomConstraint = {0.0,DBL_MAX,0.2}; -const App::PropertyIntegerConstraint::Constraints FontConstraint = {1,INT_MAX,1}; +const App::PropertyFloatConstraint::Constraints ZoomConstraint = { + 0.0, std::numeric_limits::max(), 0.2}; +const App::PropertyIntegerConstraint::Constraints FontConstraint = { + 1,std::numeric_limits::max(), 1}; ViewProviderDatumCoordinateSystem::ViewProviderDatumCoordinateSystem() { diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp index cca6ab97d7..b3edfa0efe 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp @@ -228,7 +228,7 @@ void ViewProviderTransformed::showRejectedShape(TopoDS_Shape shape) // create or use the mesh on the data structure // Note: This DOES have an effect on shape - Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI; + Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * std::numbers::pi; BRepMesh_IncrementalMesh(shape, deflection, Standard_False, AngDeflectionRads, Standard_True); // We must reset the location here because the transformation data