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

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