Mesh Library - HalfEdge
Sturcture : | HalfEdge |
source file: | halfedge.c |
Definition:
struct halfedge{
Edge *hedge;
Loop *hloop;
Vertex *hvert;
HalfEdge *next;
HalfEdge *prev;
int aliveh;
};
Data Members:
- hedge - the nonoriented edge to which the current halfedge is attached.
- hloop - the loop structure, the current halfedge belongs to
- hvert - starting vertex of current halfedge
- next,prev - halfedge pointers in the loop. Next pointer are arranged so
that the loop is ccw
- aliveh- indicating if current halfedge is alive
Methods:
- void HalfEdgeConstruct( Loop **l, Vertex * s);
construct a halfedge within the loop l, with starting vertex s
- void HalfEdgeDestruct( HalfEdge ** l);
Destruct the halfedge l
- HalfEdge * HalfEdgeMate( HalfEdge * l);
Find the mate of halfedge l, suppose it is r. Then l and r have the same
vertices, but opposite orientation
- Vertex * HalfEdgeStartVertex( HalfEdge * l);
Find the starting vertex of halfedge l.
- Vertex * HalfEdgeEndVertex( HalfEdge * l);
Find the ending vertex of halfedge l
- void HalfEdgeMerge( HalfEdge * l);
Edge Collapse
In the mesh, merge the end vertex of l to the start vertex of l, change all
neighor structures of l, keep the mesh still a manifold. The neighor structures
are inactive, not not really removed.
- void HalfEdgeExtend( HalfEdge * l);
Vertex Split
Suppose after edge collapsation, l is the last halfedge collapsed, then
recover the mesh by extending l again.
- double HalfEdgeCost( HalfEdge * , double ( * )( Face * ) );
Given cost function of face, calculate halfedge cost.
You can redefine HalfEdgeCost function by yourself. One way is to
collapse a halfedge, and do some measurement, get the cost, then
recover the mesh. You evaluate all the halfedges, then select the
minimum one to collapse.