All functors but FaceRayIntersectFunctor removed and placed in appropriate files.
This commit is contained in:
parent
cb0aab5473
commit
cd7fc5bedf
|
@ -25,6 +25,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2005/09/26 18:33:16 m_di_benedetto
|
||||
First Commit.
|
||||
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -32,68 +35,26 @@ $Log: not supported by cvs2svn $
|
|||
#define __VCGLIB_FACEFUNCTORS
|
||||
|
||||
// vcg headers
|
||||
#include <vcg/space/point3.h>
|
||||
#include <vcg/space/box3.h>
|
||||
#include <vcg/space/line3.h>
|
||||
#include <vcg/space/intersection3.h>
|
||||
#include <vcg/simplex/face/distance.h>
|
||||
|
||||
namespace vcg {
|
||||
|
||||
class FaceBarycenterFunctor {
|
||||
public:
|
||||
template <class FACETYPE, class COORDTYPE>
|
||||
inline void operator () (const FACETYPE & f, COORDTYPE & b) {
|
||||
b = COORDTYPE::Construct(f.Barycenter());
|
||||
}
|
||||
};
|
||||
|
||||
class FaceBoxFunctor {
|
||||
public:
|
||||
template <class FACETYPE, class BOXTYPE>
|
||||
inline void operator () (const FACETYPE & f, BOXTYPE & b) {
|
||||
b.Set(Point3<BOXTYPE::ScalarType>::Construct(f.P(0)));
|
||||
b.Add(Point3<BOXTYPE::ScalarType>::Construct(f.P(1)));
|
||||
b.Add(Point3<BOXTYPE::ScalarType>::Construct(f.P(2)));
|
||||
}
|
||||
};
|
||||
|
||||
class FacePointDistanceFunctor {
|
||||
public:
|
||||
template <class FACETYPE, class COORDTYPE>
|
||||
inline bool operator () (const FACETYPE & f, const COORDTYPE & p, typename COORDTYPE::ScalarType & minDist, COORDTYPE & q) {
|
||||
const Point3<typename FACETYPE::ScalarType> fp = Point3<typename FACETYPE::ScalarType>::Construct(p);
|
||||
Point3<typename FACETYPE::ScalarType> fq;
|
||||
typename FACETYPE::ScalarType md = (typename FACETYPE::ScalarType)(minDist);
|
||||
const bool ret = face::PointDistance(f, fp, md, fq);
|
||||
minDist = (typename COORDTYPE::ScalarType)(md);
|
||||
q = COORDTYPE::Construct(fq);
|
||||
return (ret);
|
||||
}
|
||||
};
|
||||
|
||||
template <bool BACKFACETEST = true>
|
||||
class FaceRayIntersectFunctor {
|
||||
public:
|
||||
template <class FACETYPE, class COORDTYPE>
|
||||
inline bool operator () (const FACETYPE & f, const COORDTYPE & rayOrigin, const COORDTYPE & rayDirection, typename COORDTYPE::ScalarType & t, COORDTYPE & q) {
|
||||
typedef typename COORDTYPE::ScalarType ScalarType;
|
||||
Line3<ScalarType, false> ln(rayOrigin, rayDirection);
|
||||
template <class FACETYPE, class SCALARTYPE>
|
||||
inline bool operator () (const FACETYPE & f, const Ray3<SCALARTYPE> & ray, SCALARTYPE & t) {
|
||||
typedef typename SCALARTYPE ScalarType;
|
||||
ScalarType a;
|
||||
ScalarType b;
|
||||
|
||||
bool bret = Intersection(ln, f.P(0), f.P(1), f.P(2), a, b, t);
|
||||
bool bret = Intersection(ray, f.P(0), f.P(1), f.P(2), a, b, t);
|
||||
if (BACKFACETEST) {
|
||||
if (!bret) {
|
||||
bret = Intersection(ln, f.P(0), f.P(2), f.P(1), a, b, t);
|
||||
bret = Intersection(ray, f.P(0), f.P(2), f.P(1), a, b, t);
|
||||
}
|
||||
}
|
||||
|
||||
if (bret) {
|
||||
q = rayOrigin + rayDirection * t;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
return (bret);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue