- added color_cast from Vec4f to Vec4i and Vec4ui
- added colori and colorAi functions to BaseExporter which return Vec3i and Vec4i respectively - adjusted the PLYWriter to use colori and colorAi for writing ascii files refs #1405 git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@815 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -91,6 +91,8 @@ public:
|
||||
virtual Vec3f normal(VertexHandle _vh) const = 0;
|
||||
virtual Vec3uc color(VertexHandle _vh) const = 0;
|
||||
virtual Vec4uc colorA(VertexHandle _vh) const = 0;
|
||||
virtual Vec3ui colori(VertexHandle _vh) const = 0;
|
||||
virtual Vec4ui colorAi(VertexHandle _vh) const = 0;
|
||||
virtual Vec2f texcoord(VertexHandle _vh) const = 0;
|
||||
|
||||
|
||||
@@ -105,6 +107,8 @@ public:
|
||||
// get edge data
|
||||
virtual Vec3uc color(EdgeHandle _eh) const = 0;
|
||||
virtual Vec4uc colorA(EdgeHandle _eh) const = 0;
|
||||
virtual Vec3ui colori(EdgeHandle _vh) const = 0;
|
||||
virtual Vec4ui colorAi(EdgeHandle _vh) const = 0;
|
||||
|
||||
// get reference to base kernel
|
||||
virtual const BaseKernel* kernel() { return 0; }
|
||||
|
||||
@@ -113,6 +113,20 @@ public:
|
||||
: Vec4uc(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
Vec3ui colori(VertexHandle _vh) const
|
||||
{
|
||||
return (mesh_.has_vertex_colors()
|
||||
? color_cast<Vec3ui>(mesh_.color(_vh))
|
||||
: Vec3ui(0, 0, 0));
|
||||
}
|
||||
|
||||
Vec4ui colorAi(VertexHandle _vh) const
|
||||
{
|
||||
return (mesh_.has_vertex_colors()
|
||||
? color_cast<Vec4ui>(mesh_.color(_vh))
|
||||
: Vec4ui(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
Vec2f texcoord(VertexHandle _vh) const
|
||||
{
|
||||
#if defined(OM_CC_GCC) && (OM_CC_VERSION<30000)
|
||||
@@ -145,6 +159,19 @@ public:
|
||||
: Vec4uc(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
Vec3ui colori(EdgeHandle _eh) const
|
||||
{
|
||||
return (mesh_.has_edge_colors()
|
||||
? color_cast<Vec3ui>(mesh_.color(_eh))
|
||||
: Vec3ui(0, 0, 0));
|
||||
}
|
||||
|
||||
Vec4ui colorAi(EdgeHandle _eh) const
|
||||
{
|
||||
return (mesh_.has_edge_colors()
|
||||
? color_cast<Vec4ui>(mesh_.color(_eh))
|
||||
: Vec4ui(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
// get face data
|
||||
|
||||
@@ -182,6 +209,20 @@ public:
|
||||
: Vec4uc(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
Vec3ui colori(FaceHandle _fh) const
|
||||
{
|
||||
return (mesh_.has_face_colors()
|
||||
? color_cast<Vec3ui>(mesh_.color(_fh))
|
||||
: Vec3ui(0, 0, 0));
|
||||
}
|
||||
|
||||
Vec4ui colorAi(FaceHandle _fh) const
|
||||
{
|
||||
return (mesh_.has_face_colors()
|
||||
? color_cast<Vec4ui>(mesh_.color(_fh))
|
||||
: Vec4ui(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
virtual const BaseKernel* kernel() { return &mesh_; }
|
||||
|
||||
|
||||
|
||||
@@ -178,8 +178,8 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
||||
|
||||
unsigned int i, j, nV, nF;
|
||||
Vec3f v, n;
|
||||
OpenMesh::Vec3uc c;
|
||||
OpenMesh::Vec4uc cA;
|
||||
OpenMesh::Vec3ui c;
|
||||
OpenMesh::Vec4ui cA;
|
||||
OpenMesh::Vec2f t;
|
||||
VertexHandle vh;
|
||||
std::vector<VertexHandle> vhandles;
|
||||
@@ -242,12 +242,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
||||
if ( _opt.vertex_has_color() ) {
|
||||
//with alpha
|
||||
if ( _opt.color_has_alpha() ){
|
||||
cA = _be.colorA(vh);
|
||||
_out << " " << (unsigned int)cA[0] << " " << (unsigned int)cA[1] << " " << (unsigned int)cA[2] << " " << (unsigned int)cA[3];
|
||||
cA = _be.colorAi(vh);
|
||||
_out << " " << cA;
|
||||
}else{
|
||||
//without alpha
|
||||
c = _be.color(vh);
|
||||
_out << " " << (unsigned int)c[0] << " " << (unsigned int)c[1] << " " << (unsigned int)c[2];
|
||||
c = _be.colori(vh);
|
||||
_out << " " << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,20 @@ struct color_caster<Vec3i,Vec4f>
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct color_caster<Vec4i,Vec4f>
|
||||
{
|
||||
typedef Vec4i return_type;
|
||||
|
||||
inline static return_type cast(const Vec4f& _src)
|
||||
{
|
||||
return Vec4i( (int)(_src[0]* 255.0f + 0.5f),
|
||||
(int)(_src[1]* 255.0f + 0.5f),
|
||||
(int)(_src[2]* 255.0f + 0.5f),
|
||||
(int)(_src[3]* 255.0f + 0.5f) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct color_caster<Vec3ui,Vec3f>
|
||||
{
|
||||
@@ -166,6 +180,20 @@ struct color_caster<Vec3ui,Vec4f>
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct color_caster<Vec4ui,Vec4f>
|
||||
{
|
||||
typedef Vec4ui return_type;
|
||||
|
||||
inline static return_type cast(const Vec4f& _src)
|
||||
{
|
||||
return Vec4ui( (unsigned int)(_src[0]* 255.0f + 0.5f),
|
||||
(unsigned int)(_src[1]* 255.0f + 0.5f),
|
||||
(unsigned int)(_src[2]* 255.0f + 0.5f),
|
||||
(unsigned int)(_src[3]* 255.0f + 0.5f) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct color_caster<Vec4uc,Vec3f>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user