drawFecEntity.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------*/
00002 /* file: drawFecEntity.c                                                  */
00003 /* Copyright INRIA 2006                                                   */
00004 /* Authors : Jean-Baptiste Silvy                                          */
00005 /* desc : Contains functions needed to draw a fec handle                  */
00006 /*------------------------------------------------------------------------*/
00007 
00008 #include "drawFecEntity.h"
00009 #include "MALLOC.h"
00010 #include "GetProperty.h"
00011 #include "Xcall1.h"
00012 #include "periScreen.h"
00013 #include "sciCall.h"
00014 #include "sciprint.h"
00015 #include "PloEch.h"
00016 #include "axesScale.h"
00017 #include "Fec.h"
00018 #include "Vertices.h"
00019 
00020 /*---------------------------------------------------------------------------------*/
00021 int drawFecEntity( sciPointObj * pObj )
00022 {
00023   sciFec      * ppFec        = pFEC_FEATURE(pObj)       ;
00024   sciPointObj * parentSubWin = sciGetParentSubwin(pObj) ;
00025   int           curLineStyle = 0                        ;
00026   int           lineStyle    = 1                        ;
00027   int           verbose      = 0                        ;
00028   int           nbNode       = ppFec->Nnode             ;
00029   int         * xCoords      = NULL                     ;
00030   int         * yCoords      = NULL                     ;
00031   int           narg         = 1                        ;
00032   int           i                                       ;
00033 
00034   if ( !sciGetVisibility( pObj ) ) { return 0 ; }
00035 
00036   xCoords = MALLOC( nbNode * sizeof(int) ) ;
00037   if ( xCoords == NULL )
00038   {
00039     sciprint("Can not allocate temporary vector, memory full.\n") ;
00040     return -1 ;
00041   }
00042 
00043   yCoords = MALLOC( nbNode * sizeof(int) ) ;
00044   if ( yCoords == NULL )
00045   {
00046     FREE( xCoords ) ;
00047     sciprint("Can not allocate temporary vector, memory full.\n") ;
00048     return -1 ;
00049   }
00050 
00051   if ( sciGetIs3d( parentSubWin ) )
00052   {
00053     double * xVect = NULL;
00054     double * yVect = NULL;
00055 
00056     xVect = MALLOC ( nbNode * sizeof(double) ) ;
00057     if ( xVect == NULL )
00058     {
00059       FREE( xCoords ) ;
00060       FREE( yCoords ) ;
00061       return -1 ;
00062     }
00063 
00064     yVect = MALLOC ( nbNode * sizeof(double) ) ;
00065     if ( yVect == NULL )
00066     {
00067       FREE( xVect   ) ;
00068       FREE( xCoords ) ;
00069       FREE( yCoords ) ;
00070       return -1 ;
00071     }
00072 
00073     for( i = 0 ; i < nbNode ; i++ )
00074     {
00075       xVect[i] = ppFec->pvecx[i];
00076       yVect[i] = ppFec->pvecy[i];
00077     }
00078 
00079     ReverseDataFor3DXonly( parentSubWin, xVect, nbNode ) ;
00080     ReverseDataFor3DYonly( parentSubWin, yVect, nbNode ) ;
00081 
00082     trans3d( parentSubWin, nbNode, xCoords, yCoords, xVect, yVect, NULL ) ;
00083 
00084     FREE(xVect) ;
00085     FREE(yVect) ;
00086   }
00087   else
00088   {
00089     for ( i = 0 ; i < nbNode ; i++ )
00090     {
00091       xCoords[i] = XScale( ppFec->pvecx[i] ) ; 
00092       yCoords[i] = YScale( ppFec->pvecy[i] ) ;
00093     }
00094   }
00095 
00096 #ifdef _MSC_VER
00097   flag_DO = MaybeSetWinhdc();
00098 #endif
00099 
00100   /* need to put line style to plain otherwise bug 1872 occurs */
00101   C2F(dr)("xget","line style",&verbose,&curLineStyle,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00102   C2F(dr)("xset", "line style", &lineStyle, PI0, PI0, PI0, PI0, PI0, PD0, PD0, PD0, PD0, 0L, 0L);
00103 
00104   newfec( xCoords,yCoords,ppFec->pnoeud,ppFec->pfun,
00105     &ppFec->Nnode,&ppFec->Ntr,
00106     ppFec->zminmax,ppFec->colminmax,
00107     ppFec->colout, ppFec->with_mesh ) ;
00108 
00109   C2F(dr)("xset", "line style", &curLineStyle, PI0, PI0, PI0, PI0, PI0, PD0, PD0, PD0, PD0, 0L, 0L);
00110 
00111 #ifdef _MSC_VER
00112   if ( flag_DO == 1) { ReleaseWinHdc() ; }
00113 #endif
00114 
00115   FREE( xCoords ) ;
00116   FREE( yCoords ) ;
00117 
00118   return 0 ;
00119 
00120 }
00121 /*---------------------------------------------------------------------------------*/

Generated on Sun Mar 4 15:03:51 2007 for Scilab [trunk] by  doxygen 1.5.1