Point Cloud Library (PCL)  1.14.1-dev
marching_cubes_poisson.h
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer. Redistributions in binary form must reproduce
10 the above copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the distribution.
12 
13 Neither the name of the Johns Hopkins University nor the names of its contributors
14 may be used to endorse or promote products derived from this software without specific
15 prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 */
28 
29 #ifndef MARCHING_CUBES_INCLUDED
30 #define MARCHING_CUBES_INCLUDED
31 #include <pcl/pcl_macros.h>
32 #include "geometry.h"
33 
34 
35 namespace pcl
36 {
37  namespace poisson
38  {
39 
41  {
42  public:
43  enum { CORNERS=4,EDGES=4,NEIGHBORS=4 };
44  static int CornerIndex (int x,int y);
45  static int AntipodalCornerIndex(int idx);
46  static void FactorCornerIndex (int idx,int& x,int& y);
47  static int EdgeIndex (int orientation,int i);
48  static void FactorEdgeIndex (int idx,int& orientation,int& i);
49 
50  static int ReflectCornerIndex (int idx,int edgeIndex);
51  static int ReflectEdgeIndex (int idx,int edgeIndex);
52 
53  static void EdgeCorners(int idx,int& c1,int &c2);
54  };
55 
57  {
58  public:
59  enum { CORNERS=8,EDGES=12,NEIGHBORS=6 };
60 
61  static int CornerIndex (int x,int y,int z);
62  static void FactorCornerIndex (int idx,int& x,int& y,int& z);
63  static int EdgeIndex (int orientation,int i,int j);
64  static void FactorEdgeIndex (int idx,int& orientation,int& i,int &j);
65  static int FaceIndex (int dir,int offSet);
66  static int FaceIndex (int x,int y,int z);
67  static void FactorFaceIndex (int idx,int& x,int &y,int& z);
68  static void FactorFaceIndex (int idx,int& dir,int& offSet);
69 
70  static int AntipodalCornerIndex (int idx);
71  static int FaceReflectCornerIndex (int idx,int faceIndex);
72  static int FaceReflectEdgeIndex (int idx,int faceIndex);
73  static int FaceReflectFaceIndex (int idx,int faceIndex);
74  static int EdgeReflectCornerIndex (int idx,int edgeIndex);
75  static int EdgeReflectEdgeIndex (int edgeIndex);
76 
77  static int FaceAdjacentToEdges (int eIndex1,int eIndex2);
78  static void FacesAdjacentToEdge (int eIndex,int& f1Index,int& f2Index);
79 
80  static void EdgeCorners(int idx,int& c1,int &c2);
81  static void FaceCorners(int idx,int& c1,int &c2,int& c3,int& c4);
82  };
83 
85  {
86  static double Interpolate(double v1,double v2);
87  static void SetVertex(int e,const double values[Square::CORNERS],double iso);
88  public:
89  enum { MAX_EDGES=2 };
90  static const int* edgeMask();
91  static int edges(int i, int j);
92  static double& vertexList(int i, int j);
93 
94  static int GetIndex(const double values[Square::CORNERS],double iso);
95  static int IsAmbiguous(const double v[Square::CORNERS],double isoValue);
96  static int AddEdges(const double v[Square::CORNERS],double isoValue,Edge* edges);
97  static int AddEdgeIndices(const double v[Square::CORNERS],double isoValue,int* edges);
98  };
99 
101  {
102  static void SetVertex(int e,const double values[Cube::CORNERS],double iso);
103  static int GetFaceIndex(const double values[Cube::CORNERS],double iso,int faceIndex);
104 
105  static void SetVertex(int e,const float values[Cube::CORNERS],float iso);
106  static int GetFaceIndex(const float values[Cube::CORNERS],float iso,int faceIndex);
107 
108  static int GetFaceIndex(int mcIndex,int faceIndex);
109  public:
110  static double Interpolate(double v1,double v2);
111  static float Interpolate(float v1,float v2);
112  enum { MAX_TRIANGLES=5 };
113  static const int* edgeMask();
114  static int triangles(int i, int j);
115  static const int* cornerMap();
116  static double& vertexList(int i, int j);
117 
118  static int AddTriangleIndices(int mcIndex,int* triangles);
119 
120  static int GetIndex(const double values[Cube::CORNERS],double iso);
121  static int IsAmbiguous(const double v[Cube::CORNERS],double isoValue,int faceIndex);
122  static int HasRoots(const double v[Cube::CORNERS],double isoValue);
123  static int HasRoots(const double v[Cube::CORNERS],double isoValue,int faceIndex);
124  static int AddTriangles(const double v[Cube::CORNERS],double isoValue,Triangle* triangles);
125  static int AddTriangleIndices(const double v[Cube::CORNERS],double isoValue,int* triangles);
126 
127  static int GetIndex(const float values[Cube::CORNERS],float iso);
128  static int IsAmbiguous(const float v[Cube::CORNERS],float isoValue,int faceIndex);
129  static int HasRoots(const float v[Cube::CORNERS],float isoValue);
130  static int HasRoots(const float v[Cube::CORNERS],float isoValue,int faceIndex);
131  static int AddTriangles(const float v[Cube::CORNERS],float isoValue,Triangle* triangles);
132  static int AddTriangleIndices(const float v[Cube::CORNERS],float isoValue,int* triangles);
133 
134  static int IsAmbiguous(int mcIndex,int faceIndex);
135  static int HasRoots(int mcIndex);
136  static int HasFaceRoots(int mcIndex,int faceIndex);
137  static int HasEdgeRoots(int mcIndex,int edgeIndex);
138  };
139  }
140 }
141 
142 
143 #endif //MARCHING_CUBES_INCLUDED
static void FactorFaceIndex(int idx, int &dir, int &offSet)
static int FaceReflectEdgeIndex(int idx, int faceIndex)
static int FaceAdjacentToEdges(int eIndex1, int eIndex2)
static void FactorEdgeIndex(int idx, int &orientation, int &i, int &j)
static void FactorCornerIndex(int idx, int &x, int &y, int &z)
static int FaceIndex(int x, int y, int z)
static void FacesAdjacentToEdge(int eIndex, int &f1Index, int &f2Index)
static int FaceReflectFaceIndex(int idx, int faceIndex)
static int EdgeReflectCornerIndex(int idx, int edgeIndex)
static int FaceReflectCornerIndex(int idx, int faceIndex)
static void FaceCorners(int idx, int &c1, int &c2, int &c3, int &c4)
static int AntipodalCornerIndex(int idx)
static int CornerIndex(int x, int y, int z)
static int EdgeIndex(int orientation, int i, int j)
static int FaceIndex(int dir, int offSet)
static int EdgeReflectEdgeIndex(int edgeIndex)
static void FactorFaceIndex(int idx, int &x, int &y, int &z)
static void EdgeCorners(int idx, int &c1, int &c2)
static double Interpolate(double v1, double v2)
static int AddTriangles(const double v[Cube::CORNERS], double isoValue, Triangle *triangles)
static int HasRoots(const float v[Cube::CORNERS], float isoValue)
static int AddTriangles(const float v[Cube::CORNERS], float isoValue, Triangle *triangles)
static float Interpolate(float v1, float v2)
static const int * cornerMap()
static int HasRoots(int mcIndex)
static int AddTriangleIndices(const float v[Cube::CORNERS], float isoValue, int *triangles)
static int IsAmbiguous(int mcIndex, int faceIndex)
static int IsAmbiguous(const float v[Cube::CORNERS], float isoValue, int faceIndex)
static int AddTriangleIndices(int mcIndex, int *triangles)
static int HasRoots(const float v[Cube::CORNERS], float isoValue, int faceIndex)
static int HasEdgeRoots(int mcIndex, int edgeIndex)
static int HasFaceRoots(int mcIndex, int faceIndex)
static int HasRoots(const double v[Cube::CORNERS], double isoValue, int faceIndex)
static double & vertexList(int i, int j)
static int IsAmbiguous(const double v[Cube::CORNERS], double isoValue, int faceIndex)
static int AddTriangleIndices(const double v[Cube::CORNERS], double isoValue, int *triangles)
static int HasRoots(const double v[Cube::CORNERS], double isoValue)
static int GetIndex(const double values[Cube::CORNERS], double iso)
static int GetIndex(const float values[Cube::CORNERS], float iso)
static const int * edgeMask()
static int triangles(int i, int j)
static int GetIndex(const double values[Square::CORNERS], double iso)
static int edges(int i, int j)
static int AddEdges(const double v[Square::CORNERS], double isoValue, Edge *edges)
static double & vertexList(int i, int j)
static const int * edgeMask()
static int IsAmbiguous(const double v[Square::CORNERS], double isoValue)
static int AddEdgeIndices(const double v[Square::CORNERS], double isoValue, int *edges)
static int EdgeIndex(int orientation, int i)
static void FactorEdgeIndex(int idx, int &orientation, int &i)
static int CornerIndex(int x, int y)
static int ReflectCornerIndex(int idx, int edgeIndex)
static void EdgeCorners(int idx, int &c1, int &c2)
static int AntipodalCornerIndex(int idx)
static void FactorCornerIndex(int idx, int &x, int &y)
static int ReflectEdgeIndex(int idx, int edgeIndex)
Defines all the PCL and non-PCL macros used.
#define PCL_EXPORTS
Definition: pcl_macros.h:325