OpenMesh
Traits.hh
Go to the documentation of this file.
1 /* ========================================================================= *
2  * *
3  * OpenMesh *
4  * Copyright (c) 2001-2022, 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>
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 
164 {
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 
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 
This file provides some macros containing attribute usage.
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
@ Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
@ Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:83
@ PrevHalfedge
Add storage for previous halfedge (halfedges). The bit is set by default in the DefaultTraits.
Definition: Attributes.hh:84
Base class for all traits.
Definition: Traits.hh:122
int TextureIndex
The default texture index type.
Definition: Traits.hh:137
float TexCoord1D
The default 1D texture coordinate type is float.
Definition: Traits.hh:130
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
Vec3uc Color
The default color type is OpenMesh::Vec3uc.
Definition: Traits.hh:140
Vec3f Normal
The default normal type is OpenMesh::Vec3f.
Definition: Traits.hh:127
Vec3f TexCoord3D
The default 3D texture coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:134
Version of Default Traits that uses double precision for points and normals as well as floating point...
Definition: Traits.hh:164
OpenMesh::Vec4f Color
Use RGBA Color.
Definition: Traits.hh:170
OpenMesh::Vec3d Normal
Use double precision Normals.
Definition: Traits.hh:168
OpenMesh::Vec3d Point
Use double precision points.
Definition: Traits.hh:166
Helper class to merge two mesh traits.
Definition: Traits.hh:189
#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
#define FaceTraits
Macro for defining the face traits. See Specifying your MyMesh.
Definition: Traits.hh:103
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:82
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:88
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:85
#define VertexTraits
Macro for defining the vertex traits. See Specifying your MyMesh.
Definition: Traits.hh:91
#define EdgeTraits
Macro for defining the edge traits. See Specifying your MyMesh.
Definition: Traits.hh:99

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .