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

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