[vtkusers] panning with periodic/cyclic sides

Gerard Gorman g.gorman at imperial.ac.uk
Thu Oct 2 14:47:24 EDT 2003


Hi,

I'm trying to implement an image viewer in python where the sides of the 
image are periodic - so that when you pan the image, what goes out one 
side enters the other (for the curious, I'm looking at the world 
projected onto a long/lat plane). The problem is that what I implemented 
is depressingly slow. Can anyone point me in the right direction. You 
can find below the gibberish that I wrote myself.

Cheers
g

tmp = vtk.vtkImageData ()
tmp.DeepCopy (self.image)

ijk = [0,0,0]
ijk[2] = 0

#181 => -90 degrees to 90 degrees
#361 => -180 degrees to 180 deprees
#1 degree between each point
for j in range(181):
     ijk[1] = j
     for i in range(360):
         ijk[0] = (361 + (i + dx))%361
         id = self.image.ComputePointId(ijk)
         c = self.image.GetPointData ().GetScalars ().GetValue(id)

         ijk[0] = i
         id = tmp.ComputePointId(ijk)
         tmp.GetPointData ().GetScalars ().SetValue(id, c)
     # repeat the western line on eastern side
     ijk[0] = 0
     id = tmp.ComputePointId(ijk)
     c = tmp.GetPointData ().GetScalars ().GetValue(id)

     ijk[0] = 360
     id = tmp.ComputePointId(ijk)
     tmp.GetPointData ().GetScalars ().SetValue(id, c)
self.image = tmp




More information about the vtkusers mailing list