Developer Documentation

Traits.hh
Go to the documentation of this file.
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42
43
44
50 //=============================================================================
51 //
52 // CLASS Traits
53 //
54 //=============================================================================
55
56 #ifndef OPENMESH_TRAITS_HH
57 #define OPENMESH_TRAITS_HH
58
59
60 //== INCLUDES =================================================================
61
62
63 #include <OpenMesh/Core/System/config.h>
64 #include <OpenMesh/Core/Geometry/VectorT.hh>
65 #include <OpenMesh/Core/Mesh/Attributes.hh>
66 #include <OpenMesh/Core/Mesh/Handles.hh>
67
68
69 //== NAMESPACES ===============================================================
70
71
72 namespace OpenMesh {
73
74
75 //== CLASS DEFINITION =========================================================
76
77
79 #define VertexAttributes(_i) enum { VertexAttributes = _i }
80
82 #define HalfedgeAttributes(_i) enum { HalfedgeAttributes = _i }
83
85 #define EdgeAttributes(_i) enum { EdgeAttributes = _i }
86
88 #define FaceAttributes(_i) enum { FaceAttributes = _i }
89
91 #define VertexTraits \
92 template <class Base, class Refs> struct VertexT : public Base
93
95 #define HalfedgeTraits \
96 template <class Base, class Refs> struct HalfedgeT : public Base
97
99 #define EdgeTraits \
100 template <class Base, class Refs> struct EdgeT : public Base
101
103 #define FaceTraits \
104 template <class Base, class Refs> struct FaceT : public Base
105
106
107
108 //== CLASS DEFINITION =========================================================
109
110
121 struct DefaultTraits
122 {
124 typedef Vec3f Point;
125
127 typedef Vec3f Normal;
128
130 typedef float TexCoord1D;
132 typedef Vec2f TexCoord2D;
134 typedef Vec3f TexCoord3D;
135
137 typedef int TextureIndex;
138
140 typedef Vec3uc Color;
141
142 #ifndef DOXY_IGNORE_THIS
143 VertexTraits {};
144 HalfedgeTraits {};
145 EdgeTraits {};
146 FaceTraits {};
147 #endif
148
149 VertexAttributes(0);
150 HalfedgeAttributes(Attributes::PrevHalfedge);
151 EdgeAttributes(0);
152 FaceAttributes(0);
153 };
154
163 struct DefaultTraitsDouble : public DefaultTraits
164 {
166 typedef OpenMesh::Vec3d Point;
168 typedef OpenMesh::Vec3d Normal;
170 typedef OpenMesh::Vec4f Color;
171 };
172
173
174 //== CLASS DEFINITION =========================================================
175
176
188 template <class _Traits1, class _Traits2> struct MergeTraits
189 {
190 #ifndef DOXY_IGNORE_THIS
191 struct Result
192 {
193 // Mipspro needs this (strange) typedef
194 typedef _Traits1 T1;
195 typedef _Traits2 T2;
196
197
198 VertexAttributes ( T1::VertexAttributes | T2::VertexAttributes );
199 HalfedgeAttributes ( T1::HalfedgeAttributes | T2::HalfedgeAttributes );
200 EdgeAttributes ( T1::EdgeAttributes | T2::EdgeAttributes );
201 FaceAttributes ( T1::FaceAttributes | T2::FaceAttributes );
202
203
204 typedef typename T1::Point Point;
205 typedef typename T1::Normal Normal;
206 typedef typename T1::Color Color;
207 typedef typename T1::TexCoord TexCoord;
208
209 template <class Base, class Refs> class VertexT :
210 public T1::template VertexT<
211 typename T2::template VertexT<Base, Refs>, Refs>
212 {};
213
214 template <class Base, class Refs> class HalfedgeT :
215 public T1::template HalfedgeT<
216 typename T2::template HalfedgeT<Base, Refs>, Refs>
217 {};
218
219
220 template <class Base, class Refs> class EdgeT :
221 public T1::template EdgeT<
222 typename T2::template EdgeT<Base, Refs>, Refs>
223 {};
224
225
226 template <class Base, class Refs> class FaceT :
227 public T1::template FaceT<
228 typename T2::template FaceT<Base, Refs>, Refs>
229 {};
230 };
231 #endif
232 };
233
234
241 #define OM_Merge_Traits(_S1, _S2, _D) \
242 typedef OpenMesh::MergeTraits<_S1, _S2>::Result _D;
243
244
249 #define OM_Merge_Traits_In_Template(_S1, _S2, _D) \
250 typedef typename OpenMesh::MergeTraits<_S1, _S2>::Result _D;
251
252
253 //=============================================================================
254 } // namespace OpenMesh
255 //=============================================================================
256 #endif // OPENMESH_TRAITS_HH defined
257 //=============================================================================
258
OpenMesh::DefaultTraits::TexCoord3D
Vec3f TexCoord3D
The default 3D texture coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:134
OpenMesh::Attributes::PrevHalfedge
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:84
OpenMesh::DefaultTraitsDouble::Normal
OpenMesh::Vec3d Normal
Use double precision Normals.
Definition: Traits.hh:168
FaceTraits
#define FaceTraits
Macro for defining the face traits. See Specifying your MyMesh.
Definition: Traits.hh:103
config.h
OpenMesh::DefaultTraitsDouble::Point
OpenMesh::Vec3d Point
Use double precision points.
Definition: Traits.hh:166
OpenMesh::DefaultTraitsDouble::Color
OpenMesh::Vec4f Color
Use RGBA Color.
Definition: Traits.hh:170
OpenMesh::VectorT< float, 3 >
VertexTraits
#define VertexTraits
Macro for defining the vertex traits. See Specifying your MyMesh.
Definition: Traits.hh:91
OpenMesh::Attributes::Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:83
OpenMesh
Definition: MeshItems.hh:59
VertexAttributes
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:79
EdgeAttributes
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:85
OpenMesh::DefaultTraits::Normal
Vec3f Normal
The default normal type is OpenMesh::Vec3f.
Definition: Traits.hh:127
EdgeTraits
#define EdgeTraits
Macro for defining the edge traits. See Specifying your MyMesh.
Definition: Traits.hh:99
OpenMesh::DefaultTraits::TexCoord2D
Vec2f TexCoord2D
The default 2D texture coordinate type is OpenMesh::Vec2f.
Definition: Traits.hh:132
OpenMesh::DefaultTraits::TexCoord1D
float TexCoord1D
The default 1D texture coordinate type is float.
Definition: Traits.hh:130
Attributes.hh
OpenMesh::MergeTraits
Definition: Traits.hh:188
HalfedgeTraits
#define HalfedgeTraits
Macro for defining the halfedge traits. See Specifying your MyMesh.
Definition: Traits.hh:95
OpenMesh::DefaultTraits::Color
Vec3uc Color
The default color type is OpenMesh::Vec3uc.
Definition: Traits.hh:140
OpenMesh::DefaultTraits
Definition: Traits.hh:121
HalfedgeAttributes
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:82
FaceAttributes
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:88
OpenMesh::DefaultTraits::TextureIndex
int TextureIndex
The default texture index type.
Definition: Traits.hh:137
OpenMesh::DefaultTraits::Point
Vec3f Point
The default coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:124
OpenMesh::DefaultTraitsDouble
Definition: Traits.hh:163