15 std::array<int, 6> neighbors;
23 std::array<int, 18> neighbors;
31 std::array<int, 26> neighbors;
38 std::array<std::array<int, 3>, 6> neighbors;
40 Dilate(6, &neighbors[0], inImage, outImage);
46 std::array<std::array<int, 3>, 18> neighbors;
48 Dilate(18, &neighbors[0], inImage, outImage);
54 std::array<std::array<int, 3>, 26> neighbors;
56 Dilate(26, &neighbors[0], inImage, outImage);
67 for (i1 = 0; i1 < dim1; ++i1)
69 for (i0 = 0; i0 < dim0; ++i0)
72 for (i2min = 0; i2min < dim2; ++i2min)
74 if ((temp(i0, i1, i2min) & 1) == 0)
76 temp(i0, i1, i2min) |= 2;
86 for (i2max = dim2 - 1; i2max >= i2min; --i2max)
88 if ((temp(i0, i1, i2max) & 1) == 0)
90 temp(i0, i1, i2max) |= 2;
101 for (i2 = 0; i2 < dim2; ++i2)
103 for (i0 = 0; i0 < dim0; ++i0)
106 for (i1min = 0; i1min < dim1; ++i1min)
108 if ((temp(i0, i1min, i2) & 1) == 0)
110 temp(i0, i1min, i2) |= 2;
120 for (i1max = dim1 - 1; i1max >= i1min; --i1max)
122 if ((temp(i0, i1max, i2) & 1) == 0)
124 temp(i0, i1max, i2) |= 2;
135 for (i2 = 0; i2 < dim2; ++i2)
137 for (i1 = 0; i1 < dim1; ++i1)
140 for (i0min = 0; i0min < dim0; ++i0min)
142 if ((temp(i0min, i1, i2) & 1) == 0)
144 temp(i0min, i1, i2) |= 2;
154 for (i0max = dim0 - 1; i0max >= i0min; --i0max)
156 if ((temp(i0max, i1, i2) & 1) == 0)
158 temp(i0max, i1, i2) |= 2;
171 image[i] = (temp[i] & 2 ? 0 : 1);
176 std::function<
void(
int,
int,
int)>
const& callback)
182 int dx = x1-
x0, dy = y1-
y0, dz = z1-z0;
185 int sx = (dx > 0 ? 1 : (dx < 0 ? -1 : 0));
186 int sy = (dy > 0 ? 1 : (dy < 0 ? -1 : 0));
187 int sz = (dz > 0 ? 1 : (dz < 0 ? -1 : 0));
202 int ax = 2*dx, ay = 2*dy, az = 2*dz;
203 int decX, decY, decZ;
206 int maxValue = dx, var = 0;
223 for (; ; x += sx, decY += ay, decZ += az)
248 for (; ; y += sy, decX += ax, decZ += az)
273 for (; ; z += sz, decX += ax, decY += ay)
304 for (
int i2 = 1; i2 < bound2M1; ++i2)
306 for (
int i1 = 1; i1 < bound1M1; ++i1)
308 for (
int i0 = 1; i0 < bound0M1; ++i0)
310 if (inImage(i0, i1, i2) == 0)
312 for (
int n = 0;
n < numNeighbors; ++
n)
314 int d0 = delta[
n][0];
315 int d1 = delta[
n][1];
316 int d2 = delta[
n][2];
317 if (inImage(i0 + d0, i1 + d1, i2 + d2) == 1)
319 outImage(i0, i1, i2) = 1;
326 outImage(i0, i1, i2) = 1;
337 std::vector<int> numElements(numVoxels);
338 std::vector<size_t> vstack(numVoxels);
339 size_t i, numComponents = 0;
341 for (i = 0; i < numVoxels; ++i)
348 int&
count = numElements[numComponents + 1];
352 size_t v = vstack[
top];
355 for (j = 0; j < numNeighbors; ++j)
357 size_t adj = v + delta[j];
364 if (j == numNeighbors)
377 if (numComponents > 0)
380 for (i = 1; i <= numComponents; ++i)
386 for (i = 0; i < numVoxels; ++i)
388 int value = image[i];
395 ++numElements[
value];
static void GetComponents6(Image3< int > &image, std::vector< std::vector< size_t >> &components)
static void Dilate6(Image3< int > const &inImage, Image3< int > &outImage)
int GetDimension(int d) const
GLenum GLenum GLsizei void * image
GLsizei const GLfloat * value
static void Dilate26(Image3< int > const &inImage, Image3< int > &outImage)
static void GetComponents18(Image3< int > &image, std::vector< std::vector< size_t >> &components)
void GetNeighborhood(std::array< int, 6 > &nbr) const
GLuint GLsizei const GLchar * label
size_t GetNumPixels() const
static void GetComponents26(Image3< int > &image, std::vector< std::vector< size_t >> &components)
static void Dilate18(Image3< int > const &inImage, Image3< int > &outImage)
GLdouble GLdouble GLdouble z
static void GetComponents(int numNeighbors, int const *delta, Image3< int > &image, std::vector< std::vector< size_t >> &components)
GLuint GLfloat GLfloat GLfloat x1
static void ComputeCDConvex(Image3< int > &image)
GLenum GLenum GLuint components
GLuint GLfloat GLfloat y0
static void DrawLine(int x0, int y0, int z0, int x1, int y1, int z1, std::function< void(int, int, int)> const &callback)
GLdouble GLdouble GLdouble GLdouble top
static void Dilate(int numNeighbors, std::array< int, 3 > const *delta, Image3< int > const &inImage, Image3< int > &outImage)