46 #ifndef OPENMESH_KERNEL_OSG_VECTORADAPTER_HH 47 #define OPENMESH_KERNEL_OSG_VECTORADAPTER_HH 52 #include <osg/Geometry> 53 #include <OpenMesh/Core/Utils/vector_cast.hh> 63 #define OSG_VECTOR_TRAITS( VecType ) \ 64 template <> struct vector_traits< VecType > { \ 65 typedef VecType vector_type; \ 66 typedef vector_type::ValueType value_type; \ 67 typedef GenProg::Int2Type< vector_type::_iSize > typed_size; \ 69 static const size_t size_ = vector_type::_iSize; \ 70 static size_t size() { return size_; } \ 106 #define OSG_COLOR_TRAITS( VecType, N ) \ 107 template <> struct vector_traits< VecType > { \ 108 typedef VecType vector_type; \ 109 typedef vector_type::ValueType value_type; \ 110 typedef GenProg::Int2Type< N > typed_size; \ 112 static const size_t size_ = N; \ 113 static size_t size() { return size_; } \ 126 #undef OSG_VECTOR_TRAITS 131 #define PNT2VEC_CASTER( DST, SRC ) \ 132 template <> struct vector_caster< DST, SRC > { \ 135 typedef const dst_t& return_type; \ 136 inline static return_type cast( const src_t& _src ) {\ 137 return _src.subZero(); \ 157 struct vector_caster< osg::
Vec3f, osg::Pnt3f >
159 typedef osg::Vec3f dst_t;
160 typedef osg::Pnt3f src_t;
162 typedef const dst_t& return_type;
163 inline static return_type cast(
const src_t& _src )
165 std::cout <<
"casting Pnt3f to Vec3f\n";
166 return _src.subZero();
176 osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
177 {
return _v1.dot(_v2); }
181 osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Pnt3f &_v2 )
182 {
return _v1.dot(_v2); }
186 osg::Vec2f::ValueType
dot(
const osg::Vec2f &_v1,
const osg::Vec2f &_v2 )
187 {
return _v1.dot(_v2); }
191 osg::Vec3f
cross(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
192 {
return _v1.cross(_v2); }
198 #endif // OPENMESH_VECTORADAPTER_HH defined PNT2VEC_CASTER(osg::Vec3f, osg::Pnt3f)
convert Pnt3f to Vec3f
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
OSG_COLOR_TRAITS(osg::Color3ub, 3)
Vector traits for OpenSG color type.
OSG_VECTOR_TRAITS(osg::Pnt4f)
Vector traits for OpenSG vector type.