<div dir="ltr">Hi Edgar,<div><br></div><div>Have a look at this Tcl example:</div><div><br></div><div><a href="http://vtk.org/gitweb?p=VTK.git;a=blob;f=Common/DataModel/Testing/Tcl/SelectionLoop.tcl">http://vtk.org/gitweb?p=VTK.git;a=blob;f=Common/DataModel/Testing/Tcl/SelectionLoop.tcl</a><br>
</div><div><br></div><div>You could also try replacing vtkExtractGeometry in the example with vtkClipDataSet</div><div><br></div><div>hth</div><div><br></div><div>Goodwin</div><div><br></div><div>ps This is more a VTK Users type question... I've moved to that list</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 24, 2014 at 5:17 AM, darkcminor <span dir="ltr"><<a href="mailto:darkcminor@gmail.com" target="_blank">darkcminor@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I want to extract a part of a surface defined here by red points, in fact it<br>
is a closed contour (What I want is to get a piece of cake defined by<br>
contour)<br>
<br>
I have this:<br>
<br>
<<a href="http://vtk.1045678.n5.nabble.com/file/n5726086/have.png" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5726086/have.png</a>><br>
<br>
<br>
To get taht The current code is<br>
<br>
<br>
/package require vtk<br>
<br>
# Create a reader to read the unstructured grid data. We use a<br>
# vtkDataSetReader which means the type of the output is unknown until<br>
# the data file is read.<br>
vtkDEMReader reader<br>
reader SetFileName "$VTK_DATA_ROOT/Data/SainteHelens.dem"<br>
reader Update<br>
puts "Dataset reader actual memory: [[reader GetOutput]<br>
GetActualMemorySize]"<br>
puts "Dataset reader no of points: [[reader GetOutput]<br>
GetNumberOfPoints]"<br>
<br>
set lo [lindex [[reader GetOutput] GetScalarRange] 0]<br>
set hi [lindex [[reader GetOutput] GetScalarRange] 1]<br>
<br>
# Get the physical xy extent of dataset<br>
scan [[reader GetOutput] GetWholeExtent] "%d %d %d %d %d %d" XminR XmaxR<br>
YminR YmaxR ZminR ZmaxR<br>
puts "Physical extent of dataset: $XminR $XmaxR $YminR $YmaxR $ZminR $ZmaxR"<br>
<br>
# trims off points with no data (value -9999) in DEMS converted<br>
# from ASCII arc grid files. This step could be used to crop the data<br>
# at another elevation by changing the threshold value<br>
vtkThreshold cropped<br>
cropped SetInput [reader GetOutput]<br>
cropped ThresholdByUpper -9998; # threshold value<br>
cropped Update<br>
puts "Threshold filter no of cells : [[cropped GetOutput]<br>
GetNumberOfCells]"<br>
puts "Threshold filter no of points: [[cropped GetOutput]<br>
GetNumberOfPoints]"<br>
<br>
# Create the geometry conneting the grid of location points<br>
# at this point the surface is flat with an x-y grid of numbers<br>
# (scalars) representing elevations<br>
vtkGeometryFilter geom<br>
geom SetInput [cropped GetOutput]<br>
geom Update<br>
puts "Geometry filter no of cells : [[geom GetOutput] GetNumberOfCells]"<br>
puts "Geometry filter no of points: [[geom GetOutput] GetNumberOfPoints]"<br>
<br>
# Now warp the surface based on the scalar elevation values<br>
# This creates the 3D mesh model of the terrain.<br>
vtkWarpScalar surface<br>
surface SetInput [geom GetOutput]<br>
surface SetScaleFactor 1; # $scale variable controls vertical exaggeration<br>
surface Update<br>
#surface UseNormalOn<br>
#surface SetNormal 0 0 1<br>
puts "Warp scalar no of cells : [[surface GetOutput] GetNumberOfCells]"<br>
puts "Warp scalar no of points: [[surface GetOutput] GetNumberOfPoints]"<br>
<br>
<br>
<br>
# Map dataset to graphics primitives<br>
#<br>
vtkDataSetMapper demMapper<br>
demMapper SetInputConnection [surface GetOutputPort]<br>
demMapper ScalarVisibilityOff; # This prevents surface being colored based<br>
on scalar value<br>
<br>
#<br>
===========================================================================<br>
# Create actor for surface topogrpahy<br>
#<br>
===========================================================================<br>
<br>
vtkLODActor demActor<br>
demActor SetMapper demMapper<br>
[demActor GetProperty] SetInterpolationToGouraud<br>
[demActor GetProperty] SetRepresentationToSurface<br>
<br>
#<br>
===========================================================================<br>
# Create projected terrain path<br>
#<br>
===========================================================================<br>
<br>
# Create some paths<br>
vtkPoints pts<br>
pts InsertNextPoint 562669 5.1198e+006 1992.77<br>
pts InsertNextPoint 562100 5.1170e+006 1900.77<br>
pts InsertNextPoint 562850 5.11181e+006 1912.57<br>
pts InsertNextPoint 562659 5.1198e+006 1992.77<br>
<br>
<br>
<br>
vtkCellArray lines<br>
lines InsertNextCell 4<br>
lines InsertCellPoint 0<br>
lines InsertCellPoint 1<br>
lines InsertCellPoint 2<br>
lines InsertCellPoint 3<br>
<br>
vtkPolyData terrainPaths<br>
terrainPaths SetPoints pts<br>
terrainPaths SetLines lines<br>
<br>
vtkProjectedTerrainPath projectedPaths<br>
projectedPaths SetInput terrainPaths<br>
projectedPaths SetSource [reader GetOutput]<br>
projectedPaths SetHeightOffset 25<br>
projectedPaths SetHeightTolerance 5<br>
projectedPaths SetProjectionModeToNonOccluded<br>
projectedPaths SetProjectionModeToHug<br>
projectedPaths Update<br>
puts "Projected path filter no of cells : [[projectedPaths GetOutput]<br>
GetNumberOfCells]"<br>
<br>
#vtkPolyDataMapper pathMapper<br>
# pathMapper SetInputConnection [projectedPaths GetOutputPort]<br>
<br>
vtkTubeFilter pathTube<br>
pathTube SetNumberOfSides 8<br>
pathTube SetInputConnection [projectedPaths GetOutputPort]<br>
pathTube SetRadius 10<br>
<br>
vtkPolyDataMapper pathTubeMapper<br>
pathTubeMapper SetInputConnection [pathTube GetOutputPort]<br>
<br>
vtkActor pathActor<br>
pathActor SetMapper pathTubeMapper<br>
[pathActor GetProperty] SetColor 1 0 0<br>
[pathActor GetProperty] SetSpecular .3<br>
[pathActor GetProperty] SetSpecularPower 30<br>
<br>
#<br>
===========================================================================<br>
# Create a cell picker<br>
#<br>
===========================================================================<br>
<br>
# Create a cell picker.<br>
vtkCellPicker picker<br>
picker AddObserver EndPickEvent annotatePick<br>
<br>
# Create a text mapper and actor to display the results of picking.<br>
vtkTextMapper textMapper<br>
set tprop [textMapper GetTextProperty]<br>
$tprop SetFontFamilyToArial<br>
$tprop SetFontSize 10<br>
$tprop BoldOn<br>
$tprop ShadowOn<br>
$tprop SetColor 1 0 0<br>
vtkActor2D textActor<br>
textActor VisibilityOff<br>
textActor SetMapper textMapper<br>
<br>
#<br>
===========================================================================<br>
# Create renderer, render window and add actors to the renderer<br>
#<br>
===========================================================================<br>
<br>
# Create the RenderWindow, Renderer and both Actors<br>
#<br>
vtkRenderer ren1<br>
vtkRenderWindow renWin<br>
renWin AddRenderer ren1<br>
vtkRenderWindowInteractor iren<br>
iren SetRenderWindow renWin<br>
iren SetPicker picker<br>
<br>
# Add the actors to the renderer, set the background and size<br>
#<br>
ren1 AddActor demActor<br>
ren1 AddActor pathActor<br>
ren1 AddActor2D textActor<br>
#ren1 AddActor probeActor<br>
ren1 SetBackground .1 .2 .4<br>
<br>
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br>
iren SetDesiredUpdateRate 5<br>
<br>
ren1 ResetCamera<br>
ren1 ResetCameraClippingRange<br>
<br>
renWin Render<br>
<br>
wm withdraw .<br>
<br>
# Create a Tcl procedure to create the text for the text mapper used to<br>
# display the results of picking.<br>
proc annotatePick {} {<br>
if { [picker GetCellId] < 0 } {<br>
textActor VisibilityOff<br>
<br>
} else {<br>
set selPt [picker GetSelectionPoint]<br>
set x [lindex $selPt 0]<br>
set y [lindex $selPt 1]<br>
set pickPos [picker GetPickPosition]<br>
set xp [lindex $pickPos 0]<br>
set yp [lindex $pickPos 1]<br>
set zp [lindex $pickPos 2]<br>
<br>
textMapper SetInput "($xp, $yp, $zp)"<br>
textActor SetPosition $x $y<br>
textActor VisibilityOn<br>
}<br>
<br>
renWin Render<br>
}/<br>
<br>
Now I was taking a look at vtkExtractGrid, however as surface is no<br>
structured grid I do not know how to extract a part of the surface,<br>
I was trying<br>
<br>
/vtkExtractGrid extract<br>
extract SetVOI 1 55 -1000 1000 -1000 1000<br>
extract SetInputData #pass reader Output as surface?<br>
<br>
vtkPlane plane<br>
plane SetOrigin 0 4 2<br>
plane SetNormal 0 1 0<br>
vtkCutter cutter<br>
cutter SetInputConnection [extract GetOutputPort]<br>
cutter SetCutFunction plane<br>
cutter GenerateCutScalarsOff<br>
cutter SetSortByToSortByCell<br>
<br>
vtkLookupTable clut<br>
clut SetHueRange 0 .67<br>
clut Build<br>
<br>
vtkPolyDataMapper cutterMapper<br>
cutterMapper SetInputConnection [cutter GetOutputPort]<br>
cutterMapper SetScalarRange .18 .7<br>
cutterMapper SetLookupTable clut<br>
<br>
vtkActor cut<br>
cut SetMapper cutterMapper<br>
/<br>
<br>
Could you please suggest an idea on how to extract or cut this surface<br>
defined by contour?<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/How-to-extract-a-part-defined-by-closed-points-inside-a-unstructured-Grid-Surface-tp5726086.html" target="_blank">http://vtk.1045678.n5.nabble.com/How-to-extract-a-part-defined-by-closed-points-inside-a-unstructured-Grid-Surface-tp5726086.html</a><br>
Sent from the VTK - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
</blockquote></div><br></div></div>