[vtk-developers] Render mesh using triangle strips with adjacency

Pelt, R.F.P. van R.F.P.v.Pelt at tue.nl
Thu Nov 1 05:03:26 EDT 2012


Dear all,

I currently render a mesh as triangle strips, roughly as follows:

  vtkPolyData  *mesh     = ...
  vtkCellArray *strips   = mesh->GetStrips();
  vtkPoints    *points   = mesh->GetPoints();

  for (strips->InitTraversal(); strips->GetNextCell(nPts,ptIds);)
  {
    // Build the structures
    vertex.clear();

    for (int j = 0; j < nPts; j++)
    {
      double v[3];
      points->GetPoint(ptIds[j], v);

      vertex.push_back(v[0]);
      vertex.push_back(v[1]);
      vertex.push_back(v[2]);
    }

    // Build the buffers
    sizeBuffer = vertex.size()*sizeof(GLfloat);

    // Render
    glEnableClientState(GL_VERTEX_ARRAY);

    glVertexPointer(3, GL_FLOAT, 0, &vertex[0]);

    glDrawArrays(GL_TRIANGLE_STRIP, 0, (int)vertex.size()/3);

    glDisableClientState(GL_VERTEX_ARRAY);
  }

I render it in this OpenGL way since I process the mesh with a geometry shader.
Now I would like to include adjacency information, using GL_TRIANGLE_STRIP_ADJACENCY, or possibly GL_TRIANGLE_ADJACENCY.
(See for example: http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/primitive-assembly/)

I'm not sure how to build the structure, and parse the right information from the polydata.
I was playing around with mesh->GetCellEdgeNeighbors,  but that did not yet provide me the results I need.
I guess I need to find the neighboring point connected to an edge, which does not belong to the current triangle?

Anybody that can give me a pointer where to look next?

Thanks.

Regards

-Roy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20121101/ccb0af8b/attachment.html>


More information about the vtk-developers mailing list