[vtkusers] how to get Cell ID?

David Doria daviddoria+vtk at gmail.com
Mon Nov 30 17:26:28 EST 2009


On Thu, Nov 12, 2009 at 8:35 AM, Grzegorz Pytel <bioinfguy at gmail.com> wrote:
> I want to get cell id while traversing vtkCellArray. How can I get it?
> Regards,
> Gregory
> This is my code:
> vtkCellArray * CA = this->data->GetPolys();
> CA->InitTraversal();
> vtkIdType npts;
> vtkIdType *pts;
>
> int i=0;
> while(CA->GetNextCell(npts,pts))
> {
> glBegin(GL_TRIANGLES);
> for (int j = 0; j < npts; ++j)
> {
> if (i == 0)
> {
> //double * p = points->GetPoint(pts[j]);
> double * p = this->data->GetPoint(pts[j]);
> points->SetPoint(pts[j], p[0] - 0.3, p[1], p[2]);
> }
> double *p = points->GetPoint(pts[j]);
> double x = p[0];
> double y = p[1];
> double z = p[2];
> glVertex3f((float)x,(float)y,(float)z);
> //cout << endl;
> //cout << "X: " << x << " " << "Y: " << y << " " << "Z: " << z << endl;
> //cout << endl;
> }
> glEnd();
> i++;
> }
> cout << i << endl;


Did you ever get this resolved? Why are you calling OpenGL functions
if you are using VTK?

Thanks,

David



More information about the vtkusers mailing list