vee_marching_cubes.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /* COPYRIGHT
00004  *
00005  * This file is part of the Visual Effects Engine - VEE
00006  *
00007  * Read the "VEE-LICENSE" file for the license.
00008  *
00009  * Authors & Copyright:   
00010  *
00011  * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 
00012  * Janne Kontkanen 2001-2004
00013  *
00014  * Additional copyrights: Tekes 2003-2004
00015  *
00016  * firstname.lastname@hut.fi
00017  *
00018  */
00019 
00020 #ifndef VEE_MARCHING_CUBES_H
00021 #define VEE_MARCHING_CUBES_H
00022 
00023 #include <vee_vector3.h>
00024 
00025 #include <mj_array3d.h>
00026 
00027 #include <vector>
00028 
00029 class VEE_VolumeGrid2;
00030 
00031 class VEE_MarchingCubes
00032 {
00033 public:
00034   class Triangle
00035   {
00036   public:
00037     VEE_Vector3 m_vertices[3];
00038   };
00039 
00040   VEE_MarchingCubes();
00041   ~VEE_MarchingCubes();
00042   
00043   void triangulateGrid(const MJ_Array3D<float> &field, float threshold = 0.5);
00044 
00045   void triangulateSubGrid(VEE_VolumeGrid2 *grid, 
00046         int xmin, int ymin, int zmin,
00047         int xmax, int ymax, int zmax,
00048         float threshold = 0.5);
00049 
00050   const Triangle & triangle(uint i) const { return m_triangles[i]; }
00051   uint triangleCount() const { return m_triCount; }
00052 
00053   void clear() { m_triCount = 0; }
00054 
00055 protected:
00056 
00057   inline void addTri(const Triangle &tri)
00058   {
00059     if(m_triCount >= m_triangles.size())
00060       m_triangles.resize(m_triCount + 10);
00061     m_triangles[m_triCount++] = tri;
00062   }
00063 
00064   inline void handleCube(VEE_VolumeGrid2 *field, float threshold,
00065        int x, int y, int z);
00066 
00067   inline void handleCube(const MJ_Array3D<float> &, float threshold,
00068        uint x, uint y, uint z);
00069 
00070   std::vector<Triangle> m_triangles;
00071   uint m_triCount;
00072 };
00073 
00074 #endif

Generated on Mon Mar 12 21:09:00 2007 for VEE - The Visual Effects Engine by  doxygen 1.4.6