Commit ea7c9b42 authored by Ken Martin's avatar Ken Martin Committed by David E. DeMarle

fix an access violation happening in StructureGridGeom filter

When handling a 3d volume it was accessing too far when
there was cell data present.

(cherry picked from commit 428d603a)
parent 9ab1a120
......@@ -351,20 +351,27 @@ int vtkStructuredGridGeometryFilter::RequestData(
for (j=0; j < (diff[1]+1); j++)
{
pos = startIdx + j*offset[0] + k*offset[1];
// avoid accessing cells past the end of the grid
vtkIdType cellK = (k == dims[2] - 1) ? k - 1 : k;
vtkIdType cellJ = (j == dims[1] - 1) ? j - 1 : j;
cellPos = startCellIdx + (cellK*(dims[1] - 1) + cellJ)*(dims[0] - 1);
for (i=0; i < (diff[0]+1); i++)
{
if ( input->IsPointVisible(pos+i) )
{
vtkIdType cellI = (i == dims[0] - 1) ? i - 1 : i;
input->GetPoint(pos+i, x);
ptIds[0] = newPts->InsertNextPoint(x);
outPD->CopyData(pd,pos+i,ptIds[0]);
cellId = newVerts->InsertNextCell(1,ptIds);
outCD->CopyData(cd,pos+i,cellId);
outCD->CopyData(cd,cellPos + cellI, cellId);
}
}
}
}
break; /* end this case */
break; /* end this case */
} // switch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment