OpenMesh
OpenMesh/Core/Mesh/Traits.hh
Go to the documentation of this file.
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         * 
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/ 
00034 
00035 /*===========================================================================*\
00036  *                                                                           *             
00037  *   $Revision: 362 $                                                         *
00038  *   $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 
00048 //=============================================================================
00049 //
00050 //  CLASS Traits
00051 //
00052 //=============================================================================
00053 
00054 #ifndef OPENMESH_TRAITS_HH
00055 #define OPENMESH_TRAITS_HH
00056 
00057 
00058 //== INCLUDES =================================================================
00059 
00060 
00061 #include <OpenMesh/Core/System/config.h>
00062 #include <OpenMesh/Core/Geometry/VectorT.hh>
00063 #include <OpenMesh/Core/Mesh/Attributes.hh>
00064 #include <OpenMesh/Core/Mesh/Handles.hh>
00065 
00066 
00067 //== NAMESPACES ===============================================================
00068 
00069 
00070 namespace OpenMesh {
00071 
00072 
00073 //== CLASS DEFINITION =========================================================
00074 
00075 
00077 #define VertexAttributes(_i) enum { VertexAttributes = _i }
00078 
00080 #define HalfedgeAttributes(_i) enum { HalfedgeAttributes = _i }
00081 
00083 #define EdgeAttributes(_i) enum { EdgeAttributes = _i }
00084 
00086 #define FaceAttributes(_i) enum { FaceAttributes = _i }
00087 
00089 #define VertexTraits \
00090   template <class Base, class Refs> struct VertexT : public Base
00091 
00093 #define HalfedgeTraits \
00094   template <class Base, class Refs> struct HalfedgeT : public Base
00095 
00097 #define EdgeTraits \
00098   template <class Base, class Refs> struct EdgeT : public Base
00099 
00101 #define FaceTraits \
00102   template <class Base, class Refs> struct FaceT : public Base
00103 
00104 
00105 
00106 //== CLASS DEFINITION =========================================================
00107 
00108 
00119 struct DefaultTraits
00120 {
00122   typedef Vec3f  Point;
00123 
00125   typedef Vec3f  Normal;
00126 
00128   typedef float  TexCoord1D;
00130   typedef Vec2f  TexCoord2D;
00132   typedef Vec3f  TexCoord3D;
00133 
00135   typedef int TextureIndex;
00136 
00138   typedef Vec3uc Color;
00139 
00140 #ifndef DOXY_IGNORE_THIS
00141   VertexTraits    {};
00142   HalfedgeTraits  {};
00143   EdgeTraits      {};
00144   FaceTraits      {};
00145 #endif
00146 
00147   VertexAttributes(0);
00148   HalfedgeAttributes(Attributes::PrevHalfedge);
00149   EdgeAttributes(0);
00150   FaceAttributes(0);
00151 };
00152 
00153 
00154 //== CLASS DEFINITION =========================================================
00155 
00156 
00168 template <class _Traits1, class _Traits2> struct MergeTraits
00169 {
00170 #ifndef DOXY_IGNORE_THIS
00171   struct Result
00172   {
00173     // Mipspro needs this (strange) typedef
00174     typedef _Traits1  T1;
00175     typedef _Traits2  T2;
00176 
00177 
00178     VertexAttributes   ( T1::VertexAttributes   | T2::VertexAttributes   );
00179     HalfedgeAttributes ( T1::HalfedgeAttributes | T2::HalfedgeAttributes );
00180     EdgeAttributes     ( T1::EdgeAttributes     | T2::EdgeAttributes     );
00181     FaceAttributes     ( T1::FaceAttributes     | T2::FaceAttributes     );
00182 
00183 
00184     typedef typename T1::Point    Point;
00185     typedef typename T1::Normal   Normal;
00186     typedef typename T1::Color    Color;
00187     typedef typename T1::TexCoord TexCoord;
00188 
00189     template <class Base, class Refs> class VertexT :
00190       public T1::template VertexT<
00191       typename T2::template VertexT<Base, Refs>, Refs>
00192     {};
00193 
00194     template <class Base, class Refs> class HalfedgeT :
00195       public T1::template HalfedgeT<
00196       typename T2::template HalfedgeT<Base, Refs>, Refs>
00197     {};
00198 
00199 
00200     template <class Base, class Refs> class EdgeT :
00201       public T1::template EdgeT<
00202       typename T2::template EdgeT<Base, Refs>, Refs>
00203     {};
00204 
00205 
00206     template <class Base, class Refs> class FaceT :
00207       public T1::template FaceT<
00208       typename T2::template FaceT<Base, Refs>, Refs>
00209     {};
00210   };
00211 #endif
00212 };
00213 
00214 
00221 #define OM_Merge_Traits(_S1, _S2, _D) \
00222   typedef OpenMesh::MergeTraits<_S1, _S2>::Result _D;
00223 
00224 
00229 #define OM_Merge_Traits_In_Template(_S1, _S2, _D) \
00230   typedef typename OpenMesh::MergeTraits<_S1, _S2>::Result _D;
00231 
00232 
00233 //=============================================================================
00234 } // namespace OpenMesh
00235 //=============================================================================
00236 #endif // OPENMESH_TRAITS_HH defined
00237 //=============================================================================
00238 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines