/**************************************************************************** * 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 $ ****************************************************************************/ #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; template static inline Point3 ConvertP3(const Point3 & p) { return (Point3(S(p[0]), S(p[1]), S(p[2]))); } class EmptyClass { }; class ObjIteratorPtrFunct { public: template inline T * operator () (T & t) { return (&t); } template inline T * operator () (T * & t) { return (t); } }; template class FaceBoxFunct { public: typedef FACETYPE FaceType; inline Box3 operator () (const FaceType & f) { Box3 box; box.SetNull(); box.Add(AABBBinaryTreeUtils::ConvertP3(f.P(0))); box.Add(AABBBinaryTreeUtils::ConvertP3(f.P(1))); box.Add(AABBBinaryTreeUtils::ConvertP3(f.P(2))); return (box); } }; template class ObjBarycenterFunct { public: typedef OBJTYPE ObjType; inline Point3 operator () (const ObjType & obj) { return (AABBBinaryTreeUtils::ConvertP3(obj.Barycenter())); } }; template class FacePointDistanceFunct { public: typedef FACETYPE FaceType; inline bool operator () (const FaceType & f, const Point3 & p, ScalarType & minDist, Point3 & res) { FaceType::ScalarType fdist; const AFace::CoordType fp = ConvertP3(p); FaceType::CoordType fres; const bool br = face::PointDistance(f, fp, fdist, fres); minDist = (ScalarType)(fdist); res = ConvertP3(fres); return (br); } }; }; /***************************************************************************************/ } // end namespace vcg #endif // #ifndef __VCGLIB_AABBBINARYTREEUTILS