Logo Search packages:      
Sourcecode: opencascade version File versions  Download package

OpenGl_attri.c

/***********************************************************************

     FONCTION :
     ----------
        File OpenGl_attri :
 

     REMARQUES:
     ---------- 
 
        ATTENTION: Actuellement les materiaux ont le Front et Back identiques.
            (cf PRO6327). On met temporairement de cote le mode Distinguish.
      

     HISTORIQUE DES MODIFICATIONS   :
     --------------------------------
       xx-xx-xx : xxx ; Creation.
       06-03-96 : FMN ; Ajout OpenGl_tgl_tox.h pour call_thedisplay
       01-04-96 : CAL ; Integration MINSK portage WNT
       12-04-96 : CAL ; Travail sur les materiaux
       07-05-96 : CAL ; Debug temporaire pour ROB, TelRobSetRGB ()
       10-06-96 : CAL ; Transparence dans TsmSetAttri
       13-06-96 : CAL ; Introduction de TsmPushAttriLight et TsmPopAttriLight
       28-06-96 : FMN ; Amelioration des performances sur les materiaux
       01-07-96 : FMN ; Correction + performance antialiasing;
       03-07-96 : FMN ; Test sur ZBuffer avant appel a TelUpdateMaterial.
       17-07-96 : FMN ; Suppression de HLHSRMode.
       07-10-96 : FMN ; Suppression appel TelUpdateMaterial et define TELCO.
       08-11-96 : FMN ; Suppression code CAL_OPTIM
       21-11-96 : FMN ; Correction PRO6181 et PRO4138 Suppression (balise FMN)
       05-12-96 : FMN ; PRO6327: Pas defaut on positionne les materiaux pour
                        le front et le back. 
       15-02-97 : FMN ; Suppression OpenGl_gl_compat.h
       25-02-97 : FMN ; Ajout print informations
       30-06-97 : FMN ; Appel de la toolkit OpenGl_LightBox.
       03-07-97 : PCT ; Modif material.
       05-08-97 : PCT ; support texture mapping
       21-08-97 : PCT ; ajout deuxieme passe pour les textures
       08-12-97 : FMN ; Correction Flat/Gouraud
       09-12-97 : FMN ; Correction Antialing + Textures + Transparence
       22-12-97 : FMN ; Suppression DEBUG_TEMPO_FOR_ROB
                        Correction PRO10217 sur le mode Transient
       23-12-97 : FMN ; Suppression TelBackInteriorStyle, TelBackInteriorStyleIndex
                        et TelBackInteriorShadingMethod
       30-12-97 : FMN ; CTS18312: Correction back material
       31-12-97 : FMN ; Optimisation gestion material
       15-01-98 : FMN ; Ajout Hidden line
       08-04-98 : FGU ; Ajout emission
       30-06-98 : FMN ; Correction init des materiaux dans TelUpdateMateriaux.
       08-07-98 : FMN ; PRO14399: Meilleure gestion de la matrice locale sur
                        une structure.
       21-07-98 : FMN ; Correction init attri_default et du hatch
       30-11-98 : FMN ; S4069 : Textes toujours visibles
       05-01-99 : CAL ; Warning WNT
       22-03-04 : SAN ; OCC4895 High-level interface for controlling polygon offsets

************************************************************************/

#define BUC60577        /*GG_101099     Enable to compute correctly
//                      transparency with more than one object in the view.
*/

#define IMP190100       /*GG     Push and Pop polyline type and width
//                      attributes correctly.
*/

#define G003            /*EUG   degeneration mode management
*/

#define GER61394        /*GG 26/05/00 Enable AntiAliasing also on polygons.*/

#define BUC60742        /*GG 18/09/00 Enable to use both animation and 
                        graphic structure transformation
*/

#define IMP250401       /*GG    Sets always the current polyline colour 
                        used in immediat mode context.
*/

/*OCC8568 changes made by GG rolled back due to regression*/
/*#define BUC60918*/        /*GG CADPAK_V2/RINA Enable transparency using Zbuffer
*/

#define OCC2934         /* SAN 22/01/04 Texture mapped fonts on WNT */

#define OCC7667         /* asl Export to vector graphic file

/*----------------------------------------------------------------------*/
/*
 * Constantes
 */

#define NO_TRACE                   
#define NO_TRACE_UPMATERIAL   
#define NO_TRACE_MATERIAL          
#define NO_TRACE_LIGHT      
#define NO_TRACE_MATRIX     
#define NO_TRACE_TEXT       

/*----------------------------------------------------------------------*/
/*
 * Includes
 */

#ifdef OCC7667
#define GL2PS_LINE_STIPPLE 3
#endif


#include <OpenGl_tgl_all.h>

#include <stdio.h>
#include <string.h>

#include <GL/gl.h>

#include <OpenGl_cmn_memory.h>
#include <OpenGl_cmn_stg_tbl.h>
#include <OpenGl_cmn_varargs.h>
#include <OpenGl_telem_attri.h>
#include <OpenGl_telem_view.h>
#include <OpenGl_telem_depthcue.h>
#include <OpenGl_telem.h>
#include <OpenGl_telem_util.h>
#include <OpenGl_tsm.h>
#include <OpenGl_tsm_ws.h>
#include <OpenGl_tgl.h>
#include <OpenGl_tgl_util.h>
#include <OpenGl_tgl_tox.h>
#include <OpenGl_tXfm.h>
#include <OpenGl_animation.h>

#include <OpenGl_trsf_stack.h>
#include <OpenGl_tgl_funcs.h>

#include <OpenGl_TextureBox.h>

/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
#include <Aspect_PolygonOffsetMode.hxx>
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */

/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
#include <OpenGl_transform_persistence.h>
/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */

#ifdef OCC7667
#include <OpenGl_gl2ps.h>
#endif

/* printer font base */
extern GLuint printerFontBase;
/* update printer font */
extern void updatePrinterFont( char*, int );
/*----------------------------------------------------------------------*/
/*
 * Definitions type
 */

typedef  struct  TSM_ATTRI_BLK_STRUCT {
    struct          TSM_ATTRI_BLK_STRUCT  *next;
    /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
    /*Tint            TransPersFlag;*/
    TEL_TRANSFORM_PERSISTENCE TransPers;
    /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
    TEL_COLOUR      PolylineColour;
    Tfloat          PolylineWidth;
    Tint            PolylineType;
    TEL_COLOUR      EdgeColour;
    Tfloat          EdgeWidth;
    Tint            EdgeType;
    Tint            AntiAliasing;
    TEL_COLOUR      InteriorColour;
    Tint            EdgeFlag;
    Tint            InteriorStyle;
    Tint            InteriorStyleIndex;
    Tfloat          PolymarkerSize;
    TEL_COLOUR      PolymarkerColour;
    TEL_COLOUR      BackInteriorColour;
    Tint            FaceDistinguishingMode;
    TEL_COLOUR      TextColour;
    TEL_COLOUR      TextColourSubTitle;
    Tint            TextStyle;
    Tint            TextDisplayType;
    Tchar           *TextFont;
    Tfloat          TextHeight;
    Tfloat          CharacterSpacing;
    Tfloat          CharacterExpansionFactor;
#if defined(OCC2934) && defined(WNT)
    Tint            TextureMappedFont;
#endif
/*OCC7456 abd 14.12.2004 Text alingnment attributes  */
    TEL_ALIGN_DATA  TextAlign;
/*OCC7456 abd 14.12.2004 Text alingnment attributes  */
    Tint            PolymarkerType;
    Tint            InteriorReflectanceEquation;
    Tint            BackInteriorReflectanceEquation;
    TEL_SURF_PROP   SurfaceAreaProperties;
    TEL_SURF_PROP   BackSurfaceAreaProperties;
    TelCullMode     FaceCullingMode;
    Tint            DepthCueIndex;
    Tint            InteriorShadingMethod;
    Tint            ViewIndex;
    Tint            HighlightIndex;
    Tmatrix3        LocalTran3;
    Tint            DoTextureMap;
    Tint            TextureId;
#ifdef G003
    Tint            DegenerationMode;
#endif  /* G003 */
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
    TEL_POFFSET_PARAM PolygonOffsetParams;
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
} TSM_ATTRI_BLK, *tsm_attri_blk;


/*----------------------------------------------------------------------*/
/*
 * Variables statiques
 */

static  tsm_attri_blk  attri_tail = NULL;
static  cmn_stg_tbl    attri_tbl = NULL;

/* FSXXX */
static  Tint need_reset = 0;

/* Est-il necessaire de faire de la transparence ? */
static  Tint need_trans = 0;

