[vtkusers] Extracting particles and plane
Shiva Bissoon
sbissoo2 at hotmail.com
Tue Jun 19 16:56:39 EDT 2001
Hi all,
I was having a problem of extracting a plane with some particles.
What I want to do is to capture the intersection of the particles with a
given plane and view that image.
Here is some code.
Step 1: I created a box
Step2: I created some particles in the box
Step3: I created a plane using the box as the input
Step4: How do I find the intersection of the particles with the plane and
display them????
I really appreciate any help one can give, since I am stuck.
I think I have to use the particles as the input for the clippolydata but
how do I still use the cube to define the boundary for the plane?
If I have to use the particles...what do I put as my input
SetInput [ sphereActor$i] and put this inside another loop????
# Written by Shiva Bissoon
catch {load vtktcl}
source vtkInt.tcl
source colors.tcl
#create a window and renderer
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
#create a cube
vtkCubeSource cubex
cubex SetXLength 100 ;# -50<x<50
cubex SetYLength 100 ;# -50<y<50
cubex SetZLength 100 ;# -50<z<50
cubex SetCenter 0 0 0
vtkPolyDataMapper mapper
mapper SetInput [cubex GetOutput]
vtkActor boxactor
boxactor SetMapper mapper
eval [boxactor GetProperty] SetOpacity 0.3
ren1 AddActor boxactor
#create the particles
......etc.
vtkSphereSource sphere$i
sphere$i SetRadius 1
sphere$i SetThetaResolution 18
sphere$i SetPhiResolution 18
.....etc.
vtkActor sphereActor$i
sphereActor$i SetMapper sphereMapper$i
sphereActor$i SetPosition $x $y $z
eval [sphereActor$i GetProperty] SetColor $black
sphereActor$i RotateX $Rx
sphereActor$i RotateY $Ry
sphereActor$i RotateZ $Rz
ren1 AddActor sphereActor$i
}
#creates a third plane for cutting
vtkPlane plane3
plane3 SetOrigin 0 0 0
plane3 SetNormal 0 0 1
vtkClipPolyData clipper3
clipper3 SetInput [cubex GetOutput]
clipper3 SetClipFunction plane3
clipper3 GenerateClipScalarsOn
clipper3 GenerateClippedOutputOn
clipper3 SetValue 11.5
#changing this parameter moves the plane along
#the given normal axis axis
vtkContourFilter clips
clips SetInput [clipper3 GetOutput]
clips GenerateValues 5 1 1
vtkPolyDataMapper clipMapper3
clipMapper3 SetInput [clips GetOutput]
#clipMapper ScalarVisibilityOn
clipMapper3 ScalarVisibilityOff
vtkActor clipActor3
clipActor3 SetMapper clipMapper3
eval [clipActor3 GetProperty] SetColor $peacock
ren1 AddActor clipActor3
#clipActor SetBackfaceProperty backProp
# now extract feature edges
vtkFeatureEdges boundaryEdges3
boundaryEdges3 SetInput [clipper3 GetOutput]
boundaryEdges3 BoundaryEdgesOn
boundaryEdges3 FeatureEdgesOff
boundaryEdges3 NonManifoldEdgesOff
vtkCleanPolyData boundaryClean3
boundaryClean3 SetInput [boundaryEdges3 GetOutput]
vtkStripper boundaryStrips3
boundaryStrips3 SetInput [boundaryClean3 GetOutput]
boundaryStrips3 Update
vtkPolyData boundaryPoly3
boundaryPoly3 SetPoints [[boundaryStrips3 GetOutput]GetPoints]
boundaryPoly3 SetPolys [[boundaryStrips3 GetOutput] GetLines]
vtkTriangleFilter boundaryTriangles3
boundaryTriangles3 SetInput boundaryPoly3
vtkPolyDataMapper boundaryMapper3
boundaryMapper3 SetInput boundaryPoly3
vtkActor boundaryActor3
boundaryActor3 SetMapper boundaryMapper3
eval [boundaryActor3 GetProperty] SetColor $cyan
ren1 AddActor boundaryActor3
# add the actors and backgrd
renWin SetSize 500 500
ren1 SetBackground 1 1 1
# add the outliner
# ren1 AddActor outlineActor
iren SetUserMethod {wm deiconify .vtkInteract}
iren Initialize
#renWin SetFileName iterate.ppm
#renWin SaveImageAsPPM
# prevent the tk window from showing up then start the event loop
wm withdraw .
Thanks in advance...
Shiva
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
More information about the vtkusers
mailing list