Edge colors are now supported as standard property.

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@260 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Mike Kremer
2010-01-21 14:40:03 +00:00
parent 658c8ec12f
commit 77cfce2770
8 changed files with 136 additions and 14 deletions

View File

@@ -94,17 +94,18 @@ public:
/// Definitions of %Options for reading and writing. The options can be
/// or'ed.
enum Flag {
Default = 0x0000, ///< No options
Binary = 0x0001, ///< Set binary mode for r/w
MSB = 0x0002, ///< Assume big endian byte ordering
LSB = 0x0004, ///< Assume little endian byte ordering
Swap = 0x0006, ///< Swap byte order in binary mode
VertexNormal = 0x0010, ///< Has (r) / store (w) vertex normals
VertexColor = 0x0020, ///< Has (r) / store (w) vertex colors
VertexTexCoord = 0x0040, ///< Has (r) / store (w) texture coordinates
FaceNormal = 0x0100, ///< Has (r) / store (w) face normals
FaceColor = 0x0200, ///< Has (r) / store (w) face colors
ColorAlpha = 0x0400 ///< Has (r) / store (w) alpha values for colors
Default = 0x00000, ///< No options
Binary = 0x00001, ///< Set binary mode for r/w
MSB = 0x00002, ///< Assume big endian byte ordering
LSB = 0x00004, ///< Assume little endian byte ordering
Swap = 0x00006, ///< Swap byte order in binary mode
VertexNormal = 0x00010, ///< Has (r) / store (w) vertex normals
VertexColor = 0x00020, ///< Has (r) / store (w) vertex colors
VertexTexCoord = 0x00040, ///< Has (r) / store (w) texture coordinates
EdgeColor = 0x00100, ///< Has (r) / store (w) texture coordinates
FaceNormal = 0x01000, ///< Has (r) / store (w) face normals
FaceColor = 0x02000, ///< Has (r) / store (w) face colors
ColorAlpha = 0x04000 ///< Has (r) / store (w) alpha values for colors
};
public:
@@ -195,6 +196,7 @@ public:
bool vertex_has_normal() const { return check(VertexNormal); }
bool vertex_has_color() const { return check(VertexColor); }
bool vertex_has_texcoord() const { return check(VertexTexCoord); }
bool edge_has_color() const { return check(EdgeColor); }
bool face_has_normal() const { return check(FaceNormal); }
bool face_has_color() const { return check(FaceColor); }
bool color_has_alpha() const { return check(ColorAlpha); }

View File

@@ -101,6 +101,10 @@ public:
virtual Vec3f normal(FaceHandle _fh) const = 0;
virtual Vec3uc color (FaceHandle _fh) const = 0;
virtual Vec4uc colorA(FaceHandle _fh) const = 0;
// get edge data
virtual Vec3uc color(EdgeHandle _eh) const = 0;
virtual Vec4uc colorA(EdgeHandle _eh) const = 0;
// get reference to base kernel
virtual const BaseKernel* kernel() { return 0; }
@@ -116,7 +120,8 @@ public:
virtual bool is_triangle_mesh() const { return false; }
virtual bool has_vertex_normals() const { return false; }
virtual bool has_vertex_colors() const { return false; }
virtual bool has_vertex_texcoords() const { return false; }
virtual bool has_vertex_texcoords() const { return false; }
virtual bool has_edge_colors() const { return false; }
virtual bool has_face_normals() const { return false; }
virtual bool has_face_colors() const { return false; }
};

View File

@@ -128,6 +128,22 @@ public:
: Vec2f(0.0f, 0.0f));
#endif
}
// get edge data
Vec3uc color(EdgeHandle _eh) const
{
return (mesh_.has_edge_colors()
? color_cast<Vec3uc>(mesh_.color(_eh))
: Vec3uc(0, 0, 0));
}
Vec4uc colorA(EdgeHandle _eh) const
{
return (mesh_.has_edge_colors()
? color_cast<Vec4uc>(mesh_.color(_eh))
: Vec4uc(0, 0, 0, 0));
}
// get face data
@@ -182,6 +198,7 @@ public:
bool has_vertex_normals() const { return mesh_.has_vertex_normals(); }
bool has_vertex_colors() const { return mesh_.has_vertex_colors(); }
bool has_vertex_texcoords() const { return mesh_.has_vertex_texcoords2D(); }
bool has_edge_colors() const { return mesh_.has_edge_colors(); }
bool has_face_normals() const { return mesh_.has_face_normals(); }
bool has_face_colors() const { return mesh_.has_face_colors(); }

View File

@@ -114,6 +114,12 @@ public:
// set vertex texture coordinate
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
// set edge color
virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
// set edge color
virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) = 0;
// set face normal
virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;

View File

@@ -169,6 +169,19 @@ public:
mesh_.set_texcoord2D(_heh, vector_cast<TexCoord2D>(_texcoord));
}
// edge attributes
virtual void set_color(EdgeHandle _eh, const Vec4uc& _color)
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
virtual void set_color(EdgeHandle _eh, const Vec3uc& _color)
{
if (mesh_.has_edge_colors())
mesh_.set_color(_eh, color_cast<Color>(_color));
}
// face attributes