Hi, I’m newbie at VTK.
When I try to visualize a sphere, and I adjust z value in sphere.SetCenter(0.0, 0.0, z_value), I only can visualize cut sphere. I guess there is a viewing frame(:cube). How can I extend my viewing cube?
z_value = -1.0
ren = vtk.vtkRenderer()
sphere = vtk.vtkSphere()
sphere.SetCenter(0.0, 0.0, z_value)
sphere.SetRadius(0.1)
# The sample function generates a distance function from the implicit
# function. This is then contoured to get a polygonal surface.
sample = vtk.vtkSampleFunction()
sample.SetImplicitFunction(sphere)
#sample.SetModelBounds(-100.0, 100.0, -100.0, 100.0, -100.0, 100.0)
#sample.SetSampleDimensions(20, 20, 20)
sample.ComputeNormalsOff()
# contour
surface = vtk.vtkContourFilter()
surface.SetInputConnection(sample.GetOutputPort())
surface.SetValue(0, 0.0)
# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(surface.GetOutputPort())
mapper.ScalarVisibilityOff()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().EdgeVisibilityOn()
actor.GetProperty().SetEdgeColor(.2, .2, .5)
# A renderer and render window
ren = vtk.vtkRenderer()
ren.SetBackground(0, 0, 0)
# add the actor
ren.AddActor(actor)
renWin = vtk.vtkRenderWindow()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renWin.AddRenderer(ren)
# This allows the interactor to initalize itself. It has to be
# called before an event loop.
iren.Initialize()
# We'll zoom in a little by accessing the camera and invoking a "Zoom"
# method on it.
ren.ResetCamera()
#ren.GetActiveCamera().Zoom(1.5)
renWin.Render()
# Start the event loop.
iren.Start()