00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef OPENMESH_KERNEL_OSG_PROPERTYKERNEL_HH
00043 #define OPENMESH_KENREL_OSG_PROPERTYKERNEL_HH
00044
00045
00046
00047
00048 #include <OpenMesh/Core/Utils/Property.hh>
00049 #include <OpenMesh/Core/Mesh/BaseKernel.hh>
00050
00051 #include <OpenMesh/Tools/Kernel_OSG/PropertyT.hh>
00052
00053
00054
00055 namespace OpenMesh {
00056 namespace Kernel_OSG {
00057
00058
00059
00065 template < typename IsTriMesh >
00066 class PropertyKernel : public OpenMesh::BaseKernel
00067 {
00068 public:
00069
00070
00071
00072 typedef FPropHandleT<osg::UInt8> FPTypesHandle;
00073 typedef FPropHandleT<osg::UInt32> FPLengthsHandle;
00074 typedef FPropHandleT<osg::UInt32> FIndicesHandle;
00075
00076 typedef FP::GeoPTypesUI8 GeoPTypes;
00077 typedef FP::GeoPLengthsUI32 GeoPLengths;
00078 typedef FP::GeoIndicesUI32<IsTriMesh> GeoIndices;
00079
00080
00081
00082 PropertyKernel() {}
00083 virtual ~PropertyKernel() { }
00084
00085
00086 protected:
00087
00088
00089
00090 template < typename T >
00091 VPropHandleT<T> add_vpositions( const T& _t, const std::string& _n )
00092 { return VPropHandleT<T>(_add_vprop( new typename _t2vp<T>::prop(_n))); }
00093
00094 template < typename T >
00095 VPropHandleT<T> add_vnormals( const T& _t, const std::string& _n )
00096 { return VPropHandleT<T>(_add_vprop( new typename _t2vn<T>::prop(_n) )); }
00097
00098 template < typename T >
00099 VPropHandleT<T> add_vcolors( const T& _t, const std::string& _n )
00100 { return VPropHandleT<T>(_add_vprop( new typename _t2vc<T>::prop(_n) )); }
00101
00102 template < typename T >
00103 VPropHandleT<T> add_vtexcoords( const T& _t, const std::string& _n )
00104 { return VPropHandleT<T>(_add_vprop( new typename _t2vtc<T>::prop(_n) )); }
00105
00106
00107
00108
00109 FPTypesHandle add_fptypes( )
00110 { return FPTypesHandle(_add_fprop(new GeoPTypes)); }
00111
00112 FPLengthsHandle add_fplengths( )
00113 { return FPLengthsHandle(_add_fprop(new GeoPLengths)); }
00114
00115 FIndicesHandle add_findices( FPTypesHandle _pht, FPLengthsHandle _phl )
00116 {
00117 GeoIndices *bp = new GeoIndices( fptypes(_pht), fplengths(_phl ) );
00118 return FIndicesHandle(_add_fprop( bp ) );
00119 }
00120
00121 protected:
00122
00123 template < typename T >
00124 typename _t2vp<T>::prop& vpositions( VPropHandleT<T> _ph )
00125 { return static_cast<typename _t2vp<T>::prop&>( _vprop( _ph ) ); }
00126
00127 template < typename T >
00128 const typename _t2vp<T>::prop& vpositions( VPropHandleT<T> _ph) const
00129 { return static_cast<const typename _t2vp<T>::prop&>( _vprop( _ph ) ); }
00130
00131
00132 template < typename T >
00133 typename _t2vn<T>::prop& vnormals( VPropHandleT<T> _ph )
00134 { return static_cast<typename _t2vn<T>::prop&>( _vprop( _ph ) ); }
00135
00136 template < typename T >
00137 const typename _t2vn<T>::prop& vnormals( VPropHandleT<T> _ph) const
00138 { return static_cast<const typename _t2vn<T>::prop&>( _vprop( _ph ) ); }
00139
00140
00141 template < typename T >
00142 typename _t2vc<T>::prop& vcolors( VPropHandleT<T> _ph )
00143 { return static_cast<typename _t2vc<T>::prop&>( _vprop( _ph ) ); }
00144
00145 template < typename T >
00146 const typename _t2vc<T>::prop& vcolors( VPropHandleT<T> _ph ) const
00147 { return static_cast<const typename _t2vc<T>::prop&>( _vprop( _ph ) ); }
00148
00149
00150 template < typename T >
00151 typename _t2vtc<T>::prop& vtexcoords( VPropHandleT<T> _ph )
00152 { return static_cast<typename _t2vtc<T>::prop&>( _vprop( _ph ) ); }
00153
00154 template < typename T >
00155 const typename _t2vtc<T>::prop& vtexcoords( VPropHandleT<T> _ph ) const
00156 { return static_cast<const typename _t2vtc<T>::prop&>( _vprop( _ph ) ); }
00157
00158
00159
00160 GeoPTypes& fptypes( FPTypesHandle _ph )
00161 { return static_cast<GeoPTypes&>( _fprop(_ph) ); }
00162
00163 const GeoPTypes& fptypes( FPTypesHandle _ph ) const
00164 { return static_cast<const GeoPTypes&>( _fprop(_ph) ); }
00165
00166
00167 GeoPLengths& fplengths( FPLengthsHandle _ph )
00168 { return static_cast<GeoPLengths&>( _fprop(_ph) ); }
00169
00170 const GeoPLengths& fplengths( FPLengthsHandle _ph ) const
00171 { return static_cast<const GeoPLengths&>( _fprop(_ph) ); }
00172
00173
00174 GeoIndices& findices( FIndicesHandle _ph )
00175 { return static_cast<GeoIndices&>( _fprop(_ph) ); }
00176
00177 const GeoIndices& findices( FIndicesHandle _ph ) const
00178 { return static_cast<const GeoIndices&>( _fprop(_ph) ); }
00179
00180
00181 protected:
00182
00183 template <typename T>
00184 T& vpositions( VPropHandleT<T> _ph, VertexHandle _vh )
00185 { return vpositions(_ph)[_vh.idx()]; }
00186
00187 template <class T>
00188 const T& vpositions( VPropHandleT<T> _ph, VertexHandle _vh ) const
00189 { return vpositions(_ph)[_vh.idx()]; }
00190
00191
00192 template < typename T>
00193 T& vnormals( VPropHandleT<T> _ph, VertexHandle _vh )
00194 { return vnormals(_ph)[_vh.idx()]; }
00195
00196 template <class T>
00197 const T& vnormals( VPropHandleT<T> _ph, VertexHandle _vh ) const
00198 { return vnormals(_ph)[_vh.idx()]; }
00199
00200
00201 template < typename T>
00202 T& vcolors( VPropHandleT<T> _ph, VertexHandle _vh )
00203 { return vcolors(_ph)[_vh.idx()]; }
00204
00205 template <class T>
00206 const T& vcolors( VPropHandleT<T> _ph, VertexHandle _vh ) const
00207 { return vcolors(_ph)[_vh.idx()]; }
00208
00209
00210 template < typename T>
00211 T& vtexcoords( VPropHandleT<T> _ph, VertexHandle _vh )
00212 { return vtexcoords(_ph)[_vh.idx()]; }
00213
00214 template <class T>
00215 const T& vtexcoords( VPropHandleT<T> _ph, VertexHandle _vh ) const
00216 { return vtexcoords(_ph)[_vh.idx()]; }
00217
00218
00219
00220
00221 FPTypesHandle::value_type&
00222 fptypes( FPTypesHandle _ph, FaceHandle _fh )
00223 { return fptypes( _ph )[ _fh.idx()]; }
00224
00225 const FPTypesHandle::value_type&
00226 fptypes( FPTypesHandle _ph, FaceHandle _fh ) const
00227 { return fptypes( _ph )[ _fh.idx()]; }
00228
00229
00230 FPLengthsHandle::value_type&
00231 fplengths( FPLengthsHandle _ph, FaceHandle _fh )
00232 { return fplengths( _ph )[ _fh.idx()]; }
00233
00234 const FPLengthsHandle::value_type&
00235 fplengths( FPLengthsHandle _ph, FaceHandle _fh ) const
00236 { return fplengths( _ph )[ _fh.idx()]; }
00237
00238
00239 FIndicesHandle::value_type&
00240 findices( FIndicesHandle _ph, FaceHandle _fh )
00241 { return findices( _ph )[ _fh.idx()]; }
00242
00243 const FIndicesHandle::value_type&
00244 findices( FIndicesHandle _ph, FaceHandle _fh ) const
00245 { return findices( _ph )[ _fh.idx()]; }
00246
00247 public:
00248
00249 void stats(void)
00250 {
00251 std::cout << "#V : " << n_vertices() << std::endl;
00252 std::cout << "#E : " << n_edges() << std::endl;
00253 std::cout << "#F : " << n_faces() << std::endl;
00254 property_stats();
00255 }
00256 };
00257
00258
00259
00260 }
00261 }
00262
00263 #endif // OPENMESH_KERNEL_OSG_PROPERTYKERNEL_HH defined
00264
00265