Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

color_cast.hh

00001 #ifndef OPENMESH_KERNEL_OSG_COLOR_CAST_HH
00002 #define OPENMESH_KERNEL_OSG_COLOR_CAST_HH
00003 
00004 #include <algorithm>
00005 #include <OpenMesh/Core/Utils/color_cast.hh>
00006 #include <OpenSG/OSGGeometry.h>
00007 
00008 namespace OpenMesh {
00009 
00012 template <>
00013 struct color_caster<osg::Color3ub,osg::Color3f>
00014 {
00015   typedef osg::Color3ub return_type;
00016   typedef unsigned char ub;
00017 
00018   inline static return_type cast(const osg::Color3f& _src)
00019   {
00020     return return_type( (ub)std::min((_src[0]* 255.0f + 0.5f),255.0f),
00021                         (ub)std::min((_src[1]* 255.0f + 0.5f),255.0f),
00022                         (ub)std::min((_src[2]* 255.0f + 0.5f),255.0f) );
00023   }
00024 };
00025 
00028 template <>
00029 struct color_caster<osg::Color3f,osg::Color3ub>
00030 {
00031   typedef osg::Color3f return_type;
00032 
00033   inline static return_type cast(const osg::Color3ub& _src)
00034   {
00035     return return_type( (float)(_src[0] / 255.0f ),
00036                         (float)(_src[1] / 255.0f ),
00037                         (float)(_src[2] / 255.0f ) );
00038   }
00039 };
00040 
00041 } // namespace OpenMesh
00042 
00043 #endif // OPENMESH_KERNEL_OSG_COLOR_CAST_HH 

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .