diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp
index 98ffcf02f1..20d680b364 100644
--- a/src/Mod/Part/App/AppPartPy.cpp
+++ b/src/Mod/Part/App/AppPartPy.cpp
@@ -81,6 +81,7 @@
#include
#include
#include
+#include
#include
#include "BSplineSurfacePy.h"
@@ -112,14 +113,6 @@
extern const char* BRepBuilderAPI_FaceErrorText(BRepBuilderAPI_FaceError fe);
-#ifndef M_PI
-#define M_PI 3.14159265358979323846 /* pi */
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#endif
-
namespace Part {
PartExport void getPyShapes(PyObject* obj, std::vector& shapes)
@@ -1427,7 +1420,9 @@ private:
circle.SetRadius(radius);
Handle(Geom_Circle) hCircle = new Geom_Circle (circle);
- BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, angle1*(M_PI/180), angle2*(M_PI/180));
+ BRepBuilderAPI_MakeEdge aMakeEdge(hCircle,
+ Base::toRadians(angle1),
+ Base::toRadians(angle2));
TopoDS_Edge edge = aMakeEdge.Edge();
return Py::asObject(new TopoShapeEdgePy(new TopoShape(edge)));
}
@@ -1457,7 +1452,10 @@ private:
Base::Vector3d vec = static_cast(pDir)->value();
d.SetCoord(vec.x, vec.y, vec.z);
}
- BRepPrimAPI_MakeSphere mkSphere(gp_Ax2(p,d), radius, angle1*(M_PI/180), angle2*(M_PI/180), angle3*(M_PI/180));
+ BRepPrimAPI_MakeSphere mkSphere(gp_Ax2(p,d), radius,
+ Base::toRadians(angle1),
+ Base::toRadians(angle2),
+ Base::toRadians(angle3));
TopoDS_Shape shape = mkSphere.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1487,7 +1485,8 @@ private:
Base::Vector3d vec = static_cast(pDir)->value();
d.SetCoord(vec.x, vec.y, vec.z);
}
- BRepPrimAPI_MakeCylinder mkCyl(gp_Ax2(p,d),radius, height, angle*(M_PI/180));
+ BRepPrimAPI_MakeCylinder mkCyl(gp_Ax2(p,d),radius, height,
+ Base::toRadians(angle));
TopoDS_Shape shape = mkCyl.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1517,7 +1516,8 @@ private:
Base::Vector3d vec = static_cast(pDir)->value();
d.SetCoord(vec.x, vec.y, vec.z);
}
- BRepPrimAPI_MakeCone mkCone(gp_Ax2(p,d),radius1, radius2, height, angle*(M_PI/180));
+ BRepPrimAPI_MakeCone mkCone(gp_Ax2(p,d),radius1, radius2, height,
+ Base::toRadians(angle));
TopoDS_Shape shape = mkCone.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1547,7 +1547,10 @@ private:
Base::Vector3d vec = static_cast(pDir)->value();
d.SetCoord(vec.x, vec.y, vec.z);
}
- BRepPrimAPI_MakeTorus mkTorus(gp_Ax2(p,d), radius1, radius2, angle1*(M_PI/180), angle2*(M_PI/180), angle*(M_PI/180));
+ BRepPrimAPI_MakeTorus mkTorus(gp_Ax2(p,d), radius1, radius2,
+ Base::toRadians(angle1),
+ Base::toRadians(angle2),
+ Base::toRadians(angle));
const TopoDS_Shape& shape = mkTorus.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1695,7 +1698,8 @@ private:
PyObject* shellType = Base::getTypeAsObject(&Part::TopoShapeShellPy::Type);
PyObject* faceType = Base::getTypeAsObject(&Part::TopoShapeFacePy::Type);
- BRepPrimAPI_MakeRevolution mkRev(gp_Ax2(p,d),curve, vmin, vmax, angle*(M_PI/180));
+ BRepPrimAPI_MakeRevolution mkRev(gp_Ax2(p,d),curve, vmin, vmax,
+ Base::toRadians(angle));
if (type == defaultType) {
TopoDS_Shape shape = mkRev.Solid();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp
index ba3d40a3bd..0f363bbe0d 100644
--- a/src/Mod/Part/App/Part2DObject.cpp
+++ b/src/Mod/Part/App/Part2DObject.cpp
@@ -39,10 +39,6 @@
# include
#endif
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
#include
#include
#include
diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp
index 1be4ee684d..095ce83a3c 100644
--- a/src/Mod/Part/App/PrimitiveFeature.cpp
+++ b/src/Mod/Part/App/PrimitiveFeature.cpp
@@ -52,11 +52,6 @@
#include "PrimitiveFeature.h"
#include "PartFeaturePy.h"
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-
namespace Part {
const App::PropertyQuantityConstraint::Constraints apexRange = {-89.9, 89.9, 0.1};
const App::PropertyQuantityConstraint::Constraints torusRangeV = {-180.0, 180.0, 1.0};
@@ -363,9 +358,9 @@ App::DocumentObjectExecReturn *Sphere::execute()
return new App::DocumentObjectExecReturn("Radius of sphere too small");
try {
BRepPrimAPI_MakeSphere mkSphere(Radius.getValue(),
- Angle1.getValue()/180.0f*M_PI,
- Angle2.getValue()/180.0f*M_PI,
- Angle3.getValue()/180.0f*M_PI);
+ Base::toRadians(Angle1.getValue()),
+ Base::toRadians(Angle2.getValue()),
+ Base::toRadians(Angle3.getValue()));
TopoDS_Shape ResultShape = mkSphere.Shape();
this->Shape.setValue(ResultShape);
}
@@ -426,9 +421,9 @@ App::DocumentObjectExecReturn *Ellipsoid::execute()
gp_Ax2 ax2(pnt,dir);
BRepPrimAPI_MakeSphere mkSphere(ax2,
Radius2.getValue(),
- Angle1.getValue()/180.0f*M_PI,
- Angle2.getValue()/180.0f*M_PI,
- Angle3.getValue()/180.0f*M_PI);
+ Base::toRadians(Angle1.getValue()),
+ Base::toRadians(Angle2.getValue()),
+ Base::toRadians(Angle3.getValue()));
Standard_Real scaleX = 1.0;
Standard_Real scaleZ = Radius1.getValue()/Radius2.getValue();
// issue #1798: A third radius has been introduced. To be backward
@@ -803,7 +798,7 @@ App::DocumentObjectExecReturn *Helix::execute()
Standard_Real nbTurns = myHeight / myPitch;
if (nbTurns > 1e4)
Standard_Failure::Raise("Number of turns too high (> 1e4)");
- Standard_Real myRadiusTop = myRadius + myHeight * tan(myAngle/180.0f*M_PI);
+ Standard_Real myRadiusTop = myRadius + myHeight * tan(Base::toRadians(myAngle));
this->Shape.setValue(TopoShape().makeSpiralHelix(myRadius, myRadiusTop, myHeight, nbTurns, mySegLen, myLocalCS));
// props.Mass() may seem a strange way to get the Length, but
diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp
index 051c980675..80131c668e 100644
--- a/src/Mod/Part/App/TopoShapePyImp.cpp
+++ b/src/Mod/Part/App/TopoShapePyImp.cpp
@@ -74,6 +74,7 @@
#include
#include
#include
+#include
#include
#include
@@ -100,14 +101,6 @@
using namespace Part;
-#ifndef M_PI
- #define M_PI 3.14159265358979323846 /* pi */
-#endif
-
-#ifndef M_PI_2
- #define M_PI_2 1.57079632679489661923 /* pi/2 */
-#endif
-
static Py_hash_t _TopoShapeHash(PyObject* self)
{
if (!self) {
@@ -647,15 +640,15 @@ PyObject* TopoShapePy::extrude(PyObject *args)
PyObject* TopoShapePy::revolve(PyObject *args)
{
PyObject *pPos,*pDir;
- double d=360;
- if (!PyArg_ParseTuple(args, "O!O!|d", &(Base::VectorPy::Type), &pPos, &(Base::VectorPy::Type), &pDir,&d))
+ double angle=360;
+ if (!PyArg_ParseTuple(args, "O!O!|d", &(Base::VectorPy::Type), &pPos, &(Base::VectorPy::Type), &pDir,&angle))
return nullptr;
Base::Vector3d pos = static_cast(pPos)->value();
Base::Vector3d dir = static_cast(pDir)->value();
try {
return Py::new_reference_to(shape2pyshape(getTopoShapePtr()->makeElementRevolve(
gp_Ax1(gp_Pnt(pos.x, pos.y, pos.z), gp_Dir(dir.x, dir.y, dir.z)),
- d * (M_PI / 180))));
+ Base::toRadians(angle))));
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
@@ -1081,7 +1074,7 @@ PyObject* TopoShapePy::rotate(PyObject *args)
gp_Ax1 axis(pos, dir);
gp_Trsf mov;
- mov.SetRotation(axis, angle*(M_PI/180));
+ mov.SetRotation(axis, Base::toRadians(angle));
TopLoc_Location loc(mov);
TopoDS_Shape shape = getTopoShapePtr()->getShape();
shape.Move(loc);
diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp
index 8908df80ec..ca4a67cad8 100644
--- a/src/Mod/PartDesign/App/ShapeBinder.cpp
+++ b/src/Mod/PartDesign/App/ShapeBinder.cpp
@@ -48,10 +48,6 @@
FC_LOG_LEVEL_INIT("PartDesign",true,true)
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
using namespace PartDesign;
namespace sp = std::placeholders;