[vtkusers] (no subject)

David Doria daviddoria at gmail.com
Tue May 15 08:01:46 EDT 2012


On Tue, May 15, 2012 at 5:18 AM, tasnim <hanene-jeder at hotmail.fr> wrote:
> Good morning,
> I could'nt get my points from my selected cell in order to reconstruct a
> vtkPolyData from it. Here is the code:

> I didn't have a function for my selected cell called "selected" that gives
> me my Pointids and my cell Edges, in order to use them in my triangle's
> construction. Any help please, and thanks

Ok, you need to take a step back. Instead of doing all of this in your
real code, make a new project where you simply create a
vtkSphereSource and try to extract one of its cells. This way when you
get stuck, you can show us compilable code and try to explain what and
where it is going wrong.

I guess there is one more step than I originally mentioned. Once you
have the vtkCell, you need to create a new vtkPoints object with it's
points:

vtkPoints* cellPoints = cell->GetPoints();
newPolydata->SetPoints(cellPoints);

I think you'll also need to change the points that the cells reference
to the new point ids (since you will now only have N points with ids 0
to N) instead of the larger ids corresponding to the ids of the points
in the large input data set.

Alternatively, you could use this:

http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ExtractSelectionCells

I just always hesitate to suggest these filters because the API is a
bit confusing (SetFieldType, etc).

Good luck,

David



More information about the vtkusers mailing list