44#ifndef OPENMESH_KERNEL_OSG_PROPERTYT_HH
45#define OPENMESH_KERNEL_OSG_PROPERTYT_HH
51#include <OpenMesh/Core/Mesh/BaseKernel.hh>
52#include <OpenMesh/Core/Utils/GenProg.hh>
53#include <OpenMesh/Core/Utils/Property.hh>
55#include <osg/Geometry>
86template <
typename GeoProperty>
92 typedef GeoProperty property_t;
93 typedef typename property_t::PtrType property_ptr_t;
95 typedef typename property_t::StoredFieldType field_t;
96 typedef typename field_t::StoredType element_t;
97 typedef typename field_t::StoredType value_type;
103 const std::string& _name =
"<unknown>" )
110 oPropertyT(
const std::string& _name =
"<unknown>" )
113 data_ = property_t::create();
138 virtual void reserve(
size_t _n) { data_->getField().reserve( _n ); }
139 virtual void resize(
size_t _n) { data_->resize( _n ); }
140 virtual void push_back() { data_->resize( data_->size()+1 ); }
141 virtual void swap(
size_t _i0,
size_t _i1)
142 { std::swap( data_->getField()[_i0], data_->getField()[_i1] ); }
151 element_t *begin =
const_cast<element_t*
>(data());
153 element_t *dst =
const_cast<element_t*
>(dolly->data());
154 std::copy( begin, end, dst );
163 check_and_set_persistent<element_t>(_yn);
167 {
return data_==osg::NullFC ?
UnknownSize : data_->getSize(); }
172 virtual size_t store( std::ostream& _ostr,
bool _swap )
const
175 virtual size_t restore( std::istream& _istr,
bool _swap )
181 void clear(
void) { data_->clear(); }
186 property_ptr_t& osg_ptr()
189 const property_ptr_t& osg_ptr()
const
193 const element_t *data()
const
194 {
return &( (*this)[ 0 ] ); }
196 element_t& operator[](
size_t idx)
197 {
return data_->getField()[ idx ]; }
199 const element_t& operator[](
size_t idx)
const
200 {
return data_->getField()[ idx ]; }
205 property_ptr_t data_;
210 void osg_init_check(
void)
214 if ( data_ == osg::NullFC )
215 throw std::logic_error(
"OpenSG Runtime Environment is not initialized: " \
216 "Use osg::osgInit()");
219 oPropertyT(
const oPropertyT& );
287 template <
typename IsTriMesh >
293 typedef typename inherited_t::property_ptr_t property_ptr_t;
300 :
inherited_t( _geo_prop ), types_(_types), length_(_lengths)
313 void swap(
size_t _i0,
size_t _i1) { _swap( _i0, _i1, IsTriMesh() ); }
314 virtual void reserve(
size_t _n) { _reserve( _n, IsTriMesh() ); }
315 virtual void resize(
size_t _n) { _resize( _n, IsTriMesh() ); }
319 void _swap(
size_t _i0,
size_t _i1, GenProg::False )
321 omerr() <<
"Unsupported mesh type!" << std::endl;
325 void _swap(
size_t _i0,
size_t _i1, GenProg::True )
327 size_t j0 = _i0 + _i0 + _i0;
328 size_t j1 = _i1 + _i1 + _i1;
335 virtual void _reserve(
size_t _n, GenProg::True )
338 virtual void _reserve(
size_t _n, GenProg::False )
341 virtual void _resize(
size_t _n, GenProg::True )
344 virtual void _resize(
size_t _n, GenProg::False )
360#ifndef DOXY_IGNORE_THIS
362template <
typename T>
struct _t2vp;
363template <>
struct _t2vp< osg::Pnt2f >
366template <>
struct _t2vp< osg::Pnt3f >
369template <>
struct _t2vp< osg::Pnt4f >
372template <>
struct _t2vp< osg::Pnt2d >
374template <>
struct _t2vp< osg::Pnt3d >
376template <>
struct _t2vp< osg::Pnt4d >
379template <
typename T>
struct _t2vn;
380template <>
struct _t2vn< osg::
Vec3f >
383template <
typename T>
struct _t2vc;
384template <>
struct _t2vc< osg::Color3f >
387template <>
struct _t2vc< osg::Color4f >
390template <>
struct _t2vc< osg::Color3ub >
393template <>
struct _t2vc< osg::Color4ub >
396template <
typename T>
struct _t2vtc;
397template <>
struct _t2vtc< osg::
Vec2f >
400template <>
struct _t2vtc< osg::
Vec3f >
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:59
VectorT< float, 2 > Vec2f
2-float vector
Definition: Vector11T.hh:834
VectorT< float, 3 > Vec3f
3-float vector
Definition: Vector11T.hh:851
oPropertyT< osg::GeoColors3f > GeoColors3f
Adaptor for osg::GeoColors.
Definition: PropertyT.hh:262
oPropertyT< osg::GeoPositions2d > GeoPositions2d
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:234
oPropertyT< osg::GeoColors4ub > GeoColors4ub
Adaptor for osg::GeoColors.
Definition: PropertyT.hh:265
oPropertyT< osg::GeoPositions3f > GeoPositions3f
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:237
oPropertyT< osg::GeoTexCoords2f > GeoTexCoords2f
Adaptor for osg::GeoTexCoords.
Definition: PropertyT.hh:254
oPropertyT< osg::GeoTexCoords3f > GeoTexCoords3f
Adaptor for osg::GeoTexCoords.
Definition: PropertyT.hh:255
oPropertyT< osg::GeoColors4f > GeoColors4f
Adaptor for osg::GeoColors.
Definition: PropertyT.hh:264
oPropertyT< osg::GeoPositions3d > GeoPositions3d
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:236
oPropertyT< osg::GeoTexCoords1f > GeoTexCoords1f
Adaptor for osg::GeoTexCoords.
Definition: PropertyT.hh:253
oPropertyT< osg::GeoNormals3f > GeoNormals3f
Adaptor for osg::GeoNormals.
Definition: PropertyT.hh:246
oPropertyT< osg::GeoPositions4d > GeoPositions4d
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:238
oPropertyT< osg::GeoColors3ub > GeoColors3ub
Adaptor for osg::GeoColors.
Definition: PropertyT.hh:263
oPropertyT< osg::GeoPositions2f > GeoPositions2f
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:235
oPropertyT< osg::GeoPositions4f > GeoPositions4f
Adaptor for osg::GeoPositions.
Definition: PropertyT.hh:239
oPropertyT< osg::GeoPTypesUI8 > GeoPTypesUI8
Adaptor for osg::GeoPTypesUI8.
Definition: PropertyT.hh:276
oPropertyT< osg::GeoPLengthsUI32 > GeoPLengthsUI32
Adaptor for osg::GeoPLengthsUI32.
Definition: PropertyT.hh:280
Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:61
BaseProperty(const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:84
static const size_t UnknownSize
Indicates an error when a size is returned by a member.
Definition: BaseProperty.hh:65
Property adaptor for OpenSG GeoProperties.
Definition: PropertyT.hh:88
virtual size_t store(std::ostream &_ostr, bool _swap) const
Store self as one binary block.
Definition: PropertyT.hh:172
virtual size_t n_elements() const
Number of elements in property.
Definition: PropertyT.hh:166
virtual void reserve(size_t _n)
Reserve memory for n elements.
Definition: PropertyT.hh:138
virtual void resize(size_t _n)
Resize storage to hold n elements.
Definition: PropertyT.hh:139
void clear(void)
Clear all elements and free memory.
Definition: PropertyT.hh:181
virtual void push_back()
Extend the number of elements by one.
Definition: PropertyT.hh:140
virtual void swap(size_t _i0, size_t _i1)
Let two elements swap their storage place.
Definition: PropertyT.hh:141
virtual void set_persistent(bool _yn)
Enable or disable persistency.
Definition: PropertyT.hh:161
virtual oPropertyT< property_t > * clone() const
Return a deep copy of self.
Definition: PropertyT.hh:144
virtual size_t element_size() const
Size of one element in bytes or UnknownSize if not known.
Definition: PropertyT.hh:169
virtual size_t restore(std::istream &_istr, bool _swap)
Restore self from a binary block.
Definition: PropertyT.hh:175
Adaptor for osg::GeoIndicesUI32.
Definition: PropertyT.hh:289
void swap(size_t _i0, size_t _i1)
Let two elements swap their storage place.
Definition: PropertyT.hh:313
virtual void reserve(size_t _n)
Reserve memory for n elements.
Definition: PropertyT.hh:314
virtual void resize(size_t _n)
Resize storage to hold n elements.
Definition: PropertyT.hh:315