67 lines
2.9 KiB
C++
67 lines
2.9 KiB
C++
/****************************************************************************
|
|
* VCGLib o o *
|
|
* Visual and Computer Graphics Library o o *
|
|
* _ O _ *
|
|
* Copyright(C) 2004 \/)\/ *
|
|
* Visual Computing Lab /\/| *
|
|
* ISTI - Italian National Research Council | *
|
|
* \ *
|
|
* All rights reserved. *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
* for more details. *
|
|
* *
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
History
|
|
|
|
$Log: not supported by cvs2svn $
|
|
Revision 1.2 2005/09/28 19:55:08 m_di_benedetto
|
|
All functors but FaceRayIntersectFunctor removed and placed in appropriate files.
|
|
|
|
Revision 1.1 2005/09/26 18:33:16 m_di_benedetto
|
|
First Commit.
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __VCGLIB_FACEFUNCTORS
|
|
#define __VCGLIB_FACEFUNCTORS
|
|
|
|
// vcg headers
|
|
#include <vcg/space/intersection3.h>
|
|
|
|
namespace vcg {
|
|
|
|
template <bool BACKFACETEST = true>
|
|
class FaceRayIntersectFunctor {
|
|
public:
|
|
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(ray, Point3<SCALARTYPE>::Construct(f.P(0)), Point3<SCALARTYPE>::Construct(f.P(1)), Point3<SCALARTYPE>::Construct(f.P(2)), a, b, t);
|
|
if (BACKFACETEST) {
|
|
if (!bret) {
|
|
bret = Intersection(ray, Point3<SCALARTYPE>::Construct(f.P(0)), Point3<SCALARTYPE>::Construct(f.P(2)), Point3<SCALARTYPE>::Construct(f.P(1)), a, b, t);
|
|
}
|
|
}
|
|
return (bret);
|
|
}
|
|
};
|
|
|
|
} // end namespace vcg
|
|
|
|
#endif // #ifndef __VCGLIB_FACEFUNCTORS
|