Commit 8afeb70f authored by Mike Kremer's avatar Mike Kremer

Integrated optional infinity override for custom types that do not have...

Integrated optional infinity override for custom types that do not have std::numeric_limits<Type>::infinity().

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16007 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 62045448
......@@ -70,7 +70,7 @@ nearest(const Point& _p) const
{
NearestNeighborData data;
data.ref = _p;
data.dist = std::numeric_limits<Scalar>::infinity();
data.dist = infinity_;
if (this->root_ == 0)
throw std::runtime_error("It seems like the BSP hasn't been built, yet. Did you call build(...)?");
_nearest(this->root_, data);
......@@ -89,8 +89,7 @@ _nearest(Node* _node, NearestNeighborData& _data) const
// terminal node
if (!_node->left_child_)
{
Scalar dist;
Scalar dist(0);
for (HandleIter it=_node->begin(); it!=_node->end(); ++it)
{
dist = this->traits_.sqrdist(*it, _data.ref);
......@@ -106,7 +105,6 @@ _nearest(Node* _node, NearestNeighborData& _data) const
else
{
Scalar dist = _node->plane_.distance(_data.ref);
if (dist > 0.0)
{
_nearest(_node->left_child_, _data);
......
......@@ -79,7 +79,9 @@ public: //---------------------------------------------------------------------
public: //---------------------------------------------------------------------
BSPImplT(const Traits& _traits) : BSPCore(_traits) {}
BSPImplT(const Traits& _traits, const Scalar _infinity = std::numeric_limits<Scalar>::infinity()) :
BSPCore(_traits),
infinity_(_infinity) {}
~BSPImplT() {}
......@@ -173,6 +175,8 @@ private: //---------------------------------------------------------------------
}
};
const Scalar infinity_;
};
//=============================================================================
......
......@@ -67,7 +67,9 @@ class TriangleBSPT : public BSPImplT< TriangleBSPCoreT<BSPTraits> >
{
public:
typedef BSPImplT< TriangleBSPCoreT<BSPTraits> > Base;
TriangleBSPT(const BSPTraits& _traits) : Base(_traits) {}
typedef typename Base::Scalar Scalar;
TriangleBSPT(const BSPTraits& _traits,
const Scalar _infinity = std::numeric_limits<Scalar>::infinity()) : Base(_traits, _infinity) {}
};
//== CLASS DEFINITION =========================================================
......@@ -200,7 +202,9 @@ class OpenMeshTriangleBSPT
public:
typedef OpenMeshTriangleBSPTraits<Mesh> Traits;
typedef TriangleBSPT<Traits> Base;
OpenMeshTriangleBSPT(const Mesh& _mesh) : Base(Traits(_mesh)) {}
typedef typename Traits::Scalar Scalar;
OpenMeshTriangleBSPT(const Mesh& _mesh,
const Scalar _infinity = std::numeric_limits<Scalar>::infinity()) : Base(Traits(_mesh), _infinity) {}
};
//=============================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment