[Insight-users] How to render ITK mesh in OpenGL-based environment?

Bjorn Hanch Sollie bhs at pvv . org
Mon, 11 Aug 2003 21:50:17 +0200 (CEST)


On Thu, 7 Aug 2003, Luis Ibanez wrote:

Hi Luis,

Thank you so much for replying!

> You may want to take a look at the method
>
>     void CellularAggregate::Draw(void) const
>
> in CellularAggregate.cxx

Done, and I do see how to use the basic mesh operators to retrieve the
mesh data.  I do, however, still have some problems understanding
exactly what the rest of the code does (besides drawing, of course).
What I need is to construct a data buffer that is to be drawn by the
(relatively straightforward) OpenGL code listed below.  How exactly do
I retrieve the vertices (and what do the VoroniRegion data types have
to do with that anyway; a bit confusing)?  How do I create the needed
normals from the available mesh data?  I will be very grateful for
hints and help on how to do this.

  while(npolys--)
  {
    glBegin( GL_TRIANGLE_STRIP );
    glColor3fv((float*)&data[(PNTINTS*0)+OFFSET_COLOR]);
    glNormal3fv((float*)&data[(PNTINTS*0)+OFFSET_NORMAL]);
    glVertex3fv((float*)&data[(PNTINTS*0)+OFFSET_POINT]);
    glColor3fv((float*)&data[(PNTINTS*1)+OFFSET_COLOR]);
    glNormal3fv((float*)&data[(PNTINTS*1)+OFFSET_NORMAL]);
    glVertex3fv((float*)&data[(PNTINTS*1)+OFFSET_POINT]);
    glColor3fv((float*)&data[(PNTINTS*3)+OFFSET_COLOR]);
    glNormal3fv((float*)&data[(PNTINTS*3)+OFFSET_NORMAL]);
    glVertex3fv((float*)&data[(PNTINTS*3)+OFFSET_POINT]);
    glColor3fv((float*)&data[(PNTINTS*2)+OFFSET_COLOR]);
    glNormal3fv((float*)&data[(PNTINTS*2)+OFFSET_NORMAL]);
    glVertex3fv((float*)&data[(PNTINTS*2)+OFFSET_POINT]);
    glEnd();
    data += PNTINTS*4;
  }

Thanks in advance,

-Beorn
-- 
Truth is often just a widely held opinion.