[vtkusers] vtkImageStencil from arbitrary voxels
sumit shah
shah at ucla.edu
Fri Sep 2 03:07:14 EDT 2005
Dear vtkusers:
I think I have a simple question and a possible solution. I would
like to know if this is the best way to approach this problem and if
my implementation is on track. I have a vtkImageData object and a
volume of interest. This VOI could be anything arbitrary, it is
simply an array of voxels that are considered to be the VOI ie there
is no specific intrinsic order or anything of that sort. I would
like to render only what is specified by that VOI from the image
data. My approach is as follows in this Java snippet:
vtkVertex vv = new vtkVertex();
vv.GetPoints().SetNumberOfPoints(roi.numVoxels());
int i = 0;
do {
int x roi.currentPoint().x();
int z roi.currentPoint().y();
int y roi.currentPoint().z();
vv.GetPoints().SetPoint(i++, x, y, z);
} while(roi.gotoNextPoint());
vtkCellArray vca = new vtkCellArray();
vca.InsertNextCell(vv);
vtkPolyData vpd = new vtkPolyData();
vpd.SetVerts(vca);
vtkPolyDataToImageStencil vpdtis = new
vtkPolyDataToImageStencil();
vpdtis.SetInput(vpd);
vis = new vtkImageStencil();
vis.SetStencil(vpdtis.GetOutput());
// vitsp is an object of type vtkImageStructuredPoints
vis.SetInput(vitsp.GetOutput());
vis.SetBackgroundValue(0);
vis.Update();
However this does not seem to work and it crashes on the last line.
Is this the right approach or is there a more efficient approach?
Thanks,
Sumit
More information about the vtkusers
mailing list