add methods to import to set positions and normals from doubles

This commit is contained in:
Max Lyon
2020-02-05 22:12:53 +01:00
parent 2356364085
commit 337fb4571d
2 changed files with 22 additions and 0 deletions

View File

@@ -91,6 +91,9 @@ public:
// add a vertex with coordinate \c _point
virtual VertexHandle add_vertex(const Vec3f& _point) = 0;
// add a vertex with coordinate \c _point
virtual VertexHandle add_vertex(const Vec3d& _point) { return add_vertex(Vec3f(_point)); }
// add a vertex without coordinate. Use set_point to set the position deferred
virtual VertexHandle add_vertex() = 0;
@@ -122,6 +125,9 @@ public:
// set vertex normal
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
// set vertex normal
virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) { set_normal(_vh, Vec3f(_normal)); }
// set vertex color
virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0;

View File

@@ -97,6 +97,11 @@ public:
return mesh_.add_vertex(vector_cast<Point>(_point));
}
virtual VertexHandle add_vertex(const Vec3d& _point) override
{
return mesh_.add_vertex(vector_cast<Point>(_point));
}
virtual VertexHandle add_vertex() override
{
return mesh_.new_vertex();
@@ -222,6 +227,17 @@ public:
halfedgeNormals_[_vh] = vector_cast<Normal>(_normal);
}
virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) override
{
if (mesh_.has_vertex_normals())
mesh_.set_normal(_vh, vector_cast<Normal>(_normal));
//saves normals for half edges.
//they will be written, when the face is added
if (mesh_.has_halfedge_normals())
halfedgeNormals_[_vh] = vector_cast<Normal>(_normal);
}
virtual void set_color(VertexHandle _vh, const Vec4uc& _color) override
{
if (mesh_.has_vertex_colors())