Mesh.h

00001 /*************************************************************************************************
00002  *
00003  * Modeling and animation (TNM079) 2007
00004  * Code base for lab assignments. Copyright:
00005  *   Gunnar Johansson (gunnar.johansson@itn.liu.se)
00006  *   Ken Museth (ken.museth@itn.liu.se)
00007  *   Michael Bang Nielsen (bang@daimi.au.dk)
00008  *   Ola Nilsson (ola.nilsson@itn.liu.se)
00009  *   Andreas Sderstrm (andreas.soderstrom@itn.liu.se)
00010  *
00011  *************************************************************************************************/
00012 #ifndef __MESH_H__
00013 #define __MESH_H__
00014 
00015 #include "Geometry.h"
00016 #include "Vector3.h"
00017 #include "Matrix4x4.h"
00018 #include <vector>
00019 
00020 
00021 class Mesh : public Geometry
00022 {
00023 public:
00024   enum SHADING {SMOOTH_SHADING, FLAT_SHADING};
00025 protected:
00027   virtual bool addVertex(const Vector3<float>& v, unsigned int &indx) = 0;
00028   
00029   // Given a vertex, find all triangles that includes this vertex
00030   virtual bool findNeighbourTriangles(const unsigned int vertexIndex, std::vector<unsigned int>& foundTriangles) const = 0;
00031   
00032   SHADING mShadingFlag;
00033 public: 
00034   Mesh() : mShadingFlag(SMOOTH_SHADING) { }
00035   ~Mesh() { }
00036     
00038   virtual bool addTriangle(const Vector3<float> &v1, const Vector3<float> &v2, const Vector3<float> & v3) = 0;
00039      
00041   virtual float area() const;
00043   virtual float volume() const;
00044 
00046   virtual int genus() const;
00047 
00049   static float triArea(const Vector3<float> &v1, const Vector3<float> &v2, const Vector3<float> & v3);
00050   virtual float curvature(const unsigned int vertexIndex, const Vector3<float>& n) = 0;
00051 
00053   virtual void calculateFaceNormals();
00054   virtual void calculateVertexNormals();
00055   
00057   virtual void draw() = 0;
00058   void setShadingFlag(SHADING s);
00059   SHADING getShadingFlag() const;
00060 };
00061 
00062 
00063 #endif

Generated on Fri Jul 20 23:57:42 2007 for HalfEdge by  doxygen 1.5.1