Represents a triangle strip or quad strip in progress, as assembled by the mesher. More...
#include "eggMesherStrip.h"
Public Types | |
typedef plist< EggMesherEdge * > | Edges |
enum | MesherOrigin { MO_unknown, MO_user, MO_firstquad, MO_fanpoly, MO_mate } |
enum | MesherStatus { MS_alive, MS_dead, MS_done, MS_paired } |
typedef plist< CPT(EggPrimitive) > | Prims |
enum | PrimType { PT_poly, PT_point, PT_line, PT_tri, PT_tristrip, PT_trifan, PT_quad, PT_quadstrip, PT_linestrip } |
typedef plist< int > | Verts |
Public Member Functions | |
EggMesherStrip (PrimType prim_type, MesherOrigin origin) | |
EggMesherStrip (const EggPrimitive *prim, int index, const EggVertexPool *vertex_pool, bool flat_shaded) | |
EggMesherStrip (const EggMesherStrip ©) | |
bool | can_invert () const |
Returns true if the strip can be inverted (reverse its facing direction). More... | |
void | combine_edges (EggMesherStrip &other, int remove_sides) |
Removes the edges from the given strip and appends them to our own. More... | |
void | convert_to_type (PrimType want_type) |
Converts the EggMesherStrip from whatever form it is–triangle, quad, or quadstrip–into a tristrip or quadstrip. More... | |
PN_stdfloat | coplanarity (const EggMesherStrip &other) const |
Returns the degree to which the two strips are coplanar. More... | |
int | count_neighbors () const |
Returns the number of neighbors the strip shares. More... | |
void | cut_sheet (int first_row_id, int do_mate, const EggVertexPool *vertex_pool) |
const EggMesherEdge * | find_adjacent_edge (const EggMesherEdge *edge) const |
Returns the first edge found that shares exactly one vertex with the given edge. More... | |
bool | find_ideal_mate (EggMesherStrip *&mate, EggMesherEdge *&common_edge, const EggVertexPool *vertex_pool) |
Searches our neighbors for the most suitable mate. More... | |
const EggMesherEdge * | find_opposite_edge (int vi) const |
Returns the first edge found that does not contain the given vertex. More... | |
const EggMesherEdge * | find_opposite_edge (const EggMesherEdge *edge) const |
Returns the first edge found that shares no vertices with the given edge. More... | |
int | find_uncommon_vertex (const EggMesherEdge *edge) const |
Returns the first vertex found that is not shared by the given edge. More... | |
EggMesherEdge | get_head_edge () const |
Returns an EggMesherEdge which represents the leading edge in the quadstrip or tristrip. More... | |
EggMesherEdge | get_tail_edge () const |
Returns an EggMesherEdge which represents the trailing edge in the quadstrip or tristrip. More... | |
bool | invert () |
Reverses the facing of a quadstrip by reversing pairs of vertices. More... | |
bool | is_coplanar_with (const EggMesherStrip &other, PN_stdfloat threshold) const |
Returns true if the strip and the other strip are coplanar, within the indicated threshold. More... | |
bool | is_odd () const |
Returns true if the tristrip or quadstrip contains an odd number of pieces. More... | |
bool | mate (const EggVertexPool *vertex_pool) |
Finds a neighboring strip and joins up with it to make a larger strip. More... | |
void | measure_sheet (const EggMesherEdge *edge, int new_row, int &num_prims, int &num_rows, int first_row_id, int this_row_id, int this_row_distance) |
Determines the extents of the quadsheet that can be derived by starting with this strip, and searching in the direction indicated by the given edge. More... | |
bool | operator != (const EggMesherStrip &other) const |
bool | operator== (const EggMesherStrip &other) const |
Defines equality for strips. More... | |
void | output (std::ostream &out) const |
Formats the vertex for output in some sensible way. More... | |
void | output_neighbors (std::ostream &out) const |
Writes all the neighbor indexes to the ostream. More... | |
bool | pick_mate (const EggMesherStrip &a_strip, const EggMesherStrip &b_strip, const EggMesherEdge &a_edge, const EggMesherEdge &b_edge, const EggVertexPool *vertex_pool) const |
Defines an ordering to select neighbors to mate with. More... | |
bool | pick_sheet_mate (const EggMesherStrip &a_strip, const EggMesherStrip &b_strip) const |
Defines an ordering to select neighbors to follow when measuring out a quadsheet. More... | |
PT (EggPrimitive) make_prim(const EggVertexPool *vertex_pool) | |
void | remove_all_edges () |
Removes all active edges from the strip. More... | |
void | rotate_back () |
Rotates a triangle or quad by bringing its last vertex to the front. More... | |
void | rotate_forward () |
Rotates a triangle or quad by bringing its first vertex to the back. More... | |
void | rotate_to_back (const EggMesherEdge *edge) |
Rotates a triangle or quad so that the given edge is last in the vertex list. More... | |
void | rotate_to_front (const EggMesherEdge *edge) |
Rotates a triangle or quad so that the given edge is first in the vertex list. More... | |
int | type_category () const |
Returns an integer which gives a heuristic about the similarity of different strip types. More... | |
bool | would_reverse_tail (PrimType want_type) const |
Returns true if convert_to_type() would reverse the tail edge of the given strip, false otherwise. More... | |
Static Public Member Functions | |
static bool | convex_quad (EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, const EggVertexPool *vertex_pool) |
Returns true if the quad that would be formed by connecting coplanar tris front and back along common_edge is convex, false otherwise. More... | |
static bool | mate_pieces (EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, const EggVertexPool *vertex_pool) |
Connects two pieces of arbitrary type, if possible. More... | |
static bool | mate_strips (EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, PrimType type) |
Stitches two strips together, producing in "front" a new strip of the indicated type (quadstrip or tristrip). More... | |
static bool | must_invert (const EggMesherStrip &front, const EggMesherStrip &back, bool will_reverse_back, PrimType type) |
Returns false if the strips can be mated as they currently are. More... | |
Public Attributes | |
Edges | _edges |
bool | _flat_shaded |
int | _index |
MesherOrigin | _origin |
bool | _planar |
LNormald | _plane_normal |
PN_stdfloat | _plane_offset |
Prims | _prims |
int | _row_distance |
int | _row_id |
MesherStatus | _status |
PrimType | _type |
Verts | _verts |
Represents a triangle strip or quad strip in progress, as assembled by the mesher.
It might also represent a single polygon such as a triangle or quad, since that's how strips generally start out.
Definition at line 30 of file eggMesherStrip.h.
bool EggMesherStrip::can_invert | ( | ) | const |
Returns true if the strip can be inverted (reverse its facing direction).
Generally, this is true for quadstrips and false for tristrips.
Definition at line 1030 of file eggMesherStrip.cxx.
Referenced by invert(), and mate_strips().
void EggMesherStrip::combine_edges | ( | EggMesherStrip & | other, |
int | remove_sides | ||
) |
Removes the edges from the given strip and appends them to our own.
If remove_sides is true, then removes all the edges except the head and the tail.
Definition at line 1203 of file eggMesherStrip.cxx.
References get_head_edge(), get_tail_edge(), and is_odd().
void EggMesherStrip::convert_to_type | ( | EggMesherStrip::PrimType | want_type | ) |
Converts the EggMesherStrip from whatever form it is–triangle, quad, or quadstrip–into a tristrip or quadstrip.
Definition at line 1134 of file eggMesherStrip.cxx.
Referenced by mate_strips().
|
static |
Returns true if the quad that would be formed by connecting coplanar tris front and back along common_edge is convex, false otherwise.
Definition at line 766 of file eggMesherStrip.cxx.
References find_uncommon_vertex().
|
inline |
Returns the degree to which the two strips are coplanar.
0.0 is exactly coplanar; numbers somewhat larger than zero indicate less coplanar. 1.0 is at right angles; 2.0 is exactly backfacing. If either strip is not itself planar, 3.0 is returned.
Definition at line 49 of file eggMesherStrip.I.
Referenced by is_coplanar_with(), and pick_mate().
int EggMesherStrip::count_neighbors | ( | ) | const |
Returns the number of neighbors the strip shares.
Definition at line 838 of file eggMesherStrip.cxx.
Referenced by pick_mate().
const EggMesherEdge * EggMesherStrip::find_adjacent_edge | ( | const EggMesherEdge * | edge | ) | const |
Returns the first edge found that shares exactly one vertex with the given edge.
In a quad, this will be one of two edges adjacent to the given edge.
Definition at line 929 of file eggMesherStrip.cxx.
References EggMesherEdge::contains_vertex().
bool EggMesherStrip::find_ideal_mate | ( | EggMesherStrip *& | mate, |
EggMesherEdge *& | common_edge, | ||
const EggVertexPool * | vertex_pool | ||
) |
Searches our neighbors for the most suitable mate.
Returns true if one is found, false if we have no neighbors.
Definition at line 427 of file eggMesherStrip.cxx.
References mate(), and pick_mate().
const EggMesherEdge * EggMesherStrip::find_opposite_edge | ( | int | vi | ) | const |
Returns the first edge found that does not contain the given vertex.
In a tri, this will be the edge opposite the given vertex.
Definition at line 892 of file eggMesherStrip.cxx.
const EggMesherEdge * EggMesherStrip::find_opposite_edge | ( | const EggMesherEdge * | edge | ) | const |
Returns the first edge found that shares no vertices with the given edge.
In a quad, this will be the edge opposite the given edge.
Definition at line 909 of file eggMesherStrip.cxx.
References EggMesherEdge::contains_vertex().
int EggMesherStrip::find_uncommon_vertex | ( | const EggMesherEdge * | edge | ) | const |
Returns the first vertex found that is not shared by the given edge.
Definition at line 869 of file eggMesherStrip.cxx.
Referenced by convex_quad().
|
inline |
Returns an EggMesherEdge which represents the leading edge in the quadstrip or tristrip.
This EggMesherEdge will not have pointer equality with any shared EggMesherEdge.
Definition at line 104 of file eggMesherStrip.I.
Referenced by combine_edges(), and mate_strips().
|
inline |
Returns an EggMesherEdge which represents the trailing edge in the quadstrip or tristrip.
This EggMesherEdge will not have pointer equality with any shared EggMesherEdge.
Definition at line 117 of file eggMesherStrip.I.
Referenced by combine_edges(), and mate_strips().
bool EggMesherStrip::invert | ( | ) |
Reverses the facing of a quadstrip by reversing pairs of vertices.
Returns true if successful, false if failure (for instance, on a tristrip).
Definition at line 1039 of file eggMesherStrip.cxx.
References can_invert().
Referenced by mate_strips(), and must_invert().
|
inline |
Returns true if the strip and the other strip are coplanar, within the indicated threshold.
See coplanarity().
Definition at line 38 of file eggMesherStrip.I.
References coplanarity().
bool EggMesherStrip::is_odd | ( | ) | const |
Returns true if the tristrip or quadstrip contains an odd number of pieces.
Definition at line 1066 of file eggMesherStrip.cxx.
Referenced by combine_edges(), mate_strips(), and must_invert().
bool EggMesherStrip::mate | ( | const EggVertexPool * | vertex_pool | ) |
Finds a neighboring strip and joins up with it to make a larger strip.
Returns true if mating was successful or at least possible, false if the strip has no neighbors.
Definition at line 398 of file eggMesherStrip.cxx.
Referenced by find_ideal_mate(), and measure_sheet().
|
static |
Connects two pieces of arbitrary type, if possible.
Returns true if successful, false if failure.
Definition at line 459 of file eggMesherStrip.cxx.
|
static |
Stitches two strips together, producing in "front" a new strip of the indicated type (quadstrip or tristrip).
The front strip stores the result, and the back strip is emptied on success.
Returns true if successful, false if failure (generally because of incorrect polarity of tristrips), in which case nothing has changed (or at least, not much).
Definition at line 602 of file eggMesherStrip.cxx.
References can_invert(), convert_to_type(), get_head_edge(), get_tail_edge(), invert(), is_odd(), EggMesherEdge::matches(), must_invert(), rotate_to_back(), rotate_to_front(), and would_reverse_tail().
void EggMesherStrip::measure_sheet | ( | const EggMesherEdge * | edge, |
int | new_row, | ||
int & | num_prims, | ||
int & | num_rows, | ||
int | first_row_id, | ||
int | this_row_id, | ||
int | this_row_distance | ||
) |
Determines the extents of the quadsheet that can be derived by starting with this strip, and searching in the direction indicated by the given edge.
Definition at line 173 of file eggMesherStrip.cxx.
References mate(), and pick_sheet_mate().
|
static |
Returns false if the strips can be mated as they currently are.
Returns true if the back strip must be inverted first.
Definition at line 733 of file eggMesherStrip.cxx.
References invert(), and is_odd().
Referenced by mate_strips().
|
inline |
Defines equality for strips.
This actually tests only pointer equality; it's used only when removing a strip from the list.
Definition at line 129 of file eggMesherStrip.I.
void EggMesherStrip::output | ( | std::ostream & | out | ) | const |
Formats the vertex for output in some sensible way.
Definition at line 1353 of file eggMesherStrip.cxx.
void EggMesherStrip::output_neighbors | ( | std::ostream & | out | ) | const |
Writes all the neighbor indexes to the ostream.
Definition at line 852 of file eggMesherStrip.cxx.
bool EggMesherStrip::pick_mate | ( | const EggMesherStrip & | a_strip, |
const EggMesherStrip & | b_strip, | ||
const EggMesherEdge & | a_edge, | ||
const EggMesherEdge & | b_edge, | ||
const EggVertexPool * | vertex_pool | ||
) | const |
Defines an ordering to select neighbors to mate with.
This compares strip a with strip b and returns true if strip a is the preferable choice, false if strip b.
Definition at line 1271 of file eggMesherStrip.cxx.
References EggMesherEdge::compute_length(), coplanarity(), count_neighbors(), and type_category().
Referenced by find_ideal_mate().
bool EggMesherStrip::pick_sheet_mate | ( | const EggMesherStrip & | a_strip, |
const EggMesherStrip & | b_strip | ||
) | const |
Defines an ordering to select neighbors to follow when measuring out a quadsheet.
This is only called when three or more prims share a single edge, which should be rarely–generally only when coplanar polys are going on.
Definition at line 1325 of file eggMesherStrip.cxx.
Referenced by measure_sheet().
void EggMesherStrip::remove_all_edges | ( | ) |
Removes all active edges from the strip.
This effectively renders it ineligible to mate with anything else.
Definition at line 1252 of file eggMesherStrip.cxx.
|
inline |
Rotates a triangle or quad by bringing its last vertex to the front.
Definition at line 92 of file eggMesherStrip.I.
|
inline |
Rotates a triangle or quad by bringing its first vertex to the back.
Definition at line 83 of file eggMesherStrip.I.
void EggMesherStrip::rotate_to_back | ( | const EggMesherEdge * | edge | ) |
Rotates a triangle or quad so that the given edge is last in the vertex list.
Definition at line 989 of file eggMesherStrip.cxx.
Referenced by mate_strips().
void EggMesherStrip::rotate_to_front | ( | const EggMesherEdge * | edge | ) |
Rotates a triangle or quad so that the given edge is first in the vertex list.
Definition at line 949 of file eggMesherStrip.cxx.
Referenced by mate_strips().
|
inline |
Returns an integer which gives a heuristic about the similarity of different strip types.
In general, closer numbers are more similar.
Definition at line 61 of file eggMesherStrip.I.
Referenced by pick_mate().
bool EggMesherStrip::would_reverse_tail | ( | EggMesherStrip::PrimType | want_type | ) | const |
Returns true if convert_to_type() would reverse the tail edge of the given strip, false otherwise.
Definition at line 1083 of file eggMesherStrip.cxx.
Referenced by mate_strips().