/* --------------------------------------------------------------------  */
/*                          CALCULIX                                     */
/*                   - GRAPHICAL INTERFACE -                             */
/*                                                                       */
/*     A 3-dimensional pre- and post-processor for finite elements       */
/*              Copyright (C) 1996 Klaus Wittig                          */
/*                                                                       */
/*     This program is free software; you can redistribute it and/or     */
/*     modify it under the terms of the GNU General Public License as    */
/*     published by the Free Software Foundation; version 2 of           */
/*     the License.                                                      */
/*                                                                       */
/*     This program is distributed in the hope that it will be useful,   */
/*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
/*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
/*     GNU General Public License for more details.                      */
/*                                                                       */
/*     You should have received a copy of the GNU General Public License */
/*     along with this program; if not, write to the Free Software       */
/*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
/* --------------------------------------------------------------------  */

/* TO DO
*/
#include <cgx.h>

#define TEST 0


extern GLfloat entity_r[SET_COLS];                     /* predefined colors of entities */
extern GLfloat entity_g[SET_COLS];
extern GLfloat entity_b[SET_COLS];


extern int   basCol[3];                        /* color indexes due to basic colormap: 0=bl. 1=w 2=gy */
extern int   foregrndcol, backgrndcol;          /* default fore- and background color */
extern double foregrndcol_rgb[4];
extern double backgrndcol_rgb[4];

extern unsigned char  datin[MAX_LINE_LENGTH];         /* Input-data-file */
extern unsigned char  buffer[MAX_LINE_LENGTH];
extern int   offset, maxIndex;                        /* offset+steps-1 = maxIndex */
extern int   width_ini, height_ini; /* Grafig-Fensterbreite/hoehe */
extern int   width_menu, height_menu;
extern int   w0, w1, w_index, w_rgb, activWindow;
extern int   width_w0, height_w0;
extern int   width_w1, height_w1;
extern int   MouseMode;                                   /* status maustasten */
extern double dtx, dty, dtz, drx, dry, drz, ds;                 /* Verschiebungen */
extern double vmem[4];                                     /* kor. bis auswahl eines neuen drehpkts */
extern double anim_faktor;                            /* Scalierung der Amplitude */
extern unsigned char  drawMode;               /* protokoliert drawFunktion (Load=1,Light=2,Animate=3,preprocessor=4, vector=5)*/
extern   double lmodel_twoside[1];
extern GLint   gl_max_eval_order;                         /* max order of NURBS */
extern GLdouble R[4][4];                                   /* Rotationsmatrix */
extern unsigned char  surfFlag;                /* zeichne nur Oberflaechenelemente (1), sonst (0)*/
extern unsigned char  modelEdgeFlag;                /* zeichne mit Modell-Ecken (1), sonst (0)*/
extern unsigned char  frameFlag;                   /* mit (1) oder ohne Rahmen um das Grafikfenster */
extern unsigned char  filenamFlag;                   /* mit (1) oder ohne filename im Menufenster */
extern unsigned char  textFlag;                   /* mit (1) oder ohne text im Menufenster */
extern unsigned char  printFlag;                     /* printf 1:on 0:off */
extern unsigned char  cullFlag;                     /* (1) enable Culling */
extern unsigned char  frameFlag;               /* mit (1) oder ohne Rahmen um das Grafigfenster */
extern unsigned char  scalaFlag;                 /* mit (1) oder ohne scala und wertetexte */ 
extern unsigned char  addDispFlag;                    /* 0: original node-coordinates, 1: node-coordinates+displacements */
extern double dx ,dy;                                      /* Mauskoordinaten */
extern int   steps;                          /* Schrittweite der Farbscala */
extern double gtol;
extern int     ddiv;
extern double     dbias;
extern unsigned char  picture_text[MAX_LINE_LENGTH], datin[MAX_LINE_LENGTH];
extern double v_scale;                                    /* scaling-factor for the vectors in the vector-plot */

extern unsigned char  delPntFlag;                    /* 1: deleted points exists */
extern unsigned char  delLineFlag;                   /* 1: deleted lines exists */
extern unsigned char  delLcmbFlag;                   /* 1: deleted lcmbs exists */
extern unsigned char  delSurfFlag;                   /* 1: deleted surfs exists */
extern unsigned char  delBodyFlag;                   /* 1: deleted bodys exists */
extern unsigned char  delNursFlag;
extern unsigned char  delSetFlag;                  /* 1: deleted sets exists */
extern unsigned char  writeCFDflag;                /* 1: write cfd-files for duns during meshing */
extern unsigned char  movieFlag;                     /* >0: save sequence of gif pictures */

extern int     num_olc;          /* nr-of-original-loadcases (lc from input-file) */
extern int     elemMat[99];      /*  Material Numbers, Number of Materials stored in elemMat[0]  */

#if INX_MODE
int       *colNr;
#define  GLCOLOR   glIndexi
#endif
#if TEX_MODE
double     *colNr;
#define  GLCOLOR   glTexCoord1d
#endif


extern Scale     scale[1];
extern double     *value_n;
extern Elements  *e_enqire;
extern Summen    anz[1];
extern Edges     *edge;
extern Nodes     *node;
extern Nodes     *n_anim;
extern Datasets *lcase;
extern Faces     *face;

extern Meshp meshp;

extern Alias     *alias;
extern Sets      *set;
extern Psets     *pset;
extern Points    *point;
extern Lines     *line;
extern Lcmb      *lcmb;
extern Gsur      *surf;
extern Gbod      *body;
extern Nurbl     *nurbl;
extern Nurbs     *nurbs;
extern SumGeo    anzGeo[1];
extern SumAsci   sumAsci[1];

extern int       num_olc;


/* additional entities */
extern OpenSets   openSets[1];
extern SpecialSet specialset[1];

int current_nurbs;
static void NurbsErrorCallback(GLenum which)
{
  printf(" GluNURBS: error occured (%d):\n", which);
  if(current_nurbs>-1)
  {
    printf("    %s in nurbs:%s see set:%s\n", gluErrorString(which), nurbs[current_nurbs].name,specialset->bnur);
    pre_seta(specialset->bnur,"S",nurbs[current_nurbs].name);
  }
  else
  {
    printf("    %s in nurl:%s see set:%s\n", gluErrorString(which), nurbs[-current_nurbs-1].name,specialset->bnur);
    pre_seta(specialset->bnur,"L",nurbs[current_nurbs].name);
  }
}



/* prepares vectors pointing from the center of the element-face (like a tape in a storm)*/
/* the lengt is proportional to the value of the vector */
/* lc Dataset */
/* ne number of entities */
/* *e entities */
/* v_factor scale factor for the vectors */
void drawFaces_vector(  int lc, int ne, int *e, double v_factor, int num, int *name, Nodes *node, Faces *face )
{
  int i,j,k,n;
  double p1[3], p2[3], v2[3];

#if TEST
  printf ("in drawSurfaces_vector\n");
#endif 

  glLineWidth(1);
  glPointSize (2);
#if INX_MODE
  glIndexi( basCol[foregrndcol] );
#endif
#if TEX_MODE
  glColor3dv( foregrndcol_rgb );
#endif

  for (i=0; i<num; i++ )
  {
    n=0;
    if ( face[name[i]].type == 7 ) n=3;
    if ( face[name[i]].type == 8 ) n=6;
    if ( face[name[i]].type == 9 ) n=4;
    if ( face[name[i]].type == 10) n=8;
    if(n>0)
    {
      /* calculate the start and end-point of the vector */
      for(j=0; j<n; j++)
      {
        if(node[face[name[i]].nod[j]].pflag!=1)
        {
          for(k=0; k<3; k++) v2[k]=0.;
          for(k=0; k<ne; k++) v2[k]+=lcase[lc].dat[e[k]][face[name[i]].nod[j]];
          p1[0]=node[face[name[i]].nod[j]].nx-(v2[0]*v_factor);  
          p1[1]=node[face[name[i]].nod[j]].ny-(v2[1]*v_factor);  
          p1[2]=node[face[name[i]].nod[j]].nz-(v2[2]*v_factor);  
          p2[0]=node[face[name[i]].nod[j]].nx+(v2[0]*v_factor);  
          p2[1]=node[face[name[i]].nod[j]].ny+(v2[1]*v_factor);  
          p2[2]=node[face[name[i]].nod[j]].nz+(v2[2]*v_factor);  
          glBegin ( GL_LINES );
          glVertex3dv ( p1 );
          glVertex3dv ( p2 );
          glEnd();
          glBegin ( GL_POINTS );
          glVertex3dv ( p2 );
          glEnd();
        }
      }
    }
  }
}


void drawElements_vector( int lc, int ne, int *e, double v_factor, int num, int *name, Nodes *node, Elements *e_enqire )
{
  int i,j,k,n;
  double p1[3], p2[3], v2[3];

#if TEST
  printf ("in drawElements_vector\n");
#endif 

  glLineWidth(1);
  glPointSize (2);
#if INX_MODE
  glIndexi( basCol[foregrndcol] );
#endif
#if TEX_MODE
  glColor3dv( foregrndcol_rgb );
#endif

  for (i=0; i<num; i++ )
  {
    n=0;
    if( e_enqire[name[i]].type == 1 ) n=8;
    if( e_enqire[name[i]].type == 3 ) n=4;
    if( e_enqire[name[i]].type == 4 ) n=20;
    if( e_enqire[name[i]].type == 6 ) n=10;
    if( e_enqire[name[i]].type == 9 ) n=4;
    if( e_enqire[name[i]].type == 10 ) n=8;
    if(n>0)
    {
      /* calculate the start and end-point of the vector */
      for(j=0; j<n; j++)
      {
        for(k=0; k<3; k++) v2[k]=0.;
        for(k=0; k<ne; k++) v2[k]+=lcase[lc].dat[e[k]][e_enqire[name[i]].nod[j]];
        p1[0]=node[e_enqire[name[i]].nod[j]].nx-(v2[0]*v_factor);  
        p1[1]=node[e_enqire[name[i]].nod[j]].ny-(v2[1]*v_factor);  
        p1[2]=node[e_enqire[name[i]].nod[j]].nz-(v2[2]*v_factor);  
        p2[0]=node[e_enqire[name[i]].nod[j]].nx+(v2[0]*v_factor);  
        p2[1]=node[e_enqire[name[i]].nod[j]].ny+(v2[1]*v_factor);  
        p2[2]=node[e_enqire[name[i]].nod[j]].nz+(v2[2]*v_factor);  
        glBegin ( GL_LINES );
        glVertex3dv ( p1 );
        glVertex3dv ( p2 );
        glEnd();
        glBegin ( GL_POINTS );
        glVertex3dv ( p2 );
        glEnd();
      }
    }
  }
}




void drawNodes_plot( int num, int *name, Nodes *node , int col, unsigned char type)
{
  register int i;


  glPointSize (4);

#if INX_MODE
  glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
  glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif
  glLoadName('n');
  for (i=0; i<num; i++ )
  {
    glPushName(name[i]);
    glBegin ( GL_POINTS );
    glVertex3d ( node[name[i]].nx, node[name[i]].ny, node[name[i]].nz );
    glEnd();
    glPopName();
  }
  glLoadName(-1);

  if(type=='a')
  {
    /* glDisable ( GL_CULL_FACE ); */
    for (i=0; i<num; i++ )
    {
      sprintf( buffer, "%d ", name[i]);
      text( node[name[i]].nx, node[name[i]].ny, node[name[i]].nz, buffer );
    }
    /* glEnable ( GL_CULL_FACE ); */
  }
  if(type=='v')
  {
    for (i=0; i<num; i++ )
    {
      sprintf( buffer, "%6.2le ", value_n[name[i]]);
      text( node[name[i]].nx, node[name[i]].ny, node[name[i]].nz, buffer );
    }
  }
}



void drawElements_plot( int num, int *name, Nodes *node, Elements *e_enqire, int col, unsigned char type, int pickflag )
{
  int i, j, n;
  double x, y, z;
  static GLint ipuf[2];

  glLineWidth(1.);
  glGetIntegerv( GL_POLYGON_MODE, ipuf );

  if(type=='v')
  {
#if TEX_MODE
    /* enable all colors for the TEX_MODE */
    glColor3d( 1,1,1);
    glEnable(GL_TEXTURE_1D);
#endif
    for (i=0; i<num; i++ )
    {
      if(( e_enqire[name[i]].type <7 )&&( ipuf[1] == GL_FILL )) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );
      if( e_enqire[name[i]].type == 1 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 2 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLES      );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 3 )
      {
        glBegin ( GL_TRIANGLE_FAN );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
        glBegin ( GL_TRIANGLES );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 4 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[13]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[21]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[21]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[17]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[16]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[25]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[25]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[19]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[12]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[23]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[23]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[11]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[21]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[21]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[14]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[17]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[25]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[25]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[18]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[19]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[23]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[23]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[15]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[11]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[16]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[13]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[20]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[20]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[24]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[24]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[14]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[22]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[22]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[18]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[16]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[20]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[20]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[12]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[24]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[24]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[11]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[22]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[22]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[15]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[18]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 5 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[15]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[17]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[11]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[16]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[15]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[12]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[17]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[14]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[11]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[16]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[13]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[10]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[18]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[18]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[13]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[12]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[19]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[13]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[ 5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[19]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[14]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 6 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN   );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[9]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEnd();
        glBegin ( GL_TRIANGLES   );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 7 )
      {
        glBegin ( GL_TRIANGLES );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 8 )
      {
        glBegin ( GL_TRIANGLES );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[5]].nx );
    
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[4]].nx );
    
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[3]].nx );
    
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR     ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv  ( &node[e_enqire[name[i]].nod[4]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 9 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 10 )
      {
        glBegin ( GL_TRIANGLE_FAN   );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[8]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[4]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[5]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[6]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[3]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[7]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 11 )
      {
        glBegin ( GL_LINES );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 12 )
      {
        glBegin ( GL_LINE_STRIP );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[0]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[2]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[e_enqire[name[i]].nod[1]] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
      }
    }
#if TEX_MODE
    glDisable(GL_TEXTURE_1D);
#endif
  }
  else if(pickflag)
  {
    /* any other color */
#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
    glLoadName('e');

    glGetIntegerv( GL_POLYGON_MODE, ipuf );

    for (i=0; i<num; i++ )
    {
      if(( e_enqire[name[i]].type <7 )&&( ipuf[1] == GL_FILL )) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );
      glPushName(name[i]);
      if(( e_enqire[name[i]].type == 1 )||( e_enqire[name[i]].type == 4 ))
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
  
      /* new strip */
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
       glEnd();
      }

      if(( e_enqire[name[i]].type == 2 )||( e_enqire[name[i]].type == 5 ))
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
       glEnd();
      }
    
      if(( e_enqire[name[i]].type == 3 )||( e_enqire[name[i]].type == 6 ))
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
       glEnd();
       glBegin ( GL_TRIANGLE_FAN   );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
       glEnd();
      }
  
      if(( e_enqire[name[i]].type == 7 )||( e_enqire[name[i]].type == 8 ))
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
       glEnd();
      }
      if( e_enqire[name[i]].type == 9 )
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
  
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
       glEnd();
      }
      if( e_enqire[name[i]].type == 10 )
      {
       glBegin ( GL_TRIANGLES  );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
  
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
  
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
  
  
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
  
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
  
        glEdgeFlag ( GL_TRUE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEdgeFlag ( GL_FALSE );
         glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEdgeFlag ( GL_TRUE );
  
      glEnd();
      }
      if( e_enqire[name[i]].type == 11 )
      {
       glBegin ( GL_LINES );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
       glEnd();
      }
      if( e_enqire[name[i]].type == 12 )
      {
       glBegin ( GL_LINE_STRIP );
         glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
         glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
       glEnd();
      }
  
      if(type=='a')
      {
        j=0;
        if(( e_enqire[name[i]].type == 1 )||( e_enqire[name[i]].type == 4 )) j=8;
        else if(( e_enqire[name[i]].type == 2 )||( e_enqire[name[i]].type == 5 )) j=6;
        else if(( e_enqire[name[i]].type == 3 )||( e_enqire[name[i]].type == 6 )) j=4;
        else if(( e_enqire[name[i]].type == 7 )||( e_enqire[name[i]].type == 8 )) j=3;
        else if(( e_enqire[name[i]].type == 9 )||( e_enqire[name[i]].type == 10)) j=4;
        else if( e_enqire[name[i]].type == 11 ) j=2;
        else if( e_enqire[name[i]].type == 12 ) j=3;
        x=0.; y=0.; z=0.;
        for (n=0; n<j; n++)
        {
          x+= node[e_enqire[name[i]].nod[n]].nx;
          y+= node[e_enqire[name[i]].nod[n]].ny;
          z+= node[e_enqire[name[i]].nod[n]].nz;
        }
        x/= j; y/= j; z/= j;
        sprintf( buffer, "%d ", name[i]);
        text( x, y, z, buffer );
      }
      glPopName();
    }
    glLoadName(-1);
  }
  else
  {
    getElemNormalen( e_enqire, node, anz->e );

    /* color is lighted grey */
    glEnable( GL_LIGHTING );

    for (i=0; i<num; i++ )
    {
      if(( e_enqire[name[i]].type <7 )&&( ipuf[1] == GL_FILL )) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );

      if( e_enqire[name[i]].type == 1 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
        /* math.pos von z->y  */
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[5] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 2 )
      {
        glBegin ( GL_TRIANGLES      );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
        glBegin ( GL_TRIANGLES      );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 3 )
      {
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLES );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 4 )
      {
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[21]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glNormal3dv ( e_enqire[name[i]].side[5] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[6] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glNormal3dv ( e_enqire[name[i]].side[7] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[8] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[22]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glNormal3dv ( e_enqire[name[i]].side[9] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[10] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glNormal3dv ( e_enqire[name[i]].side[11] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[12] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glNormal3dv ( e_enqire[name[i]].side[13] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[14] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glNormal3dv ( e_enqire[name[i]].side[15] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[16] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[23]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glNormal3dv ( e_enqire[name[i]].side[17] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[18] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glNormal3dv ( e_enqire[name[i]].side[19] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[20] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glNormal3dv ( e_enqire[name[i]].side[21] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[22] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glNormal3dv ( e_enqire[name[i]].side[23] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[24] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[24]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[25] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[26] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glNormal3dv ( e_enqire[name[i]].side[27] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[28] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glNormal3dv ( e_enqire[name[i]].side[29] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[30] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[31] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[32] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[25]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glNormal3dv ( e_enqire[name[i]].side[33] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[34] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glNormal3dv ( e_enqire[name[i]].side[35] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[36] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glNormal3dv ( e_enqire[name[i]].side[37] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[38] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glNormal3dv ( e_enqire[name[i]].side[39] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
        glEnd();
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[40] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[20]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[41] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glNormal3dv ( e_enqire[name[i]].side[42] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glNormal3dv ( e_enqire[name[i]].side[43] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[44] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glNormal3dv ( e_enqire[name[i]].side[45] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[46] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glNormal3dv ( e_enqire[name[i]].side[47] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 5 )
      {
        glBegin ( GL_TRIANGLES );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glNormal3dv ( e_enqire[name[i]].side[5] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glNormal3dv ( e_enqire[name[i]].side[6] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[7] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[8] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[9] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glNormal3dv ( e_enqire[name[i]].side[10] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glNormal3dv ( e_enqire[name[i]].side[11] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glNormal3dv ( e_enqire[name[i]].side[12] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glNormal3dv ( e_enqire[name[i]].side[13] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glNormal3dv ( e_enqire[name[i]].side[14] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glNormal3dv ( e_enqire[name[i]].side[15] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[16] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[17] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glNormal3dv ( e_enqire[name[i]].side[18] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[19] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glNormal3dv ( e_enqire[name[i]].side[20] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glNormal3dv ( e_enqire[name[i]].side[21] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glNormal3dv ( e_enqire[name[i]].side[22] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glNormal3dv ( e_enqire[name[i]].side[23] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[24] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[25] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glNormal3dv ( e_enqire[name[i]].side[26] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[27] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[28] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glNormal3dv ( e_enqire[name[i]].side[29] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[30] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[31] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[32] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glNormal3dv ( e_enqire[name[i]].side[33] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glNormal3dv ( e_enqire[name[i]].side[34] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[35] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[36] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glNormal3dv ( e_enqire[name[i]].side[37] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glNormal3dv ( e_enqire[name[i]].side[38] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[39] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 6 )
      {
        glBegin ( GL_TRIANGLES );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glNormal3dv ( e_enqire[name[i]].side[5] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[6] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[7] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[8] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glNormal3dv ( e_enqire[name[i]].side[9] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[10] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glNormal3dv ( e_enqire[name[i]].side[11] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[12] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[13] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[14] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[15] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 7 )
      {
        glBegin ( GL_TRIANGLES );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 8 )
      {
        glBegin ( GL_TRIANGLES );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 9 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 10 )
      {
        glBegin ( GL_TRIANGLE_FAN );
          glNormal3dv ( e_enqire[name[i]].side[0] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
          glNormal3dv ( e_enqire[name[i]].side[1] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
          glNormal3dv ( e_enqire[name[i]].side[2] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 5]].nx );
          glNormal3dv ( e_enqire[name[i]].side[3] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 2]].nx );
          glNormal3dv ( e_enqire[name[i]].side[4] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 6]].nx );
          glNormal3dv ( e_enqire[name[i]].side[5] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 3]].nx );
          glNormal3dv ( e_enqire[name[i]].side[6] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
          glNormal3dv ( e_enqire[name[i]].side[7] );
          glVertex3dv ( &node[e_enqire[name[i]].nod[ 0]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 11 )
      {
        glBegin ( GL_LINES );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
      }
      if( e_enqire[name[i]].type == 12 )
      {
        glBegin ( GL_LINE_STRIP );
          glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
          glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
        glEnd();
      }
  
      if(type=='a')
      {
        j=0;
        if(( e_enqire[name[i]].type == 1 )||( e_enqire[name[i]].type == 4 )) j=8;
        else if(( e_enqire[name[i]].type == 2 )||( e_enqire[name[i]].type == 5 )) j=6;
        else if(( e_enqire[name[i]].type == 3 )||( e_enqire[name[i]].type == 6 )) j=4;
        else if(( e_enqire[name[i]].type == 7 )||( e_enqire[name[i]].type == 8 )) j=3;
        else if(( e_enqire[name[i]].type == 9 )||( e_enqire[name[i]].type == 10)) j=4;
        else if( e_enqire[name[i]].type == 11 ) j=2;
        else if( e_enqire[name[i]].type == 12 ) j=3;
        x=0.; y=0.; z=0.;
        for (n=0; n<j; n++)
        {
          x+= node[e_enqire[name[i]].nod[n]].nx;
          y+= node[e_enqire[name[i]].nod[n]].ny;
          z+= node[e_enqire[name[i]].nod[n]].nz;
        }
        x/= j; y/= j; z/= j;
        sprintf( buffer, "%d ", name[i]);
#if INX_MODE
        glIndexi (offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
        glColor3f ( entity_r[0], entity_g[0], entity_b[0]  );
#endif 
        glDisable( GL_LIGHTING );
        text( x, y, z, buffer );
        glEnable( GL_LIGHTING );
      }
    }
    glDisable( GL_LIGHTING );
  }
}



void drawFaces_plot( int num, int *name, Nodes *node, Faces *face, int col, unsigned char type, int pickflag )
{
  int i, j, n;
  double x, y, z;
  static GLint ipuf[2];
  extern Elements  *e_enqire;

  glLineWidth(1.);
  if(type=='v')
  {
#if TEX_MODE
    /* enable all colors for the TEX_MODE */
    glColor3d( 1,1,1);
    glEnable(GL_TEXTURE_1D);
#endif
    for (i=0; i<num; i++ )
    {
      if(( e_enqire[face[name[i]].elem_nr].type <7 )&&(drawMode<4)) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );
      if( face[name[i]].type == 7 )
      {
        glBegin ( GL_TRIANGLES );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[1]] );
          glVertex3dv ( &node[face[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[2]] );
          glVertex3dv ( &node[face[name[i]].nod[2]].nx );
        glEnd();
      }
      if( face[name[i]].type == 8 )
      {
        glBegin ( GL_TRIANGLES );
          GLCOLOR     ( colNr[face[name[i]].nod[0]] );
          glVertex3dv  ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[3]] );
          glVertex3dv  ( &node[face[name[i]].nod[3]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[5]] );
          glVertex3dv  ( &node[face[name[i]].nod[5]].nx );
    
          GLCOLOR     ( colNr[face[name[i]].nod[2]] );
          glVertex3dv  ( &node[face[name[i]].nod[2]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[5]] );
          glVertex3dv  ( &node[face[name[i]].nod[5]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[4]] );
          glVertex3dv  ( &node[face[name[i]].nod[4]].nx );
    
          GLCOLOR     ( colNr[face[name[i]].nod[4]] );
          glVertex3dv  ( &node[face[name[i]].nod[4]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[5]] );
          glVertex3dv  ( &node[face[name[i]].nod[5]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[3]] );
          glVertex3dv  ( &node[face[name[i]].nod[3]].nx );
    
          GLCOLOR     ( colNr[face[name[i]].nod[3]] );
          glVertex3dv  ( &node[face[name[i]].nod[3]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[1]] );
          glVertex3dv  ( &node[face[name[i]].nod[1]].nx );
          GLCOLOR     ( colNr[face[name[i]].nod[4]] );
          glVertex3dv  ( &node[face[name[i]].nod[4]].nx );
        glEnd();
      }
      if( face[name[i]].type == 9 )
      {
        glBegin ( GL_TRIANGLE_STRIP );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[1]] );
          glVertex3dv ( &node[face[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[3]] );
          glVertex3dv ( &node[face[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[2]] );
          glVertex3dv ( &node[face[name[i]].nod[2]].nx );
        glEnd();
      }
      if( face[name[i]].type == 10 )
      {
        glBegin ( GL_TRIANGLE_FAN );
          GLCOLOR    ( colNr[face[name[i]].nod[8]] );
          glVertex3dv ( &node[face[name[i]].nod[8]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[4]] );
          glVertex3dv ( &node[face[name[i]].nod[4]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[1]] );
          glVertex3dv ( &node[face[name[i]].nod[1]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[5]] );
          glVertex3dv ( &node[face[name[i]].nod[5]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[2]] );
          glVertex3dv ( &node[face[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[6]] );
          glVertex3dv ( &node[face[name[i]].nod[6]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[3]] );
          glVertex3dv ( &node[face[name[i]].nod[3]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[7]] );
          glVertex3dv ( &node[face[name[i]].nod[7]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
        glEnd();
      }
      if( face[name[i]].type == 11 )
      {
        glBegin ( GL_LINES );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[1]] );
          glVertex3dv ( &node[face[name[i]].nod[1]].nx );
        glEnd();
      }
      if( face[name[i]].type == 12 )
      {
        glBegin ( GL_LINE_STRIP );
          GLCOLOR    ( colNr[face[name[i]].nod[0]] );
          glVertex3dv ( &node[face[name[i]].nod[0]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[2]] );
          glVertex3dv ( &node[face[name[i]].nod[2]].nx );
          GLCOLOR    ( colNr[face[name[i]].nod[1]] );
          glVertex3dv ( &node[face[name[i]].nod[1]].nx );
        glEnd();
      }
    }
#if TEX_MODE
    glDisable(GL_TEXTURE_1D);
#endif
  }
  else if(pickflag)
  {
    /* any other color */
#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif

    if(type=='e') glLoadName('e'); else glLoadName('f');

    glGetIntegerv( GL_POLYGON_MODE, ipuf );

    for (i=0; i<num; i++ )
    {
      if(( e_enqire[face[name[i]].elem_nr].type <7 )&&(drawMode<4)) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );

      if(type=='e') glPushName(face[name[i]].elem_nr); else glPushName(name[i]);
      if( face[name[i]].type == 7 )
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
       glEnd();
      }
      if( face[name[i]].type == 8 )
      {
        glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
       glEnd();
      }
      if( face[name[i]].type == 9 )
      {
       glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );  
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
       glEnd();
      }
      if( face[name[i]].type == 10 )
      {
        glBegin ( GL_TRIANGLE_FAN);
         glVertex3dv ( &node[face[name[i]].nod[8]].nx );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );  
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
         glVertex3dv ( &node[face[name[i]].nod[6]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[7]].nx );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
      glEnd();
      }
      if( face[name[i]].type == 11 )
      {
       glBegin ( GL_LINES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
       glEnd();
      }
      if( face[name[i]].type == 12 )
      {
       glBegin ( GL_LINE_STRIP );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
       glEnd();
      }
  
      if(type=='a')
      {
        j=0;
        if(( face[name[i]].type == 7 )||( face[name[i]].type == 8 )) j=3;
        else if(( face[name[i]].type == 9 )||( face[name[i]].type == 10)) j=4;
        x=0.; y=0.; z=0.;
        for (n=0; n<j; n++)
        {
          x+= node[face[name[i]].nod[n]].nx;
          y+= node[face[name[i]].nod[n]].ny;
          z+= node[face[name[i]].nod[n]].nz;
        }
        x/= j; y/= j; z/= j;
        sprintf( buffer, "%d ", name[i]);
        text( x, y, z, buffer );
      }
      glPopName();
    }
    glLoadName(-1);
  }
  else
  {
    getFaceNormalen( face, node, anz->f );

    /* color is lighted grey */
    glEnable( GL_LIGHTING );

        /* Achtung! glNormal3dv nur VOR den ersten nodes fuert (nur hier im face-code!) auf mtu-linux zum haengen */
        /* Die normale des ersten Dreiecks muss vor- und im block spez. werden damit alle modi laufen */
	/*
       glBegin ( GL_TRIANGLE_FAN   );
         <glNormal3dv ( face[name[i]].side[0] );>
         glVertex3dv ( &node[face[name[i]].nod[8]].nx );
         etc.
	*/

    for (i=0; i<num; i++ )
    {
      if(( e_enqire[face[name[i]].elem_nr].type <7 )&&(drawMode<4)) glEnable ( GL_CULL_FACE ); else glDisable ( GL_CULL_FACE );
      if( face[name[i]].type == 7 )
      {
        glNormal3dv ( face[name[i]].side[0] );
        glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glNormal3dv ( face[name[i]].side[0] );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
       glEnd();
      }
      if( face[name[i]].type == 8 )
      {
        glNormal3dv ( face[name[i]].side[0] );
        glBegin ( GL_TRIANGLES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glNormal3dv ( face[name[i]].side[0] );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glNormal3dv ( face[name[i]].side[1] );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glNormal3dv ( face[name[i]].side[2] );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glNormal3dv ( face[name[i]].side[3] );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
       glEnd();
      }
      if( face[name[i]].type == 9 )
      {
       glNormal3dv ( face[name[i]].side[0] );
       glBegin ( GL_TRIANGLE_STRIP );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glNormal3dv ( face[name[i]].side[0] );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
       glEnd();
      }
      if( face[name[i]].type == 10 )
      {
       glNormal3dv ( face[name[i]].side[0] );
       glBegin ( GL_TRIANGLE_FAN   );
         glVertex3dv ( &node[face[name[i]].nod[8]].nx );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glNormal3dv ( face[name[i]].side[0] );
         glVertex3dv ( &node[face[name[i]].nod[4]].nx );
         glNormal3dv ( face[name[i]].side[1] );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glNormal3dv ( face[name[i]].side[2] );
         glVertex3dv ( &node[face[name[i]].nod[5]].nx );
         glNormal3dv ( face[name[i]].side[3] );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
         glNormal3dv ( face[name[i]].side[4] );
         glVertex3dv ( &node[face[name[i]].nod[6]].nx );
         glNormal3dv ( face[name[i]].side[5] );
         glVertex3dv ( &node[face[name[i]].nod[3]].nx );
         glNormal3dv ( face[name[i]].side[6] );
         glVertex3dv ( &node[face[name[i]].nod[7]].nx );
         glNormal3dv ( face[name[i]].side[7] );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glEnd();
      }
      if( face[name[i]].type == 11 )
      {
        glBegin ( GL_LINES );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
       glEnd();
      }
      if( face[name[i]].type == 12 )
      {
        glBegin ( GL_LINE_STRIP );
         glVertex3dv ( &node[face[name[i]].nod[0]].nx );
         glVertex3dv ( &node[face[name[i]].nod[1]].nx );
         glVertex3dv ( &node[face[name[i]].nod[2]].nx );
       glEnd();
      }
  
      if(type=='a')
      {
        j=0;
        if(( face[name[i]].type == 7 )||( face[name[i]].type == 8 )) j=3;
        else if(( face[name[i]].type == 9 )||( face[name[i]].type == 10)) j=4;
        x=0.; y=0.; z=0.;
        for (n=0; n<j; n++)
        {
          x+= node[face[name[i]].nod[n]].nx;
          y+= node[face[name[i]].nod[n]].ny;
          z+= node[face[name[i]].nod[n]].nz;
        }
        x/= j; y/= j; z/= j;
        sprintf( buffer, "%d ", name[i]);
#if INX_MODE
        glIndexi (offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
        glColor3f ( entity_r[0], entity_g[0], entity_b[0]  );
#endif 
        glDisable( GL_LIGHTING );
        text( x, y, z, buffer );
        glEnable( GL_LIGHTING );
      }
    }
    glDisable( GL_LIGHTING );
  }
  glEnable ( GL_CULL_FACE );
}




void drawFaces_edge( int num, int *name, Nodes *node, Faces *face, int color, unsigned char type )
{
  int i;
  static GLint ipuf[2];

  /* change the offset of the edges to the backside of the elements if */
  /* the interiour is visible */
  glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
  if ( ipuf[0] == GL_FRONT ) ds*=-1;

#if INX_MODE
  glIndexi    ( color );
#endif
#if TEX_MODE
  glColor3d(color,color,color);
#endif
  glLineWidth(1.);

  for (i=0; i<num; i++ )
  {
    if( face[name[i]].type == 7 )
    {
      glBegin ( GL_LINE_LOOP );
      glVertex3d ( node[face[name[i]].nod[0]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[0]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[0]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[1]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[1]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[1]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[2]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[2]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[2]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glEnd();
    }
    if( face[name[i]].type == 8 )
    {
      glBegin ( GL_LINE_LOOP );
      glVertex3d ( node[face[name[i]].nod[0]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[0]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[0]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[3]].nx+face[name[i]].side[2][0]*1.e-3*ds, 
                   node[face[name[i]].nod[3]].ny+face[name[i]].side[2][1]*1.e-3*ds,
                   node[face[name[i]].nod[3]].nz+face[name[i]].side[2][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[1]].nx+face[name[i]].side[3][0]*1.e-3*ds, 
                   node[face[name[i]].nod[1]].ny+face[name[i]].side[3][1]*1.e-3*ds,
                   node[face[name[i]].nod[1]].nz+face[name[i]].side[3][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[4]].nx+face[name[i]].side[2][0]*1.e-3*ds, 
                   node[face[name[i]].nod[4]].ny+face[name[i]].side[2][1]*1.e-3*ds,
                   node[face[name[i]].nod[4]].nz+face[name[i]].side[2][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[2]].nx+face[name[i]].side[1][0]*1.e-3*ds, 
                   node[face[name[i]].nod[2]].ny+face[name[i]].side[1][1]*1.e-3*ds,
                   node[face[name[i]].nod[2]].nz+face[name[i]].side[1][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[5]].nx+face[name[i]].side[2][0]*1.e-3*ds, 
                   node[face[name[i]].nod[5]].ny+face[name[i]].side[2][1]*1.e-3*ds,
                   node[face[name[i]].nod[5]].nz+face[name[i]].side[2][2]*1.e-3*ds );
      glEnd();
    }
    if( face[name[i]].type == 9 )
    {
      glBegin ( GL_LINE_LOOP );
      glVertex3d ( node[face[name[i]].nod[0]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[0]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[0]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[1]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[1]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[1]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[2]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[2]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[2]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[3]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[3]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[3]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glEnd();	
    }
    if( face[name[i]].type == 10 )
    {
      glBegin ( GL_LINE_LOOP );
      glVertex3d ( node[face[name[i]].nod[0]].nx+face[name[i]].side[0][0]*1.e-3*ds, 
                   node[face[name[i]].nod[0]].ny+face[name[i]].side[0][1]*1.e-3*ds,
                   node[face[name[i]].nod[0]].nz+face[name[i]].side[0][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[4]].nx+face[name[i]].side[1][0]*1.e-3*ds, 
                   node[face[name[i]].nod[4]].ny+face[name[i]].side[1][1]*1.e-3*ds,
                   node[face[name[i]].nod[4]].nz+face[name[i]].side[1][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[1]].nx+face[name[i]].side[5][0]*1.e-3*ds, 
                   node[face[name[i]].nod[1]].ny+face[name[i]].side[5][1]*1.e-3*ds,
                   node[face[name[i]].nod[1]].nz+face[name[i]].side[5][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[5]].nx+face[name[i]].side[4][0]*1.e-3*ds, 
                   node[face[name[i]].nod[5]].ny+face[name[i]].side[4][1]*1.e-3*ds,
                   node[face[name[i]].nod[5]].nz+face[name[i]].side[4][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[2]].nx+face[name[i]].side[3][0]*1.e-3*ds, 
                   node[face[name[i]].nod[2]].ny+face[name[i]].side[3][1]*1.e-3*ds,
                   node[face[name[i]].nod[2]].nz+face[name[i]].side[3][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[6]].nx+face[name[i]].side[4][0]*1.e-3*ds, 
                   node[face[name[i]].nod[6]].ny+face[name[i]].side[4][1]*1.e-3*ds,
                   node[face[name[i]].nod[6]].nz+face[name[i]].side[4][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[3]].nx+face[name[i]].side[2][0]*1.e-3*ds, 
                   node[face[name[i]].nod[3]].ny+face[name[i]].side[2][1]*1.e-3*ds,
                   node[face[name[i]].nod[3]].nz+face[name[i]].side[2][2]*1.e-3*ds );
      glVertex3d ( node[face[name[i]].nod[7]].nx+face[name[i]].side[1][0]*1.e-3*ds, 
                   node[face[name[i]].nod[7]].ny+face[name[i]].side[1][1]*1.e-3*ds,
                   node[face[name[i]].nod[7]].nz+face[name[i]].side[1][2]*1.e-3*ds );
      glEnd();
    }
  }

  glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
  if ( ipuf[0] == GL_FRONT ) ds*=-1;
}




void drawElem_edge( int num, int *name, Nodes *node, Elements *e_enqire, int color, unsigned char type )
{
  int i;

#if INX_MODE
  glIndexi    ( color );
#endif
#if TEX_MODE
  glColor3d(color,color,color);
#endif
  glLineWidth(1.);

#if TEST
  printf ("in drawElemEdges\n");
#endif 

  for (i=0; i<num; i++ )
  {
    if( e_enqire[name[i]].type == 1 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
    glEnd();
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
    glEnd();
    glBegin ( GL_LINES );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 2 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
    glEnd();
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
    glEnd();
    glBegin ( GL_LINES );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 3 )
    {
    glBegin ( GL_LINE_STRIP);
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
    glEnd();
    glBegin ( GL_LINE_STRIP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 4 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
    glEnd();
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[16]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[17]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[18]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[19]].nx );
    glEnd();
    glBegin ( GL_LINES );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[15]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 5 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 8]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 7]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
    glEnd();
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[14]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[13]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[12]].nx );
    glEnd();
    glBegin ( GL_LINES );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 9]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[10]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[ 4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[11]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 6 )
    {
    glBegin ( GL_LINE_STRIP);
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[8]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[9]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
    glEnd();
    glBegin ( GL_LINE_STRIP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 7 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 8 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 9 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 10 )
    {
    glBegin ( GL_LINE_LOOP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[4]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[5]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[6]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[3]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[7]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 11 )
    {
    glBegin ( GL_LINES );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
    glEnd();
    }
    if( e_enqire[name[i]].type == 12 )
    {
    glBegin ( GL_LINE_STRIP );
      glVertex3dv ( &node[e_enqire[name[i]].nod[0]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[1]].nx );
      glVertex3dv ( &node[e_enqire[name[i]].nod[2]].nx );
    glEnd();
    }
  }
}



void drawElemNodes_plot( int num, int *name, Nodes *node, Elements *e_enqire, int col, unsigned char type )
{
  int i, n, sum=0;
  int *nodnr;

  if ( (nodnr = (int *)malloc( (int)(anz->nmax+1) * sizeof(int))) == NULL )
  {  printf(" ERROR: malloc in drawElemNodes_plot(), nodnr\n\n") ; return;}
  for (i=0; i<=anz->nmax; i++ ) nodnr[i]=0;

  for (i=0; i<num; i++ )
  {
    if( e_enqire[name[i]].type == 1 )   sum=8;
    if( e_enqire[name[i]].type == 2 )   sum=6;
    if( e_enqire[name[i]].type == 3 )   sum=4;
    if( e_enqire[name[i]].type == 4 )   sum=20;;
    if( e_enqire[name[i]].type == 5 )   sum=20;
    if( e_enqire[name[i]].type == 6 )   sum=10;
    if( e_enqire[name[i]].type == 7 )   sum=3;
    if( e_enqire[name[i]].type == 8 )   sum=6;
    if( e_enqire[name[i]].type == 9 )   sum=4;
    if( e_enqire[name[i]].type == 10 )  sum=8;
    if( e_enqire[name[i]].type == 11 )  sum=1;
    if( e_enqire[name[i]].type == 12 )  sum=3;
    for (n=0; n<sum; n++) nodnr[e_enqire[name[i]].nod[n]]=e_enqire[name[i]].nod[n];
  }

  /* draw all selected nodes */
#if INX_MODE
  glIndexi (2);
#endif
#if TEX_MODE
  glColor3d  ( 0.5,0.5,0. );
#endif
  glLoadName('n');
  for (i=0; i<=anz->nmax; i++ )
  {
    if(nodnr[i])
    {
      glPushName(nodnr[i]);
      glBegin ( GL_POINTS );
      glVertex3dv ( &node[nodnr[i]].nx );
      glEnd();
      glPopName();
    }
  }
  glLoadName(-1);
  free(nodnr);
}



void drawFaceNodes_plot( int num, int *name, Nodes *node, Faces *face, int col, unsigned char type )
{
  int i, n, sum=0;
  int *nodnr;

  if ( (nodnr = (int *)malloc( (int)(anz->nmax+1) * sizeof(int))) == NULL )
  {  printf(" ERROR: malloc in drawSurfNodes_plot(), nodnr\n\n") ; return;}
  for (i=0; i<=anz->nmax; i++ ) nodnr[i]=0;

  for (i=0; i<num; i++ )
  {
    if( face[name[i]].type == 7 )   sum=3;
    if( face[name[i]].type == 8 )   sum=6;
    if( face[name[i]].type == 9 )   sum=4;
    if( face[name[i]].type == 10 )  sum=8;
    if( face[name[i]].type == 11 )  sum=1;
    if( face[name[i]].type == 12 )  sum=3;
    for (n=0; n<sum; n++) nodnr[face[name[i]].nod[n]]=face[name[i]].nod[n];
  }

  /* draw all selected nodes */
#if INX_MODE
  glIndexi (2);
#endif
#if TEX_MODE
  glColor3d  ( 0.5,0.5,0. );
#endif
  glLoadName('n');
  for (i=0; i<=anz->nmax; i++ )
  {
    if(nodnr[i])
    {
      glPushName(nodnr[i]);
      glBegin ( GL_POINTS );
      glVertex3dv ( &node[nodnr[i]].nx );
      glEnd();
      glPopName();
    }
  }
  glLoadName(-1);
  free(nodnr);
}


void drawPoints_plot( int num, int *name, Points *point , int col, unsigned char type)
{
  int i;

  glPointSize (4);

#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
    glLoadName('p');
      for (i=0; i<num; i++ )
      {
      glPushName(name[i]);
       glBegin ( GL_POINTS );
       glVertex3d ( point[name[i]].px, point[name[i]].py, point[name[i]].pz );
      glEnd();
      glPopName();
      }
    glLoadName(-1);

  if(type=='a')
  {
    for (i=0; i<num; i++ )
      text( point[name[i]].px, point[name[i]].py, point[name[i]].pz, point[name[i]].name );
  }
}


void drawLines_plot( int num, int *name, Lines *line , Points *point, int col, unsigned char type)
{
  int i,n;
  int bias_fbd;
  double x,y,z;

  glLineWidth(1.);
#if INX_MODE
  glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
  glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
  glLoadName('l');
  for (i=0; i<num; i++ )
  {
    glPushName(name[i]);
    glBegin ( GL_LINE_STRIP );
      for (n=0; n<line[name[i]].nip; n+=3)
      {
        glVertex3dv( &line[name[i]].ip[n]);
      }
    glEnd();
    if ((type=='a')||(type=='d'))
    {
      x =point[line[name[i]].p1].px;
      y =point[line[name[i]].p1].py;
      z =point[line[name[i]].p1].pz;
      x+=point[line[name[i]].p2].px;
      y+=point[line[name[i]].p2].py;
      z+=point[line[name[i]].p2].pz;
      x*=.5;
      y*=.5;
      z*=.5;
      if (type=='a') sprintf( buffer, "%s", line[name[i]].name);
      if (type=='d')
      {
        /* load bias and division in buffer */
        if(line[name[i]].div ==1) sprintf(buffer, "%d", line[name[i]].div);
        else if(line[name[i]].bias!=1.)
	{
          bias_fbd=getBias_fbd(name[i],line);
          if(line[name[i]].div<10) sprintf(buffer, "%d0%d", bias_fbd, line[name[i]].div);
          else if(line[name[i]].div<100) sprintf(buffer, "%d%d", bias_fbd, line[name[i]].div);
	}
        else sprintf(buffer, "%d", line[name[i]].div);
      }
      text( x, y, z, buffer );
    }
    glPopName();
    }
  glLoadName(-1);
}


void drawSurfs_plot( int num, int *name, Gsur *surf, Lcmb *lcmb, Lines *line , Points *point, int col, unsigned char type)
{
  int i,j,k,n,nl,nc;

  glLineWidth(1.);

  glLoadName('s');

  if(col==-1)
  {
      // glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
    if(cullFlag) glDisable ( GL_CULL_FACE );
    glShadeModel ( GL_FLAT );
    glEnable( GL_LIGHTING );

    for (i=0; i<num; i++)
    {
      /* printf("surf:%s w:%lf xyz: %lf %lf %lf\n",surf[name[i]].name,scale->w,scale->x,scale->y,scale->z); */
      glPushName(name[i]);
      n=0;
      while((surf[name[i]].npgn-n))
      {
        n++; /* jump over the polygon token (ie.GL_POLYGON_TOKEN) */
        j=surf[name[i]].pgn[n++];
        glBegin ( GL_POLYGON );
        glNormal3dv (&surf[name[i]].pgn[n]); n+=3;
        for(k=0; k<j; k++)
        {
          /* printf("%d %lf %lf %lf\n", k,surf[name[i]].pgn[n],surf[name[i]].pgn[n+1],surf[name[i]].pgn[n+2]); */
          glVertex3dv (&surf[name[i]].pgn[n]); n+=3; 
        }
        glEnd();
      }
      if(type=='a')
      {
        sprintf( buffer, "%s", surf[name[i]].name );
        text( (surf[name[i]].cx-scale->x)/scale->w,
            (surf[name[i]].cy-scale->y)/scale->w,
            (surf[name[i]].cz-scale->z)/scale->w, buffer );
      }
      glPopName();
    }
    glDisable( GL_LIGHTING );
  }
  else
  {
#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
    for (i=0; i<num; i++)
    {
      glPushName(name[i]);
      for (j=0; j<surf[name[i]].nl; j++ )
      {
        nl=surf[name[i]].l[j];
        if (surf[name[i]].typ[j]=='l')
        {
          glBegin ( GL_LINE_STRIP );
          for (n=0; n<line[nl].nip; n+=3)
          {
            glVertex3dv ( &line[nl].ip[n]);
          }
          glEnd();
        }
        else
        {
          for (k=0; k<lcmb[nl].nl; k++ )
          {
            nc=lcmb[nl].l[k];
            glBegin ( GL_LINE_STRIP );
            for (n=0; n<line[nc].nip; n+=3)
            {
              glVertex3dv ( &line[nc].ip[n]);
            }
            glEnd();
	  }
        } 
      }
    
      if(type=='a')
      {
        sprintf( buffer, "%s", surf[name[i]].name );
        text( (surf[name[i]].cx-scale->x)/scale->w,
            (surf[name[i]].cy-scale->y)/scale->w,
            (surf[name[i]].cz-scale->z)/scale->w, buffer );
      }
      glPopName();
    }
  }
  glLoadName(-1);
}


void drawBodys_plot( int num, int *name, Gbod *body, Gsur *surf, Lcmb *lcmb, Lines *line , Points *point, int col, unsigned char type)
{
  int i,j,k,n,nl,nc, b, s;

  glLineWidth(1.);

#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
  glLoadName('b');
  for (i=0; i<num; i++)
  {
    glPushName(name[i]);
    for (b=0; b<body[name[i]].ns; b++ )
    {
      s=body[name[i]].s[b];
      for (j=0; j<surf[s].nl; j++ )
      {
        nl=surf[s].l[j];
        if (surf[s].typ[j]=='l')
        {
          glBegin ( GL_LINE_STRIP );
            for (n=0; n<line[nl].nip; n+=3)
            {
              glVertex3dv
              ( &line[nl].ip[n]);
            }
          glEnd();
        }
        else
        {
          for (k=0; k<lcmb[nl].nl; k++ )
          {
          nc=lcmb[nl].l[k];
          glBegin ( GL_LINE_STRIP );
            for (n=0; n<line[nc].nip; n+=3)
            {
              glVertex3dv
              ( &line[nc].ip[n]);
            }
          glEnd();
          }
        }
      }
      if(type=='a')
      {
        sprintf( buffer, "%s", body[name[i]].name );
        text( (body[name[i]].cx-scale->x)/scale->w,
              (body[name[i]].cy-scale->y)/scale->w,
              (body[name[i]].cz-scale->z)/scale->w, buffer );
      }
    }
    glPopName();
  }
  glLoadName(-1);

}

void drawNurl_plot( int num, int *name, int col, unsigned char type, int pickflag)
{
  int i, nr;
  int mode[2];
  GLfloat NurlFillFlag;
  double tx, ty, tz;
  glLineWidth(1.);

  glGetIntegerv( GL_POLYGON_MODE, mode );
  if ( mode[1] == GL_FILL )
      NurlFillFlag=GLU_FILL;
  else
      NurlFillFlag=GLU_OUTLINE_POLYGON;

#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
  glLoadName('L');

  for (nr=0; nr<num; nr++ )
  {
    if((nurbl[name[nr]].u_exp<gl_max_eval_order)&&(nurbl[name[nr]].endFlag==1))
    {
      /*
      printf("u_nknt:%d  u_stride:%d  exp:%d typ:%d %d\n", nurbl[name[nr]].u_nknt, nurbl[name[nr]].u_stride, nurbl[name[nr]].u_exp, nurbl[name[nr]].type, GL_MAP1_VERTEX_4);
      for(i=0; i<nurbl[name[nr]].u_nknt; i++) printf("uknt[%d]:%f\n", i, nurbl[name[nr]].uknt[i]);
      for(i=0; i<(nurbl[name[nr]].u_npnt*nurbl[name[nr]].u_stride); i++) { if(i%4==0) printf("\n"); printf(" ctlarray[%d]:%f", i, nurbl[name[nr]].ctlarray[i]);  }
      */

      /* for NurbsErrorCallback */
      if(printFlag) 
      {
        current_nurbs=-name[nr]-1;
        gluNurbsCallback(nurbl[name[nr]].Nurb, GLU_ERROR, (void*)NurbsErrorCallback);
      }
      
      gluNurbsProperty(nurbl[name[nr]].Nurb, GLU_CULLING, GL_TRUE);
      gluNurbsProperty(nurbl[name[nr]].Nurb, GLU_DISPLAY_MODE, NurlFillFlag);
      if(pickflag==PICK) gluNurbsProperty(nurbl[name[nr]].Nurb, GLU_SAMPLING_TOLERANCE, NURS_TOLERANCE_PICK );
      else gluNurbsProperty(nurbl[name[nr]].Nurb, GLU_SAMPLING_TOLERANCE, NURS_TOLERANCE );
      
      glPushName(name[nr]);
      gluBeginCurve(nurbl[name[nr]].Nurb);
      gluNurbsCurve(nurbl[name[nr]].Nurb,
            nurbl[name[nr]].u_nknt,
            nurbl[name[nr]].uknt,
            nurbl[name[nr]].u_stride,
            nurbl[name[nr]].ctlarray,
            nurbl[name[nr]].u_exp+1,
            nurbl[name[nr]].type);
      gluEndCurve(nurbl[name[nr]].Nurb);

      if(type=='a')
      {
        tx=ty=tz=0.; for (i=0; i<nurbl[name[nr]].u_npnt; i++)
        {
          tx+= point[nurbl[name[nr]].ctlpnt[i]].px ;
          ty+= point[nurbl[name[nr]].ctlpnt[i]].py ;
          tz+= point[nurbl[name[nr]].ctlpnt[i]].pz ;
        }
        tx/=nurbl[name[nr]].u_npnt;
        ty/=nurbl[name[nr]].u_npnt;
        tz/=nurbl[name[nr]].u_npnt;
        text( tx,ty,tz, nurbl[name[nr]].name );
      }
      glPopName();
    }
    else
    {
      if(printFlag)  printf("ERROR: Nurbl[%d]:%s of order:%d is not supported. Only %d is supported by the gl-lib.\n", nr, nurbl[name[nr]].name, nurbl[name[nr]].u_exp+1, gl_max_eval_order);

    }
  }
  glLoadName(-1);
}



/* the nurbs was evaluated and drawn into a back-buffer, the contents of the back-buffer will be displayed */

void drawNurs_plot( int num, int *name, int col, unsigned char type, int pickflag)
{
  int i, nr, s;
  int mode[2];
  GLfloat NursFillFlag;
  static GLint ipuf[2];

  glLineWidth(1.);

  /* evaluate and draw into the back-buffer */
  glGetIntegerv( GL_POLYGON_MODE, mode );
  if ( mode[1] == GL_FILL )
      NursFillFlag=GLU_FILL;
  else
      NursFillFlag=GLU_OUTLINE_POLYGON;
  
  glShadeModel ( GL_SMOOTH );
  glEnable( GL_LIGHTING );
  glEnable(GL_AUTO_NORMAL);
  /* glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); */

#if INX_MODE
    glIndexi (col+offset+CMAP_CELLS_LIGHT);
#endif
#if TEX_MODE
    glColor3f ( entity_r[col], entity_g[col], entity_b[col]  );
#endif 
  glLoadName('S');

  glGetIntegerv( GL_CULL_FACE_MODE, ipuf );
  glDisable ( GL_CULL_FACE );

  for (nr=0; nr<num; nr++ )
  {
    if ((nurbs[name[nr]].u_exp<gl_max_eval_order)&&(nurbs[name[nr]].v_exp<gl_max_eval_order)&&(nurbs[name[nr]].endFlag==1)&&(nurbs[name[nr]].name != (unsigned char *)NULL))
    {
      /* for NurbsErrorCallback */
      if(printFlag) 
      {
        current_nurbs=name[nr];
        gluNurbsCallback(nurbs[name[nr]].Nurb, GLU_ERROR, (void*)NurbsErrorCallback);
      }     
      gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_DISPLAY_MODE, NursFillFlag);
      gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_CULLING, GL_TRUE);
      gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_SAMPLING_METHOD, GLU_DOMAIN_DISTANCE );

      if(nurbs[name[nr]].patches==0)
      {
        /* no trimming */
        gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_U_STEP,  nurbs[name[nr]].ures );
        gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_V_STEP,  nurbs[name[nr]].vres );
       

          glPushName(name[nr]);
          gluBeginSurface(nurbs[name[nr]].Nurb);
          gluNurbsSurface(nurbs[name[nr]].Nurb,
            nurbs[name[nr]].u_nknt, nurbs[name[nr]].uknt,
            nurbs[name[nr]].v_nknt, nurbs[name[nr]].vknt,
            nurbs[name[nr]].u_stride, nurbs[name[nr]].v_stride,
            nurbs[name[nr]].ctlarray,
            nurbs[name[nr]].u_exp+1, nurbs[name[nr]].v_exp+1,
            nurbs[name[nr]].type);
          gluEndSurface(nurbs[name[nr]].Nurb);
          glPopName();
      }
      else
      {
        /* trimming of multiple patches */
        for(s=0; s<nurbs[name[nr]].patches; s++)
        {      
          gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_U_STEP,  nurbs[name[nr]].ures );
          gluNurbsProperty(nurbs[name[nr]].Nurb, GLU_V_STEP,  nurbs[name[nr]].vres );
       

          glPushName(name[nr]);
          gluBeginSurface(nurbs[name[nr]].Nurb);
          gluNurbsSurface(nurbs[name[nr]].Nurb,
            nurbs[name[nr]].u_nknt, nurbs[name[nr]].uknt,
            nurbs[name[nr]].v_nknt, nurbs[name[nr]].vknt,
            nurbs[name[nr]].u_stride, nurbs[name[nr]].v_stride,
            nurbs[name[nr]].ctlarray,
            nurbs[name[nr]].u_exp+1, nurbs[name[nr]].v_exp+1,
            nurbs[name[nr]].type);
          
          for(i=0; i<nurbs[name[nr]].nc[s]; i++)
          {
            gluBeginTrim(nurbs[name[nr]].Nurb);
            gluPwlCurve(nurbs[name[nr]].Nurb, nurbs[name[nr]].np[s][i], nurbs[name[nr]].uv[s][i], (GLint)2, GLU_MAP1_TRIM_2);
            gluEndTrim(nurbs[name[nr]].Nurb);
          }
          
          gluEndSurface(nurbs[name[nr]].Nurb);
          glPopName();
        }
      }
    }
    else
    {
      if(printFlag)  printf("ERROR: Nurbs[%d]:%s of order:%d %d is not supported. Only %d is supported by the gl-lib.\n", nr, nurbs[name[nr]].name, nurbs[name[nr]].u_exp+1, nurbs[name[nr]].v_exp+1, gl_max_eval_order);

    }
  }
  glLoadName(-1);

  glDisable(GL_AUTO_NORMAL);
  glDisable( GL_LIGHTING );
  glShadeModel ( GL_FLAT );

  if(type=='a')
  {
    for (nr=0; nr<num; nr++ )
    {
      text( nurbs[name[nr]].tx,nurbs[name[nr]].ty,nurbs[name[nr]].tz, nurbs[name[nr]].name );
    }
  }

  /* resore the original cull mode */
  if ( ipuf[0] == GL_BACK ) glCullFace ( GL_BACK );
  if ( ipuf[0] == GL_FRONT ) glCullFace ( GL_FRONT );
 
}
