Skip to content

Commit

Permalink
Merge pull request #1477 from Kitware/fix-cutter
Browse files Browse the repository at this point in the history
fix(Cutter): Incorrect cell array traversal
  • Loading branch information
floryst committed Jun 4, 2020
2 parents 1c78d4c + 9bcb131 commit d3386a2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Sources/Filters/Core/Cutter/index.js
Expand Up @@ -55,22 +55,24 @@ function vtkCutter(publicAPI, model) {
// Loop over all cells; get scalar values for all cell points
// and process each cell.
/* eslint-disable no-continue */
let cellOffset = 0;
let prevCellSize = -1;
for (let cellId = 0; cellId < numCells; cellId++) {
const nbPointsInCell = dataCell[0];
cellOffset += prevCellSize + 1; // account for length of cell

const nbPointsInCell = dataCell[cellOffset];
prevCellSize = nbPointsInCell;

// Check that cells have at least 3 points
if (nbPointsInCell <= 2) {
continue;
}
const nextCellOffset = cellOffset + 1 + nbPointsInCell;

// Get associated scalar of points that constitute the current cell
const cellPointsScalars = [];
const valuesInCell = nbPointsInCell + 1; // first value is size
let pointIndex;
for (
let i = valuesInCell * cellId + 1;
i < valuesInCell * (cellId + 1);
i++
) {
for (let i = cellOffset + 1; i < nextCellOffset; i++) {
pointIndex = dataCell[i];
cellPointsScalars.push(model.cutScalars[pointIndex]);
}
Expand All @@ -94,11 +96,7 @@ function vtkCutter(publicAPI, model) {

// Get id of points that constitute the current cell
const cellPointsID = [];
for (
let i = valuesInCell * cellId + 1;
i < valuesInCell * (cellId + 1);
i++
) {
for (let i = cellOffset + 1; i < nextCellOffset; i++) {
cellPointsID.push(dataCell[i]);
}

Expand Down

0 comments on commit d3386a2

Please sign in to comment.