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