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

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18