Point Cloud Library (PCL)  1.9.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 <vector>
33 #include "geometry.h"
34 
35 
36 namespace pcl
37 {
38  namespace poisson
39  {
40 
41  class PCL_EXPORTS Square
42  {
43  public:
44  enum { CORNERS=4,EDGES=4,NEIGHBORS=4 };
45  static int CornerIndex (int x,int y);
46  static int AntipodalCornerIndex(int idx);
47  static void FactorCornerIndex (int idx,int& x,int& y);
48  static int EdgeIndex (int orientation,int i);
49  static void FactorEdgeIndex (int idx,int& orientation,int& i);
50 
51  static int ReflectCornerIndex (int idx,int edgeIndex);
52  static int ReflectEdgeIndex (int idx,int edgeIndex);
53 
54  static void EdgeCorners(int idx,int& c1,int &c2);
55  };
56 
57  class PCL_EXPORTS Cube
58  {
59  public:
60  enum { CORNERS=8,EDGES=12,NEIGHBORS=6 };
61 
62  static int CornerIndex (int x,int y,int z);
63  static void FactorCornerIndex (int idx,int& x,int& y,int& z);
64  static int EdgeIndex (int orientation,int i,int j);
65  static void FactorEdgeIndex (int idx,int& orientation,int& i,int &j);
66  static int FaceIndex (int dir,int offSet);
67  static int FaceIndex (int x,int y,int z);
68  static void FactorFaceIndex (int idx,int& x,int &y,int& z);
69  static void FactorFaceIndex (int idx,int& dir,int& offSet);
70 
71  static int AntipodalCornerIndex (int idx);
72  static int FaceReflectCornerIndex (int idx,int faceIndex);
73  static int FaceReflectEdgeIndex (int idx,int faceIndex);
74  static int FaceReflectFaceIndex (int idx,int faceIndex);
75  static int EdgeReflectCornerIndex (int idx,int edgeIndex);
76  static int EdgeReflectEdgeIndex (int edgeIndex);
77 
78  static int FaceAdjacentToEdges (int eIndex1,int eIndex2);
79  static void FacesAdjacentToEdge (int eIndex,int& f1Index,int& f2Index);
80 
81  static void EdgeCorners(int idx,int& c1,int &c2);
82  static void FaceCorners(int idx,int& c1,int &c2,int& c3,int& c4);
83  };
84 
85  class PCL_EXPORTS MarchingSquares
86  {
87  static double Interpolate(double v1,double v2);
88  static void SetVertex(int e,const double values[Square::CORNERS],double iso);
89  public:
90  enum { MAX_EDGES=2 };
91  static const int* edgeMask();
92  static int edges(int i, int j);
93  static double& vertexList(int i, int j);
94 
95  static int GetIndex(const double values[Square::CORNERS],double iso);
96  static int IsAmbiguous(const double v[Square::CORNERS],double isoValue);
97  static int AddEdges(const double v[Square::CORNERS],double isoValue,Edge* edges);
98  static int AddEdgeIndices(const double v[Square::CORNERS],double isoValue,int* edges);
99  };
100 
101  class PCL_EXPORTS MarchingCubes
102  {
103  static void SetVertex(int e,const double values[Cube::CORNERS],double iso);
104  static int GetFaceIndex(const double values[Cube::CORNERS],double iso,int faceIndex);
105 
106  static void SetVertex(int e,const float values[Cube::CORNERS],float iso);
107  static int GetFaceIndex(const float values[Cube::CORNERS],float iso,int faceIndex);
108 
109  static int GetFaceIndex(int mcIndex,int faceIndex);
110  public:
111  static double Interpolate(double v1,double v2);
112  static float Interpolate(float v1,float v2);
113  enum { MAX_TRIANGLES=5 };
114  static const int* edgeMask();
115  static int triangles(int i, int j);
116  static const int* cornerMap();
117  static double& vertexList(int i, int j);
118 
119  static int AddTriangleIndices(int mcIndex,int* triangles);
120 
121  static int GetIndex(const double values[Cube::CORNERS],double iso);
122  static int IsAmbiguous(const double v[Cube::CORNERS],double isoValue,int faceIndex);
123  static int HasRoots(const double v[Cube::CORNERS],double isoValue);
124  static int HasRoots(const double v[Cube::CORNERS],double isoValue,int faceIndex);
125  static int AddTriangles(const double v[Cube::CORNERS],double isoValue,Triangle* triangles);
126  static int AddTriangleIndices(const double v[Cube::CORNERS],double isoValue,int* triangles);
127 
128  static int GetIndex(const float values[Cube::CORNERS],float iso);
129  static int IsAmbiguous(const float v[Cube::CORNERS],float isoValue,int faceIndex);
130  static int HasRoots(const float v[Cube::CORNERS],float isoValue);
131  static int HasRoots(const float v[Cube::CORNERS],float isoValue,int faceIndex);
132  static int AddTriangles(const float v[Cube::CORNERS],float isoValue,Triangle* triangles);
133  static int AddTriangleIndices(const float v[Cube::CORNERS],float isoValue,int* triangles);
134 
135  static int IsAmbiguous(int mcIndex,int faceIndex);
136  static int HasRoots(int mcIndex);
137  static int HasFaceRoots(int mcIndex,int faceIndex);
138  static int HasEdgeRoots(int mcIndex,int edgeIndex);
139  };
140  }
141 }
142 
143 
144 #endif //MARCHING_CUBES_INCLUDED
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45