[vtkusers] pointer to vtkpoint ID's?

Arvind Rao arvind.sbia at gmail.com
Fri Apr 15 09:52:20 EDT 2011


Hi All,

I want a pointer to point ID's from an instance of class vtkPoints. At
present I simply assume that points are indexed from 0 to N, and this may
not be good. Below illustrates what I'm trying to do in general:

    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    const float p[4][3] = { {1.0, 2.0, 3.0},
                                       {0.5, 1.0, .76},
                                       {0.3, 0.1,  .9}, };
    // Create the topology of the point (a vertex)
     vtkSmartPointer<vtkCellArray> vertices  =
vtkSmartPointer<vtkCellArray>::New();
     vtkIdType pid[1];

     for(int i = 0; i < 3; ++i)
     {
        pid[0] = points->InsertNextPoint(p[i]);
        vertices->InsertNextCell(1,pid);
     }

    // Create a polydata object
    vtkSmartPointer<vtkPolyData> poly = vtkSmartPointer<vtkPolyData>::New();
    poly->SetPoints(points);    poly->SetVerts(vertices);
    vtkSmartPointer<vtkPoints> pointss = poly->GetPoints();
    vtkIdType numPts = pointss->GetNumberOfPoints();
    double x[3]={0,0,0};
    for (int i = 0; i< numPts; ++i)
    {
         pointss->GetPoint(i, x);  //here is where I want to use a pointer
to point ID's instead of 'int i'
         std::cout<< "Point: " << x[0] << " " << x[1] << " "<< x[2] << "\n";
    }
//end code snippet

Got an idea?

All the best,
Arvind
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110415/a13e0961/attachment.htm>


More information about the vtkusers mailing list