[vtkusers] Re: problem viewing merged PolyData sets using
Denis Saussus
saussus at skynet.be
Fri Feb 4 04:50:09 EST 2005
Thanks for the replies Goodwin. You say that vtkGlyph3D needs both
geometry and topology to work -- is that really true? How come the
code fragment I posted works just fine as long as the input to
vtkGlyph3D is the original vtkPolyData object (made manually with just
points) and NOT the output of vtkAppendPolyData().GetOutput() ?
Anyway, here is the how I created the vtkPolyData objects.
import RandomArray
points = vtk.vtkPoints()
for n in range(1000):
x,y,z = [ RandomArray.normal(0, 1) for i in range(3) ]
points.InsertPoint(n, x, y, z)
a = vtk.vtkPolyData()
a.SetPoints(points)
... and so on for b = vtk.vtkPolyData()
Let me clarify the problem what is at the heart of the problem (I think
;)
This works:
...
a = vtk.vtkPolyData()
a.GetNumberOfPoints()
...
This does not work: Why?
...
a = vtk.vtkPolyData()
apd = vtk.vtkAppendPolyData()
apd.AddInput(a)
apd.GetOutput().GetNumberOfPoints()
Can you post the code where you've added points to the vtkPolyData
objects?
"Denis Saussus" <dsaussus at fugro-jason.com> wrote in message
news:F42290EAAE100A4A99A3A9BE2059504FBDB121 at MAIL.fugro-jason.local...
How can I get the following to print the total
number of points in the appended set?
a = vtk.vtkPolyData()
b = vtk.vtkPolyData()
apd = vtk.vtkAppendPolyData()
apd.AddInput(a)
apd.AddInput(b)
print apd.GetOutput().GetNumberOfPoints()
==> this prints '0' instead of a+b ?
I tried doing apd.Update() before but it didn't help.
What am I missing?
i Denis,
At a guess, I would say your vtkPolyData's have points (geometry) but no
vertices (topology). vtkGlyph3D needs both to work, although in theory
it
should only need the points.
Here's a trick to get it to work:
...
...
apd = vtk.vtkAppendPolyData()
apd.AddInput(somePolyData)
apd.AddInput(someMorePolyData)
verts = vtk.vtkMaskPoints()
verts.SetInput(apd.GetOutput())
verts.GenerateVerticesOn()
verts.SetOnRatio(1)
aSphere = vtk.vtkSphereSource()
aSphere.SetRadius(1.0)
spheres = vtk.vtkGlyph3D()
spheres.SetInput(verts.GetOutput())
spheres.SetSource(aSphere.GetOutput())
...
...
hth
Goodwin
"Denis Saussus" <dsaussus at fugro-jason.com> wrote in message
news:F42290EAAE100A4A99A3A9BE2059504FBDB11C at MAIL.fugro-jason.local...
I am plotting a vtkPolyData set containing 3d points so that
they display as spheres. I can get this to work very easily.
Now I have two vtkPolyData sets, each containing 3d points.
I want to plot them using a single mapper/actor. I am doing this
simply by using vtkAppendPolyData to merge the two sets into
one. My problem is that now nothing shows up.
Below is the script I am using. Help greatly aprpeciated...
##########################
# Why does this not work?
##########################
somePolyData = vtk.vtkPolyData()
# assume this contains some valid 3d points
apd = vtk.vtkAppendPolyData()
apd.AddInput(somePolyData)
apd.AddInput(someMorePolyData)
aSphere = vtk.vtkSphereSource()
aSphere.SetRadius(1.0)
spheres = vtk.vtkGlyph3D()
spheres.SetInput(apd.GetOutput())
spheres.SetSource(aSphere.GetOutput())
mapSpheres = vtk.vtkPolyDataMapper()
mapSpheres.SetInput(spheres.GetOutput())
spheresActor = vtk.vtkActor()
spheresActor.SetMapper(mapSpheres)
ren = vtk.vtkRenderer()
ren.AddActor(spheresActor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
renWin.Render()
iren.Start()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 4000 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050204/f8a0444d/attachment.bin>
More information about the vtkusers
mailing list