| 1 | /**************************************************************************** |
| 2 | * VCGLib o o * |
| 3 | * Visual and Computer Graphics Library o o * |
| 4 | * _ O _ * |
| 5 | * Copyright(C) 2004 \/)\/ * |
| 6 | * Visual Computing Lab /\/| * |
| 7 | * ISTI - Italian National Research Council | * |
| 8 | * \ * |
| 9 | * All rights reserved. * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | * This program is distributed in the hope that it will be useful, * |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 19 | * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
| 20 | * for more details. * |
| 21 | * * |
| 22 | ****************************************************************************/ |
| 23 | |
| 24 | /**************************************************************************** |
| 25 | History |
| 26 | |
| 27 | $Log: utils.h,v $ |
| 28 | Revision 1.4 2006/10/13 13:10:05 cignoni |
| 29 | Changed barycenter functor to the new Baricenter(face) style |
| 30 | |
| 31 | Revision 1.3 2005/11/12 18:10:35 cignoni |
| 32 | Removed Abs and LowClampToZero and added comments |
| 33 | |
| 34 | Revision 1.2 2005/09/29 22:22:59 m_di_benedetto |
| 35 | Added classes GetBox3Functor and GetBarycenter3Functor. |
| 36 | |
| 37 | Revision 1.1 2005/09/28 20:01:35 m_di_benedetto |
| 38 | First Commit. |
| 39 | |
| 40 | |
| 41 | ****************************************************************************/ |
| 42 | |
| 43 | #ifndef __VCGLIB_WRAPUTILS_H |
| 44 | #define __VCGLIB_WRAPUTILS_H |
| 45 | |
| 46 | // vcg headers |
| 47 | #include <vcg/math/base.h> |
| 48 | #include <vcg/space/point3.h> |
| 49 | #include <vcg/space/box3.h> |
| 50 | |
| 51 | namespace vcg { |
| 52 | |
| 53 | class EmptyClass { |
| 54 | public: |
| 55 | typedef EmptyClass ClassType; |
| 56 | }; |
| 57 | |
| 58 | class GetPointerFunctor { |
| 59 | public: |
| 60 | typedef GetPointerFunctor ClassType; |
| 61 | |
| 62 | template <class T> |
| 63 | inline T * operator () (T & t) { |
| 64 | return (&t); |
| 65 | } |
| 66 | |
| 67 | template <class T> |
| 68 | inline T * operator () (T * & t) { |
| 69 | return (t); |
| 70 | } |
| 71 | }; |
| 72 | /// Helper class used to build in a easy way a functor that gives the bbox of a face |
| 73 | /// used mainly in the aabbtree that require such a functor as a parameter |
| 74 | |
| 75 | class GetBox3Functor { |
| 76 | public: |
| 77 | template <class OBJTYPE, class SCALARTYPE> |
| 78 | void operator () (const OBJTYPE & obj, Box3<SCALARTYPE> & box) { |
| 79 | Box3<typename OBJTYPE::ScalarType> tb; |
| 80 | obj.GetBBox(tb); |
| 81 | box.Import(tb); |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | class GetBarycenter3Functor { |
| 86 | public: |
| 87 | template <class OBJTYPE, class SCALARTYPE> |
| 88 | void operator () (const OBJTYPE & obj, Point3<SCALARTYPE> & bar) { |
| 89 | bar.Import(Barycenter<OBJTYPE>(obj)); |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | } // end namespace vcg |
| 94 | |
| 95 | #endif // #ifndef __VCGLIB_WRAPUTILS_H |