OpenMesh
PropertyKernel.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_KERNEL_OSG_PROPERTYKERNEL_HH
43 #define OPENMESH_KENREL_OSG_PROPERTYKERNEL_HH
44 
45 
46 //== INCLUDES =================================================================
47 
48 #include <OpenMesh/Core/Utils/Property.hh>
49 #include <OpenMesh/Core/Mesh/BaseKernel.hh>
50 // --------------------
51 #include <OpenMesh/Tools/Kernel_OSG/PropertyT.hh>
52 
53 //== NAMESPACES ===============================================================
54 
55 namespace OpenMesh {
56 namespace Kernel_OSG {
57 
58 //== CLASS DEFINITION =========================================================
59 
65 template < typename IsTriMesh >
67 {
68 public:
69 
70  // --------------------------------------------------------------- item types
71 
75 
79 
80  // ------------------------------------------------- constructor / destructor
81 
82  PropertyKernel() {}
83  virtual ~PropertyKernel() { }
84 
85 
86 protected: // ---------------------------------------------- add osg properties
87 
88  // -------------------- vertex properties
89 
90  template < typename T >
91  VPropHandleT<T> add_vpositions( const T& _t, const std::string& _n )
92  { return VPropHandleT<T>(_add_vprop( new typename _t2vp<T>::prop(_n))); }
93 
94  template < typename T >
95  VPropHandleT<T> add_vnormals( const T& _t, const std::string& _n )
96  { return VPropHandleT<T>(_add_vprop( new typename _t2vn<T>::prop(_n) )); }
97 
98  template < typename T >
99  VPropHandleT<T> add_vcolors( const T& _t, const std::string& _n )
100  { return VPropHandleT<T>(_add_vprop( new typename _t2vc<T>::prop(_n) )); }
101 
102  template < typename T >
103  VPropHandleT<T> add_vtexcoords( const T& _t, const std::string& _n )
104  { return VPropHandleT<T>(_add_vprop( new typename _t2vtc<T>::prop(_n) )); }
105 
106 
107  // -------------------- face properties
108 
109  FPTypesHandle add_fptypes( )
110  { return FPTypesHandle(_add_fprop(new GeoPTypes)); }
111 
112  FPLengthsHandle add_fplengths( )
113  { return FPLengthsHandle(_add_fprop(new GeoPLengths)); }
114 
115  FIndicesHandle add_findices( FPTypesHandle _pht, FPLengthsHandle _phl )
116  {
117  GeoIndices *bp = new GeoIndices( fptypes(_pht), fplengths(_phl ) );
118  return FIndicesHandle(_add_fprop( bp ) );
119  }
120 
121 protected: // ------------------------------------------- access osg properties
122 
123  template < typename T >
124  typename _t2vp<T>::prop& vpositions( VPropHandleT<T> _ph )
125  { return static_cast<typename _t2vp<T>::prop&>( _vprop( _ph ) ); }
126 
127  template < typename T >
128  const typename _t2vp<T>::prop& vpositions( VPropHandleT<T> _ph) const
129  { return static_cast<const typename _t2vp<T>::prop&>( _vprop( _ph ) ); }
130 
131 
132  template < typename T >
133  typename _t2vn<T>::prop& vnormals( VPropHandleT<T> _ph )
134  { return static_cast<typename _t2vn<T>::prop&>( _vprop( _ph ) ); }
135 
136  template < typename T >
137  const typename _t2vn<T>::prop& vnormals( VPropHandleT<T> _ph) const
138  { return static_cast<const typename _t2vn<T>::prop&>( _vprop( _ph ) ); }
139 
140 
141  template < typename T >
142  typename _t2vc<T>::prop& vcolors( VPropHandleT<T> _ph )
143  { return static_cast<typename _t2vc<T>::prop&>( _vprop( _ph ) ); }
144 
145  template < typename T >
146  const typename _t2vc<T>::prop& vcolors( VPropHandleT<T> _ph ) const
147  { return static_cast<const typename _t2vc<T>::prop&>( _vprop( _ph ) ); }
148 
149 
150  template < typename T >
151  typename _t2vtc<T>::prop& vtexcoords( VPropHandleT<T> _ph )
152  { return static_cast<typename _t2vtc<T>::prop&>( _vprop( _ph ) ); }
153 
154  template < typename T >
155  const typename _t2vtc<T>::prop& vtexcoords( VPropHandleT<T> _ph ) const
156  { return static_cast<const typename _t2vtc<T>::prop&>( _vprop( _ph ) ); }
157 
158 
159  //
160  GeoPTypes& fptypes( FPTypesHandle _ph )
161  { return static_cast<GeoPTypes&>( _fprop(_ph) ); }
162 
163  const GeoPTypes& fptypes( FPTypesHandle _ph ) const
164  { return static_cast<const GeoPTypes&>( _fprop(_ph) ); }
165 
166 
167  GeoPLengths& fplengths( FPLengthsHandle _ph )
168  { return static_cast<GeoPLengths&>( _fprop(_ph) ); }
169 
170  const GeoPLengths& fplengths( FPLengthsHandle _ph ) const
171  { return static_cast<const GeoPLengths&>( _fprop(_ph) ); }
172 
173 
174  GeoIndices& findices( FIndicesHandle _ph )
175  { return static_cast<GeoIndices&>( _fprop(_ph) ); }
176 
177  const GeoIndices& findices( FIndicesHandle _ph ) const
178  { return static_cast<const GeoIndices&>( _fprop(_ph) ); }
179 
180 
181 protected: // ------------------------------------ access osg property elements
182 
183  template <typename T>
184  T& vpositions( VPropHandleT<T> _ph, VertexHandle _vh )
185  { return vpositions(_ph)[_vh.idx()]; }
186 
187  template <class T>
188  const T& vpositions( VPropHandleT<T> _ph, VertexHandle _vh ) const
189  { return vpositions(_ph)[_vh.idx()]; }
190 
191 
192  template < typename T>
193  T& vnormals( VPropHandleT<T> _ph, VertexHandle _vh )
194  { return vnormals(_ph)[_vh.idx()]; }
195 
196  template <class T>
197  const T& vnormals( VPropHandleT<T> _ph, VertexHandle _vh ) const
198  { return vnormals(_ph)[_vh.idx()]; }
199 
200 
201  template < typename T>
202  T& vcolors( VPropHandleT<T> _ph, VertexHandle _vh )
203  { return vcolors(_ph)[_vh.idx()]; }
204 
205  template <class T>
206  const T& vcolors( VPropHandleT<T> _ph, VertexHandle _vh ) const
207  { return vcolors(_ph)[_vh.idx()]; }
208 
209 
210  template < typename T>
211  T& vtexcoords( VPropHandleT<T> _ph, VertexHandle _vh )
212  { return vtexcoords(_ph)[_vh.idx()]; }
213 
214  template <class T>
215  const T& vtexcoords( VPropHandleT<T> _ph, VertexHandle _vh ) const
216  { return vtexcoords(_ph)[_vh.idx()]; }
217 
218 
219  // -------------------- access face property elements
220 
221  FPTypesHandle::value_type&
222  fptypes( FPTypesHandle _ph, FaceHandle _fh )
223  { return fptypes( _ph )[ _fh.idx()]; }
224 
225  const FPTypesHandle::value_type&
226  fptypes( FPTypesHandle _ph, FaceHandle _fh ) const
227  { return fptypes( _ph )[ _fh.idx()]; }
228 
229 
230  FPLengthsHandle::value_type&
231  fplengths( FPLengthsHandle _ph, FaceHandle _fh )
232  { return fplengths( _ph )[ _fh.idx()]; }
233 
234  const FPLengthsHandle::value_type&
235  fplengths( FPLengthsHandle _ph, FaceHandle _fh ) const
236  { return fplengths( _ph )[ _fh.idx()]; }
237 
238 
239  FIndicesHandle::value_type&
240  findices( FIndicesHandle _ph, FaceHandle _fh )
241  { return findices( _ph )[ _fh.idx()]; }
242 
243  const FIndicesHandle::value_type&
244  findices( FIndicesHandle _ph, FaceHandle _fh ) const
245  { return findices( _ph )[ _fh.idx()]; }
246 
247 public:
248 
249  void stats(void)
250  {
251  std::cout << "#V : " << n_vertices() << std::endl;
252  std::cout << "#E : " << n_edges() << std::endl;
253  std::cout << "#F : " << n_faces() << std::endl;
254  property_stats();
255  }
256 };
257 
258 
259 //=============================================================================
260 } // namespace Kernel_OSG
261 } // namespace OpenMesh
262 //=============================================================================
263 #endif // OPENMESH_KERNEL_OSG_PROPERTYKERNEL_HH defined
264 //=============================================================================
265 
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:67
Adaptor for osg::GeoIndicesUI32.
Definition: PropertyT.hh:286
Property adaptor for OpenSG GeoProperties.
Definition: PropertyT.hh:85
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
Helper class, extending functionaliy of OpenMesh::BaseKernel to OpenSG specific property adaptors...
Definition: PropertyKernel.hh:66
Handle representing a face property.
Definition: Property.hh:518
Handle for a face entity.
Definition: Handles.hh:135
Handle representing a vertex property.
Definition: Property.hh:476
This class provides the basic property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:91
Handle for a vertex entity.
Definition: Handles.hh:114

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