[vtkusers] extract/filter the underlying vtkPolyData from vtkPolyDataMapper

Gerrick Bivins gbivins at objectreservoir.com
Mon Jul 20 10:59:13 EDT 2009


Hi Jochen,
> Altenativelly is there a way to read the file directly into a vtkPolyData
> object?
 vtkOBJReader is an implementation of vtkPolyDataAlgorithm so it's output is
a vtkPolyData object.
See:
http://www.vtk.org/doc/release/5.2/html/a01061.html

After updating, a call to GetOutput() will return the resulting vtkPolyData.
> vtk.vtkOBJReader reader = new vtk.vtkOBJReader();
> vtk.vtkPolyDataMapper pDataMapper = new vtk.vtkPolyDataMapper();
>         reader.SetFileName("c:/data/grid.obj");
  reader.Update();
  vtk.vtkPolyData polyData = reader.GetOutput();


It's not clear why you want to go from PolyData to UnstructuredGrid.
Typically pipelines go the other direction from unstructuredGrid to polydata
which is what is rendered (like your current code is setup).
What is it you are trying to do with the resultant unstructuredGrid?

Gerrick

On 7/20/09 9:42 AM, "Jochen Kling" <Jochen.Kling at gmx.de> wrote:

> Hi all,
> 
> reading an mesh file (wavefront obj format) looks like being straight forward:
> 
> vtk.vtkOBJReader reader = new vtk.vtkOBJReader();
> vtk.vtkPolyDataMapper pDataMapper = new vtk.vtkPolyDataMapper();
>         reader.SetFileName("c:/data/grid.obj");
>         pDataMapper.SetInputConnection(reader.GetOutputPort());
>         ...
> 
> This is working fine and I'm able to render it.
> 
> Now I would like to convert it to an unstructured grid. In order to do this I
> thought it might be worth having access to the underlying vtkPolyData object
> of the vtkPolyDataMapper.
> 
> Can anybody explain me how to accomplish this?
> 

> 
> Or might it be possible to extract a vtkUnstructuredGrid directly from the
> pPolyDataMapper object?
> 
> I know these are lot of questions.
> 
> Thanks a lot in advance.
> 
> with best regards
> Jochen Kling
> 




More information about the vtkusers mailing list