[vtkusers] X,Y,Z -> STL?

anast.jm at pg.com anast.jm at pg.com
Thu Feb 12 18:56:15 EST 2004


Don, Here's a small tcl program to do just that, it also outputs a VRML 
file as well. At the end of the script the write commands are commented 
out. Once you get it working uncomment the file you want... 

I have similar programs that use instead of Delauney 3D
1) PowerCrust Reconstruction FIlter
2) Surface Reconstruction Filter
3) vtkShepard Method

...john

tcl code
============================
# This program demonstrates and tests the use of vtkDelauney3D
# The input is a cloud of points sampled from the MRI contours.
# The output is a complete surface

package require vtk
package require vtkinteraction

vtkOutputWindow con
vtkPolyData myCloud

# Read some points.
vtkPolyDataReader pointSource
    pointSource SetFileName "cleo2.vtk"
    pointSource SetOutput myCloud
    pointSource Update

set numPts [myCloud GetNumberOfPoints]
vtkCellArray vertices

# here a vertex cell is inserted in the CellArray for
# every point in the point list
for {set i 0} {$i < $numPts} {incr i} {
    vertices InsertNextCell 1
    vertices InsertCellPoint $i
}

myCloud SetVerts vertices

# render the raw input points into the first renderer
vtkPolyDataMapper rawpointsmapper
    rawpointsmapper SetInput myCloud
vtkActor rawpointsactor
    rawpointsactor SetMapper rawpointsmapper
    [rawpointsactor GetProperty] SetColor 0.5 0.5 0.5

# construct surface with Delaunay3D
vtkDelaunay3D surf
  surf SetInput [pointSource GetOutput]
  surf SetTolerance 0.0001
  surf SetAlpha 4.0
  #surf BoundingTriangulationOn

vtkGeometryFilter pd
    pd SetInput [surf GetOutput]

vtkDataSetMapper map
    map SetInput [pd GetOutput]
    map ScalarVisibilityOff

vtkActor surfaceActor
    surfaceActor SetMapper map
    [surfaceActor GetProperty] SetDiffuseColor 1.0000 0.3882 0.2784
    [surfaceActor GetProperty] SetSpecularColor 1 1 1
    [surfaceActor GetProperty] SetSpecular .4
    [surfaceActor GetProperty] SetSpecularPower 50

# Render everything
vtkRenderer ren1
vtkRenderer ren2
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin AddRenderer ren2
    renWin SetSize 600 200
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Add the actors to the renderer
ren1 AddActor rawpointsactor
ren2 AddActor surfaceActor

# set the properties of the renderers

ren1 SetBackground 1 1 1
ren1 SetViewport 0.0 0.0 0.50 1.0
[ren1 GetActiveCamera] SetPosition 1 -1 0
ren1 ResetCamera

ren2 SetBackground 0 0 1
ren2 SetViewport 0.50 0.0 1.00 1.0
[ren2 GetActiveCamera] SetPosition 1 -1 0 
ren2 ResetCamera

# render the image
iren AddObserver UserEvent {wm deiconify .vtkInteract}
renWin Render
wm withdraw .

vtkSTLWriter stlBinary
   stlBinary SetInput [pd GetOutput]
   stlBinary SetFileName cleo2_d3d.stl
   stlBinary SetFileType 2
   #stlBinary Write

vtkVRMLExporter vrml
  vrml SetInput renWin
  vrml SetFileName cleo2.wrl
  vrml SetSpeed 5.5
  #vrml Write






Donald S Dunbar <dsd at lorax.ca>
Sent by: vtkusers-admin at vtk.org
02/12/2004 06:29 PM

 
        To:     vtkusers at vtk.org
        cc:     (bcc: John Anast-JM/PGI)
        Subject:        [vtkusers] X,Y,Z -> STL?


I would like to do the following:
                 input topography as a set of unstructured (X,Y,Z) grid 
points
                 generate a surface (i.e., the ground)
                 output the surface as a stereo-lithography file (STL)

So far I've managed to input the data, generate a surface using 
vtkDelauney3D, and look at it.  I don't know how to take the next step; 
that is, convert the unstructured grid output of vtkDelauney3D to the 
PolyData type required by vtkSTLWriter.  Can someone please tell me how 
to complete this, or suggest a better way.  Thanks.

Don Dunbar
Lorax Environmental
Vancouver, BC

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040212/a137cbcf/attachment.htm>


More information about the vtkusers mailing list