i
i
i
i
i
i
i
i
12.3. Consolidation 543
There are a number of conditions necessary to ensure that a surface
can be successfully oriented. Each polygon edge should be shared by at
most two polygons in the mesh. For example, if two cubes touched along
an edge and were a part of the same mesh, that edge would be shared by
four polygons. This makes simple orientation computation more difficult.
Also, one-sided objects such as M¨obius strips will of course not be able to
be oriented.
Given a reasonable model, here is one approach to orient a polygonal
mesh:
1. Form edge-face structures for all polygons.
2. Sort or hash the edges to find which edges match.
3. Find groups of polygons that touch each other.
4. For each group, flip faces to obtain consistency.
The first step is to create a set of half-edge objects. A half-edge is an
edge of a polygon, with a pointer to its associated face (polygon). Since
an edge is normally shared by two polygons, this data structure is called
a half-edge. Create each half-edge with its first vertex stored before the
second vertex, using sorting order. One vertex comes before another in
sorting order if its x-coordinate value is smaller. If the x-coordinates are
equal, then the y-value is used; if these match, then z is used. For example,
vertex (−3, 5, 2) comes before vertex (−3, 6, −8); the −3s match, but 5 < 6.
The goal is to find which edges are identical. Since each edge is stored
such that the first vertex is less than the second, comparing edges is sim-
ply a matter of comparing first to first and second to second vertices; no
permutations such as comparing one edge’s first vertex to another’s second
vertex are needed. A hash table can be used to find matching edges [8, 407].
If all vertices have previously been merged, so that half-edges use the same
vertex indices, then each half-edge can be matched by putting it on a tem-
porary list associated with its first vertex index. A vertex has an average
of 6 edges attached to it, making edge matching extremely rapid [1063].
Once the edges are matched, connections among neighboring polygons
are known, forming an adjacency graph. For a triangle mesh, an adjacency
graph can be represented as a list of (up to) three triangle indices associ-
ated with each triangle, its neighbors. Boundary edges can be determined
from adjacency: Any edge that does not have two neighboring polygons
is a boundary edge. The set of polygons that touch each other forms a
continuous group. A single data set can have more than one continuous
group. For example, a teapot can have two groups, the pot and the lid.
The next step is to give the mesh orientation consistency, e.g., we may
want all polygons to have counterclockwise outlines. For each continuous