[vtkusers] 3D point to UnstructuredGrid‏

Meehan, Bernard MEEHANBT at nv.doe.gov
Tue Sep 2 11:41:54 EDT 2014

Hi -

First, there are a lot of things you are asking about in your email:
1) create vtkUnstructuredGrid from a collection of points
2) extracting points that exceed a given threshold
3) meshing the points

The meshing of the points can probably be done with a vtkDelaunay3D filter, and the rest of it I will describe - but in general the more specific you can be about your problem, the more likely it is that you will find answers. I'd also point you to the examples page on the wiki: http://www.vtk.org/Wiki/VTK/Examples, there are examples of how to do almost everything that you might want.

So, a partial answer to your question (at least as I was able to see it - Python source follows):

# First comment - is that all of this can easily be done in ParaView, however,
# it is easier for me to show this to you in a Python script than for me to
# describe what to click on in ParaView. Unless you have to go through piles of
# data - you should probably figure out how to do this in ParaView.

import random, vtk

points = vtk.vtkPoints()
temperature = vtk.vtkDoubleArray()

# Set up your array of random points, random temperature samples.
for i in range(5000):
  points.InsertPoint(i, random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(-1, 1))
  temperature.InsertNextValue(random.weibullvariate(1, 5))

print temperature.GetMaxNorm()

# The situation you described did not necessarily require a
# vtkUnstructuredGrid, you could have also done it with a vtkPolyData. However,
# adding points and their associated temperature samples to a
# vtkUnstructuredGrid is straightforward.
ugrid = vtk.vtkUnstructuredGrid()

# Here, I am going to select points that have an associated temperature value
# that is greater than 1.0:
ugrid_thresh = vtk.vtkThresholdPoints()
# Depending on what you're doing with the thresholded dataset, you may need to
# call "Update" on it to make sure that the data is ready to use.

# All you have is points in your vtkUnstructuredGrid, so you will need to do
# something to see the structure in your data. The data I have created has sort
# of a messy structure though. Below, the vtkVertexGlyph filters are set up
# differently because in the first case, you are using the data itself to start
# the pipeline - in the second case, you are using the output of a filter to
# feed the input of the next filter.
before_glyph = vtk.vtkVertexGlyphFilter()

after_glyph = vtk.vtkVertexGlyphFilter()

# I'm using a vtkOutlineFilter here mostly to make the data look nicer. This
# isn't strictly necessary for any of the parts of your question.
outline = vtk.vtkOutlineFilter()

# Rendering Stuff #
# The unstructured grid by itself doesn't have much interesting to look at
# inside of it, but if you were to change that, you would need a different
# mapper:
# umapper = vtk.vtkDataSetMapper()
# umapper.SetInputData(ugrid)

before_mapper = vtk.vtkPolyDataMapper()

after_mapper = vtk.vtkPolyDataMapper()

# If you are re-using data or filter outputs in the visualization pipeline,
# avoid re-using mappers and actors. Since I'm showing a before and after
# scenario as a left and right image, I will need two mappers and two actors to
# represent the outline.
outline_mapper1 = vtk.vtkPolyDataMapper()

outline_mapper2 = vtk.vtkPolyDataMapper()

outline_actor1 = vtk.vtkActor()

outline_actor2 = vtk.vtkActor()

before_actor = vtk.vtkActor()

after_actor = vtk.vtkActor()

left_ren = vtk.vtkRenderer()
left_ren.SetBackground(.3, .3, .3)
left_ren.SetViewport(0.0, 0.0, 0.5, 1.0)

right_ren = vtk.vtkRenderer()
right_ren.SetBackground(.3, .3, .3)
right_ren.SetViewport(0.5, 0.0, 1.0, 1.0)
# This line links the cameras for the two renderers so that manipulating the
# view in one viewport manipulates the view in both viewports.

renw = vtk.vtkRenderWindow()

iren = vtk.vtkRenderWindowInteractor()


From: Selcuk ÇALLI <selcukcalli at gmail.com<mailto:selcukcalli at gmail.com>>
Date: Tuesday, September 2, 2014 6:53 AM
To: "vtkusers at vtk.org<mailto:vtkusers at vtk.org>" <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: [vtkusers] 3D point to UnstructuredGrid‏

Can we obtain an UnstructuredGrid from 3D point array with values that exceed a threshold? I want to apply mesh to 3D point array. Is it possible? What kind of filters/functions do we need to do this process?

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140902/dc4e8b6c/attachment.html>

More information about the vtkusers mailing list