fix double vs. float problem to solve problems in Mesh.nearestFacetOnRay
This commit is contained in:
@@ -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<unsigned long> &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.
|
||||
*/
|
||||
|
||||
@@ -26,16 +26,19 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "Definitions.h"
|
||||
#include <Base/Tools.h>
|
||||
|
||||
using namespace MeshCore;
|
||||
namespace MeshCore {
|
||||
|
||||
template<> const float Math<float> ::PI = (float)(4.0*atan(1.0));
|
||||
template<> const double Math<double>::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<float>(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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 Prec>
|
||||
class Math
|
||||
{
|
||||
public:
|
||||
MeshExport static const Prec PI;
|
||||
};
|
||||
|
||||
typedef Math<float> Mathf;
|
||||
typedef Math<double> Mathd;
|
||||
|
||||
/**
|
||||
* Global defined tolerances used to compare points
|
||||
* for equality.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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<float>(CreaseAngle.getValue());
|
||||
}
|
||||
else if (prop == &OpenEdges) {
|
||||
showOpenEdges(OpenEdges.getValue());
|
||||
|
||||
Reference in New Issue
Block a user