[vtkusers] Implicit surface generation
Wesley Brooks
wesbrooks at gmail.com
Fri Jun 17 08:15:21 EDT 2005
Dear Users,
In the past I've used the example bellow to create an implicit
triangular mesh surfaces that is a given distance from the input at
all time.
What I now need is a set of contours at a given disitance from the
input and I don't want to display, and if at all possible avoid
calculating the triangular mesh that forms the implicit surface.
In the example bellow it creates data between the bounds set in
SetModalBounds() which is then sampled and surfaced using the contour
filter. The resulting surface's accuracy being controlled by the
SetSampleDimentions() function.
To get an individual contour I would then use a clip function and
retrieve the intersection of the surface and plane.
What concerns me is that when the surface is being created with the
contour filter it is probably creating these individual slices then
building an aproximate surface on these contours. This would mean I'm
effectively contouring, surfacing then reducing back to contours
unnecessaraly increasing processing time and memory usage as well as
increasing the error between the ideal contour and the retrieved
contour.
If vtk does build the surface on a set of contours can I grab these
before I create the surface insted of taking four steps forward and
two back to get my result? If not I'll have to investigate writting my
own filter.
Thank you for your time and in advance of your help.
Yours Faithfully,
Wesley Brooks
#!/usr/bin/env python
# This example demonstrates how to use implicit modelling.
import vtk
from vtk.util.misc import vtkGetDataRoot
from vtk.util.colors import red, peacock
VTK_DATA_ROOT = vtkGetDataRoot()
# Create lines which serve as the "seed" geometry. The lines spell the
# word "hello".
reader = vtk.vtkPolyDataReader()
reader.SetFileName(VTK_DATA_ROOT + "/Data/hello.vtk")
lineMapper = vtk.vtkPolyDataMapper()
lineMapper.SetInput(reader.GetOutput())
lineActor = vtk.vtkActor()
lineActor.SetMapper(lineMapper)
lineActor.GetProperty().SetColor(red)
# Create implicit model with vtkImplicitModeller. This computes a
# scalar field which is the distance from the generating geometry. The
# contour filter then extracts the geoemtry at the distance value 0.25
# from the generating geometry.
imp = vtk.vtkImplicitModeller()
imp.SetInput(reader.GetOutput())
imp.SetSampleDimensions(110, 40, 20)
imp.SetMaximumDistance(0.25)
imp.SetModelBounds(-1.0, 10.0, -1.0, 3.0, -1.0, 1.0)
contour = vtk.vtkContourFilter()
contour.SetInput(imp.GetOutput())
contour.SetValue(0, 0.25)
impMapper = vtk.vtkPolyDataMapper()
impMapper.SetInput(contour.GetOutput())
impMapper.ScalarVisibilityOff()
impActor = vtk.vtkActor()
impActor.SetMapper(impMapper)
impActor.GetProperty().SetColor(peacock)
impActor.GetProperty().SetOpacity(0.5)
# Create the usual graphics stuff.
# Create the RenderWindow, Renderer and both Actors
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
ren.AddActor(lineActor)
ren.AddActor(impActor)
ren.SetBackground(1, 1, 1)
renWin.SetSize(600, 250)
camera = vtk.vtkCamera()
camera.SetClippingRange(1.81325, 90.6627)
camera.SetFocalPoint(4.5, 1, 0)
camera.SetPosition(4.5, 1.0, 6.73257)
camera.SetViewUp(0, 1, 0)
camera.Zoom(0.8)
ren.SetActiveCamera(camera)
iren.Initialize()
renWin.Render()
iren.Start()
More information about the vtkusers
mailing list