[vtkusers] Build my own polydata ?

David Gobbi david.gobbi at gmail.com
Mon Dec 7 12:00:42 EST 2009


On Mon, Dec 7, 2009 at 9:45 AM, Adeline Joliet <adeline_joli at hotmail.com> wrote:
> Hello,
>
> Here my question, I'using AreaPicker to get the frustum (getClipPoint)
> created from 4 points.getClipPoint return me the 8 points (8 vertices) that
> define the selected frustum.
>
> Is there any posibilitie to build a polydata from that ? If so, how ?
>
> any help would be appreciable :)

Briefly, the recipe is as follows:

  vtkPoints *points = vtkPoints::New();
  vtkCellArray *polys = vtkCellArray::New();

  points->InsertNextPoint(x,y,z);
  // etcetera

  polys->InsertNextCell(4); // or however many points are in the polygon
  polys->InsertCellPoint(0);  // ID of first point in poly
  polys->InsertCellPoint(1);
  // etcetera until polygon is done, then call InsertNextCell for next polygon

  vtkPolyData *data = vtkPolyData::New();
  data->SetPoints(points);
  data->SetPolys(polys);
  points->Delete();
  strips->Delete();

  // use "data" as your polydata

Constructing the cells is the only difficult part, but there is a good
discussion of it in the VTK book or in any modern computer graphics
text.

   David



More information about the vtkusers mailing list