Panda3D
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
EggMesherStrip Class Reference

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 (const EggMesherStrip &copy)
 
 EggMesherStrip (const EggPrimitive *prim, int index, const EggVertexPool *vertex_pool, bool flat_shaded)
 
 EggMesherStrip (PrimType prim_type, MesherOrigin origin)
 
bool can_invert () const
 Returns true if the strip can be inverted (reverse its facing direction).
 
void combine_edges (EggMesherStrip &other, int remove_sides)
 Removes the edges from the given strip and appends them to our own.
 
void convert_to_type (PrimType want_type)
 Converts the EggMesherStrip from whatever form it is–triangle, quad, or quadstrip–into a tristrip or quadstrip.
 
PN_stdfloat coplanarity (const EggMesherStrip &other) const
 Returns the degree to which the two strips are coplanar.
 
int count_neighbors () const
 Returns the number of neighbors the strip shares.
 
void cut_sheet (int first_row_id, int do_mate, const EggVertexPool *vertex_pool)
 
const EggMesherEdgefind_adjacent_edge (const EggMesherEdge *edge) const
 Returns the first edge found that shares exactly one vertex with the given edge.
 
bool find_ideal_mate (EggMesherStrip *&mate, EggMesherEdge *&common_edge, const EggVertexPool *vertex_pool)
 Searches our neighbors for the most suitable mate.
 
const EggMesherEdgefind_opposite_edge (const EggMesherEdge *edge) const
 Returns the first edge found that shares no vertices with the given edge.
 
const EggMesherEdgefind_opposite_edge (int vi) const
 Returns the first edge found that does not contain the given vertex.
 
int find_uncommon_vertex (const EggMesherEdge *edge) const
 Returns the first vertex found that is not shared by the given edge.
 
EggMesherEdge get_head_edge () const
 Returns an EggMesherEdge which represents the leading edge in the quadstrip or tristrip.
 
EggMesherEdge get_tail_edge () const
 Returns an EggMesherEdge which represents the trailing edge in the quadstrip or tristrip.
 
bool invert ()
 Reverses the facing of a quadstrip by reversing pairs of vertices.
 
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.
 
bool is_odd () const
 Returns true if the tristrip or quadstrip contains an odd number of pieces.
 
bool mate (const EggVertexPool *vertex_pool)
 Finds a neighboring strip and joins up with it to make a larger strip.
 
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.
 
bool operator!= (const EggMesherStrip &other) const
 
bool operator== (const EggMesherStrip &other) const
 Defines equality for strips.
 
void output (std::ostream &out) const
 Formats the vertex for output in some sensible way.
 
void output_neighbors (std::ostream &out) const
 Writes all the neighbor indexes to the ostream.
 
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.
 
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.
 
 PT (EggPrimitive) make_prim(const EggVertexPool *vertex_pool)
 
void remove_all_edges ()
 Removes all active edges from the strip.
 
void rotate_back ()
 Rotates a triangle or quad by bringing its last vertex to the front.
 
void rotate_forward ()
 Rotates a triangle or quad by bringing its first vertex to the back.
 
void rotate_to_back (const EggMesherEdge *edge)
 Rotates a triangle or quad so that the given edge is last in the vertex list.
 
void rotate_to_front (const EggMesherEdge *edge)
 Rotates a triangle or quad so that the given edge is first in the vertex list.
 
int type_category () const
 Returns an integer which gives a heuristic about the similarity of different strip types.
 
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.
 

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.
 
static bool mate_pieces (EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, const EggVertexPool *vertex_pool)
 Connects two pieces of arbitrary type, if possible.
 
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).
 
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.
 

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
 

Detailed Description

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.

Member Typedef Documentation

◆ Edges

Definition at line 121 of file eggMesherStrip.h.

◆ Prims

Definition at line 120 of file eggMesherStrip.h.

◆ Verts

Definition at line 122 of file eggMesherStrip.h.

Member Enumeration Documentation

◆ MesherOrigin

enum EggMesherStrip::MesherOrigin

Definition at line 44 of file eggMesherStrip.h.

◆ MesherStatus

enum EggMesherStrip::MesherStatus

Definition at line 128 of file eggMesherStrip.h.

◆ PrimType

enum EggMesherStrip::PrimType

Definition at line 32 of file eggMesherStrip.h.

Constructor & Destructor Documentation

◆ EggMesherStrip() [1/3]

EggMesherStrip::EggMesherStrip ( PrimType prim_type,
MesherOrigin origin )

Definition at line 26 of file eggMesherStrip.cxx.

◆ EggMesherStrip() [2/3]

