[vtkusers] Create Cells from Points
David E DeMarle
dave.demarle at kitware.com
Thu Feb 12 01:07:31 EST 2009
On Tue, Feb 10, 2009 at 1:30 PM, David Doria <daviddoria at gmail.com> wrote:
> If I create points one at a time, I have to add them to a CellArray
> one at a time too, like this
>
> vtkPoints* points3D = vtkPoints::New();
> vtkCellArray* Vertices = vtkCellArray::New();
>
> for ( unsigned int i = 0; i < NumPoints(); ++i )
> {
> vtkIdType pid[1];
> vgl_point_3d<double> Point = getPoint(i);
> pid[0] = points3D->InsertNextPoint(Point.x(), Point.y(), Point.z());
> Vertices->InsertNextCell(1,pid);
> }
>
> Is there a better way to do this?
You can apply a glyph filter with a single cell glyph. But that
internally will do the above.
Also, what is the idea of having to
> use cells for everything rather than operating on the array of points
> directly?
True it is odd to have to create cells when you are working with pure
point location data, but in the majoritiy of cases people deal with
higher dimensional cells. Because of that you don't want to assume
that all points are cells. Otherwise defining a triangle would
implicitly define 4 cells instead of one.
>
>
> --
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109
More information about the vtkusers
mailing list