00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MESHERSTRIP_H
00020 #define MESHERSTRIP_H
00021
00022 #include <pandabase.h>
00023
00024 #include "mesherConfig.h"
00025 #include "builderTypes.h"
00026 #include "builderBucket.h"
00027
00028 #include "plist.h"
00029 #include <math.h>
00030
00031
00032 template <class PrimType>
00033 class MesherEdge;
00034
00035 template <class PrimType>
00036 class MesherTempl;
00037
00038 enum MesherStripStatus {
00039 MS_alive, MS_dead, MS_done, MS_paired
00040 };
00041
00042 enum MesherStripOrigin {
00043 MO_unknown, MO_user, MO_firstquad, MO_fanpoly, MO_mate
00044 };
00045
00046 template <class PrimType>
00047 class MesherStrip {
00048 public:
00049 typedef PrimType Prim;
00050 typedef TYPENAME PrimType::Vertex Vertex;
00051 typedef TYPENAME PrimType::DAttrib SAttrib;
00052 typedef MesherEdge<PrimType> Edge;
00053
00054 MesherStrip() {}
00055 MesherStrip(const PrimType &prim, int index, const BuilderBucket &bucket);
00056 INLINE MesherStrip(const MesherStrip ©);
00057
00058 Prim make_prim(const BuilderBucket &bucket);
00059
00060 void measure_sheet(const Edge *edge, int new_row,
00061 int &num_prims, int &num_rows,
00062 int first_row_id, int this_row_id,
00063 int this_row_distance);
00064 void cut_sheet(int first_row_id, int do_mate,
00065 const BuilderBucket &bucket);
00066
00067 bool mate(const BuilderBucket &bucket);
00068 bool find_ideal_mate(MesherStrip *&mate, Edge *&common_edge,
00069 const BuilderBucket &bucket);
00070 static bool mate_pieces(Edge *common_edge, MesherStrip &front,
00071 MesherStrip &back, const BuilderBucket &bucket);
00072 static bool mate_strips(Edge *common_edge, MesherStrip &front,
00073 MesherStrip &back, BuilderPrimType type);
00074 static bool must_invert(const MesherStrip &front, const MesherStrip &back,
00075 bool will_reverse_back, BuilderPrimType type);
00076 static bool convex_quad(Edge *common_edge, MesherStrip &front,
00077 MesherStrip &back, const BuilderBucket &bucket);
00078
00079 int count_neighbors() const;
00080 ostream &show_neighbors(ostream &out) const;
00081
00082 INLINE bool is_coplanar_with(const MesherStrip &other, float threshold) const;
00083 INLINE float coplanarity(const MesherStrip &other) const;
00084 INLINE int type_category() const;
00085
00086 const Vertex *find_uncommon_vertex(const Edge *edge) const;
00087 const Edge *find_opposite_edge(const Vertex *vertex) const;
00088 const Edge *find_opposite_edge(const Edge *edge) const;
00089 const Edge *find_adjacent_edge(const Edge *edge) const;
00090
00091 INLINE void rotate_forward();
00092 INLINE void rotate_back();
00093 void rotate_to_front(const Edge *edge);
00094 void rotate_to_back(const Edge *edge);
00095 bool can_invert() const;
00096 bool invert();
00097
00098 INLINE Edge get_head_edge() const;
00099 INLINE Edge get_tail_edge() const;
00100
00101 bool is_odd() const;
00102 bool would_reverse_tail(BuilderPrimType wantType) const;
00103 void convert_to_type(BuilderPrimType wantType);
00104
00105 void combine_edges(MesherStrip<PrimType> &other, int removeSides);
00106 void remove_all_edges();
00107
00108
00109 INLINE bool operator == (const MesherStrip &other) const;
00110 INLINE bool operator != (const MesherStrip &other) const;
00111
00112 bool pick_mate(const MesherStrip &a_strip, const MesherStrip &b_strip,
00113 const Edge &a_edge, const Edge &b_edge,
00114 const BuilderBucket &bucket) const;
00115
00116 bool pick_sheet_mate(const MesherStrip &a_strip,
00117 const MesherStrip &b_strip) const;
00118
00119 ostream &output(ostream &out) const;
00120
00121 typedef plist<SAttrib> Prims;
00122 typedef plist<Edge *> Edges;
00123 typedef plist<const Vertex *> Verts;
00124
00125 Prims _prims;
00126 Edges _edges;
00127 Verts _verts;
00128
00129 BuilderPrimType _type;
00130 int _index;
00131 MesherStripStatus _status;
00132
00133 int _planar;
00134 LVector3f _plane_normal;
00135 float _plane_offset;
00136 int _row_id, _row_distance;
00137 int _origin;
00138 };
00139
00140 template <class PrimType>
00141 INLINE ostream &operator << (ostream &out,
00142 const MesherStrip<PrimType> &strip) {
00143 return strip.output(out);
00144 }
00145
00146 #include "mesherStrip.I"
00147
00148 #endif