OpenMesh

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FinalMeshItemsT.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2014 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: 990 $ *
38 * $Date: 2014-02-05 10:01:07 +0100 (Mi, 05. Feb 2014) $ *
39 * *
40 \*===========================================================================*/
41
42 #ifndef OPENMESH_MESH_ITEMS_HH
43 #define OPENMESH_MESH_ITEMS_HH
44
45
46 //== INCLUDES =================================================================
47
48
49 #include <OpenMesh/Core/System/config.h>
50 #include <OpenMesh/Core/Utils/GenProg.hh>
51 #include <OpenMesh/Core/Utils/vector_traits.hh>
52 #include <OpenMesh/Core/Mesh/Handles.hh>
53
54
55 //== NAMESPACES ===============================================================
56
57
58 namespace OpenMesh {
59
60
61 //== CLASS DEFINITION =========================================================
62
64 template <class Traits, bool IsTriMesh>
65 struct FinalMeshItemsT
66 {
67 //--- build Refs structure ---
68 #ifndef DOXY_IGNORE_THIS
69 struct Refs
70 {
71 typedef typename Traits::Point Point;
72 typedef typename vector_traits<Point>::value_type Scalar;
73
74 typedef typename Traits::Normal Normal;
75 typedef typename Traits::Color Color;
76 typedef typename Traits::TexCoord1D TexCoord1D;
77 typedef typename Traits::TexCoord2D TexCoord2D;
78 typedef typename Traits::TexCoord3D TexCoord3D;
79 typedef typename Traits::TextureIndex TextureIndex;
80 typedef OpenMesh::VertexHandle VertexHandle;
81 typedef OpenMesh::FaceHandle FaceHandle;
82 typedef OpenMesh::EdgeHandle EdgeHandle;
83 typedef OpenMesh::HalfedgeHandle HalfedgeHandle;
84 };
85 #endif
86 //--- export Refs types ---
87 typedef typename Refs::Point Point;
88 typedef typename Refs::Scalar Scalar;
89 typedef typename Refs::Normal Normal;
90 typedef typename Refs::Color Color;
91 typedef typename Refs::TexCoord1D TexCoord1D;
92 typedef typename Refs::TexCoord2D TexCoord2D;
93 typedef typename Refs::TexCoord3D TexCoord3D;
94 typedef typename Refs::TextureIndex TextureIndex;
95
96 //--- get attribute bits from Traits ---
97 enum Attribs
98 {
99 VAttribs = Traits::VertexAttributes,
100 HAttribs = Traits::HalfedgeAttributes,
101 EAttribs = Traits::EdgeAttributes,
102 FAttribs = Traits::FaceAttributes
103 };
104 //--- merge internal items with traits items ---
105
106
107 /*
108 typedef typename GenProg::IF<
109 (bool)(HAttribs & Attributes::PrevHalfedge),
110 typename InternalItems::Halfedge_with_prev,
111 typename InternalItems::Halfedge_without_prev
112 >::Result InternalHalfedge;
113 */
114 //typedef typename InternalItems::Vertex InternalVertex;
115 //typedef typename InternalItems::template Edge<Halfedge> InternalEdge;
116 //typedef typename InternalItems::template Face<IsTriMesh> InternalFace;
117 class ITraits
118 {};
119
120 typedef typename Traits::template VertexT<ITraits, Refs> VertexData;
121 typedef typename Traits::template HalfedgeT<ITraits, Refs> HalfedgeData;
122 typedef typename Traits::template EdgeT<ITraits, Refs> EdgeData;
123 typedef typename Traits::template FaceT<ITraits, Refs> FaceData;
124 };
125
126
127 #ifndef DOXY_IGNORE_THIS
128 namespace {
129 namespace TM {
130 template<typename Lhs, typename Rhs> struct TypeEquality;
131 template<typename Lhs> struct TypeEquality<Lhs, Lhs> {};
132
133 template<typename LhsTraits, typename RhsTraits> struct ItemsEquality {
134 TypeEquality<typename LhsTraits::Point, typename RhsTraits::Point> te1;
135 TypeEquality<typename LhsTraits::Scalar, typename RhsTraits::Scalar> te2;
136 TypeEquality<typename LhsTraits::Normal, typename RhsTraits::Normal> te3;
137 TypeEquality<typename LhsTraits::Color, typename RhsTraits::Color> te4;
138 TypeEquality<typename LhsTraits::TexCoord1D, typename RhsTraits::TexCoord1D> te5;
139 TypeEquality<typename LhsTraits::TexCoord2D, typename RhsTraits::TexCoord2D> te6;
140 TypeEquality<typename LhsTraits::TexCoord3D, typename RhsTraits::TexCoord3D> te7;
141 TypeEquality<typename LhsTraits::TextureIndex, typename RhsTraits::TextureIndex> te8;
142 };
143
144 } /* namespace TM */
145 } /* anonymous namespace */
146 #endif
147
176 template<typename LhsMeshT, typename RhsMeshT> struct MeshCast;
177
178 template<typename LhsMeshT, typename RhsMeshT>
179 struct MeshCast<LhsMeshT&, RhsMeshT&> {
180 static LhsMeshT &cast(RhsMeshT &rhs) {
181 (void)sizeof(TM::ItemsEquality<typename LhsMeshT::MeshItemsT, typename RhsMeshT::MeshItemsT>);
182 (void)sizeof(TM::TypeEquality<typename LhsMeshT::ConnectivityT, typename RhsMeshT::ConnectivityT>);
183 return reinterpret_cast<LhsMeshT&>(rhs);
184 }
185 };
186
187 template<typename LhsMeshT, typename RhsMeshT>
188 struct MeshCast<const LhsMeshT&, const RhsMeshT&> {
189 static const LhsMeshT &cast(const RhsMeshT &rhs) {
190 (void)sizeof(TM::ItemsEquality<typename LhsMeshT::MeshItemsT, typename RhsMeshT::MeshItemsT>);
191 (void)sizeof(TM::TypeEquality<typename LhsMeshT::ConnectivityT, typename RhsMeshT::ConnectivityT>);
192 return reinterpret_cast<const LhsMeshT&>(rhs);
193 }
194 };
195
196 template<typename LhsMeshT, typename RhsMeshT>
197 struct MeshCast<LhsMeshT*, RhsMeshT*> {
198 static LhsMeshT *cast(RhsMeshT *rhs) {
199 (void)sizeof(TM::ItemsEquality<typename LhsMeshT::MeshItemsT, typename RhsMeshT::MeshItemsT>);
200 (void)sizeof(TM::TypeEquality<typename LhsMeshT::ConnectivityT, typename RhsMeshT::ConnectivityT>);
201 return reinterpret_cast<LhsMeshT*>(rhs);
202 }
203 };
204
205 template<typename LhsMeshT, typename RhsMeshT>
206 struct MeshCast<const LhsMeshT*, const RhsMeshT*> {
207 static const LhsMeshT *cast(const RhsMeshT *rhs) {
208 (void)sizeof(TM::ItemsEquality<typename LhsMeshT::MeshItemsT, typename RhsMeshT::MeshItemsT>);
209 (void)sizeof(TM::TypeEquality<typename LhsMeshT::ConnectivityT, typename RhsMeshT::ConnectivityT>);
210 return reinterpret_cast<const LhsMeshT*>(rhs);
211 }
212 };
213
214
215 //=============================================================================
216 } // namespace OpenMesh
217 //=============================================================================
218 #endif // OPENMESH_MESH_ITEMS_HH defined
219 //=============================================================================
220
OpenMesh::EdgeHandle
Handle for a edge entity.
Definition: Handles.hh:128
FaceAttributes
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Definition: Traits.hh:86
OpenMesh::Attributes::TexCoord3D
Add 3D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:86
OpenMesh::Attributes::Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:81
OpenMesh::FaceHandle
Handle for a face entity.
Definition: Handles.hh:135
OpenMesh::VertexHandle
Handle for a vertex entity.
Definition: Handles.hh:114
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:80
OpenMesh::Attributes::TextureIndex
Add texture index (faces)
Definition: Attributes.hh:87
OpenMesh::FinalMeshItemsT
Definition of the mesh entities (items).
Definition: FinalMeshItemsT.hh:65
EdgeAttributes
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.
Definition: Traits.hh:83
OpenMesh::MeshCast
Cast a mesh with different but identical traits into each other.
Definition: FinalMeshItemsT.hh:176
HalfedgeAttributes
#define HalfedgeAttributes(_i)
Macro for defining the halfedge attributes. See Specifying your MyMesh.
Definition: Traits.hh:80
OpenMesh::vector_traits
Helper class providing information about a vector type.
Definition: vector_traits.hh:86
OpenMesh::Attributes::TexCoord1D
Add 1D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:84
VertexAttributes
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Definition: Traits.hh:77
OpenMesh::FinalMeshItemsT::ITraits
Definition: FinalMeshItemsT.hh:117
OpenMesh::HalfedgeHandle
Handle for a halfedge entity.
Definition: Handles.hh:121
OpenMesh::Attributes::TexCoord2D
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:85