static  TSM_ATTRI_BLK  attri_default =
{
/*    0,*/                  /* next */
    NULL,                  /* next */
    /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
    /*0,*/
    /*{0 , { 0.0F, 0.0F, 0.0F } },*/
    {0 , 0.0F, 0.0F, 0.0F },
    /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
    {{ 1.0F, 1.0F, 1.0F }},   /* PolylineColour */
    1.0F,                   /* PolylineWidth */
    TEL_LS_SOLID,           /* PolylineType */
    {{ 1.0F, 1.0F, 1.0F }},   /* EdgeColour */
    1.0F,                   /* EdgeWidth */
    0,                      /* EdgeType */
    TOff,                   /* AntiAliasing */
    {{ 1.0F, 1.0F, 1.0F }},   /* InteriorColour */
    TOn,                    /* EdgeFlag */
    TSM_SOLID,              /* InteriorStyle */
    TEL_HS_SOLID,           /* InteriorStyleIndex */
    1.0F,                   /* PolymarkerSize */
    {{ 1.0F, 1.0F, 1.0F }},   /* PolymarkerColour */
    {{ 1.0F, 1.0F, 1.0F }},   /* BackInteriorColour */
    TOn,                    /* FaceDistinguishingMode */
    {{ 1.0F, 1.0F, 1.0F }},   /* TextColour */
    {{ 1.0F, 1.0F, 1.0F }},   /* TextColourSubTitle */
    ASPECT_TOST_NORMAL,     /* TextStyle */
    ASPECT_TODT_NORMAL,     /* TextDisplayType */
    "Times-Roman",          /* TextFont */
    12.0F,                  /* TextHeight */
    0.3F,                   /* CharacterSpacing */
    1.0F,                   /* CharacterExpansionFactor */
#if defined(OCC2934) && defined(WNT)
    0,                      /* TextureMappedFont */
#endif
    /*OCC7456 abd 14.12.2004 Text alingnment attributes  */
    { 0,    /*Horizontal Text Alignment*/
      0 }, /*Vertical Text Alignment*/
    /*OCC7456 abd 14.12.2004 Text alingnment attributes  */
    TEL_PM_PLUS,            /* PolymarkerType */
    CALL_PHIGS_REFL_NONE,      /* InteriorReflectanceEquation */
    CALL_PHIGS_REFL_NONE,      /* BackInteriorReflectanceEquation */
    { 0.2F, 0.8F, 0.1F, 0.0F,  /* Coef d eclairage */
      1.0F, 10.0F, 0.0F,  
      1,  1,  1,  0, 0,          /* Etat des eclairage */
      {{ 1.0F, 1.0F, 1.0F }},    /* ambient color */
      {{ 1.0F, 1.0F, 1.0F }},    /* diffuse color */
      {{ 1.0F, 1.0F, 1.0F }},    /* specular color */
      {{ 1.0F, 1.0F, 1.0F }},    /* emissive color */
      {{ 1.0F, 1.0F, 1.0F }}},   /* material color */       /* SurfaceAreaProperties */
    { 0.2F, 0.8F, 0.1F, 0.0F,  /* Coef d eclairage */
      1.0F, 10.0F, 0.0F,
      1,  1,  1,  0, 0,          /* Etat des eclairage */
      {{ 1.0F, 1.0F, 1.0F }},    /* ambient color */
      {{ 1.0F, 1.0F, 1.0F }},    /* diffuse color */
      {{ 1.0F, 1.0F, 1.0F }},    /* specular color */
      {{ 1.0F, 1.0F, 1.0F }},    /* emissive color */
      {{ 1.0F, 1.0F, 1.0F }}},   /* material color */      /* BackSurfaceAreaProperties */
    TelCullNone,            /* FaceCullingMode */
    0,                      /* DepthCueIndex */
    TEL_SM_GOURAUD,         /* InteriorShadingMethod */
    0,                      /* ViewIndex */
    0,                      /* HighlightIndex */
    {
        { 1.0F, 0.0F, 0.0F, 0.0F },
        { 0.0F, 1.0F, 0.0F, 0.0F },
        { 0.0F, 0.0F, 1.0F, 0.0F },
        { 0.0F, 0.0F, 0.0F, 1.0F }
    },                     /* LocalTran3 */
    TEL_SD_SHADING,
    -1
#ifdef G003
    , 0  /* DegenerationMode */
#endif  /* G003 */
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
    , { Aspect_POM_Fill, 1.0F, 0.0F }
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
};

#ifdef G003
extern int g_nBackfacing;
#endif  /* G003 */

/*----------------------------------------------------------------------*/
/*
 * Prototypes
 */

static  void  TelUpdateFog( Tint, Tint, Tint ); /* ws, vid, dcid */
static  void  TelSetViewMatrix( Tmatrix3, Tint ); /* mat, vid */
static  void  call_util_transpose_mat (float tmat[16], float mat[4][4]);
static  void  TelUpdatePolygonOffsets( tel_poffset_param );

/*----------------------------------------------------------------------*/
/*
 * Variables externes
 */

extern tsm_trsf_stack cur_trsf_stack;

GLuint fontBase;
extern GLuint linestyleBase;
extern GLuint patternBase;

extern  Tint  ForbidSetTextureMapping; /* currently defined in tsm/tsm.c */
extern  Tint  SecondPassNeeded;     /* currently defined in tsm/tsm.c */
extern  Tint  SecondPassDo;         /* currently defined in tsm/tsm.c */

/*----------------------------------------------------------------------*/
#ifdef OCC7667
  extern GLint gl2psLineWidth( GLfloat );
  extern GLint gl2psEnable   ( GLint );
  extern GLint gl2psDisable  ( GLint );
#endif


TStatus
TsmPushAttri( void )
{
tsm_attri_blk node;

    if( !attri_tbl )
    {
        attri_tbl = cmn_stg_tbl_create( 10, sizeof(TSM_ATTRI_BLK) );
        if( !attri_tbl )
            return TFailure;
    }

    node = cmn_stg_tbl_get( attri_tbl );
    if( !node )
        return TFailure;

    if( attri_tail )
    {
        *node = *attri_tail;
        node->next = attri_tail;
        attri_tail = node;
#ifdef TRACE
        printf("TsmPushAttri %x\n",attri_tail);
#endif
    }
    else
    {
        *node = attri_default;
        node->next = attri_tail;
        attri_tail = node;

#ifdef TRACE
        printf("TsmPushAttri attri_default %x\n",attri_tail);
#endif

        /* Register all default attributes with gl */

        glLineWidth( ( GLfloat )attri_default.PolylineWidth );
#ifdef OCC7667
        gl2psLineWidth( ( GLfloat )attri_default.PolylineWidth );
#endif


#ifdef TRACE_TEXT
        printf("TsmPushAttri::tXfmfindfont \n");
#endif
#ifndef WNT
        tXfmfindfont (call_thedisplay, node->TextFont, node->TextHeight);
        fontBase = tXfmsetfont (1.0F, 1.0F);
#else
        WNTFindFont (node->TextFont, node->TextHeight);
        fontBase = WNTSetFont (1.0F, 1.0F);
#endif  /* WNT */

#if defined(OCC2934) && defined(WNT)
        WNTUseTexMappedFont(0);
#endif

#ifdef G003
        if ( !g_nBackfacing ) 
#endif  /* G003 */
        switch (node->FaceCullingMode) {
            case TelCullNone:
                glDisable (GL_CULL_FACE);
            break;

            case TelCullFront:
                glCullFace (GL_FRONT);
                glEnable (GL_CULL_FACE);
            break;

            case TelCullBack:
                glCullFace (GL_BACK);
                glEnable (GL_CULL_FACE);
            break;
        }
        /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
        transform_persistence_begin( 0, 0.0, 0.0, 0.0 );
        /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
        
    }

    return TSuccess;
}

/*----------------------------------------------------------------------*/

