[vtkusers] get unstructured grid from vtkXdmf3Reader

Nico Schlömer nico.schloemer at gmail.com
Tue Jun 16 09:04:19 EDT 2015


Apparently,
```
 xreader->GetNumberOfGrids()
```
doesn't say much. One can simply
```
  vtkDataObject *rOutput = xreader->GetOutputDataObject(0);
  TEUCHOS_ASSERT(rOutput != nullptr);
  vtkUnstructuredGrid * m = dynamic_cast<vtkUnstructuredGrid*>(rOutput);
  TEUCHOS_ASSERT(m != nullptr);
```
which gives you a pointer to the vtkUnstructuredGrid, if there is one.

Cheers,
Nico

On Tue, Jun 16, 2015 at 1:46 PM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
> Hi everyone,
>
> I have an XDMF file which I'm reading with vtk::vtkXdmf3Reader,
> ```
>   vtkXdmf3Reader *xreader = vtkXdmf3Reader::New();
>   xreader->SetFileName("data/brick-w-hole.xmf");
>   xreader->Update();
> ```
> and I would like to get the corresponding vtk::UnstructuredGrid from
> this. For some reason, however,
> ```
>  xreader->GetNumberOfGrids()
> ```
> returns 0. Also, I wouldn't know how to retrieve the grid if there was one.
>
> Is there example code for this around?
>
> Cheers,
> Nico


More information about the vtkusers mailing list