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 
64 #include <OpenMesh/Core/Geometry/VectorT.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 
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 
155 
156 //== CLASS DEFINITION =========================================================
157 
158 
170 template <class _Traits1, class _Traits2> struct MergeTraits
171 {
172 #ifndef DOXY_IGNORE_THIS
173  struct Result
174  {
175  // Mipspro needs this (strange) typedef
176  typedef _Traits1 T1;
177  typedef _Traits2 T2;
178 
179 
184 
185 
186  typedef typename T1::Point Point;
187  typedef typename T1::Normal Normal;
188  typedef typename T1::Color Color;
189  typedef typename T1::TexCoord TexCoord;
190 
191  template <class Base, class Refs> class VertexT :
192  public T1::template VertexT<
193  typename T2::template VertexT<Base, Refs>, Refs>
194  {};
195 
196  template <class Base, class Refs> class HalfedgeT :
197  public T1::template HalfedgeT<
198  typename T2::template HalfedgeT<Base, Refs>, Refs>
199  {};
200 
201 
202  template <class Base, class Refs> class EdgeT :
203  public T1::template EdgeT<
204  typename T2::template EdgeT<Base, Refs>, Refs>
205  {};
206 
207 
208  template <class Base, class Refs> class FaceT :
209  public T1::template FaceT<
210  typename T2::template FaceT<Base, Refs>, Refs>
211  {};
212  };
213 #endif
214 };
215 
216 
223 #define OM_Merge_Traits(_S1, _S2, _D) \
224  typedef OpenMesh::MergeTraits<_S1, _S2>::Result _D;
225 
226 
231 #define OM_Merge_Traits_In_Template(_S1, _S2, _D) \
232  typedef typename OpenMesh::MergeTraits<_S1, _S2>::Result _D;
233 
234 
235 //=============================================================================
236 } // namespace OpenMesh
237 //=============================================================================
238 #endif // OPENMESH_TRAITS_HH defined
239 //=============================================================================
240 
Vec3f Normal
The default normal type is OpenMesh::Vec3f.
Definition: Traits.hh:127
#define FaceTraits
Macro for defining the face traits. See Specifying your MyMesh.
Definition: Traits.hh:103
#define EdgeTraits
Macro for defining the edge traits. See Specifying your MyMesh.
Definition: Traits.hh:99
float TexCoord1D
The default 1D texture coordinate type is float.
Definition: Traits.hh:130
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:83
#define VertexTraits
Macro for defining the vertex traits. See Specifying your MyMesh.
Definition: Traits.hh:91
int TextureIndex
The default texture index type.
Definition: Traits.hh:137
Vec3f TexCoord3D
The default 3D texture coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:134
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:82
Vec3uc Color
The default color type is OpenMesh::Vec3uc.
Definition: Traits.hh:140
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:85
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:84
#define HalfedgeTraits
Macro for defining the halfedge traits. See Specifying your MyMesh.
Definition: Traits.hh:95
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:79
Vec2f TexCoord2D
The default 2D texture coordinate type is OpenMesh::Vec2f.
Definition: Traits.hh:132
Vec3f Point
The default coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:124
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:88