00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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