[vtkusers] vtkTexturedActor2D: scale an image with texture support (make use of bilinear filtering)
Meister, Martin MM (E F CI C5 5)
martin.meister at siemens.com
Fri Apr 12 06:57:21 EDT 2013
Hi guys,
wondering what I did wrong: I want to display a 2D image as an annotation. can do the job many ways, one is with imagemapper and actor2d but rescaling just looked bad.
So I decided to use vtkTexturedActor2D, since the vtkTexture works so well in 2D. I want to give the user the opportunity to scale ans position the image. Positioning works, but scaling the actor just wont work. Scaling the texture/imagedata itself is not an option.
Ideas are very much appreciated,
Thanks,
Martin
# ###############
# a plane and texcoords, image in "png"
plane = vtk.vtkPolyData();
X = png.GetOutput().GetDimensions()[0]
Y = png.GetOutput().GetDimensions()[1]
texcoords = vtk.vtkFloatArray()
texcoords.SetNumberOfComponents(2)
texcoords.InsertNextTuple([0,0])
texcoords.InsertNextTuple([0,1])
texcoords.InsertNextTuple([1,1])
texcoords.InsertNextTuple([1,0])
points = vtk.vtkPoints();
points.InsertNextPoint([0 , 0 , 0]);
points.InsertNextPoint([0 , Y , 0]);
points.InsertNextPoint([X , Y , 0]);
points.InsertNextPoint([X , 0 , 0]);
poly = vtk.vtkPolygon()
poly.GetPointIds().SetNumberOfIds(4)
poly.GetPointIds().SetId(0,0)
poly.GetPointIds().SetId(1,1)
poly.GetPointIds().SetId(2,2)
poly.GetPointIds().SetId(3,3)
polygons = vtk.vtkCellArray()
polygons.InsertNextCell(poly)
pd2d = vtk.vtkPolyData()
pd2d.SetPoints(points)
pd2d.GetPointData().SetTCoords(texcoords)
pd2d.SetPolys(polygons)
pdm = vtk.vtkPolyDataMapper2D()
pdm.SetInput(pd2d)
# vtktexturedActor stuff
act5 = vtk.vtkTexturedActor2D()
act5.SetMapper(pdm)
act5.SetTexture(tex2d)
act5.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
act5.GetPositionCoordinate().SetValue(0.333, 0.333)
# all of these do not work
act5.GetPosition2Coordinate().SetValue(0.333, 0.333)
act5.SetHeight(120)
act5.SetWidth(90)
act5.SetPosition2(0.1,0.1)
# add to renderer
ren.AddActor2D(act5)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130412/88ea098c/attachment.htm>
More information about the vtkusers
mailing list