[vtkusers] How to crop a vtkImageData volume?

Amy Squillacote ahs at cfdrc.com
Tue Sep 16 14:32:25 EDT 2008


Hi Al,

Assuming that you're cropping planes are aligned with the axes of the 
vtkImageData volume, you could try using vtkExtractVOI instead. Its 
output is still a vtkImageData, so you wouldn't have a problem with 
passing it to vtkMarchingCubes.

- Amy

allan.martin at utoronto.ca wrote:
> Hi all,
>
> I'm trying to take a vtkImageData volume and crop it with a box widget 
> to make a smaller volume, so that when I subsequently render an 
> isosurface it isn't so slow.  I think I'm close, but I can't seem to 
> get something that vtkMarchingCubes will eat (it wants a vtkImageData 
> object, and I don't know how to copy my vtkUnstructuredGrid back to a 
> vtkImageData object).  Anyone have an example of how to do this?
>
> Here is my broken code:
>
> //Start with a volume, and make it smaller with a box widget
> boxVOI = vtkBoxWidget::New();
> VoxelData = vtkImageData::New();
> ...
> //Now take the region defined by the box widget, and make a new volume 
> data set
> //that is smaller
> vtkPlanes* boxVOIPlanes = vtkPlanes::New();
> boxVOI->GetPlanes(boxVOIPlanes);
> vtkExtractGeometry* clipDataSet = vtkExtractGeometry::New();
> clipDataSet->SetInput(VoxelData);
> clipDataSet->SetImplicitFunction(boxVOIPlanes);
> vtkDataSet* output = (vtkDataSet*) clipDataSet->GetOutput();
> vtkImageData* croppedVoxelData = vtkImageData::New();
>
> //This copy doesn't seem to be sufficient as it doesn't copy the 
> number of dimensions and other vtkImageData fields
> croppedVoxelData->ShallowCopy(output);
> croppedVoxelData->AllocateScalars(); //It complains if scalars aren't 
> allocated
> mc->SetInput(croppedVoxelData);
>
>
> Thanks for your help,
>
> Al Martin
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>

-- 
Amy Squillacote                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list