00001
00010 #ifndef ISVERTEX_H
00011 #define ISVERTEX_H
00012
00013 #include "Color.H"
00014
00015
00016 #define OUTSIDE_GLUE_CORE
00017 #include <std/hash.H>
00018 #include <mlib/points.H>
00019
00020
00021 class ISEdge;
00022 class ISMesh;
00023
00024 class ISVertex
00025 {
00026 public:
00027
00028 ISVertex(cWpt &p=Origin) : _adjEdges(6) {
00029 _loc = p;
00030 _norm = Wvec(0.,0.,0.);
00031 _color = Color(1.0,1.0,1.0);
00032 _texcoords[0] = 0.0;
00033 _texcoords[1] = 0.0;
00034 _mesh = NULL;
00035 };
00036 ISVertex(cWpt &p, cWvec &n) : _adjEdges(6) {
00037 _loc = p;
00038 _norm = n;
00039 _color = Color(1.0,1.0,1.0);
00040 _texcoords[0] = 0.0;
00041 _texcoords[1] = 0.0;
00042 _mesh = NULL;
00043 };
00044 ISVertex(double x, double y, double z) : _adjEdges(6) {
00045 _loc = Wpt(x,y,z);
00046 _norm = Wvec(0.,0.,0.);
00047 _color = Color(1.0,1.0,1.0);
00048 _texcoords[0] = 0.0;
00049 _texcoords[1] = 0.0;
00050 _mesh = NULL;
00051 };
00052
00053 virtual ~ISVertex() {};
00054
00055
00056 void moveTo(cWpt& p) { _loc = p; }
00057 void offsetLoc(cWvec& v) { moveTo(_loc + v); }
00058 void transform(cWtransf& xform) { moveTo(xform * _loc); }
00059
00060
00061 void setMesh(ISMesh *m);
00062 void setColor(Color c);
00063 void setTexCoords(float u, float v);
00064 void setNormal(cWvec& n);
00065
00066
00067 cWpt& loc() const {return _loc; }
00068 cWvec& norm() const {return _norm; }
00069 Color color() { return _color; }
00070 float* texcoords() { return _texcoords; }
00071
00072
00073 int numAdjEdges() { return _adjEdges.num(); }
00074
00075
00076
00077
00078 ISEdge* adjEdge(int k) const { return _adjEdges[k]; }
00079
00080 ISVertex* neighborVert(int k);
00081
00082 ISEdge* lookupEdge(ISVertex *v);
00083
00084 int isAdjacent(ISVertex *v);
00085
00086
00087
00088
00089
00090 void addEdge(ISEdge *e) { _adjEdges += e; }
00091
00092 int removeEdge(ISEdge *e) {
00093 int ret = (_adjEdges -= e);
00094 if (!ret)
00095 cerr << "ISVertex Error: cannot remove edge!" << endl;
00096 return ret;
00097 }
00098
00099
00100
00101 friend ostream &operator <<(ostream &os, ISVertex v) {
00102 return os << "loc: (" << v.loc()[0] << ", "
00103 << v.loc()[1] << ", "
00104 << v.loc()[2] << ")";
00105 }
00106
00107 protected:
00108
00109 Wpt _loc;
00110 ARRAY<ISEdge*> _adjEdges;
00111 Color _color;
00112 Wvec _norm;
00113 float _texcoords[2];
00114 ISMesh* _mesh;
00115 };
00116
00117 #endif
00118
00119
00120
00121