/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2005 \/)\/ * * 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.3 2005/09/16 10:03:46 m_di_benedetto General interface redefinition, added special functors for faces. Revision 1.2 2005/09/11 11:46:43 m_di_benedetto First Commit ****************************************************************************/ #ifndef __VCGLIB_AABBBINARYTREEUTILS #define __VCGLIB_AABBBINARYTREEUTILS // vcg headers #include #include /***************************************************************************************/ namespace vcg { /* Class AABBBinaryTreeUtils SAMPLE USAGE: NOTES: */ template class AABBBinaryTreeUtils { public: typedef AABBBinaryTreeUtils ClassType; typedef SCALARTYPE ScalarType; typedef OBJTYPE ObjType; protected: template class P3Converter { public: static Point3 Convert(const Point3 & p) { return Point3( (T1)p[0], (T1)p[1], (T1)p[2] ); } }; template class P3Converter { public: static Point3 Convert(const Point3 & p) { return (p); } }; public: template static Point3 ConvertP3(const Point3 & p) { return (ClassType::P3Converter::Convert(p)); } class Face { }; class EmptyClass { }; class ObjIteratorPtrFunct { public: template inline T * operator () (T & t) { return (&t); } template inline T * operator () (T* & t) { return (t); } }; static ObjIteratorPtrFunct IteratorPtrFunctor(void) { ObjIteratorPtrFunct pp; return pp; } template class ObjBoxFunct { public: inline Box3 operator () (const OBJ & obj) { (void)obj; Box3 box; box.SetNull(); return (box); } }; static ObjBoxFunct BoxFunctor(void) { ObjBoxFunct tt; return tt; } template class FaceBoxFunct { public: typedef FACETYPE FaceType; inline Box3 operator () (const FaceType & f) { Box3 box; box.Set(ConvertP3(f.P(0))); box.Add(ConvertP3(f.P(1))); box.Add(ConvertP3(f.P(2))); return (box); } }; template static FaceBoxFunct FaceBoxFunctor(void) { FaceBoxFunct tt; return tt; } template class ObjBarycenterFunct { public: inline Point3 operator () (const OBJ & obj) { (void)obj; printf("GENERAL\n"); Point3 bc(ScalarType(0), ScalarType(0), ScalarType(0)); return (bc); } }; static ObjBarycenterFunct BarycenterFunctor(void) { ObjBarycenterFunct tt; return tt; } template class FaceBarycenterFunct { public: typedef FACETYPE FaceType; inline Point3 operator () (const FaceType & f) { return (ConvertP3(f.Barycenter())); } }; template static FaceBarycenterFunct FaceBarycenterFunctor(void) { FaceBarycenterFunct tt; return tt; } template class ObjPointDistanceFunct { public: inline bool operator () (const OBJ & obj, const Point3 & p, ScalarType & minDist, Point3 & res) { (void)obj; (void)p; (void)minDist; (void)res; return (false); } }; static ObjPointDistanceFunct PointDistanceFunctor(void) { ObjPointDistanceFunct tt; return tt; } template class FacePointDistanceFunct { public: typedef FACETYPE FaceType; inline bool operator () (const FaceType & f, const Point3 & p, ScalarType & minDist, Point3 & res) { Point3 fp = ConvertP3(p); typename FaceType::ScalarType md = (typename FaceType::ScalarType)minDist; Point3 fres; const bool bret = face::PointDistance(f, p, md, fres); minDist = ScalarType(md); res = ConvertP3(fres); return (bret); } }; template static FacePointDistanceFunct FacePointDistanceFunctor(void) { FacePointDistanceFunct tt; return tt; } }; /***************************************************************************************/ } // end namespace vcg #endif // #ifndef __VCGLIB_AABBBINARYTREEUTILS