def sphere( radius, options={} )
resolution = false
opacity = false
color = false
wireframe = false
options.each{ |key, val|
case key
when 'resolution'
resolution = val
when 'opacity'
opacity = val
when 'color'
color = val
if !(Array === color) || color.length != 3
raise "color must be Array whose length is three"
end
when 'wireframe'
wireframe = val
else
raise "option (#{key}) is invalid"
end
}
sphere = Vtk::SphereSource.new
sphere.SetRadius( radius )
if resolution
sphere.SetPhiResolution( resolution )
sphere.SetThetaResolution( resolution )
end
mapper = Vtk::PolyDataMapper.new
mapper.SetInput( sphere.GetOutput )
actor = Vtk::Actor.new
actor.SetMapper( mapper )
actor.GetProperty.SetDiffuseColor( *color ) if color
actor.GetProperty.SetOpacity( options['opacity'] ) if opacity
actor.GetProperty.SetRepresentationToWireframe if wireframe
@ren.AddActor( actor )
return nil
end