00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MARCHING_CUBES_INCLUDED
00030 #define MARCHING_CUBES_INCLUDED
00031 #include <pcl/pcl_macros.h>
00032 #include <vector>
00033 #include "geometry.h"
00034
00035
00036 namespace pcl
00037 {
00038 namespace poisson
00039 {
00040
00041 class PCL_EXPORTS Square
00042 {
00043 public:
00044 enum { CORNERS=4,EDGES=4,NEIGHBORS=4 };
00045 static int CornerIndex (int x,int y);
00046 static int AntipodalCornerIndex(int idx);
00047 static void FactorCornerIndex (int idx,int& x,int& y);
00048 static int EdgeIndex (int orientation,int i);
00049 static void FactorEdgeIndex (int idx,int& orientation,int& i);
00050
00051 static int ReflectCornerIndex (int idx,int edgeIndex);
00052 static int ReflectEdgeIndex (int idx,int edgeIndex);
00053
00054 static void EdgeCorners(int idx,int& c1,int &c2);
00055 };
00056
00057 class PCL_EXPORTS Cube
00058 {
00059 public:
00060 enum { CORNERS=8,EDGES=12,NEIGHBORS=6 };
00061
00062 static int CornerIndex (int x,int y,int z);
00063 static void FactorCornerIndex (int idx,int& x,int& y,int& z);
00064 static int EdgeIndex (int orientation,int i,int j);
00065 static void FactorEdgeIndex (int idx,int& orientation,int& i,int &j);
00066 static int FaceIndex (int dir,int offSet);
00067 static int FaceIndex (int x,int y,int z);
00068 static void FactorFaceIndex (int idx,int& x,int &y,int& z);
00069 static void FactorFaceIndex (int idx,int& dir,int& offSet);
00070
00071 static int AntipodalCornerIndex (int idx);
00072 static int FaceReflectCornerIndex (int idx,int faceIndex);
00073 static int FaceReflectEdgeIndex (int idx,int faceIndex);
00074 static int FaceReflectFaceIndex (int idx,int faceIndex);
00075 static int EdgeReflectCornerIndex (int idx,int edgeIndex);
00076 static int EdgeReflectEdgeIndex (int edgeIndex);
00077
00078 static int FaceAdjacentToEdges (int eIndex1,int eIndex2);
00079 static void FacesAdjacentToEdge (int eIndex,int& f1Index,int& f2Index);
00080
00081 static void EdgeCorners(int idx,int& c1,int &c2);
00082 static void FaceCorners(int idx,int& c1,int &c2,int& c3,int& c4);
00083 };
00084
00085 class PCL_EXPORTS MarchingSquares
00086 {
00087 static double Interpolate(double v1,double v2);
00088 static void SetVertex(int e,const double values[Square::CORNERS],double iso);
00089 public:
00090 enum { MAX_EDGES=2 };
00091 static const int* edgeMask();
00092 static int edges(int i, int j);
00093 static double& vertexList(int i, int j);
00094
00095 static int GetIndex(const double values[Square::CORNERS],double iso);
00096 static int IsAmbiguous(const double v[Square::CORNERS],double isoValue);
00097 static int AddEdges(const double v[Square::CORNERS],double isoValue,Edge* edges);
00098 static int AddEdgeIndices(const double v[Square::CORNERS],double isoValue,int* edges);
00099 };
00100
00101 class PCL_EXPORTS MarchingCubes
00102 {
00103 static void SetVertex(int e,const double values[Cube::CORNERS],double iso);
00104 static int GetFaceIndex(const double values[Cube::CORNERS],double iso,int faceIndex);
00105
00106 static void SetVertex(int e,const float values[Cube::CORNERS],float iso);
00107 static int GetFaceIndex(const float values[Cube::CORNERS],float iso,int faceIndex);
00108
00109 static int GetFaceIndex(int mcIndex,int faceIndex);
00110 public:
00111 static double Interpolate(double v1,double v2);
00112 static float Interpolate(float v1,float v2);
00113 enum { MAX_TRIANGLES=5 };
00114 static const int* edgeMask();
00115 static int triangles(int i, int j);
00116 static const int* cornerMap();
00117 static double& vertexList(int i, int j);
00118
00119 static int AddTriangleIndices(int mcIndex,int* triangles);
00120
00121 static int GetIndex(const double values[Cube::CORNERS],double iso);
00122 static int IsAmbiguous(const double v[Cube::CORNERS],double isoValue,int faceIndex);
00123 static int HasRoots(const double v[Cube::CORNERS],double isoValue);
00124 static int HasRoots(const double v[Cube::CORNERS],double isoValue,int faceIndex);
00125 static int AddTriangles(const double v[Cube::CORNERS],double isoValue,Triangle* triangles);
00126 static int AddTriangleIndices(const double v[Cube::CORNERS],double isoValue,int* triangles);
00127
00128 static int GetIndex(const float values[Cube::CORNERS],float iso);
00129 static int IsAmbiguous(const float v[Cube::CORNERS],float isoValue,int faceIndex);
00130 static int HasRoots(const float v[Cube::CORNERS],float isoValue);
00131 static int HasRoots(const float v[Cube::CORNERS],float isoValue,int faceIndex);
00132 static int AddTriangles(const float v[Cube::CORNERS],float isoValue,Triangle* triangles);
00133 static int AddTriangleIndices(const float v[Cube::CORNERS],float isoValue,int* triangles);
00134
00135 static int IsAmbiguous(int mcIndex,int faceIndex);
00136 static int HasRoots(int mcIndex);
00137 static int HasFaceRoots(int mcIndex,int faceIndex);
00138 static int HasEdgeRoots(int mcIndex,int edgeIndex);
00139 };
00140 }
00141 }
00142
00143
00144 #endif //MARCHING_CUBES_INCLUDED