TStatus
TsmPopAttri( void )
{
    tsm_attri_blk  node;

    if( !attri_tail )
        return TFailure; /* Underflow */

    node = attri_tail;
    attri_tail = node->next;

#ifdef TRACE
    printf("TsmPopAttri %x\n",attri_tail);
#endif

    if( attri_tail )
    {
        /* Reset the attributes */
        Tint    i;
        Tfloat  f;

        f = attri_tail->PolylineWidth;
        if( node->PolylineWidth != f ) {
#ifdef TRACE
printf("TsmPopAttri.linewidth %f\n",f);
#endif

        glLineWidth( (GLfloat)f );
#ifdef OCC7667
        gl2psLineWidth( (GLfloat)f );
#endif

        }

        i = attri_tail->InteriorStyle;
        if( node->InteriorStyle != i )
        {
            switch( i )
            {
                case TSM_SOLID:
                case TSM_HIDDENLINE:
                    glPolygonMode(GL_FRONT_AND_BACK,  GL_FILL );
                    glDisable(GL_POLYGON_STIPPLE);
                    break;

                case TSM_HOLLOW:
                    glPolygonMode(GL_FRONT_AND_BACK,  GL_LINE );
                    break;

                case TSM_EMPTY:
                    glPolygonMode(GL_FRONT_AND_BACK,  GL_LINE );
                    break;

                case TSM_HATCH:
                    glPolygonMode(GL_FRONT_AND_BACK,  GL_FILL );
                    if( node->InteriorStyleIndex ) {
                        glCallList( patternBase + node->InteriorStyleIndex );
                        glEnable(GL_POLYGON_STIPPLE);
                    } else
                        glDisable(GL_POLYGON_STIPPLE);
                    break;

                case TSM_POINT:
                    glPolygonMode(GL_FRONT_AND_BACK,  GL_POINT );
                    break;
            }
        }

        i = attri_tail->PolylineType;
        if( node->PolylineType != i ) {
#ifdef TRACE
printf("TsmPopAttri.linetype %d\n",i);
#endif
            if (i) {
                glCallList( linestyleBase+i );

                glEnable( GL_LINE_STIPPLE );
#ifdef OCC7667
                gl2psEnable( GL2PS_LINE_STIPPLE );
#endif
            } else {
                
                glDisable( GL_LINE_STIPPLE );
#ifdef OCC7667                
                gl2psDisable( GL2PS_LINE_STIPPLE );
#endif
            }
        }

        if( attri_tail->CharacterExpansionFactor !=
                          node->CharacterExpansionFactor )
        {
#ifndef WNT
            fontBase = tXfmsetfont( attri_tail->CharacterExpansionFactor, 1.0);
#else
            fontBase = WNTSetFont ( attri_tail -> CharacterExpansionFactor, 1.0F);
#endif  /* WNT */
        }

#if defined(OCC2934) && defined(WNT)
        if( attri_tail->TextureMappedFont !=
                          node->TextureMappedFont )
        {
          WNTUseTexMappedFont( attri_tail->TextureMappedFont );
        }
#endif
        if( strcmp( attri_tail->TextFont, node->TextFont ) ||
            ( attri_tail->TextHeight != node->TextHeight ) )
        {
#ifdef TRACE_TEXT           
            printf("TsmPopAttri::tXfmfindfont \n");
#endif
#ifndef WNT
            tXfmfindfont(call_thedisplay, attri_tail->TextFont, attri_tail->TextHeight);
            fontBase = tXfmsetfont( 1.0, 1.0); 
#else
            WNTFindFont (attri_tail -> TextFont, attri_tail -> TextHeight);
            fontBase = WNTSetFont ( 1.0F, 1.0F );
#endif  /* WNT */
        }
#ifdef G003
        if ( !g_nBackfacing )
#endif  /* G003 */
        {
          if( attri_tail->FaceCullingMode != node->FaceCullingMode )
          {
            switch( attri_tail->FaceCullingMode )
            {
                case  TelCullNone:
                   glDisable(GL_CULL_FACE);
                   break;

                case  TelCullFront:
                   glCullFace(GL_FRONT) ;
                   glEnable(GL_CULL_FACE);
                   break;

                case  TelCullBack:
                   glCullFace(GL_BACK);
                   glEnable(GL_CULL_FACE);
                   break;
            }
          }
        }

/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
        if( attri_tail->PolygonOffsetParams.mode   != node->PolygonOffsetParams.mode   ||
            attri_tail->PolygonOffsetParams.factor != node->PolygonOffsetParams.factor ||
            attri_tail->PolygonOffsetParams.units  != node->PolygonOffsetParams.units )
        {
          TelUpdatePolygonOffsets( &attri_tail->PolygonOffsetParams );
        }
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */

/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
        if( attri_tail->TransPers.mode != node->TransPers.mode ||
            /*attri_tail->TransPers.point.xyz[0] != node->TransPers.point.xyz[0] ||
            attri_tail->TransPers.point.xyz[1] != node->TransPers.point.xyz[1] ||
              attri_tail->TransPers.point.xyz[2] != node->TransPers.point.xyz[2] )
            */
            attri_tail->TransPers.pointX != node->TransPers.pointX ||
            attri_tail->TransPers.pointY != node->TransPers.pointY ||
              attri_tail->TransPers.pointZ != node->TransPers.pointX )

        {
              /*transform_persistence_begin( attri_tail->TransPers.mode, 
                                         attri_tail->TransPers.point.xyz[0], 
                                         attri_tail->TransPers.point.xyz[1], 
                                         attri_tail->TransPers.point.xyz[2] );
                                         */
            transform_persistence_begin( attri_tail->TransPers.mode, 
                                         attri_tail->TransPers.pointX, 
                                         attri_tail->TransPers.pointY, 
                                         attri_tail->TransPers.pointZ );
        }
/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
        
        if( attri_tail->ViewIndex != node->ViewIndex )
        {
            TelSetViewProjection( TglActiveWs, attri_tail->ViewIndex );
#ifdef TRACE_MATRIX
            printf("TsmPopAttri::TelSetViewMatrix::attri_tail->ViewIndex != node->ViewIndex \n");
#endif
            TelSetViewMatrix( attri_tail->LocalTran3, attri_tail->ViewIndex );
            TelUpdateFog( TglActiveWs, attri_tail->ViewIndex, attri_tail->DepthCueIndex );
        }
        else
        {
            if( attri_tail->DepthCueIndex != node->DepthCueIndex )
                TelUpdateFog( TglActiveWs, attri_tail->ViewIndex, attri_tail->DepthCueIndex );
            if( memcmp( node->LocalTran3, attri_tail->LocalTran3, sizeof(Tmatrix3) ) )
            {
#ifdef TRACE_MATRIX
                printf("TsmPopAttri::TelSetViewMatrix::memcmp( node->LocalTran3, attri_tail->LocalTran3, sizeof(Tmatrix3) ) \n");
#endif
                TelSetViewMatrix(attri_tail->LocalTran3,attri_tail->ViewIndex); 
            }
        }
    }
#ifdef IMP190100        /* Reset default attribs at the top */
    else {
      Tint    i;
      Tfloat  f;

      f = attri_default.PolylineWidth;
      if( node->PolylineWidth != f ) {


        glLineWidth( (GLfloat)f );
#ifdef OCC7667
        gl2psLineWidth( (GLfloat)f );
#endif



#ifdef TRACE
printf("TsmPopAttri.defaultlinewidth %f\n",f);
#endif
      }

      i = attri_default.PolylineType;
      if( node->PolylineType != i ) {
        if (i) {
          glCallList( linestyleBase+i );

          glEnable( GL_LINE_STIPPLE );
#ifdef OCC7667
          gl2psEnable( GL2PS_LINE_STIPPLE );
#endif
        } else {

          glDisable( GL_LINE_STIPPLE );
#ifdef OCC7667
          gl2psDisable( GL2PS_LINE_STIPPLE );
#endif
        }


#ifdef TRACE
printf("TsmPopAttri.defaultlinetype %d\n",i);
#endif
      }
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
      TelUpdatePolygonOffsets( &attri_default.PolygonOffsetParams );
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */

/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
      /*transform_persistence_begin( attri_default.TransPersFlag );*/
      transform_persistence_begin( attri_default.TransPers.mode, 
                                           /*attri_default.TransPers.point.xyz[0], 
                                           attri_default.TransPers.point.xyz[1], 
                                   attri_default.TransPers.point.xyz[2] );*/
                                   attri_default.TransPers.pointX, 
                                           attri_default.TransPers.pointY, 
                                   attri_default.TransPers.pointZ );
/* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
    }
#endif  /*IMP190100*/

    cmn_stg_tbl_free( (void *) node );

    return TSuccess;
}

/*----------------------------------------------------------------------*/

TStatus
TsmSetAttri( Tint n, ... )
{
    Tint      i;

#if defined (SOLARIS) || defined (IRIXO32)
    cmn_key  *k;
#else
    cmn_key  k[TMaxArgs];
#endif

#ifdef GER61394
    static int antiAliasingMode = -1;
    if( antiAliasingMode < 0 ) {
      char string[64];
      if (call_util_osd_getenv("CALL_OPENGL_ANTIALIASING_MODE", string, 64) ) {
         int v;
         if( sscanf(string,"%d",&v) > 0 ) antiAliasingMode = v;
         printf(".OpenGl driver.AntiAliasing mode is %d\n",antiAliasingMode);
      } else {
        antiAliasingMode = 3;
      }
    } 
#endif

    if( !attri_tail )
        return TFailure;

    CMN_GET_STACK( n, k );
    for( i = 0; i < n; i++ )
    {
        switch( k[i]->id )
        {
            case  TelTextureId:
                attri_tail->TextureId = k[i]->data.ldata;

                if (!ForbidSetTextureMapping) {
                  if (attri_tail->DoTextureMap)
                    {
                      DisableTexture();
                      SetCurrentTexture(attri_tail->TextureId);           
                      EnableTexture();
                    }
                  else
                    DisableTexture();
                }
                break;
                      
            case TelDoTextureMap:
                attri_tail->DoTextureMap = k[i]->data.ldata;
                break;
                      
            case TelTextStyle:
                attri_tail->TextStyle = k[i]->data.ldata;
                break;
                      
            case TelTextDisplayType:
                attri_tail->TextDisplayType = k[i]->data.ldata;
                break;

            case  TelPolylineColour:
                attri_tail->PolylineColour = *(tel_colour)(k[i]->data.pdata);
#ifdef IMP250401
                glColor3f(attri_tail->PolylineColour.rgb[0],
                          attri_tail->PolylineColour.rgb[1],
                          attri_tail->PolylineColour.rgb[2]);
#endif
                break;

            case  TelPolylineWidth:
            {
                Tfloat  w;

                w = k[i]->data.fdata;
                if( attri_tail->PolylineWidth != w )
                {
#ifdef TRACE
printf("TsmSetAttri.linewidth %f\n",w);
#endif
                    attri_tail->PolylineWidth = w;

                    glLineWidth( (GLfloat)w );
#ifdef OCC7667
                    gl2psLineWidth( (GLfloat)w );
#endif
                }
                break;
            }

            case  TelPolylineType:
            {
                Tint  ls;

                ls = k[i]->data.ldata;
                if( attri_tail->PolylineType != ls )
                {
#ifdef TRACE
printf("TsmSetAttri.linetype %d\n",ls);
#endif
                    attri_tail->PolylineType = ls;
                    if (ls) {
                        glCallList(linestyleBase+ls);

                        glEnable( GL_LINE_STIPPLE );
#ifdef OCC7667
                        gl2psEnable( GL2PS_LINE_STIPPLE );
#endif
                    } else {

                        glDisable( GL_LINE_STIPPLE );
#ifdef OCC7667
                        gl2psDisable( GL2PS_LINE_STIPPLE );
#endif
                    }
                }
                break;
            }

            case  TelEdgeType:
                attri_tail->EdgeType = k[i]->data.ldata;
                break;

            case  TelEdgeWidth:
                attri_tail->EdgeWidth = k[i]->data.fdata;
                break;

            case  TelEdgeColour:
                attri_tail->EdgeColour = *(tel_colour)(k[i]->data.pdata);
                break;

            case  TelAntiAliasing:
            {
                attri_tail->AntiAliasing = k[i]->data.ldata;

                if (!SecondPassNeeded)
                {
                    if( attri_tail->AntiAliasing == TOff )
                    {
                        glDisable(GL_POINT_SMOOTH);
                        glDisable(GL_LINE_SMOOTH);
#ifdef GER61394
                        if( antiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH);
#endif
                        glBlendFunc (GL_ONE, GL_ZERO);
                        glDisable (GL_BLEND);
                    }
                    else /* TOn */
                    {
                        glEnable(GL_POINT_SMOOTH);
                        glEnable(GL_LINE_SMOOTH);
#ifdef GER61394
                        if( antiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH);
#endif
                        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
                        glEnable (GL_BLEND);
                    }
                }
                break;
            }

            case  TelInteriorColour:
            {
                attri_tail->InteriorColour = *(tel_colour)(k[i]->data.pdata);
                break;
            }

            case  TelEdgeFlag:
            {
                attri_tail->EdgeFlag = k[i]->data.ldata;
                break;
            }

            case  TelInteriorStyle:
            {
                Tint  s;

                s = k[i]->data.ldata;
                if( attri_tail->InteriorStyle != s )
                {
                    attri_tail->InteriorStyle = s;
                    switch( s )
                    {
                       case TSM_SOLID:
                       case TSM_HIDDENLINE:
                          glPolygonMode(GL_FRONT_AND_BACK,  GL_FILL );
                          glDisable(GL_POLYGON_STIPPLE);
                          break;

                       case TSM_HOLLOW:
                          glPolygonMode(GL_FRONT_AND_BACK,  GL_LINE );
                          break;

                       case TSM_EMPTY:
                          glPolygonMode(GL_FRONT_AND_BACK,  GL_LINE );
                          break;

                       case TSM_HATCH:
                          glPolygonMode(GL_FRONT_AND_BACK,  GL_FILL );
                          if( attri_tail->InteriorStyleIndex ) {
                                glCallList( patternBase + attri_tail->InteriorStyleIndex );
                                glEnable(GL_POLYGON_STIPPLE);
                          } else
                                glDisable(GL_POLYGON_STIPPLE);
                          break;

                       case TSM_POINT:
                          glPolygonMode(GL_FRONT_AND_BACK,  GL_POINT );
                          break;
                    }
                }
                break;
            }

            case  TelInteriorStyleIndex:
            {
                Tint  is = k[i]->data.ldata;
                if( attri_tail->InteriorStyleIndex != is )
                {
                    attri_tail->InteriorStyleIndex = is;
                    if( attri_tail->InteriorStyle == TSM_HATCH )
                    {
                        if (is)
                        {
                            glCallList( patternBase + is );
                            glEnable(GL_POLYGON_STIPPLE);
                        } else
                            glDisable(GL_POLYGON_STIPPLE);
                    }
                }
                break;
            }

            case  TelPolymarkerColour:
                attri_tail->PolymarkerColour = *(tel_colour)(k[i]->data.pdata);
                break;

            case  TelPolymarkerSize:
                attri_tail->PolymarkerSize = k[i]->data.fdata;
                break;

            case  TelLocalTran3:
            {
                tel_matrix3_data  d = ((tel_matrix3_data)(k[i]->data.pdata));
                switch(d->mode)
                {
                    case  TPreConcatenate: /* not used */
                        TelMultiplymat3( attri_tail->LocalTran3,
                                         d->mat, attri_tail->LocalTran3 );
                        break;

                    case  TPostConcatenate: /* not used */
                        TelMultiplymat3( attri_tail->LocalTran3,
                                         attri_tail->LocalTran3, d->mat );
                        break;

                    case  TReplace:
#ifdef BUC60742
                        matcpy( attri_tail->LocalTran3, d->mat );
                        TelTransposemat3( attri_tail->LocalTran3 );
#else
                        /*
                         * On multiplie la trsf courante par la trsf
                         * de la structure que l'on est en train de
                         * parcourir.
                         */
                        TelMultiplymat3( cur_trsf_stack->LocalTran3,
                                         cur_trsf_stack->LocalTran3, d->mat );
                        /*
                         * On copie de resultat dans la queue d'attributs
                         * pour pouvoir changer l'orientation du reste
                         * du trace.
                         */
                        matcpy( attri_tail->LocalTran3,
                                cur_trsf_stack->LocalTran3 );
                        /*
                         * Transformation definie dans un repere direct
                         * a appliquer dans un repere indirect
                         */
                        TelTransposemat3( attri_tail->LocalTran3 );
#endif  /*BUC60742*/
                        break;
                }
#ifdef TRACE_MATRIX
                printf("TsmSetAttri::TelSetViewMatrix::TelLocalTran3 \n");
#endif
                TelSetViewMatrix(attri_tail->LocalTran3,attri_tail->ViewIndex);
                break;
            }

            case  TelBackInteriorColour:
            {
                attri_tail->BackInteriorColour = *(tel_colour)(k[i]->data.pdata);
                break;
            }

            case  TelFaceDistinguishingMode:
            {
                attri_tail->FaceDistinguishingMode = (Tint) k[i]->data.ldata;
                break;
            }

            case  TelTextColour:
                attri_tail->TextColour = *(tel_colour)(k[i]->data.pdata);
                break;

            case  TelTextColourSubTitle:
                attri_tail->TextColourSubTitle = *(tel_colour)(k[i]->data.pdata);
                break;

            case  TelTextFont:
            {
                Tchar         *fn;

                fn = k[i]->data.pdata;
#ifdef TRACE_TEXT
                printf ("TelTextFont:: %s %s \n", fn, attri_tail->TextFont);
#endif
                if( strcmp( fn, attri_tail->TextFont ) )
                {
#ifdef TRACE_TEXT
                    printf("tXfmfindfont \n");
#endif
#ifndef WNT
                    tXfmfindfont(call_thedisplay, fn, attri_tail->TextHeight);
                    fontBase = tXfmsetfont( 1.0,1.0);
#else
                    WNTFindFont ( fn, attri_tail -> TextHeight );
                    fontBase = WNTSetFont ( 1.0F, 1.0F );
#endif /* WNT */
                    attri_tail->TextFont = fn;
                }
                break;
            }

            case  TelTextHeight:
            {
                Tfloat         h;

                h = k[i]->data.fdata;
#ifdef TRACE_TEXT
                printf ("TelTextHeight:: %f %f \n", h, attri_tail->TextHeight);
#endif
                if( h != attri_tail->TextHeight )
                {
#ifdef TRACE_TEXT
                   printf("tXfmfindfont \n");
#endif
#ifndef WNT
                   tXfmfindfont( call_thedisplay, attri_tail->TextFont, h );
                   fontBase = tXfmsetfont( 1.0,1.0);
#else
                   WNTFindFont ( attri_tail -> TextFont, h );
                           fontBase = WNTSetFont ( 1.0F, 1.0F );
                   /* re-create printer font */
                   if ( printerFontBase ) 
                       updatePrinterFont( attri_tail->TextFont, (int)h );
#endif  /* WNT */
                   attri_tail->TextHeight = h;
                }
                break;
            }

            case  TelCharacterSpacing:
                attri_tail->CharacterSpacing = k[i]->data.fdata;
                break;

            case  TelCharacterExpansionFactor:
            {
                /* double m[3][2]; */

                attri_tail->CharacterExpansionFactor = k[i]->data.fdata;
                /*  FSXXX
                fminitpagematrix();
                m[0][0] = attri_tail->CharacterExpansionFactor, m[0][1] = 0.0;
                m[1][0] = 0.0, m[1][1] = 1.0;
                m[2][0] = 0.0, m[2][1] = 0.0;
                fmsetpagematrix( m );
                */
#ifndef WNT
                fontBase = tXfmsetfont( attri_tail->CharacterExpansionFactor, 1.0);
#else
                fontBase = WNTSetFont (attri_tail -> CharacterExpansionFactor, 1.0F);
#endif  /* WNT */
                break;
            }

#if defined(OCC2934) && defined(WNT)
            case  TelTextureMappedFont:
            {
                attri_tail->TextureMappedFont = k[i]->data.ldata;
                WNTUseTexMappedFont(attri_tail->TextureMappedFont);
                break;
            }
#endif

            /*OCC7456 abd 14.12.2004 Text alingnment attributes  */
            case  TelTextAlign:
                attri_tail->TextAlign = *(tel_align_data)k[i]->data.pdata;
                break;
            /*OCC7456 abd 14.12.2004 Text alingnment attributes  */

            case  TelPolymarkerType:
                attri_tail->PolymarkerType = k[i]->data.ldata;
                break;

            case  TelInteriorReflectanceEquation:
                attri_tail->InteriorReflectanceEquation =
                                            (Tint) k[i]->data.ldata;
                break;

            case  TelBackInteriorReflectanceEquation:
               attri_tail->BackInteriorReflectanceEquation =
                                            (Tint) k[i]->data.ldata;
                break;

            case  TelSurfaceAreaProperties:
                attri_tail->SurfaceAreaProperties =
                                          *(tel_surf_prop)(k[i]->data.pdata);
#ifdef TRACE_UPMATERIAL
                printf("TsmSetAttri::TelSurfaceAreaProperties:TelUpdateMaterial (TEL_FRONT_MATERIAL)\n");
#endif
                TelUpdateMaterial( TEL_FRONT_MATERIAL );
                break;

            case  TelBackSurfaceAreaProperties:
                attri_tail->BackSurfaceAreaProperties =
                                          *(tel_surf_prop)(k[i]->data.pdata);
#ifdef TRACE_UPMATERIAL
                printf("TsmSetAttri::TelBackSurfaceAreaProperties:TelUpdateMaterial (TEL_BACK_MATERIAL)\n");
#endif
                if (attri_tail->FaceDistinguishingMode == TOn)
                    TelUpdateMaterial( TEL_BACK_MATERIAL ); 
                break;

            case  TelFaceCullingMode:
#ifdef G003
              if ( !g_nBackfacing )
#endif  /* G003 */
              {
                TelCullMode mode = (TelCullMode) k[i]->data.ldata;
                if( mode != attri_tail->FaceCullingMode )
                {
                    attri_tail->FaceCullingMode = mode;
                    switch( mode )
                    {
                        case  TelCullNone:
                            glDisable(GL_CULL_FACE);
                            break;

                        case  TelCullFront:
                            glCullFace(GL_FRONT);
                            glEnable(GL_CULL_FACE);
                            break;

                        case  TelCullBack:
                            glCullFace(GL_BACK);
                            glEnable(GL_CULL_FACE);
                            break;
                    }
                }
              }
              break;

            case TelDepthCueIndex:
            {
               Tint dc;

               dc = k[i]->data.ldata;
               if( dc != attri_tail->DepthCueIndex )
               {
                   attri_tail->DepthCueIndex = dc;
                   TelUpdateFog( TglActiveWs, attri_tail->ViewIndex, dc );
               }
               break;
            }

            case  TelInteriorShadingMethod:
            {
                Tint  a;

                a = k[i]->data.ldata;
                attri_tail->InteriorShadingMethod = a;
                a == TEL_SM_FLAT ? glShadeModel( GL_FLAT ) :
                                   glShadeModel( GL_SMOOTH );
                break;
            }

            case  TelViewIndex:
            {
                Tint  vid = k[i]->data.ldata;

                if( vid != attri_tail->ViewIndex )
                {
                    attri_tail->ViewIndex = vid;
                    TelUpdateFog( TglActiveWs, vid, attri_tail->DepthCueIndex );
/*
#ifdef TRACE_MATRIX
                    printf("TsmSetAttri::TelSetViewMatrix::TelViewIndex \n");
#endif
                    TelSetViewMatrix( attri_tail->LocalTran3, vid ); 
*/
                }
                break;
            }

            case  TelHighlightIndex:
                attri_tail->HighlightIndex = k[i]->data.ldata;
                break;
#ifdef G003
            case TelDegenerationMode:
                attri_tail -> DegenerationMode = k[ i ] -> data.ldata;
                break;
#endif  /* G003 */

            /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
            case TelPolygonOffset:
            {
                tel_poffset_param pdata = (tel_poffset_param)(k[i]->data.pdata);
                /* Aspect_POM_None means: do not change current settings */
                if ( ( pdata->mode & Aspect_POM_None ) == Aspect_POM_None )
                  break;
                attri_tail->PolygonOffsetParams = *pdata;
                TelUpdatePolygonOffsets( pdata );
                break;
            }
            /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
          
          /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
          /*case TelTransformPersistenceFlag:
          {
            
            attri_tail->TransPersFlag = k[i]->data.ldata;
              transform_persistence_begin( attri_tail->TransPersFlag );
              break;
          }*/
          case TelTransformPersistence:
          {
              attri_tail->TransPers = *(tel_transform_persistence)(k[i]->data.pdata);
              transform_persistence_begin( attri_tail->TransPers.mode, 
                                           /*
                                           attri_tail->TransPers.point.xyz[0],
                                           attri_tail->TransPers.point.xyz[1],
                                           attri_tail->TransPers.point.xyz[2] );
                                           */
                                           attri_tail->TransPers.pointX,
                                           attri_tail->TransPers.pointY,
                                           attri_tail->TransPers.pointZ );

              break;
          }
            /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */

            default:
                break;
        }
    }
    return TSuccess;
}

/*----------------------------------------------------------------------*/

TStatus
TsmGetAttri( Tint n, ... )
{
    Tint      i;
#if defined (SOLARIS) || defined (IRIXO32)
    cmn_key  *k;
#else
    cmn_key  k[TMaxArgs];
#endif

    Tint flag = 0;

    if( !attri_tail ) {
#ifdef TRACE
        printf ("TsmGetAttri with attri_tail == NULL\n");
#endif
        attri_tail = &attri_default;
        flag = 1;
    }

    CMN_GET_STACK( n, k );
    for( i = 0; i < n; i++ )
    {
        switch( k[i]->id )
        {
            case  TelTextureId:
                k[i]->data.ldata = attri_tail->TextureId;
                break;
                
            case  TelDoTextureMap:
                k[i]->data.ldata = attri_tail->DoTextureMap;
                break;
                
            case  TelTextStyle:
                k[i]->data.ldata = attri_tail->TextStyle;
                break;
                
            case  TelTextDisplayType:
                k[i]->data.ldata = attri_tail->TextDisplayType;
                break;

            case  TelPolylineColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->PolylineColour;
                break;

            case  TelPolylineWidth:
                k[i]->data.fdata = attri_tail->PolylineWidth;
                break;

            case  TelPolylineType:
                k[i]->data.ldata = attri_tail->PolylineType;
                break;

            case  TelEdgeType:
                k[i]->data.ldata = attri_tail->EdgeType;
                break;

            case  TelEdgeWidth:
                k[i]->data.fdata = attri_tail->EdgeWidth;
                break;

            case  TelEdgeColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->EdgeColour;
                break;

            case  TelAntiAliasing:
                k[i]->data.ldata = attri_tail->AntiAliasing;
                break;

            case  TelInteriorColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->InteriorColour;
                break;

            case  TelEdgeFlag:
                k[i]->data.ldata = attri_tail->EdgeFlag;
                break;

            case  TelInteriorStyle:
                k[i]->data.ldata = attri_tail->InteriorStyle;
                break;

            case  TelInteriorStyleIndex:
                k[i]->data.ldata = attri_tail->InteriorStyleIndex;
                break;

            case  TelPolymarkerColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->PolymarkerColour;
                break;

            case  TelPolymarkerSize:
                k[i]->data.fdata = attri_tail->PolymarkerSize;
                break;

            case  TelLocalTran3:
                matcpy( k[i]->data.pdata, attri_tail->LocalTran3 );
                break;

            case  TelBackInteriorColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->BackInteriorColour;
                break;

            case  TelFaceDistinguishingMode:
                k[i]->data.ldata = attri_tail->FaceDistinguishingMode;
                break;

            case  TelTextColour:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->TextColour;
                break;

            case  TelTextColourSubTitle:
                *(tel_colour)(k[i]->data.pdata) = attri_tail->TextColourSubTitle;
                break;

            case  TelTextFont:
                k[i]->data.pdata = attri_tail->TextFont;
                break;

            case  TelTextHeight:
                k[i]->data.fdata = attri_tail->TextHeight;
                break;

            case  TelCharacterSpacing:
                k[i]->data.fdata = attri_tail->CharacterSpacing;
                break;

            case  TelCharacterExpansionFactor:
                k[i]->data.fdata = attri_tail->CharacterExpansionFactor;
                break;

#if defined(OCC2934) && defined(WNT)
            case TelTextureMappedFont:
                k[i]->data.ldata = attri_tail->TextureMappedFont;
                break;
#endif
            /*OCC7456 abd 14.12.2004 Text alingnment attributes  */
            case TelTextAlign:
                *(tel_align_data)(k[i]->data.pdata) = attri_tail->TextAlign;
                break;
            /*OCC7456 abd 14.12.2004 Text alingnment attributes  */
            case  TelPolymarkerType:
                k[i]->data.ldata = attri_tail->PolymarkerType;
                break;

            case  TelInteriorReflectanceEquation:
                k[i]->data.ldata = attri_tail->InteriorReflectanceEquation;
                break;

            case  TelBackInteriorReflectanceEquation:
                k[i]->data.ldata = attri_tail->BackInteriorReflectanceEquation;
                break;

            case  TelSurfaceAreaProperties:
                *(tel_surf_prop)(k[i]->data.pdata) =
                                          attri_tail->SurfaceAreaProperties;
                break;

            case  TelBackSurfaceAreaProperties:
                *(tel_surf_prop)(k[i]->data.pdata) =
                                          attri_tail->BackSurfaceAreaProperties;
                break;

            case  TelFaceCullingMode:
                k[i]->data.ldata = attri_tail->FaceCullingMode;
                break;

            case TelDepthCueIndex:
               k[i]->data.ldata = attri_tail->DepthCueIndex;
               break;

            case  TelInteriorShadingMethod:
                k[i]->data.ldata = attri_tail->InteriorShadingMethod;
                break;

            case  TelViewIndex:
                k[i]->data.ldata = attri_tail->ViewIndex;
                break;

            case  TelHighlightIndex:
                k[i]->data.ldata = attri_tail->HighlightIndex;
                break;

#ifdef G003
            case TelDegenerationMode:
                k[ i ] -> data.ldata = attri_tail -> DegenerationMode;
                break;
#endif  /* G003 */

            /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
            case TelPolygonOffset:
                *(tel_poffset_param)(k[i]->data.pdata) = attri_tail->PolygonOffsetParams;
                break;
            /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
          
          
          /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */
          /*case TelTransformPersistenceFlag:         
            k[ i ] -> data.ldata = attri_tail->TransPersFlag;
              //transform_persistence_begin( attri_tail->TransPersFlag );
            break;
            */
            case  TelTransformPersistence:
                *(tel_transform_persistence)(k[i]->data.pdata) = attri_tail->TransPers;
                break;
          /* ABD 29/10/04  Transform Persistence of Presentation( pan, zoom, rotate ) */             

            default:
                break;
        }
    }

    if( flag ) {
        attri_tail = NULL;
        flag = 0;
    }
    return TSuccess;
}

/*----------------------------------------------------------------------*/

void TelUpdateMaterial( Tint flag )  /* flag == TEL_FRONT_MATERIAL or
                                        TEL_BACK_MATERIAL */
{
   GLenum        face=0;
   tel_colour    col=NULL;
   tel_surf_prop prop=NULL;
   Tint rm=CALL_PHIGS_REFL_NONE;
   static float  mAmb[4];
   static float  mDiff[4];
   static float  mSpec[4];
   static float  mEmsv[4];
   static float  mShin;
   static float  r, g, b;
   static int    physic;
   CMN_KEY_DATA key;
   Tfloat *rgb;
   Tfloat newDiff3;

   /* Hors Hiddenline */
   if (attri_tail->InteriorStyle != TSM_HIDDENLINE)
   {
       if( flag == TEL_FRONT_MATERIAL ) {
           col  = &attri_tail->InteriorColour;
           rm   = attri_tail->InteriorReflectanceEquation;
           prop = &attri_tail->SurfaceAreaProperties;
           face = GL_FRONT_AND_BACK;       
       }
       if( flag == TEL_BACK_MATERIAL ) {
           col  = &attri_tail->BackInteriorColour;
           rm   = attri_tail->BackInteriorReflectanceEquation;
           prop = &attri_tail->BackSurfaceAreaProperties;
           face = GL_BACK;        
       }
    }
   /* Cas HiddenLine */
   else
   {
#ifdef TRACE_UPMATERIAL
       printf("OpenGl_attri::TelUpdateMaterial HiddenLine\n");
#endif
       TsmGetWSAttri (TglActiveWs, WSBackground, &key);
       rgb = key.pdata;

       attri_tail->InteriorColour.rgb[0]=rgb[0];
       attri_tail->InteriorColour.rgb[1]=rgb[1];
       attri_tail->InteriorColour.rgb[2]=rgb[2];
       attri_tail->InteriorReflectanceEquation = CALL_PHIGS_REFL_NONE;
       attri_tail->BackInteriorReflectanceEquation = CALL_PHIGS_REFL_NONE;        
       return;  
   }
   
   /* Type material */   
   physic = prop->isphysic;
    
#ifdef TRACE_UPMATERIAL
   if( flag == TEL_FRONT_MATERIAL ) printf("OpenGl_attri::TelUpdateMaterial TEL_FRONT_MATERIAL\n");
   else printf("OpenGl_attri::TelUpdateMaterial TEL_BACK_MATERIAL\n");
#endif
#ifdef TRACE_MATERIAL
    printf("    InteriorReflectanceEquation: %d\n", attri_tail->InteriorReflectanceEquation);
    printf(" controle mode rm == CALL_PHIGS_REFL_NONE : %d\n",  rm == CALL_PHIGS_REFL_NONE);
#endif

    if( rm == CALL_PHIGS_REFL_NONE ) return;

    /* 
     * Gestion de la transparence 
     */

    if (!SecondPassDo) {
        /* Passage en transparence */
        if (need_trans && prop->trans != 1.0F) {
            glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
            glEnable (GL_BLEND);
            glDepthMask (GL_FALSE);
        }
   
        /* Passage en opaque */
#ifdef BUC60577
        else 
#else 
        if (need_trans && prop->trans == 1.0F)
#endif
        {
            if( attri_tail->AntiAliasing == TOff )
            {
                glBlendFunc (GL_ONE, GL_ZERO);
                glDisable (GL_BLEND);
            }
            glDepthMask (GL_TRUE);
        }       
    }

    /* 
     * Reset Material
     */
    if( need_reset ) 
    {   
        /* Composant ambient */
        if( rm & AMBIENT_MASK )
        {
         /* Type materiau */
         if( physic )
            {r=prop->ambcol.rgb[0];g=prop->ambcol.rgb[1];b=prop->ambcol.rgb[2];}
         else
            {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
            
         mAmb[0] = prop->amb * r;
         mAmb[1] = prop->amb * g;
         mAmb[2] = prop->amb * b;
         mAmb[3] = 1.0F;
        }
        else
        {
         mAmb[0] = 0.0;
         mAmb[1] = 0.0;
         mAmb[2] = 0.0;
         mAmb[3] = 1.0F;
        }
        
        /* Composant diffus */
        if( rm & DIFFUSE_MASK )
        {
         /* Type materiau */
         if( physic )
            {r=prop->difcol.rgb[0];g=prop->difcol.rgb[1];b=prop->difcol.rgb[2];}
         else
            {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
            
         mDiff[0] = prop->diff * r;
         mDiff[1] = prop->diff * g;
         mDiff[2] = prop->diff * b;
         mDiff[3] = 1.0F;
        }
        else
        {
         mDiff[0] = 0.0;
         mDiff[1] = 0.0;
         mDiff[2] = 0.0;
         mDiff[3] = 1.0F;
        }
        
        if (SecondPassDo)
        {
            mDiff[3] = prop->env_reflexion; 
        }
        else
        {
            if (need_trans) mDiff[3] = prop->trans;
            /* si le materiau reflechi la scene environnante,
               alors il faudra faire une seconde passe */
            if (prop->env_reflexion != 0.0) SecondPassNeeded = 1;
        }
        
        /* Composant speculaire */
        if( rm & SPECULAR_MASK )
        {
           if( physic )
           {r=prop->speccol.rgb[0];g=prop->speccol.rgb[1];b=prop->speccol.rgb[2];}
           else
           {r=1.0;g=1.0;b=1.0;} /* cas des generiques */
           
           mSpec[0] = prop->spec * r;
           mSpec[1] = prop->spec * g;
           mSpec[2] = prop->spec * b;
           mSpec[3] = 1.0F;
        } 
        else {
           mSpec[0] = 0.0F;
           mSpec[1] = 0.0F;
           mSpec[2] = 0.0F;
           mSpec[3] = 1.0F;
        }
        
        
        /* Composant emission */        
        if( rm & EMISSIVE_MASK )
        {         
           if( physic )
           {r=prop->emscol.rgb[0];g=prop->emscol.rgb[1];b=prop->emscol.rgb[2];}
           else
           {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
           
           mEmsv[0] = prop->emsv * r;
           mEmsv[1] = prop->emsv * g;
           mEmsv[2] = prop->emsv * b;
           mEmsv[3] = 1.0F;
        }
        else {
           mEmsv[0] = 0.0F;
           mEmsv[1] = 0.0F;
           mEmsv[2] = 0.0F;
           mEmsv[3] = 1.0F;
        }
                
        /* Coeficient de brillance */
        mShin = prop -> shine;
        
        glMaterialfv(face, GL_AMBIENT, mAmb );
        glMaterialfv(face, GL_DIFFUSE, mDiff );
        glMaterialfv(face, GL_SPECULAR, mSpec);
        glMaterialfv(face, GL_EMISSION,  mEmsv);
        glMaterialf(face, GL_SHININESS, mShin);
        
#ifdef TRACE_MATERIAL
        printf(" Material Properties are need_reset:\n") ;
        printf("    Ambient color   is (%f, %f, %f)\n", mAmb[0], mAmb[1], mAmb[2]);
        printf("    Diffuse color   is (%f, %f, %f, %f)\n", mDiff[0], mDiff[1], mDiff[2], mDiff[3]);
        printf("    Specular color  is (%f, %f, %f)\n", mSpec[0], mSpec[1], mSpec[2]);
        printf("    Emission color  is (%f, %f, %f)\n", mEmsv[0], mEmsv[1], mEmsv[2]);
        printf("    Shininess: %f Transparency: %f EnvReflexion: %f \n", mShin, prop->trans, prop->env_reflexion);
        printf("    Prop Specular %f Prop Emissive %f \n", prop->spec, prop->emsv);
        printf("    materiel de type physic : %d\n",  prop->isphysic);
#endif

        need_reset = 0; 
    } 

    /* 
     * Set Material Optimize
     */

    else 
    {
        physic = prop->isphysic;
        /* Composant ambient */
        if( rm & AMBIENT_MASK )
        {
         /* Type materiau */
         if( physic )
            {r=prop->ambcol.rgb[0];g=prop->ambcol.rgb[1];b=prop->ambcol.rgb[2];}
         else
            {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
            
         if (mAmb[0] != prop->amb * r ||
             mAmb[1] != prop->amb * g ||
             mAmb[2] != prop->amb * b )
         {
            mAmb[0] = prop->amb * r;
            mAmb[1] = prop->amb * g;
            mAmb[2] = prop->amb * b;
            mAmb[3] = 1.0F;

            glMaterialfv(face, GL_AMBIENT, mAmb );
#ifdef TRACE_MATERIAL
            printf("    Ambient color   is (%f, %f, %f)\n", mAmb[0], mAmb[1], mAmb[2]);
#endif
         }
        }
        else
        {
            if (  mAmb[0] != 0.0 || mAmb[1] != 0.0 || mAmb[2] != 0.0 )
            {
                mAmb[0] = 0.0F;
                mAmb[1] = 0.0F;
                mAmb[2] = 0.0F;
                mAmb[3] = 1.0F;

                glMaterialfv(face, GL_AMBIENT, mAmb);
#ifdef TRACE_MATERIAL
                printf("    Ambient color  is (%f, %f, %f)\n", mAmb[0], mAmb[1], mAmb[2]);
#endif
            }
        }

        /* Composant diffus */
        if( rm & DIFFUSE_MASK )
        {
         /* Type materiau */
         if( physic )
            {r=prop->difcol.rgb[0];g=prop->difcol.rgb[1];b=prop->difcol.rgb[2];}
         else
            {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
            
         if (mDiff[0] != prop->diff * r ||
             mDiff[1] != prop->diff * g ||
             mDiff[2] != prop->diff * b ||
#ifdef BUC60577
             mDiff[3] != (SecondPassDo ? prop->env_reflexion :
                                (need_trans ? prop->trans : 1.0F)) )
#else
             mDiff[3] != (SecondPassDo ? prop->env_reflexion : 1.0F) )
#endif
         {
            mDiff[0] = prop->diff * r;
            mDiff[1] = prop->diff * g;
            mDiff[2] = prop->diff * b;
            mDiff[3] = 1.0F;
            
            if (SecondPassDo)
            {
                mDiff[3] = prop->env_reflexion; 
            }
            else
            {
                if (need_trans) mDiff[3] = prop->trans;
                /* si le materiau reflechi la scene environnante,
                   alors il faudra faire une seconde passe */
                if (prop->env_reflexion != 0.0) SecondPassNeeded = 1;
            }

            glMaterialfv(face, GL_DIFFUSE, mDiff );
#ifdef TRACE_MATERIAL
            printf("    Diffuse color   is (%f, %f, %f, %f)\n", mDiff[0], mDiff[1], mDiff[2], mDiff[3]);
#endif
         }
        }
        else
        {
            newDiff3 = 1.0F;
            if (SecondPassDo)
            {
                newDiff3 = prop->env_reflexion; 
            }
            else
            {
                if (need_trans) newDiff3 = prop->trans;
                /* si le materiau reflechi la scene environnante,
                alors il faudra faire une seconde passe */
                if (prop->env_reflexion != 0.0) SecondPassNeeded = 1;
            }
          
          /* OCC19915: Even if diffuse reflectance is disabled,
             still trying to update the current transparency if it
             differs from the previous value  */
            if (  mDiff[0] != 0.0 || mDiff[1] != 0.0 || mDiff[2] != 0.0 
                  || fabs(mDiff[3] - newDiff3) > 0.01 )
            {
                mDiff[0] = 0.0F;
                mDiff[1] = 0.0F;
                mDiff[2] = 0.0F;
                mDiff[3] = newDiff3;

                glMaterialfv(face, GL_DIFFUSE, mDiff);
#ifdef TRACE_MATERIAL
                printf("    Diffuse color  is (%f, %f, %f, %f)\n", mDiff[0], mDiff[1], mDiff[2], mDiff[3]);
#endif
            }
        }

        /* composant speculaire */
        if( rm & SPECULAR_MASK )
        {   
            /* Type materiau */
            if( physic )
            {r=prop->speccol.rgb[0];g=prop->speccol.rgb[1];b=prop->speccol.rgb[2];}
            else
             {r=1.0;g=1.0;b=1.0;} /* cas des generiques */          
             
            if (mSpec[0] != prop->spec * r ||
                mSpec[1] != prop->spec * g ||
                mSpec[2] != prop->spec * b)
            {
                mSpec[0] = prop->spec * r;
                mSpec[1] = prop->spec * g;
                mSpec[2] = prop->spec * b;
                mSpec[3] = 1.0F;
                glMaterialfv(face, GL_SPECULAR, mSpec);
        
#ifdef TRACE_MATERIAL
                printf("    Specular color  is (%f, %f, %f)\n", mSpec[0], mSpec[1], mSpec[2]);
#endif
            }
        }
        else
        {
            if (  mSpec[0] != 0.0 || mSpec[1] != 0.0 || mSpec[2] != 0.0 )
            {
                mSpec[0] = 0.0F;
                mSpec[1] = 0.0F;
                mSpec[2] = 0.0F;
                mSpec[3] = 1.0F;

                glMaterialfv(face, GL_SPECULAR, mSpec);
#ifdef TRACE_MATERIAL
                printf("    Specular color  is (%f, %f, %f)\n", mSpec[0], mSpec[1], mSpec[2]);
#endif
            }
        }
        
        /* Composant emission */        
        if( rm & EMISSIVE_MASK )
        {
           /* type materiau */
           if( physic )
           {r=prop->emscol.rgb[0];g=prop->emscol.rgb[1];b=prop->emscol.rgb[2];}
           else
           {r=col->rgb[0];g=col->rgb[1];b=col->rgb[2];}
           
           if ( mEmsv[0] != prop->emsv * r ||
                mEmsv[1] != prop->emsv * g ||
                mEmsv[2] != prop->emsv * b )
            {
                mEmsv[0] = prop->emsv * r;
                mEmsv[1] = prop->emsv * g;
                mEmsv[2] = prop->emsv * b;
                mEmsv[3] = 1.0F;
                glMaterialfv(face, GL_EMISSION, mEmsv);
#ifdef TRACE_MATERIAL
                printf("    Emissive color  is (%f, %f, %f)\n", mEmsv[0], mEmsv[1], mEmsv[2]);
#endif
            }
        }
        else 
        { 
          if (  mEmsv[0] != 0.0 || mEmsv[1] != 0.0 || mEmsv[2] != 0.0 )
            {
                mEmsv[0] = 0.0F;
                mEmsv[1] = 0.0F;
                mEmsv[2] = 0.0F;
                mEmsv[3] = 1.0F;

                glMaterialfv(face, GL_EMISSION, mEmsv);
#ifdef TRACE_MATERIAL
                printf("    Emissive surface  is (%f, %f, %f)\n", mEmsv[0], mEmsv[1], mEmsv[2]);
#endif
            }
        }           
        
        /* coef de brillance */ 
        if( mShin != prop->shine )
        {
            mShin = prop->shine;
            glMaterialf(face, GL_SHININESS, mShin);
#ifdef TRACE_MATERIAL
            printf("    Shininess factor is %f\n", mShin);
#endif
        }
    } /* need_reset */
}

/*----------------------------------------------------------------------*/
void TelResetMaterial()  /* force material definition, called by TelClearViews */
{
    need_reset = 1;
}

/*----------------------------------------------------------------------*/
void TelSetTransparency( Tint tag )
/* force transparency managment, called by redraw_all_structs */
{
    need_trans = tag;
}

/*----------------------------------------------------------------------*/

static  void
TelUpdateFog( Tint ws, Tint vid, Tint dcid )
{
    TEL_GL_DEPTHCUE  dcrep;
    float  params[5];

    if( TelGetGLDepthCue( ws, vid, dcid, &dcrep ) == TSuccess )
    {
        if( dcrep.dcrep.mode == TelDCAllowed )
        {
            params[0] = dcrep.dcrep.col.rgb[0],
            params[1] = dcrep.dcrep.col.rgb[1],
            params[2] = dcrep.dcrep.col.rgb[2];
            params[3] = 1.0F;
            glFogi(GL_FOG_MODE, GL_LINEAR);
            glFogf(GL_FOG_START, dcrep.dist[0]);
            glFogf(GL_FOG_END, dcrep.dist[1]);
            glFogfv(GL_FOG_COLOR, params);
            glEnable(GL_FOG);
#ifdef TRACE
printf(" *** TelUpdateFog START %f END %f\n",dcrep.dist[0],dcrep.dist[1]);
#endif
            return;
        }
    }
    glDisable(GL_FOG);
    return;
}

/*----------------------------------------------------------------------*/

static  void TelSetViewMatrix( Tmatrix3 mat, Tint vid )
{
    TEL_VIEW_REP  vrep;
    Tmatrix3      rmat;
    float         mat16[16];
#ifdef TRACE_MATRIX
    int           i, j;
    GLfloat       pmat[4][4];
#endif

    if( TelGetViewRepresentation( TglActiveWs, vid, &vrep ) == TSuccess )
    {
#ifdef TRACE_MATRIX
        printf ("LocalTran3 :\n");
        for (i = 0; i < 4; i++) {
            printf ("\t");
            for (j = 0; j < 4; j++)
                printf ("%f ", mat[i][j]);
            printf ("\n");
        }
#endif
        if ((!animationUseFlag) || (animationUseFlag && !animationFlag)) 
        {
#ifdef TRACE_MATRIX
            printf ("vrep.orientation_matrix :\n");
            for (i = 0; i < 4; i++) {
                printf ("\t");
                for (j = 0; j < 4; j++)
                    printf ("%f ", vrep.orientation_matrix[i][j]);
                printf ("\n");
            }
#endif
            TelMultiplymat3( rmat, mat, vrep.orientation_matrix );
#ifdef TRACE_MATRIX
            printf("OpenGl_attri.c::TelSetViewMatrix::glLoadMatrixf \n"); 
#endif
            glMatrixMode(GL_MODELVIEW);
            glLoadMatrixf((GLfloat *) rmat);
#ifdef TRACE_MATRIX
            printf ("GL_MODELVIEW_MATRIX set :\n");
            for (i = 0; i < 4; i++) {
                printf ("\t");
                for (j = 0; j < 4; j++)
                    printf ("%f ", rmat[i][j]);
                printf ("\n");
            }
#endif
        }
        else /* animationUseFlag */
        {
            call_util_transpose_mat (mat16, mat); 
            glMatrixMode (GL_MODELVIEW);
#ifdef TRACE_MATRIX
            glGetFloatv( GL_MODELVIEW_MATRIX,(GLfloat *) pmat );
            printf ("GL_MODELVIEW_MATRIX :\n");
            for (i = 0; i < 4; i++) {
                printf ("\t");
                for (j = 0; j < 4; j++)
                    printf ("%f ", pmat[i][j]);
                printf ("\n");
            }
#endif
#ifdef TRACE_MATRIX
            printf("OpenGl_attri.c::TelSetViewMatrix::glMultMatrixf \n"); 
#endif
            glMultMatrixf ((GLfloat *)mat);
#ifdef TRACE_MATRIX
            glGetFloatv( GL_MODELVIEW_MATRIX,(GLfloat *) pmat );
            printf ("GL_MODELVIEW_MATRIX set :\n");
            for (i = 0; i < 4; i++) {
                printf ("\t");
                for (j = 0; j < 4; j++)
                    printf ("%f ", pmat[i][j]);
                printf ("\n");
            }
#endif
        }
    }
    return;
}

/*----------------------------------------------------------------------*/

TStatus
TsmPushAttriLight( void )
{
    tsm_attri_blk  node;

    if( !attri_tbl )
    {
        attri_tbl = cmn_stg_tbl_create( 10, sizeof(TSM_ATTRI_BLK) );
        if( !attri_tbl )
            return TFailure;
    }

    node = cmn_stg_tbl_get( attri_tbl );
    if( !node )
        return TFailure;

    if( attri_tail )
    {
        *node = *attri_tail;
        node->next = attri_tail;
        attri_tail = node;
    }
    else
    {
        *node = attri_default;
        node->next = attri_tail;
        attri_tail = node;
    }

    return TSuccess;
}

/*----------------------------------------------------------------------*/

TStatus
TsmPopAttriLight( void )
{
    tsm_attri_blk  node;

    if( !attri_tail )
        return TFailure; /* Underflow */

    node = attri_tail;
    attri_tail = node->next;

    cmn_stg_tbl_free( (void *) node );

    return TSuccess;
}

/*----------------------------------------------------------------------*/
/*
   void call_util_transpose_mat (tmat, mat)
   float tmat[16];
   float mat[4][4];

        Transpose mat and returns tmat.
*/

static void call_util_transpose_mat (float tmat[16], float mat[4][4]) {
int i, j;

    for (i=0; i<4; i++)
        for (j=0; j<4; j++)
            tmat[j*4+i] = mat[i][j];

#ifdef TRACE
    printf ("Transposee :\n");
    for (i = 0; i < 4; i++) {
        printf ("\t");
        for (j = 0; j < 4; j++)
            printf ("%f ", tmat[i*4+j]);
        printf ("\n");
    }
#endif
}
/*----------------------------------------------------------------------*/

/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
static void TelUpdatePolygonOffsets( tel_poffset_param pdata )
{
#ifdef TRACE
    printf(" *** TelUpdatePolygonOffsets: mode = %x, factor = %f, units = %f", 
      pdata->mode, pdata->factor, pdata->units );
#endif
    if ( ( pdata->mode & Aspect_POM_Fill ) == Aspect_POM_Fill )
        glEnable ( GL_POLYGON_OFFSET_FILL );
    else 
        glDisable ( GL_POLYGON_OFFSET_FILL );

    if ( ( pdata->mode & Aspect_POM_Line ) == Aspect_POM_Line )
        glEnable ( GL_POLYGON_OFFSET_LINE );
    else
        glDisable( GL_POLYGON_OFFSET_LINE );

    if ( ( pdata->mode & Aspect_POM_Point ) == Aspect_POM_Point )
        glEnable ( GL_POLYGON_OFFSET_POINT );
    else
        glDisable( GL_POLYGON_OFFSET_POINT );

    glPolygonOffset( pdata->factor, pdata->units );
}
/* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */

Generated by  Doxygen 1.6.0   Back to index