diff --git a/src/Mod/Mesh/App/Core/Algorithm.h b/src/Mod/Mesh/App/Core/Algorithm.h index 07ff47a024..1ac12a2301 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.h +++ b/src/Mod/Mesh/App/Core/Algorithm.h @@ -304,7 +304,7 @@ protected: Base::Vector3f> > &rclLines) const; /** Searches the nearest facet in \a raulFacets to the ray (\a rclPt, \a rclDir). */ bool RayNearestField (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, const std::vector &raulFacets, - Base::Vector3f &rclRes, unsigned long &rulFacet, float fMaxAngle = F_PI) const; + Base::Vector3f &rclRes, unsigned long &rulFacet, float fMaxAngle = Mathf::PI) const; /** * Splits the boundary \a rBound in several loops and append this loops to the list of borders. */ diff --git a/src/Mod/Mesh/App/Core/Definitions.cpp b/src/Mod/Mesh/App/Core/Definitions.cpp index 86938638af..2c1b2819f2 100644 --- a/src/Mod/Mesh/App/Core/Definitions.cpp +++ b/src/Mod/Mesh/App/Core/Definitions.cpp @@ -26,16 +26,19 @@ #include #include "Definitions.h" +#include -using namespace MeshCore; +namespace MeshCore { + +template<> const float Math ::PI = (float)(4.0*atan(1.0)); +template<> const double Math::PI = 4.0*atan(1.0); float MeshDefinitions::_fMinPointDistance = float(MESH_MIN_PT_DIST); float MeshDefinitions::_fMinPointDistanceP2 = _fMinPointDistance * _fMinPointDistance; float MeshDefinitions::_fMinPointDistanceD1 = _fMinPointDistance; float MeshDefinitions::_fMinEdgeLength = MESH_MIN_EDGE_LEN; bool MeshDefinitions::_bRemoveMinLength = MESH_REMOVE_MIN_LEN; - -float MeshDefinitions::_fMinEdgeAngle = MESH_MIN_EDGE_ANGLE; +float MeshDefinitions::_fMinEdgeAngle = Base::toRadians(MESH_MIN_EDGE_ANGLE); MeshDefinitions::MeshDefinitions (void) { @@ -47,3 +50,5 @@ void MeshDefinitions::SetMinPointDistance (float fMin) _fMinPointDistanceP2 = fMin * fMin; _fMinPointDistanceD1 = float(sqrt((fMin * fMin) / 3.0f)); } + +} diff --git a/src/Mod/Mesh/App/Core/Definitions.h b/src/Mod/Mesh/App/Core/Definitions.h index ee15b2f478..454ffb6081 100644 --- a/src/Mod/Mesh/App/Core/Definitions.h +++ b/src/Mod/Mesh/App/Core/Definitions.h @@ -27,7 +27,7 @@ // default values #define MESH_MIN_PT_DIST 1.0e-6f #define MESH_MIN_EDGE_LEN 1.0e-3f -#define MESH_MIN_EDGE_ANGLE float(RAD(2.0)) +#define MESH_MIN_EDGE_ANGLE 2.0 #define MESH_REMOVE_MIN_LEN true #define MESH_REMOVE_G3_EDGES true @@ -36,14 +36,6 @@ */ #define FLOAT_EPS 1.0e-4f -#ifndef F_PI -# define F_PI 3.1415926f -#endif - -#ifndef D_PI -# define D_PI 3.141592653589793 -#endif - #ifndef FLOAT_MAX # define FLOAT_MAX 1e30f #endif @@ -56,14 +48,18 @@ # define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/ #endif -/* - * macros to convert between angles - */ -#define RAD(D) ((D) * D_PI / 180.0) -#define DEGREE(R) ((R) * 180.0 / D_PI) - namespace MeshCore { +template +class Math +{ +public: + MeshExport static const Prec PI; +}; + +typedef Math Mathf; +typedef Math Mathd; + /** * Global defined tolerances used to compare points * for equality. diff --git a/src/Mod/Mesh/App/Core/Elements.cpp b/src/Mod/Mesh/App/Core/Elements.cpp index 6faf90af38..c189e821db 100644 --- a/src/Mod/Mesh/App/Core/Elements.cpp +++ b/src/Mod/Mesh/App/Core/Elements.cpp @@ -641,7 +641,8 @@ bool MeshGeomFacet::Foraminate (const Base::Vector3f &P, const Base::Vector3f &d // check angle between facet normal and the line direction, FLOAT_MAX is // returned for degenerated facets - if (dir.GetAngle(n) > fMaxAngle) + float fAngle = dir.GetAngle(n); + if (fAngle > fMaxAngle) return false; float nn = n * n; diff --git a/src/Mod/Mesh/App/Core/Elements.h b/src/Mod/Mesh/App/Core/Elements.h index 7d2ec37a14..6b2ce74f61 100644 --- a/src/Mod/Mesh/App/Core/Elements.h +++ b/src/Mod/Mesh/App/Core/Elements.h @@ -448,7 +448,7 @@ public: * This does actually the same as IntersectWithLine() with one additionally constraint that the angle * between the direction of the line and the normal of the plane must not exceed \a fMaxAngle. */ - bool Foraminate (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes, float fMaxAngle = F_PI) const; + bool Foraminate (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes, float fMaxAngle = Mathf::PI) const; /** Checks if the facet intersects with the plane defined by the base \a rclBase and the normal * \a rclNormal and returns true if two points are found, false otherwise. */ diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index c621f8873f..d425f10171 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -349,7 +349,7 @@ void ViewProviderMesh::onChanged(const App::Property* prop) pcPointStyle->pointSize = PointSize.getValue(); } else if (prop == &CreaseAngle) { - pShapeHints->creaseAngle = (F_PI*CreaseAngle.getValue())/180.0; + pShapeHints->creaseAngle = Base::toRadians(CreaseAngle.getValue()); } else if (prop == &OpenEdges) { showOpenEdges(OpenEdges.getValue());