Part: Use Base::toRadians to convert degree to radian

This commit is contained in:
wmayer
2024-10-22 14:16:18 +02:00
committed by Chris Hennes
parent 0b0bb18323
commit 14cd061809
5 changed files with 30 additions and 46 deletions

View File

@@ -81,6 +81,7 @@
#include <Base/GeometryPyCXX.h>
#include <Base/Interpreter.h>
#include <Base/PyWrapParseTupleAndKeywords.h>
#include <Base/Tools.h>
#include <Base/VectorPy.h>
#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<TopoShape>& 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<double>(angle1),
Base::toRadians<double>(angle2));
TopoDS_Edge edge = aMakeEdge.Edge();
return Py::asObject(new TopoShapeEdgePy(new TopoShape(edge)));
}
@@ -1457,7 +1452,10 @@ private:
Base::Vector3d vec = static_cast<Base::VectorPy*>(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<double>(angle1),
Base::toRadians<double>(angle2),
Base::toRadians<double>(angle3));
TopoDS_Shape shape = mkSphere.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1487,7 +1485,8 @@ private:
Base::Vector3d vec = static_cast<Base::VectorPy*>(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<double>(angle));
TopoDS_Shape shape = mkCyl.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1517,7 +1516,8 @@ private:
Base::Vector3d vec = static_cast<Base::VectorPy*>(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<double>(angle));
TopoDS_Shape shape = mkCone.Shape();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));
}
@@ -1547,7 +1547,10 @@ private:
Base::Vector3d vec = static_cast<Base::VectorPy*>(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<double>(angle1),
Base::toRadians<double>(angle2),
Base::toRadians<double>(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<double>(angle));
if (type == defaultType) {
TopoDS_Shape shape = mkRev.Solid();
return Py::asObject(new TopoShapeSolidPy(new TopoShape(shape)));