[vtkusers] Merging an example with my data

Nick Torenvliet natorenvliet at gmail.com
Thu Oct 19 20:47:04 EDT 2017


Ummmm two things, three things, does it matter?

On Thu, Oct 19, 2017 at 8:45 PM, Nick Torenvliet <natorenvliet at gmail.com>
wrote:

> I am looking at the pointToCellData.py example.
>
> In that example an unstructured grid reader opens a .vtk file and extracts
> some named unstructured grid scalar and vector data like so...
>
> reader = vtk.vtkUnstructuredGridReader()
> reader.SetFileName(VTK_DATA_ROOT + "/Data/blow.vtk")
> reader.SetScalarsName("thickness9")
> reader.SetVectorsName("displacement9")
>
> p2c = vtk.vtkPointDataToCellData()
> p2c.SetInputConnection(reader.GetOutputPort())
> p2c.PassPointDataOn()
> warp = vtk.vtkWarpVector()
> warp.SetInputConnection(p2c.GetOutputPort())
> thresh = vtk.vtkThreshold()
> thresh.SetInputConnection(warp.GetOutputPort())
> thresh.ThresholdBetween(0.25, 0.75)
> thresh.SetInputArrayToProcess(1, 0, 0, 0, "thickness9")
>
>
> In the code I've written to front end this, I want to replace the reader
> with my own method for extracting an unstructured grid like so...
>
> gap_data_block, gap_file_info = getgap.get_gap_data_from_files(gap_file)
> points = vtk.vtkPoints()
> points.SetData(VN.numpy_to_vtk(gap_data_block, deep=True))
> ugrid = vtk.vtkUnstructuredGrid()
> ugrid.SetPoints(points)
>
> Where gap_data_block is a numpy array of shape (n,3) carrying data for
> dimensions are x/y/z.
>
> Ultimately I want to get a surface elevation plot of gap_data_block by
> working through the example code cited above.
>
> As part of this (extremely) pedagogical experience, I feel I need to do
> two things:
>
>    1. Find a way to label columns one and two of get_data_block as a
>    vector using some equivalent to reader.SetVectorsName()
>    2. Find a way to label columns three of get_data_block as a scalar
>    using some equivalent to reader.SetVectorsName()
>    3. Find a way to set the input connection, or input data of a
>    vtkPointDataToCellData object to my vtkUnstructuredGrid object ugrid.
>
> I've been looking at this for a few hours now, any help getting my ugrid
> to an elevation plot would be appreciated.
>
> Thanks,
>
> nt
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171019/5889fe35/attachment.html>


More information about the vtkusers mailing list