[vtkusers] Can vtkDataObject be downcasted to vtkUnstructuredGrid?

Mathieu Westphal mathieu.westphal at kitware.com
Thu Nov 16 03:41:57 EST 2017


Hello

For the cast to work, the object need to be of the right type. If the
output is a vtkPolyData, it cannot be a vtkUnstructuredGrid.
Take a look at the polymorphism here.

https://www.vtk.org/doc/nightly/html/classvtkDataSet.html

Best,

Mathieu Westphal

On Thu, Nov 16, 2017 at 5:30 AM, landings <landinghere at 163.com> wrote:

> Hi,
>
> I am writing a reader that outputs an unstructured solid mesh.
>
> I am referring to vtkSTLReader, in its RequestData() method I can see the
> following code:
>
>     vtkInformation *outInfo = outputVector->GetInformationObject(0);
>     vtkPolyData *output =
> vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
>
> But when I do similar things:
>
>     vtkInformation* outInfo = outputVector->GetInformationObject(0);
>     vtkUnstructuredGrid *output =
> vtkUnstructuredGrid::SafeDownCast(outInfo->Get(
> vtkDataObject::DATA_OBJECT()));
>
> I get a nullptr for output. I am sure
> outInfo->Get(vtkDataObject::DATA_OBJECT()) exists before downcasting.
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171116/177620b0/attachment.html>


More information about the vtkusers mailing list