EggMesherStrip::EggMesherStrip ( const EggPrimitive * prim,
int index,
const EggVertexPool * vertex_pool,
bool flat_shaded )

Definition at line 41 of file eggMesherStrip.cxx.

◆ EggMesherStrip() [3/3]

EggMesherStrip::EggMesherStrip ( const EggMesherStrip & copy)
inline

Definition at line 17 of file eggMesherStrip.I.

Member Function Documentation

◆ can_invert()

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 1029 of file eggMesherStrip.cxx.

Referenced by invert(), and mate_strips().

◆ combine_edges()

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 1202 of file eggMesherStrip.cxx.

References get_head_edge(), get_tail_edge(), and is_odd().

Referenced by mate_pieces().

◆ convert_to_type()

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 1133 of file eggMesherStrip.cxx.

Referenced by mate_strips(), and PT().

◆ convex_quad()

bool EggMesherStrip::convex_quad ( EggMesherEdge * common_edge,
EggMesherStrip & front,
EggMesherStrip & back,
const EggVertexPool * vertex_pool )
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 765 of file eggMesherStrip.cxx.

References find_uncommon_vertex(), EggVertex::get_pos3(), and EggVertexPool::get_vertex().

Referenced by mate_pieces().

◆ coplanarity()

PN_stdfloat EggMesherStrip::coplanarity ( const EggMesherStrip & other) const
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 48 of file eggMesherStrip.I.

Referenced by is_coplanar_with(), and pick_mate().

◆ count_neighbors()

int EggMesherStrip::count_neighbors ( ) const

Returns the number of neighbors the strip shares.

Definition at line 837 of file eggMesherStrip.cxx.

Referenced by output(), and pick_mate().

◆ cut_sheet()

void EggMesherStrip::cut_sheet ( int first_row_id,
int do_mate,
const EggVertexPool * vertex_pool )

Definition at line 305 of file eggMesherStrip.cxx.

◆ find_adjacent_edge()

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 928 of file eggMesherStrip.cxx.

References EggMesherEdge::contains_vertex().

◆ find_ideal_mate()

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 426 of file eggMesherStrip.cxx.

References mate(), and pick_mate().

Referenced by mate().

◆ find_opposite_edge() [1/2]

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 908 of file eggMesherStrip.cxx.

References EggMesherEdge::contains_vertex().

◆ find_opposite_edge() [2/2]

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 891 of file eggMesherStrip.cxx.

References EggMesherEdge::contains_vertex().

◆ find_uncommon_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 868 of file eggMesherStrip.cxx.

Referenced by convex_quad(), and mate_pieces().

◆ get_head_edge()

EggMesherEdge EggMesherStrip::get_head_edge ( ) const
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 103 of file eggMesherStrip.I.

Referenced by combine_edges(), and mate_strips().

◆ get_tail_edge()

EggMesherEdge EggMesherStrip::get_tail_edge ( ) const
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 116 of file eggMesherStrip.I.

Referenced by combine_edges(), and mate_strips().

◆ invert()

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 1038 of file eggMesherStrip.cxx.

References can_invert().

Referenced by mate_strips(), and must_invert().

◆ is_coplanar_with()

bool EggMesherStrip::is_coplanar_with ( const EggMesherStrip & other,
PN_stdfloat threshold ) const
inline

Returns true if the strip and the other strip are coplanar, within the indicated threshold.

See coplanarity().

Definition at line 37 of file eggMesherStrip.I.

References coplanarity().

Referenced by mate_pieces().

◆ is_odd()

bool EggMesherStrip::is_odd ( ) const

Returns true if the tristrip or quadstrip contains an odd number of pieces.

Definition at line 1065 of file eggMesherStrip.cxx.

Referenced by combine_edges(), mate_strips(), and must_invert().

◆ mate()

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 397 of file eggMesherStrip.cxx.

References find_ideal_mate(), mate(), and mate_pieces().

Referenced by find_ideal_mate(), mate(), and measure_sheet().

◆ mate_pieces()

bool EggMesherStrip::mate_pieces ( EggMesherEdge * common_edge,
EggMesherStrip & front,
EggMesherStrip & back,
const EggVertexPool * vertex_pool )
static

Connects two pieces of arbitrary type, if possible.

Returns true if successful, false if failure.

Definition at line 458 of file eggMesherStrip.cxx.

References combine_edges(), EggMesherEdge::contains_vertex(), convex_quad(), find_uncommon_vertex(), is_coplanar_with(), mate_strips(), EggMesherEdge::remove(), and rotate_to_back().

Referenced by mate().

◆ mate_strips()

