def set_grid( x, y, z, shape, scale=nil )
x = get_vtkArray( x )
y = get_vtkArray( y )
z = get_vtkArray( z )
unless shape.length==3
raise "length of shape must be three"
end
if scale
unless Array === scale
raise "scale must be Array"
end
if scale.length != 3
raise "length of scale must be three"
end
@scale = scale
for i in 0...x.GetNumberOfTuples
x.SetValue( i, x.GetValue(i)*scale[0] )
end
for i in 0...y.GetNumberOfTuples
y.SetValue( i, y.GetValue(i)*scale[1] )
end
for i in 0...z.GetNumberOfTuples
z.SetValue( i, z.GetValue(i)*scale[2] )
end
end
npoints = shape[0]*shape[1]*shape[2]
if x.GetNumberOfTuples != npoints
raise "length of x does not correspond to shape"
end
if y.GetNumberOfTuples != npoints
raise "length of y does not correspond to shape"
end
if z.GetNumberOfTuples != npoints
raise "length of z does not correspond to shape"
end
points = Vtk::Points.new
points.SetNumberOfPoints( npoints )
npoints.times{|i|
points.SetPoint( i, x.GetValue(i), y.GetValue(i), z.GetValue(i) )
}
@grid = Vtk::StructuredGrid.new
@grid.SetDimensions( *shape )
@grid.SetPoints( points )
return nil
end