[vtkusers] Cutting in STL

leung fung man german_leung at hotmail.com
Sun Nov 19 23:31:50 EST 2000


Dear all VTK User:
I have two STL file as a stlActor, one is hipjoin.stl and other is
cutter.stl.  I want to move the cutter to cut the hipjoin out but how can I
do this? (To remove a part of the stl. object) I study the manual Cutting
part already but I can not get the idea to do this!  Could you mind sent me
some idea?  My code is showing below:-
-----------------------------------------------------
catch {load vtktcl}
if { [catch {set VTK_TCL $env(VTK_TCL)}] != 0} { set VTK_TCL
"../../examplesTcl" }
if { [catch {set VTK_DATA $env(VTK_DATA)}] != 0} { set VTK_DATA
"../../../vtkdata" }

# get the interactor ui
source $VTK_TCL/vtkInt.tcl

# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren
vtkRenderWindow renWin
  renWin AddRenderer ren
vtkRenderWindowInteractor iren
  iren SetRenderWindow renWin

#input the hipjoin image
vtkSTLReader hip
  hip SetFileName $VTK_DATA/ballJoint60.stl
vtkPolyDataNormals normals
  normals SetInput [hip GetOutput]
vtkPolyDataMapper   hipMapper
  hipMapper SetInput [normals GetOutput]
vtkLODActor hipActor
  hipActor SetMapper hipMapper

#vtkOutlineFilter outline
  #outline SetInput [normals GetOutput]
#vtkPolyDataMapper mapOutline
  #mapOutline SetInput [outline GetOutput]
#vtkActor outlineActor
  #outlineActor SetMapper mapOutline
  #[outlineActor GetProperty] SetColor 0.9 0 0


hipActor SetOrigin 0 0 0
hipActor RotateX -90
hipActor SetPosition 0 0 2.244

#input the cutter1 image
vtkSTLReader cut
  cut SetFileName $VTK_DATA/cutter1.stl
vtkPolyDataNormals normal
  normal SetInput [cut GetOutput]
vtkPolyDataMapper   cutMapper
  cutMapper SetInput [normal GetOutput]
vtkLODActor cutActor
  cutActor SetMapper cutMapper
cutActor SetOrigin 0 50 0
cutActor RotateX -90
cutActor SetPosition 0 0 -60
# Add the actors to the renderer, set the background and size
#
ren AddActor hipActor
ren AddActor cutActor
#ren AddProp outlineActor
ren SetBackground 0.1 0.2 0.4
renWin SetSize 600 600

vtkCubeAxesActor2D axes
  axes SetProp hipActor
  axes SetCamera [ren GetActiveCamera]
  axes SetLabelFormat "%6.4g"
  axes ShadowOff
  axes SetFlyModeToOuterEdges
#axes SetFlyModeToClosestTriad
  axes SetFontFactor 1.1
  [axes GetProperty] SetColor 1 1 1
ren AddProp axes
vtkCubeAxesActor2D axes1
  axes1 SetProp cutActor
  axes1 SetCamera [ren GetActiveCamera]
  axes1 SetLabelFormat "%6.4g"
  axes1 ShadowOff
  axes1 SetFlyModeToOuterEdges
#axes1 SetFlyModeToClosestTriad
  axes1 SetFontFactor 1.1
  [axes1 GetProperty] SetColor 1 1 1
ren AddProp axes1

# render the image
#
iren SetUserMethod {wm deiconify .vtkInteract}
set cam1 [ren GetActiveCamera]
$cam1 Zoom 1.4
iren Initialize
#renWin SetFileName "ballJoint50.stl.ppm"
#renWin SaveImageAsPPM

# test regeneration of the LODMappers
# stlActor Modified

# prevent the tk window from showing up then start the event loop
wm withdraw .
-----------------------------------------------------

Thank you for your assistance.
Any advice was a great help to me.
Best regards,
German Leung


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.





More information about the vtkusers mailing list