00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MESHERTEMPL_H
00019 #define MESHERTEMPL_H
00020
00021 #include <pandabase.h>
00022
00023 #include "mesherConfig.h"
00024 #include "builderBucket.h"
00025 #include "mesherEdge.h"
00026 #include "mesherStrip.h"
00027
00028 #include "pvector.h"
00029 #include "plist.h"
00030 #include "pset.h"
00031 #include "pmap.h"
00032
00033 template <class PrimType>
00034 class MesherFanMaker;
00035
00036 template <class PrimType>
00037 class MesherTempl {
00038 public:
00039 typedef PrimType Prim;
00040 typedef TYPENAME PrimType::Vertex Vertex;
00041 typedef TYPENAME PrimType::DAttrib MAttrib;
00042 typedef MesherEdge<PrimType> Edge;
00043 typedef MesherStrip<PrimType> Strip;
00044 typedef MesherFanMaker<PrimType> FanMaker;
00045
00046 MesherTempl(BuilderBucket *bucket);
00047
00048 int add_prim(const Prim &prim, MesherStripOrigin origin = MO_user);
00049 void mesh();
00050 Prim getPrim();
00051
00052 void finalize();
00053
00054 void show(ostream &out);
00055
00056 protected:
00057 typedef plist<Strip> Strips;
00058 typedef pset<Edge, less<Edge> > Edges;
00059 typedef pset<Edge *, less<Edge *> > EdgePtrs;
00060 typedef pmap<Vertex, EdgePtrs, less<Vertex> > Verts;
00061
00062
00063 typedef pvector<BuilderC> Colors;
00064
00065 typedef pmap<int, int, less<int> > ColorSheetMap;
00066
00067 int count_vert_edges(const EdgePtrs &edges) const;
00068 plist<Strip> &choose_strip_list(const Strip &strip);
00069
00070 void build_sheets();
00071 void find_fans();
00072 void make_quads();
00073 void meshList(Strips &strips);
00074
00075 Strips _tris, _quads, _strips;
00076 Strips _dead, _done;
00077 Verts _verts;
00078 Edges _edges;
00079 int _stripIndex;
00080 BuilderBucket *_bucket;
00081 TYPENAME Strips::iterator _next_strip;
00082 Colors _colors;
00083 ColorSheetMap _color_sheets;
00084
00085 friend class MesherStrip<PrimType>;
00086 friend class MesherFanMaker<PrimType>;
00087 };
00088
00089 #include "mesherTempl.I"
00090
00091 #endif