49#ifndef OPENMESH_KERNEL_OSG_PROPERTYT_HH
50#define OPENMESH_KERNEL_OSG_PROPERTYT_HH
56#include <OpenMesh/Core/Mesh/BaseKernel.hh>
57#include <OpenMesh/Core/Utils/GenProg.hh>
58#include <OpenMesh/Core/Utils/Property.hh>
60#include <osg/Geometry>
91template <
typename GeoProperty>
97 typedef GeoProperty property_t;
98 typedef typename property_t::PtrType property_ptr_t;
100 typedef typename property_t::StoredFieldType field_t;
101 typedef typename field_t::StoredType element_t;
102 typedef typename field_t::StoredType value_type;
107 oPropertyT( property_ptr_t _geo_prop,
108 const std::string& _name =
"<unknown>" )
115 oPropertyT(
const std::string& _name =
"<unknown>" )
118 data_ = property_t::create();
126 virtual ~oPropertyT()
131 oPropertyT& operator = (
const oPropertyT& _rhs )
143 virtual void reserve(
size_t _n) { data_->getField().reserve( _n ); }
144 virtual void resize(
size_t _n) { data_->resize( _n ); }
145 virtual void push_back() { data_->resize( data_->size()+1 ); }
146 virtual void swap(
size_t _i0,
size_t _i1)
147 { std::swap( data_->getField()[_i0], data_->getField()[_i1] ); }
149 virtual oPropertyT<property_t>*
clone()
const
151 oPropertyT<property_t> *dolly =
new oPropertyT<property_t>();
156 element_t *begin =
const_cast<element_t*
>(data());
158 element_t *dst =
const_cast<element_t*
>(dolly->data());
159 std::copy( begin, end, dst );
168 check_and_set_persistent<element_t>(_yn);
172 {
return data_==osg::NullFC ?
UnknownSize : data_->getSize(); }
177 virtual size_t store( std::ostream& _ostr,
bool _swap )
const
180 virtual size_t restore( std::istream& _istr,
bool _swap )
186 void clear(
void) { data_->clear(); }
191 property_ptr_t& osg_ptr()
194 const property_ptr_t& osg_ptr()
const
198 const element_t *data()
const
199 {
return &( (*this)[ 0 ] ); }
201 element_t& operator[](
size_t idx)
202 {
return data_->getField()[ idx ]; }
204 const element_t& operator[](
size_t idx)
const
205 {
return data_->getField()[ idx ]; }
210 property_ptr_t data_;
215 void osg_init_check(
void)
219 if ( data_ == osg::NullFC )
220 throw std::logic_error(
"OpenSG Runtime Environment is not initialized: " \
221 "Use osg::osgInit()");
224 oPropertyT(
const oPropertyT& );
292 template <
typename IsTriMesh >
293 class GeoIndicesUI32 :
public _GeoIndicesUI32
297 typedef _GeoIndicesUI32 inherited_t;
298 typedef typename inherited_t::property_ptr_t property_ptr_t;
302 GeoIndicesUI32( property_ptr_t _geo_prop,
305 : inherited_t( _geo_prop ), types_(_types), length_(_lengths)
310 : inherited_t(), types_(_types), length_(_lengths)
313 virtual ~GeoIndicesUI32()
318 void swap(
size_t _i0,
size_t _i1) { _swap( _i0, _i1, IsTriMesh() ); }
319 virtual void reserve(
size_t _n) { _reserve( _n, IsTriMesh() ); }
320 virtual void resize(
size_t _n) { _resize( _n, IsTriMesh() ); }
324 void _swap(
size_t _i0,
size_t _i1, GenProg::False )
326 omerr() <<
"Unsupported mesh type!" << std::endl;
330 void _swap(
size_t _i0,
size_t _i1, GenProg::True )
332 size_t j0 = _i0 + _i0 + _i0;
333 size_t j1 = _i1 + _i1 + _i1;
340 virtual void _reserve(
size_t _n, GenProg::True )
343 virtual void _reserve(
size_t _n, GenProg::False )
346 virtual void _resize(
size_t _n, GenProg::True )
349 virtual void _resize(
size_t _n, GenProg::False )
365#ifndef DOXY_IGNORE_THIS
367template <
typename T>
struct _t2vp;
368template <>
struct _t2vp< osg::Pnt2f >
369{
typedef osg::GeoPositions2f type;
typedef VP::GeoPositions2f prop; };
371template <>
struct _t2vp< osg::Pnt3f >
372{
typedef osg::GeoPositions3f type;
typedef VP::GeoPositions3f prop; };
374template <>
struct _t2vp< osg::Pnt4f >
375{
typedef osg::GeoPositions4f type;
typedef VP::GeoPositions4f prop; };
377template <>
struct _t2vp< osg::Pnt2d >
378{
typedef osg::GeoPositions2d type;
typedef VP::GeoPositions2d prop; };
379template <>
struct _t2vp< osg::Pnt3d >
380{
typedef osg::GeoPositions3d type;
typedef VP::GeoPositions3d prop; };
381template <>
struct _t2vp< osg::Pnt4d >
382{
typedef osg::GeoPositions4d type;
typedef VP::GeoPositions4d prop; };
384template <
typename T>
struct _t2vn;
385template <>
struct _t2vn< osg::
Vec3f >
386{
typedef osg::GeoNormals3f type;
typedef VP::GeoNormals3f prop; };
388template <
typename T>
struct _t2vc;
389template <>
struct _t2vc< osg::Color3f >
390{
typedef osg::GeoColors3f type;
typedef VP::GeoColors3f prop; };
392template <>
struct _t2vc< osg::Color4f >
393{
typedef osg::GeoColors4f type;
typedef VP::GeoColors4f prop; };
395template <>
struct _t2vc< osg::Color3ub >
396{
typedef osg::GeoColors3ub type;
typedef VP::GeoColors3ub prop; };
398template <>
struct _t2vc< osg::Color4ub >
399{
typedef osg::GeoColors4ub type;
typedef VP::GeoColors3ub prop; };
401template <
typename T>
struct _t2vtc;
402template <>
struct _t2vtc< osg::
Vec2f >
403{
typedef osg::GeoTexCoords2f type;
typedef VP::GeoTexCoords2f prop; };
405template <>
struct _t2vtc< osg::
Vec3f >
406{
typedef osg::GeoTexCoords3f type;
typedef VP::GeoTexCoords3f prop; };
This file provides some macros containing attribute usage.
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:64
VectorT< float, 2 > Vec2f
2-float vector
Definition Vector11T.hh:752
VectorT< float, 3 > Vec3f
3-float vector
Definition Vector11T.hh:769
In this namespace resides the OpenSG integration of OpenMesh.
OpenSG Vertex Properties Adaptors.
Definition PropertyT.hh:233
oPropertyT< osg::GeoColors3f > GeoColors3f
Adaptor for osg::GeoColors.
Definition PropertyT.hh:267
oPropertyT< osg::GeoPositions2d > GeoPositions2d
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:239
oPropertyT< osg::GeoColors4ub > GeoColors4ub
Adaptor for osg::GeoColors.
Definition PropertyT.hh:270
oPropertyT< osg::GeoPositions3f > GeoPositions3f
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:242
oPropertyT< osg::GeoTexCoords2f > GeoTexCoords2f
Adaptor for osg::GeoTexCoords.
Definition PropertyT.hh:259
oPropertyT< osg::GeoTexCoords3f > GeoTexCoords3f
Adaptor for osg::GeoTexCoords.
Definition PropertyT.hh:260
oPropertyT< osg::GeoColors4f > GeoColors4f
Adaptor for osg::GeoColors.
Definition PropertyT.hh:269
oPropertyT< osg::GeoPositions3d > GeoPositions3d
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:241
oPropertyT< osg::GeoTexCoords1f > GeoTexCoords1f
Adaptor for osg::GeoTexCoords.
Definition PropertyT.hh:258
oPropertyT< osg::GeoNormals3f > GeoNormals3f
Adaptor for osg::GeoNormals.
Definition PropertyT.hh:251
oPropertyT< osg::GeoPositions4d > GeoPositions4d
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:243
oPropertyT< osg::GeoColors3ub > GeoColors3ub
Adaptor for osg::GeoColors.
Definition PropertyT.hh:268
oPropertyT< osg::GeoPositions2f > GeoPositions2f
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:240
oPropertyT< osg::GeoPositions4f > GeoPositions4f
Adaptor for osg::GeoPositions.
Definition PropertyT.hh:244
OpenSG Face Properties Adaptors.
Definition PropertyT.hh:277
oPropertyT< osg::GeoPTypesUI8 > GeoPTypesUI8
Adaptor for osg::GeoPTypesUI8.
Definition PropertyT.hh:281
oPropertyT< osg::GeoPLengthsUI32 > GeoPLengthsUI32
Adaptor for osg::GeoPLengthsUI32.
Definition PropertyT.hh:285
static const size_t UnknownSize
Indicates an error when a size is returned by a member.
Definition BaseProperty.hh:70
BaseProperty(const std::string &_name="<unknown>")
Default constructor.
Definition BaseProperty.hh:88
virtual size_t store(std::ostream &_ostr, bool _swap) const
Store self as one binary block.
Definition PropertyT.hh:177
virtual size_t n_elements() const
Number of elements in property.
Definition PropertyT.hh:171
virtual void reserve(size_t _n)
Reserve memory for n elements.
Definition PropertyT.hh:143
virtual void resize(size_t _n)
Resize storage to hold n elements.
Definition PropertyT.hh:144
void clear(void)
Clear all elements and free memory.
Definition PropertyT.hh:186
virtual void push_back()
Extend the number of elements by one.
Definition PropertyT.hh:145
virtual void swap(size_t _i0, size_t _i1)
Let two elements swap their storage place.
Definition PropertyT.hh:146
virtual void set_persistent(bool _yn)
Enable or disable persistency.
Definition PropertyT.hh:166
virtual oPropertyT< property_t > * clone() const
Return a deep copy of self.
Definition PropertyT.hh:149
virtual size_t element_size() const
Size of one element in bytes or UnknownSize if not known.
Definition PropertyT.hh:174
virtual size_t restore(std::istream &_istr, bool _swap)
Restore self from a binary block.
Definition PropertyT.hh:180
void swap(size_t _i0, size_t _i1)
Let two elements swap their storage place.
Definition PropertyT.hh:318
virtual void reserve(size_t _n)
Reserve memory for n elements.
Definition PropertyT.hh:319
virtual void resize(size_t _n)
Resize storage to hold n elements.
Definition PropertyT.hh:320