Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Vertex.h

00001 // Mesh Algorithms: a library of algorithms to manipulate 3D meshes
00002 // Copyright (C) 2001 Tim Garthwaite and Jason Reposa
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 #ifndef VERTEX_H
00019 #define VERTEX_H
00020 
00021 class Vertex;
00022 
00023 #include "options.h"
00024 #include <iostream>
00025 #include <vector>
00026 #include <set>
00027 #include <cmath>
00028 #include "Triangle.h"
00029 #include "Color.h"
00030 #include "Normal.h"
00031 #include "Point.h"
00032 #include <GL/gl.h>
00033 
00035 class Vertex : public Point {
00037   std::set <Triangle *> triangles;
00038 
00040   std::set <Vertex *> neighbors;
00041 
00043   std::set <Triangle *> shared;
00044 
00046   GLfloat distance;
00047 
00049   Color color;
00050 
00052   Normal normal;
00053 
00055   bool corner;
00056 
00058   GLint ID;
00059 
00061   GLvoid calculateNormal();
00062 
00064   GLvoid calculateDistance();
00065 
00066  public:
00067 
00069   Vertex(
00070     float x, 
00071     float y, 
00072     float z, 
00073     float w = 1.0 
00074   );
00075 
00077   GLfloat getDistance();
00078 
00080   bool isCorner();
00081   
00083   GLvoid isCorner(bool b);
00084 
00086   GLvoid addNeighbor(Vertex * v);
00087 
00089   GLvoid addTriangle(Triangle * t);
00090 
00092   bool removeNeighbor(Vertex * v);
00093 
00095   bool removeTriangle(Triangle * t);
00096 
00098   GLvoid setColor(Color * c);
00099 
00101   GLvoid setNormal(Normal * n);
00102 
00104   bool replace(Vertex * v1, Vertex * v2);
00105 
00107   bool contains(Vertex * v);
00108 
00110   bool contains(Triangle * t);
00111 
00113   Color * getColor();
00114 
00116   Normal * getNormal();
00117 
00119   std::set <Triangle *> * getTriangles();
00120 
00122   std::set <Vertex *> * getNeighbors();
00123 
00125   std::string toString();
00126 
00128   GLint getID();
00129 
00131   GLvoid setID(GLint id);
00132   
00134   std::set <Triangle *> * getSharedTriangles(Vertex * v);
00135 };
00136 
00137 struct less_than_distance {
00138   bool operator () (Vertex * v0, Vertex * v1) const {
00139     return (v0->getDistance() < v1->getDistance());
00140   }
00141 };
00142 
00143 typedef std::set <Vertex *> VS;
00144 typedef std::set <Vertex *>::iterator VSI;
00145 
00146 #endif

Generated on Fri Dec 21 00:16:49 2001 for Mesh Decimation by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001