bool EggMesherStrip::mate_strips ( EggMesherEdge * common_edge,
EggMesherStrip & front,
EggMesherStrip & back,
EggMesherStrip::PrimType type )
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 601 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().

Referenced by mate_pieces().

◆ measure_sheet()

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 172 of file eggMesherStrip.cxx.

References mate(), and pick_sheet_mate().

◆ must_invert()

bool EggMesherStrip::must_invert ( const EggMesherStrip & front,
const EggMesherStrip & back,
bool will_reverse_back,
EggMesherStrip::PrimType type )
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 732 of file eggMesherStrip.cxx.

References invert(), and is_odd().

Referenced by mate_strips().

◆ operator!=()

bool EggMesherStrip::operator!= ( const EggMesherStrip & other) const
inline

Definition at line 136 of file eggMesherStrip.I.

◆ operator==()

bool EggMesherStrip::operator== ( const EggMesherStrip & other) const
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 128 of file eggMesherStrip.I.

◆ output()

void EggMesherStrip::output ( std::ostream & out) const

Formats the vertex for output in some sensible way.

Definition at line 1352 of file eggMesherStrip.cxx.

References count_neighbors(), and output_neighbors().

◆ output_neighbors()

void EggMesherStrip::output_neighbors ( std::ostream & out) const

Writes all the neighbor indexes to the ostream.

Definition at line 851 of file eggMesherStrip.cxx.

Referenced by output().

◆ pick_mate()

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 1270 of file eggMesherStrip.cxx.

References EggMesherEdge::compute_length(), coplanarity(), count_neighbors(), and type_category().

Referenced by find_ideal_mate().

◆ pick_sheet_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 1324 of file eggMesherStrip.cxx.

References type_category().

Referenced by measure_sheet().

◆ remove_all_edges()

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 1251 of file eggMesherStrip.cxx.

◆ rotate_back()

void EggMesherStrip::rotate_back ( )
inline

Rotates a triangle or quad by bringing its last vertex to the front.

Definition at line 91 of file eggMesherStrip.I.

Referenced by rotate_to_back(), and rotate_to_front().

◆ rotate_forward()

void EggMesherStrip::rotate_forward ( )
inline

Rotates a triangle or quad by bringing its first vertex to the back.

Definition at line 82 of file eggMesherStrip.I.

Referenced by rotate_to_back(), and rotate_to_front().

◆ rotate_to_back()

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 988 of file eggMesherStrip.cxx.

References rotate_back(), and rotate_forward().

Referenced by mate_pieces(), and mate_strips().

◆ rotate_to_front()

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 948 of file eggMesherStrip.cxx.

References rotate_back(), and rotate_forward().

Referenced by mate_strips().

◆ type_category()

int EggMesherStrip::type_category ( ) const
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 60 of file eggMesherStrip.I.

Referenced by pick_mate(), and pick_sheet_mate().

◆ would_reverse_tail()

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 1082 of file eggMesherStrip.cxx.

Referenced by mate_strips().

Member Data Documentation

◆ _edges

Edges EggMesherStrip::_edges

Definition at line 125 of file eggMesherStrip.h.

◆ _flat_shaded

bool EggMesherStrip::_flat_shaded

Definition at line 144 of file eggMesherStrip.h.

◆ _index

int EggMesherStrip::_index

Definition at line 136 of file eggMesherStrip.h.

◆ _origin

MesherOrigin EggMesherStrip::_origin

Definition at line 143 of file eggMesherStrip.h.

◆ _planar

bool EggMesherStrip::_planar

Definition at line 139 of file eggMesherStrip.h.

◆ _plane_normal

LNormald EggMesherStrip::_plane_normal

Definition at line 140 of file eggMesherStrip.h.

◆ _plane_offset

PN_stdfloat EggMesherStrip::_plane_offset

Definition at line 141 of file eggMesherStrip.h.

◆ _prims

Prims EggMesherStrip::_prims

Definition at line 124 of file eggMesherStrip.h.

◆ _row_distance

int EggMesherStrip::_row_distance

Definition at line 142 of file eggMesherStrip.h.

◆ _row_id

int EggMesherStrip::_row_id

Definition at line 142 of file eggMesherStrip.h.

◆ _status

MesherStatus EggMesherStrip::_status

Definition at line 137 of file eggMesherStrip.h.

◆ _type

PrimType EggMesherStrip::_type

Definition at line 135 of file eggMesherStrip.h.

◆ _verts

Verts EggMesherStrip::_verts

Definition at line 126 of file eggMesherStrip.h.


The documentation for this class was generated from the following files: