[vtkusers] How to crop a vtkImageData volume?
Amy Squillacote
ahs at cfdrc.com
Mon Sep 22 09:13:02 EDT 2008
Hi Al,
I'm copying this back to the vtkusers list. Please keep the discussion
on the list so other people can contribute to the conversation and so
the discussion is archived.
- Amy
allan.martin at utoronto.ca wrote:
> Hey Amy,
>
> Thanks for your help. Do you have a brief example of how to use this?
> When I do the following, it doesn't seem to get the right region. I
> checked the bounds values and they look to be correct (a subset of the
> original VoxelData bounds), so I'm rather confused. Thoughts?
>
> vtkPlanes * boxVOIPlanes = vtkPlanes::New();
> boxVOI->GetPlanes(boxVOIPlanes);
> vtkExtractVOI * clipDataSet = vtkExtractVOI::New();
> clipDataSet->SetInput(VoxelData);
> double* bounds = boxVOIPlanes->GetPoints()->GetBounds();
> clipDataSet->SetVOI((int)bounds[0],(int)bounds[1],(int)bounds[2],
> (int)bounds[3],(int)bounds[4],(int)bounds[5]);
> clipDataSet->Update();
> mc->SetInput(clipDataSet->GetOutput());
>
> Cheers,
> Al
>
>
>
> Quoting Amy Squillacote <ahs at cfdrc.com>:
>
>> 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
>
>
>
> Regards,
>
> Al Martin
>
>
>
--
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