[vtkusers] Can a VTKDataSet be converted to a vtkImage or vtkPolyData object?
Cory Quammen
cory.quammen at kitware.com
Fri Aug 12 12:45:40 EDT 2016
Mr. Oregon Duckman,
Both vtkImageData and vtkPolyData are subclasses of vtkDataSet, so
they are already vtkDataSets.
Do you mean you have a vtkDataSet that is going to be either a
vtkImage or vtkPolyData, and you want to downcast it to the right
type? If so, you can do the following:
vtkDataSet* dataset = ...;
vtkImageData* imageData = vtkImageData::SafeDownCast(dataset);
vtkPolyData* polyData = vtkPolyData::SafeDownCast(dataset);
if (imageData) {
// handle the case for vtkImageData
} else if (polyData){
// handle the case for vtkPolyData
} else {
std::cerr << "unknown type" << std::endl;
}
HTH,
Cory
On Fri, Aug 12, 2016 at 12:15 PM, MrOregonduckman .
<oregonduckman at gmail.com> wrote:
> I am looking for a way to convert a vtkDataSet to either a vtkImage or
> vtkPolyData object depending on the source of the dataset, any ideas out
> there?
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
--
Cory Quammen
R&D Engineer
Kitware, Inc.
More information about the vtkusers
mailing list