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;
297 GeoIndicesUI32( property_ptr_t _geo_prop,
300 : inherited_t( _geo_prop ), types_(_types), length_(_lengths)
305 : inherited_t(), types_(_types), length_(_lengths)
308 virtual ~GeoIndicesUI32()
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 >
367{
typedef osg::GeoPositions3f type;
typedef VP::GeoPositions3f prop; };
369template <>
struct _t2vp< osg::Pnt4f >
370{
typedef osg::GeoPositions4f type;
typedef VP::GeoPositions4f prop; };
372template <>
struct _t2vp< osg::Pnt2d >
373{
typedef osg::GeoPositions2d type;
typedef VP::GeoPositions2d prop; };
374template <>
struct _t2vp< osg::Pnt3d >
375{
typedef osg::GeoPositions3d type;
typedef VP::GeoPositions3d prop; };
376template <>
struct _t2vp< osg::Pnt4d >
377{
typedef osg::GeoPositions4d type;
typedef VP::GeoPositions4d prop; };
379template <
typename T>
struct _t2vn;
380template <>
struct _t2vn< osg::
Vec3f >
381{
typedef osg::GeoNormals3f type;
typedef VP::GeoNormals3f prop; };
383template <
typename T>
struct _t2vc;
384template <>
struct _t2vc< osg::Color3f >
385{
typedef osg::GeoColors3f type;
typedef VP::GeoColors3f prop; };
387template <>
struct _t2vc< osg::Color4f >
388{
typedef osg::GeoColors4f type;
typedef VP::GeoColors4f prop; };
390template <>
struct _t2vc< osg::Color3ub >
391{
typedef osg::GeoColors3ub type;
typedef VP::GeoColors3ub prop; };
393template <>
struct _t2vc< osg::Color4ub >
394{
typedef osg::GeoColors4ub type;
typedef VP::GeoColors3ub prop; };
396template <
typename T>
struct _t2vtc;
397template <>
struct _t2vtc< osg::
Vec2f >
398{
typedef osg::GeoTexCoords2f type;
typedef VP::GeoTexCoords2f prop; };
400template <>
struct _t2vtc< osg::
Vec3f >
401{
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:59
VectorT< float, 2 > Vec2f
2-float vector
Definition Vector11T.hh:834
VectorT< float, 3 > Vec3f
3-float vector
Definition Vector11T.hh:851
Abstract class defining the basic interface of a dynamic property.
Definition BaseProperty.hh:61
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