[vtkusers] associating data to polydata
Malcolm Drummond
malcolm at geovision.co.za
Wed Mar 10 09:22:00 EST 2004
> this means that I need to tessellate each polygon in a different polydata to keep the link between original objects
> number and final tessellated objects
No, in your case I don't think you have to. vtkTriangle filter should copy the polygon cell-data to respective triangles, so you'll only need ids plus whatever values you require for visualization in your original polygon cell-data, the rest can be held in the polydata field-data or wherever. I just tried it in the script below with ids in scalars and they're carried through, so you can use these to look into the original field-data. I had a peek at the vtkTriangleFilter source code and it should copy any array in cell-data that doesn't have the copy flag set to off ... or maybe I misunderstand you.
HTH
Malcolm
#-------------------------------------------
from vtk import *
import sys
pts = vtkPoints()
polys = vtkCellArray()
scalars = vtkIntArray()
pd = vtkPolyData()
pd.SetPoints(pts)
pd.SetPolys(polys)
pd.GetCellData().SetScalars(scalars)
scalars.InsertNextValue(0)
scalars.InsertNextValue(1)
pts.InsertNextPoint(-100.0, -50.0, 0.0)
pts.InsertNextPoint( 0.0, -50.0, 0.0)
pts.InsertNextPoint( 0.0, 50.0, 0.0)
pts.InsertNextPoint(-100.0, 50.0, 0.0)
pts.InsertNextPoint( 100.0, -50.0, 0.0)
pts.InsertNextPoint( 100.0, 50.0, 0.0)
# define contour
polys.InsertNextCell(4)
polys.InsertCellPoint(0)
polys.InsertCellPoint(1)
polys.InsertCellPoint(2)
polys.InsertCellPoint(3)
polys.InsertNextCell(4)
polys.InsertCellPoint(1)
polys.InsertCellPoint(4)
polys.InsertCellPoint(5)
polys.InsertCellPoint(2)
tf = vtkTriangleFilter()
tf.SetInput(pd)
pdm = vtkPolyDataMapper()
pdm.SetInput(tf.GetOutput())
actor = vtkActor()
actor.SetMapper(pdm)
actor.GetProperty().SetColor(0,0,1)
ren = vtkRenderer()
renwin = vtkRenderWindow()
renwin.AddRenderer(ren)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renwin)
ren.AddActor(actor)
ren.SetBackground(1,1,1)
renwin.SetSize(600,600)
iren.Initialize
renwin.Render()
iren.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040310/013a46b7/attachment.htm>
More information about the vtkusers
mailing list