00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGVERTEXPOOL_H
00020 #define EGGVERTEXPOOL_H
00021
00022 #include <pandabase.h>
00023
00024 #include "eggVertex.h"
00025 #include "eggNode.h"
00026 #include "pt_EggVertex.h"
00027
00028 #include <pointerTo.h>
00029 #include "pset.h"
00030 #include "pmap.h"
00031 #include <lmatrix.h>
00032 #include <iterator_types.h>
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 class EXPCL_PANDAEGG EggVertexPool : public EggNode {
00050
00051
00052
00053
00054
00055 private:
00056
00057
00058
00059 typedef pmap<int, PT_EggVertex> IndexVertices;
00060
00061
00062
00063
00064
00065
00066 typedef pmultiset<EggVertex *, UniqueEggVertices> UniqueVertices;
00067
00068 public:
00069 typedef second_of_pair_iterator<IndexVertices::const_iterator> iterator;
00070 typedef iterator const_iterator;
00071 typedef IndexVertices::size_type size_type;
00072
00073
00074
00075 public:
00076 EggVertexPool(const string &name);
00077 EggVertexPool(const EggVertexPool ©);
00078 ~EggVertexPool();
00079
00080
00081 EggVertex *get_vertex(int index) const;
00082 INLINE EggVertex *operator [](int index) const;
00083
00084
00085 int get_highest_index() const;
00086
00087
00088 iterator begin() const;
00089 iterator end() const;
00090 bool empty() const;
00091 size_type size() const;
00092
00093
00094
00095 void add_vertex(EggVertex *vertex, int index = -1);
00096
00097
00098
00099 INLINE EggVertex *make_new_vertex();
00100 INLINE EggVertex *make_new_vertex(double pos);
00101 INLINE EggVertex *make_new_vertex(const LPoint2d &pos);
00102 INLINE EggVertex *make_new_vertex(const LPoint3d &pos);
00103 INLINE EggVertex *make_new_vertex(const LPoint4d &pos);
00104
00105
00106
00107
00108 EggVertex *create_unique_vertex(const EggVertex ©);
00109
00110 void remove_vertex(EggVertex *vertex);
00111 int remove_unused_vertices();
00112
00113 void transform(const LMatrix4d &mat);
00114
00115 void write(ostream &out, int indent_level) const;
00116
00117 protected:
00118 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
00119 CoordinateSystem to_cs);
00120 virtual void r_transform_vertices(const LMatrix4d &mat);
00121
00122 private:
00123 UniqueVertices _unique_vertices;
00124 IndexVertices _index_vertices;
00125
00126
00127 public:
00128
00129 static TypeHandle get_class_type() {
00130 return _type_handle;
00131 }
00132 static void init_type() {
00133 EggNode::init_type();
00134 register_type(_type_handle, "EggVertexPool",
00135 EggNode::get_class_type());
00136 }
00137 virtual TypeHandle get_type() const {
00138 return get_class_type();
00139 }
00140 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00141
00142 private:
00143 static TypeHandle _type_handle;
00144
00145 friend class EggVertex;
00146 };
00147
00148 #include "eggVertexPool.I"
00149
00150 #endif