Skip to content

Commit

Permalink
Merge pull request Kitware#2052 from Kitware/fix_marching_cubes_position
Browse files Browse the repository at this point in the history
fix(Filters): fix marching cubes position/extent error
  • Loading branch information
martinken authored Sep 10, 2021
2 parents ecc7ead + df842e8 commit 0da5564
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sources/Filters/General/ImageMarchingCubes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function vtkImageMarchingCubes(publicAPI, model) {
};

// Retrieve voxel coordinates. i-j-k is origin of voxel.
publicAPI.getVoxelPoints = (i, j, k, dims, origin, spacing) => {
publicAPI.getVoxelPoints = (i, j, k, origin, spacing) => {
// (i,i+1),(j,j+1),(k,k+1) - i varies fastest; then j; then k
voxelPts[0] = origin[0] + i * spacing[0]; // 0
voxelPts[1] = origin[1] + j * spacing[1];
Expand Down Expand Up @@ -198,6 +198,7 @@ function vtkImageMarchingCubes(publicAPI, model) {
i,
j,
k,
extent,
slice,
dims,
origin,
Expand Down Expand Up @@ -229,7 +230,13 @@ function vtkImageMarchingCubes(publicAPI, model) {
return; // don't get the voxel coordinates, nothing to do
}

publicAPI.getVoxelPoints(i, j, k, dims, origin, spacing);
publicAPI.getVoxelPoints(
i + extent[0],
j + extent[2],
k + extent[4],
origin,
spacing
);
if (model.computeNormals) {
publicAPI.getVoxelGradients(i, j, k, dims, slice, spacing, scalars);
}
Expand Down Expand Up @@ -320,6 +327,7 @@ function vtkImageMarchingCubes(publicAPI, model) {
const nBuffer = [];

// Loop over all voxels, determine case and process
const extent = input.getExtent();
const slice = dims[0] * dims[1];
for (let k = 0; k < dims[2] - 1; ++k) {
for (let j = 0; j < dims[1] - 1; ++j) {
Expand All @@ -329,6 +337,7 @@ function vtkImageMarchingCubes(publicAPI, model) {
i,
j,
k,
extent,
slice,
dims,
origin,
Expand Down

0 comments on commit 0da5564

Please # to comment.