[vtkusers] Re: problem viewing merged PolyData sets using
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Fri Feb 4 07:05:27 EST 2005
Hi Denis,
I looked up the source to vtkGlyph3D and vtkAppendPolyData...
You're right- vtkGlyph3D can use a vtkPolyData with just points set and no
topology.
The problem you seeing is because vtkAppendPolyData appends cells to its
output and so needs topology...
here's the code from vtkAppendPolyData
if ( numPts < 1 || numCells < 1 )
{
//vtkErrorMacro(<<"No data to append!");
return 1;
}
maybe that error macro should be changed to a debug macro and uncommented?
Sorry for the confusion,
Goodwin
"Denis Saussus" <saussus at skynet.be> wrote in message
news:b004f848d9c67ed63cdbd70ee72f6b37 at skynet.be...
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()
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list