51#ifndef OPENMESH_KERNEL_OSG_VECTORADAPTER_HH
52#define OPENMESH_KERNEL_OSG_VECTORADAPTER_HH
57#include <osg/Geometry>
58#include <OpenMesh/Core/Utils/vector_cast.hh>
68#define OSG_VECTOR_TRAITS( VecType ) \
69 template <> struct vector_traits< VecType > { \
70 typedef VecType vector_type; \
71 typedef vector_type::ValueType value_type; \
72 typedef GenProg::Int2Type< vector_type::_iSize > typed_size; \
74 static const size_t size_ = vector_type::_iSize; \
75 static size_t size() { return size_; } \
79OSG_VECTOR_TRAITS( osg::Pnt4f );
81OSG_VECTOR_TRAITS( osg::Pnt3f );
83OSG_VECTOR_TRAITS( osg::Pnt2f );
86OSG_VECTOR_TRAITS( osg::Vec4f );
88OSG_VECTOR_TRAITS( osg::Vec3f );
90OSG_VECTOR_TRAITS( osg::Vec2f );
93OSG_VECTOR_TRAITS( osg::Pnt4d );
95OSG_VECTOR_TRAITS( osg::Pnt3d );
97OSG_VECTOR_TRAITS( osg::Pnt2d );
100OSG_VECTOR_TRAITS( osg::Vec4d );
102OSG_VECTOR_TRAITS( osg::Vec3d );
105OSG_VECTOR_TRAITS( osg::Vec4ub );
111#define OSG_COLOR_TRAITS( VecType, N ) \
112 template <> struct vector_traits< VecType > { \
113 typedef VecType vector_type; \
114 typedef vector_type::ValueType value_type; \
115 typedef GenProg::Int2Type< N > typed_size; \
117 static const size_t size_ = N; \
118 static size_t size() { return size_; } \
123OSG_COLOR_TRAITS( osg::Color3ub, 3 );
125OSG_COLOR_TRAITS( osg::Color4ub, 4 );
127OSG_COLOR_TRAITS( osg::Color3f, 3 );
129OSG_COLOR_TRAITS( osg::Color4f, 4 );
131#undef OSG_VECTOR_TRAITS
136#define PNT2VEC_CASTER( DST, SRC ) \
137 template <> struct vector_caster< DST, SRC > { \
140 typedef const dst_t& return_type; \
141 inline static return_type cast( const src_t& _src ) {\
142 return _src.subZero(); \
147PNT2VEC_CASTER( osg::Vec3f, osg::Pnt3f );
150PNT2VEC_CASTER( osg::Vec4f, osg::Pnt4f );
153PNT2VEC_CASTER( osg::Vec3d, osg::Pnt3d );
156PNT2VEC_CASTER( osg::Vec4d, osg::Pnt4d );
162 struct vector_caster< osg::
Vec3f, osg::Pnt3f >
164 typedef osg::Vec3f dst_t;
165 typedef osg::Pnt3f src_t;
167 typedef const dst_t& return_type;
168 inline static return_type cast(
const src_t& _src )
170 std::cout <<
"casting Pnt3f to Vec3f\n";
171 return _src.subZero();
181osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
182{
return _v1.dot(_v2); }
186osg::Vec3f::ValueType
dot(
const osg::Vec3f &_v1,
const osg::Pnt3f &_v2 )
187{
return _v1.dot(_v2); }
191osg::Vec2f::ValueType
dot(
const osg::Vec2f &_v1,
const osg::Vec2f &_v2 )
192{
return _v1.dot(_v2); }
196osg::Vec3f cross(
const osg::Vec3f &_v1,
const osg::Vec3f &_v2 )
197{
return _v1.cross(_v2); }
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:181