[vtkusers] Re: Traversing a vtkCellArray in Tcl?
eduardo at cs.uno.edu
Wed Sep 18 13:33:25 EDT 2002
You can get the underlying array from the vtkCellArray, which is just an
array of indices (vtkIdType's, basically integers) into the Points array in
the poly data.
To do this, you would do something like:
set lines [pdi GetLines]
set indices [$lines GetData]
After that, you can Set/Get the elements of the 'indices' array. For
$indices GetTuple1 0
gives you the first entry, which represents the number of vertices in the
first cell (should be 2 in the case of a simple line).
Note that I have only used this to peek into the data structure, to verify
how it's built. Heaven knows (I'm sure more knowledgeable people know too)
what happens if you start inserting elements or changing existing elements.
Maybe they will be kind enough to warn you about potential problems with
modifying the data structure. Good luck!
Eduardo Kortright Department of Computer Science
eduardo at cs.uno.edu University of New Orleans
Phone: (504) 280-6626 Lakefront Campus
Fax: (504) 280-7228 New Orleans, LA 70148
> Date: Wed, 18 Sep 2002 11:03:10 -0400
> From: Jeremy Winston <winston at cat.rpi.edu>
> Organization: CAT @ RPI
> To: VTK Users <vtkusers at public.kitware.com>
> Subject: [vtkusers] Traversing a vtkCellArray in Tcl?
> I'm trying to fiddle with a vtkPolyData instance ("pdi")
> that consists of a set of 2D vtkPolyLines, using Tcl.
> I want to be able to determine the line that is closest
> to a given point. I also want to be able to delete
> arbitrary lines.
> I am having trouble using Tcl to do this.
> [pdi GetLines] returns the vtkCellArray OK, but when I
> try to traverse it:
> [pdi GetLines] InitTraversal
> set line [[pdi GetLines] GetNextCell npts pts]
> I get an error that the function doesn't exist or is being
> called with the wrong args. After reading through
> vtk-src\Wrapping\vtkWrapTcl.c, it seems that GetNextCell
> can't be wrapped since it takes references as arguments.
> Is there any other way using Tcl for me to get at the
> cell and point data to modify it?
More information about the vtkusers