Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ISVertex.H

Go to the documentation of this file.
00001 
00010 #ifndef ISVERTEX_H
00011 #define ISVERTEX_H
00012 
00013 #include "Color.H"
00014 
00015 // Gluebase includes
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   // setting location
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   // attributes
00062   void setMesh(ISMesh *m);
00063   void setColor(Color c);
00064   void setTexCoords(float u, float v);
00065   void setNormal(cWvec& n);
00066 
00067   // accessors
00068   cWpt&  loc()       const {return _loc; }
00069   cWvec& norm()      const {return _norm; }
00070   Color  color()     { return _color; }
00071   float* texcoords() { return _texcoords; }
00072 
00073   // ** added 02.09.03 amcclain ****
00074   int numAdjEdges() { return _adjEdges.num(); }
00075 
00076   // adjacency routines
00077   
00078   // return adjacent edge number k
00079   ISEdge* adjEdge(int k) const { return _adjEdges[k]; }
00080   // return neighboring ISVertex number k
00081   ISVertex* neighborVert(int k);
00082   // return the edge connecting this to a given ISVertex
00083   ISEdge* lookupEdge(ISVertex *v);
00084   // tell if this is adjacent to the given ISVertex
00085   int isAdjacent(ISVertex *v);
00086 
00087 
00088   // building / redefining edge list
00089 
00090   // register a new adjacent edge
00091   void addEdge(ISEdge *e) { _adjEdges += e; }
00092   // remove an edge that is disconnecting from this ISVertex
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   // output
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;          // location of ISVertex
00111   ARRAY<ISEdge*> _adjEdges;     // list of adjacent edges
00112   Color        _color;        // color of ISVertex
00113   Wvec         _norm;         // ISVertex normal
00114   float        _texcoords[2]; // texture coordinates (expand to 3D later)
00115   ISMesh*      _mesh;         // the mesh that this ISVertex belongs to
00116 };
00117 
00118 }
00119 #endif
00120 
00121 
00122 
00123 

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4