OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Traits.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08 Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
42
48 //=============================================================================
49 //
50 // CLASS Traits
51 //
52 //=============================================================================
53
54 #ifndef OPENMESH_TRAITS_HH
55 #define OPENMESH_TRAITS_HH
56
57
58 //== INCLUDES =================================================================
59
60
61 #include <OpenMesh/Core/System/config.h>
62 #include <OpenMesh/Core/Geometry/VectorT.hh>
63 #include <OpenMesh/Core/Mesh/Attributes.hh>
64 #include <OpenMesh/Core/Mesh/Handles.hh>
65
66
67 //== NAMESPACES ===============================================================
68
69
70 namespace OpenMesh {
71
72
73 //== CLASS DEFINITION =========================================================
74
75
77 #define VertexAttributes(_i) enum { VertexAttributes = _i }
78
80 #define HalfedgeAttributes(_i) enum { HalfedgeAttributes = _i }
81
83 #define EdgeAttributes(_i) enum { EdgeAttributes = _i }
84
86 #define FaceAttributes(_i) enum { FaceAttributes = _i }
87
89 #define VertexTraits \
90 template <class Base, class Refs> struct VertexT : public Base
91
93 #define HalfedgeTraits \
94 template <class Base, class Refs> struct HalfedgeT : public Base
95
97 #define EdgeTraits \
98 template <class Base, class Refs> struct EdgeT : public Base
99
101 #define FaceTraits \
102 template <class Base, class Refs> struct FaceT : public Base
103
104
105
106 //== CLASS DEFINITION =========================================================
107
108
119 struct DefaultTraits
120 {
122 typedef Vec3f Point;
123
125 typedef Vec3f Normal;
126
128 typedef float TexCoord1D;
130 typedef Vec2f TexCoord2D;
132 typedef Vec3f TexCoord3D;
133
135 typedef int TextureIndex;
136
138 typedef Vec3uc Color;
139
140 #ifndef DOXY_IGNORE_THIS
141 VertexTraits {};
142 HalfedgeTraits {};
143 EdgeTraits {};
144 FaceTraits {};
145 #endif
146
147 VertexAttributes(0);
148 HalfedgeAttributes(Attributes::PrevHalfedge);
149 EdgeAttributes(0);
150 FaceAttributes(0);
151 };
152
153
154 //== CLASS DEFINITION =========================================================
155
156
168 template <class _Traits1, class _Traits2> struct MergeTraits
169 {
170 #ifndef DOXY_IGNORE_THIS
171 struct Result
172 {
173 // Mipspro needs this (strange) typedef
174 typedef _Traits1 T1;
175 typedef _Traits2 T2;
176
177
178 VertexAttributes ( T1::VertexAttributes | T2::VertexAttributes );
179 HalfedgeAttributes ( T1::HalfedgeAttributes | T2::HalfedgeAttributes );
180 EdgeAttributes ( T1::EdgeAttributes | T2::EdgeAttributes );
181 FaceAttributes ( T1::FaceAttributes | T2::FaceAttributes );
182
183
184 typedef typename T1::Point Point;
185 typedef typename T1::Normal Normal;
186 typedef typename T1::Color Color;
187 typedef typename T1::TexCoord TexCoord;
188
189 template <class Base, class Refs> class VertexT :
190 public T1::template VertexT<
191 typename T2::template VertexT<Base, Refs>, Refs>
192 {};
193
194 template <class Base, class Refs> class HalfedgeT :
195 public T1::template HalfedgeT<
196 typename T2::template HalfedgeT<Base, Refs>, Refs>
197 {};
198
199
200 template <class Base, class Refs> class EdgeT :
201 public T1::template EdgeT<
202 typename T2::template EdgeT<Base, Refs>, Refs>
203 {};
204
205
206 template <class Base, class Refs> class FaceT :
207 public T1::template FaceT<
208 typename T2::template FaceT<Base, Refs>, Refs>
209 {};
210 };
211 #endif
212 };
213
214
221 #define OM_Merge_Traits(_S1, _S2, _D) \
222 typedef OpenMesh::MergeTraits<_S1, _S2>::Result _D;
223
224
229 #define OM_Merge_Traits_In_Template(_S1, _S2, _D) \
230 typedef typename OpenMesh::MergeTraits<_S1, _S2>::Result _D;
231
232
233 //=============================================================================
234 } // namespace OpenMesh
235 //=============================================================================
236 #endif // OPENMESH_TRAITS_HH defined
237 //=============================================================================
238