Commit 3583c77f authored by Max Lyon's avatar Max Lyon

add methods to importer to create a mesh based on halfedges

parent 95fceb45
......@@ -99,10 +99,16 @@ public:
// add a vertex without coordinate. Use set_point to set the position deferred
virtual VertexHandle add_vertex() = 0;
// add an edge. Use set_next, set_vertex and set_face to set corresponding entities for halfedges
virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) = 0;
// add a face with indices _indices refering to vertices
typedef std::vector<VertexHandle> VHandles;
virtual FaceHandle add_face(const VHandles& _indices) = 0;
// add a face with incident halfedge
virtual FaceHandle add_face(HalfedgeHandle _heh) = 0;
// add texture coordinates per face, _vh references the first texcoord
virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) = 0;
......@@ -115,6 +121,9 @@ public:
// Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
virtual void set_point(VertexHandle _vh, const Vec3f& _point) = 0;
// Set outgoing halfedge for the given vertex.
virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) = 0;
// set vertex normal
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
......@@ -133,6 +142,12 @@ public:
// set vertex texture coordinate
virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
// set next halfedge handle
virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) = 0;
// set incident face handle for given halfedge
virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) = 0;
// set vertex texture coordinate
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
......
......@@ -107,6 +107,11 @@ public:
return mesh_.new_vertex();
}
virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) override
{
return mesh_.new_edge(_vh0, _vh1);
}
virtual FaceHandle add_face(const VHandles& _indices)
{
FaceHandle fh;
......@@ -192,6 +197,13 @@ public:
return fh;
}
virtual FaceHandle add_face(HalfedgeHandle _heh) override
{
auto fh = mesh_.new_face();
mesh_.set_halfedge_handle(fh, _heh);
return fh;
}
// vertex attributes
virtual void set_point(VertexHandle _vh, const Vec3f& _point)
......@@ -199,6 +211,11 @@ public:
mesh_.set_point(_vh,vector_cast<Point>(_point));
}
virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) override
{
mesh_.set_halfedge_handle(_vh, _heh);
}
virtual void set_normal(VertexHandle _vh, const Vec3f& _normal)
{
if (mesh_.has_vertex_normals())
......@@ -240,6 +257,17 @@ public:
mesh_.set_texcoord2D(_vh, vector_cast<TexCoord2D>(_texcoord));
}
virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) override
{
mesh_.set_next_halfedge_handle(_heh, _next);
}
virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) override
{
mesh_.set_face_handle(_heh, _fh);
}
virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord)
{
if (mesh_.has_halfedge_texcoords2D())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment