OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * $Revision$ *
45  * $Date$ *
46  * *
47 \*===========================================================================*/
48 
49 
55 //=============================================================================
56 //
57 // CLASS Traits
58 //
59 //=============================================================================
60 
61 #ifndef OPENMESH_TRAITS_HH
62 #define OPENMESH_TRAITS_HH
63 
64 
65 //== INCLUDES =================================================================
66 
67 
68 #include <OpenMesh/Core/System/config.h>
69 #include <OpenMesh/Core/Geometry/VectorT.hh>
71 #include <OpenMesh/Core/Mesh/Handles.hh>
72 
73 
74 //== NAMESPACES ===============================================================
75 
76 
77 namespace OpenMesh {
78 
79 
80 //== CLASS DEFINITION =========================================================
81 
82 
84 #define VertexAttributes(_i) enum { VertexAttributes = _i }
85 
87 #define HalfedgeAttributes(_i) enum { HalfedgeAttributes = _i }
88 
90 #define EdgeAttributes(_i) enum { EdgeAttributes = _i }
91 
93 #define FaceAttributes(_i) enum { FaceAttributes = _i }
94 
96 #define VertexTraits \
97  template <class Base, class Refs> struct VertexT : public Base
98 
100 #define HalfedgeTraits \
101  template <class Base, class Refs> struct HalfedgeT : public Base
102 
104 #define EdgeTraits \
105  template <class Base, class Refs> struct EdgeT : public Base
106 
108 #define FaceTraits \
109  template <class Base, class Refs> struct FaceT : public Base
110 
111 
112 
113 //== CLASS DEFINITION =========================================================
114 
115 
127 {
129  typedef Vec3f Point;
130 
132  typedef Vec3f Normal;
133 
135  typedef float TexCoord1D;
137  typedef Vec2f TexCoord2D;
139  typedef Vec3f TexCoord3D;
140 
142  typedef int TextureIndex;
143 
145  typedef Vec3uc Color;
146 
147 #ifndef DOXY_IGNORE_THIS
148  VertexTraits {};
149  HalfedgeTraits {};
150  EdgeTraits {};
151  FaceTraits {};
152 #endif
153 
154  VertexAttributes(0);
155  HalfedgeAttributes(Attributes::PrevHalfedge);
156  EdgeAttributes(0);
157  FaceAttributes(0);
158 };
159 
160 
161 //== CLASS DEFINITION =========================================================
162 
163 
175 template <class _Traits1, class _Traits2> struct MergeTraits
176 {
177 #ifndef DOXY_IGNORE_THIS
178  struct Result
179  {
180  // Mipspro needs this (strange) typedef
181  typedef _Traits1 T1;
182  typedef _Traits2 T2;
183 
184 
189 
190 
191  typedef typename T1::Point Point;
192  typedef typename T1::Normal Normal;
193  typedef typename T1::Color Color;
194  typedef typename T1::TexCoord TexCoord;
195 
196  template <class Base, class Refs> class VertexT :
197  public T1::template VertexT<
198  typename T2::template VertexT<Base, Refs>, Refs>
199  {};
200 
201  template <class Base, class Refs> class HalfedgeT :
202  public T1::template HalfedgeT<
203  typename T2::template HalfedgeT<Base, Refs>, Refs>
204  {};
205 
206 
207  template <class Base, class Refs> class EdgeT :
208  public T1::template EdgeT<
209  typename T2::template EdgeT<Base, Refs>, Refs>
210  {};
211 
212 
213  template <class Base, class Refs> class FaceT :
214  public T1::template FaceT<
215  typename T2::template FaceT<Base, Refs>, Refs>
216  {};
217  };
218 #endif
219 };
220 
221 
228 #define OM_Merge_Traits(_S1, _S2, _D) \
229  typedef OpenMesh::MergeTraits<_S1, _S2>::Result _D;
230 
231 
236 #define OM_Merge_Traits_In_Template(_S1, _S2, _D) \
237  typedef typename OpenMesh::MergeTraits<_S1, _S2>::Result _D;
238 
239 
240 //=============================================================================
241 } // namespace OpenMesh
242 //=============================================================================
243 #endif // OPENMESH_TRAITS_HH defined
244 //=============================================================================
245 
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:88
#define VertexTraits
Macro for defining the vertex traits. See Specifying your MyMesh.
Definition: Traits.hh:96
#define HalfedgeTraits
Macro for defining the halfedge traits. See Specifying your MyMesh.
Definition: Traits.hh:100
This file provides some macros containing attribute usage.
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:90
Vec3f Normal
The default normal type is OpenMesh::Vec3f.
Definition: Traits.hh:132
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:89
float TexCoord1D
The default 1D texture coordinate type is float.
Definition: Traits.hh:135
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:87
Vec3f Point
The default coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:129
Vec2f TexCoord2D
The default 2D texture coordinate type is OpenMesh::Vec2f.
Definition: Traits.hh:137
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:93
int TextureIndex
The default texture index type.
Definition: Traits.hh:142
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:84
Vec3f TexCoord3D
The default 3D texture coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:139
#define FaceTraits
Macro for defining the face traits. See Specifying your MyMesh.
Definition: Traits.hh:108
Base class for all traits.
Definition: Traits.hh:126
Helper class to merge two mesh traits.
Definition: Traits.hh:175
Vec3uc Color
The default color type is OpenMesh::Vec3uc.
Definition: Traits.hh:145
#define EdgeTraits
Macro for defining the edge traits. See Specifying your MyMesh.
Definition: Traits.hh:104

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .