44 #ifndef OPENMESH_KERNEL_OSG_VECTORADAPTER_HH
45 #define OPENMESH_KERNEL_OSG_VECTORADAPTER_HH
50 #include <osg/Geometry>
51 #include <OpenMesh/Core/Utils/vector_cast.hh>
61 #define OSG_VECTOR_TRAITS( VecType ) \
62 template <> struct vector_traits< VecType > { \
63 typedef VecType vector_type; \
64 typedef vector_type::ValueType value_type; \
65 typedef GenProg::Int2Type< vector_type::_iSize > typed_size; \
67 static const size_t size_ = vector_type::_iSize; \
68 static size_t size() { return size_; } \
72 OSG_VECTOR_TRAITS( osg::Pnt4f );
74 OSG_VECTOR_TRAITS( osg::Pnt3f );
76 OSG_VECTOR_TRAITS( osg::Pnt2f );
79 OSG_VECTOR_TRAITS( osg::Vec4f );
81 OSG_VECTOR_TRAITS( osg::Vec3f );
83 OSG_VECTOR_TRAITS( osg::Vec2f );
86 OSG_VECTOR_TRAITS( osg::Pnt4d );
88 OSG_VECTOR_TRAITS( osg::Pnt3d );
90 OSG_VECTOR_TRAITS( osg::Pnt2d );
93 OSG_VECTOR_TRAITS( osg::Vec4d );
95 OSG_VECTOR_TRAITS( osg::Vec3d );
98 OSG_VECTOR_TRAITS( osg::Vec4ub );
104 #define OSG_COLOR_TRAITS( VecType, N ) \
105 template <> struct vector_traits< VecType > { \
106 typedef VecType vector_type; \
107 typedef vector_type::ValueType value_type; \
108 typedef GenProg::Int2Type< N > typed_size; \
110 static const size_t size_ = N; \
111 static size_t size() { return size_; } \
116 OSG_COLOR_TRAITS( osg::Color3ub, 3 );
118 OSG_COLOR_TRAITS( osg::Color4ub, 4 );
120 OSG_COLOR_TRAITS( osg::Color3f, 3 );
122 OSG_COLOR_TRAITS( osg::Color4f, 4 );
124 #undef OSG_VECTOR_TRAITS
129 #define PNT2VEC_CASTER( DST, SRC ) \
130 template <> struct vector_caster< DST, SRC > { \
133 typedef const dst_t& return_type; \
134 inline static return_type cast( const src_t& _src ) {\
135 return _src.subZero(); \
140 PNT2VEC_CASTER( osg::Vec3f, osg::Pnt3f );
143 PNT2VEC_CASTER( osg::Vec4f, osg::Pnt4f );
146 PNT2VEC_CASTER( osg::Vec3d, osg::Pnt3d );
149 PNT2VEC_CASTER( osg::Vec4d, osg::Pnt4d );
155 struct vector_caster< osg::Vec3f, osg::Pnt3f >
157 typedef osg::Vec3f dst_t;
158 typedef osg::Pnt3f src_t;
160 typedef const dst_t& return_type;
161 inline static return_type cast(
const src_t& _src )
163 std::cout <<
"casting Pnt3f to Vec3f\n";
164 return _src.subZero();
174 osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
175 {
return _v1.dot(_v2); }
179 osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Pnt3f &_v2 )
180 {
return _v1.dot(_v2); }
184 osg::Vec2f::ValueType
dot(
const osg::Vec2f &_v1,
const osg::Vec2f &_v2 )
185 {
return _v1.dot(_v2); }
189 osg::Vec3f
cross(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
190 {
return _v1.cross(_v2); }
196 #endif // OPENMESH_VECTORADAPTER_HH defined
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:174
osg::Vec3f cross(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:189