Changeset 1857 in Sophya


Ignore:
Timestamp:
Jan 14, 2002, 2:42:24 PM (24 years ago)
Author:
perderos
Message:

1) correction de fuites de memoire
2) integration de glpc_set.* ds gp_contour (variables en commun)

Location:
trunk/SophyaPI/PIGcont
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIGcont/Makefile

    r1844 r1857  
    44 
    55all: $(LIB)libPIGcont.a
    6 $(LIB)libPIGcont.a : $(OBJ)gp_alloc.o $(OBJ)gp_axis.o $(OBJ)gp_contour.o $(OBJ)gpc_set.o $(OBJ)picntools.o $(OBJ)pigncont.o
     6$(LIB)libPIGcont.a : $(OBJ)gp_alloc.o $(OBJ)gp_axis.o $(OBJ)gp_contour.o $(OBJ)picntools.o $(OBJ)pigncont.o
    77        $(AR) $(ARFLAGS)  $@ $($(ARARGS))
    88ifeq ($(CXX),cxx)
     
    1111 
    1212clean:
    13         rm -f $(OBJ)gp_alloc.o $(OBJ)gp_axis.o $(OBJ)gp_contour.o $(OBJ)gpc_set.o $(OBJ)picntools.o $(OBJ)pigncont.o
     13        rm -f $(OBJ)gp_alloc.o $(OBJ)gp_axis.o $(OBJ)gp_contour.o $(OBJ)picntools.o $(OBJ)pigncont.o
    1414ifeq ($(CXX),cxx)
    1515        cd $(REPM); rm -f *.o
     
    2020$(OBJ)gp_contour.o: gp_contour.c gp_contour.h gp_types.h gpc_misc.h \
    2121 gp_dynarray.h gp_graph3d.h gp_alloc.h gp_axis.h
    22 $(OBJ)gpc_set.o: gpc_set.c gpc_set.h gp_contour.h gp_types.h gpc_misc.h \
    23  gp_dynarray.h gp_graph3d.h
    2422$(OBJ)picntools.o: picntools.cc $(INC)machdefs.h \
    2523 picntools.h $(INC)pisysdep.h \
     
    8886 $(INC)ntuple.h \
    8987 $(INC)ntupintf.h gp_contour.h gp_types.h \
    90  gpc_misc.h gp_dynarray.h gp_graph3d.h gp_alloc.h gpc_set.h
     88 gpc_misc.h gp_dynarray.h gp_graph3d.h gp_alloc.h
    9189$(OBJ)pigncont.o: pigncont.cc $(INC)machdefs.h \
    9290 $(INC)histos.h \
     
    167165 $(INC)periodic.h \
    168166 $(INC)piscdrawwdg.h gp_contour.h gp_types.h \
    169  gpc_misc.h gp_dynarray.h gp_graph3d.h gp_alloc.h gpc_set.h
     167 gpc_misc.h gp_dynarray.h gp_graph3d.h gp_alloc.h
  • trunk/SophyaPI/PIGcont/gp_alloc.c

    r1844 r1857  
    5555
    5656void contour_free(struct gnuplot_contours *ptr){
    57   char *c;
     57  //char *c;
    5858  struct coordinate *coords;
    5959  struct gnuplot_contours *old;
     
    6161 
    6262  cur = ptr;
     63  //printf("\n contour_free  %x \n",cur);
    6364  while(cur){
     65    /*printf(" contour_free  %x \n",cur);*/
    6466    old = cur;
    65     cur = cur->next;
    66     c=old->label;
    67     coords = old->coords;
    68     if(c){free(c); c=NULL;}
     67    cur = cur->next;   
     68    coords = old->coords;   
    6969    if(coords){free(coords) ; coords = NULL;}
    7070    free(old);   
    71   }
     71    old=NULL;
     72  }
     73 
    7274
    7375}
  • trunk/SophyaPI/PIGcont/gp_contour.c

    r1844 r1857  
    4141 *        Hans-Martin Keller, 1995,1997 (hkeller@gwdg.de)
    4242 *
     43 *   Quelques modifs (adaptation pour SOPHYA/PEIDA) O. PErdereau 11/2001
    4344 */
    4445
     
    4748#include "gp_alloc.h"
    4849#include "gp_axis.h"
     50
     51#include <sys/time.h>
     52#include <sys/resource.h>
     53
    4954/*  #include "setshow.h" */
    5055
     
    5257
    5358char contour_format[32] = "%8.3g";      /* format for contour key entries */
    54 t_contour_kind contour_kind = CONTOUR_KIND_LINEAR;
    55 t_contour_levels_kind contour_levels_kind = LEVELS_AUTO;
    56 int contour_levels = DEFAULT_CONTOUR_LEVELS;
    57 int contour_order = DEFAULT_CONTOUR_ORDER;
    58 int contour_pts = DEFAULT_NUM_APPROX_PTS;
     59static t_contour_kind contour_kind = CONTOUR_KIND_LINEAR;
     60static t_contour_levels_kind contour_levels_kind = LEVELS_AUTO;
     61static int contour_levels = DEFAULT_CONTOUR_LEVELS;
     62static int contour_order = DEFAULT_CONTOUR_ORDER;
     63static int contour_pts = DEFAULT_NUM_APPROX_PTS;
    5964
    6065dynarray dyn_contour_levels_list;/* storage for z levels to draw contours at */
     
    7075
    7176/* Valeur de zero - Reza 21/12/2001 - Pourquoi zero = 0. ??? */
    72 static double zero = 0.;
     77        double zero = 0.;
    7378
    7479/* FIXME HBB 2000052: yet another local copy of 'epsilon'. Why? */
     
    206211struct iso_curve *iso_lines;
    207212{
     213    struct rusage r_usage;
     214    int rcus;
     215 
    208216    int i;
    209217    /*OP    int num_of_z_levels;*/      /* # Z contour levels. */
     
    217225
    218226    contour_list = NULL;
    219 
     227    /******* DEBUG ********
     228    rcus = getrusage( RUSAGE_SELF , &r_usage);
     229    if(rcus==0)
     230      printf("contour[1] / rusage -> %ld , %ld , %ld \n",  r_usage.ru_maxrss , r_usage.ru_ixrss , r_usage.ru_ixrss);
     231    else
     232      perror("contour/1er appel");
     233    *************/
    220234    /*
    221235     * Calculate min/max values :
     
    224238                 &x_min, &y_min, &z_min, &x_max, &y_max, &z_max);
    225239
     240
    226241    dz = fabs(z_max - z_min);
    227242    /*
     
    232247    gen_triangle(num_isolines, iso_lines, &p_polys, &p_edges);
    233248    crnt_cntr_pt_index = 0;
     249
     250
    234251    /*AJOUT OP */
    235252    if (contour_levels_kind == LEVELS_NUM) {
     
    279296    /* Free all contouring related temporary data. */
    280297    while (p_polys) {
     298       
    281299        p_poly = p_polys->next;
    282300        free(p_polys);
    283301        p_polys = p_poly;
    284302    }
    285     while (p_edges) {
     303
     304
     305    while (p_edges) {       
    286306        p_edge = p_edges->next;
    287307        free(p_edges);
    288308        p_edges = p_edge;
    289309    }
     310    /*********DEBUG
     311    rcus = getrusage( RUSAGE_SELF , &r_usage);
     312    if(rcus==0)
     313      printf("contour[5] / rusage -> %ld , %ld , %ld \n",  r_usage.ru_maxrss , r_usage.ru_ixrss , r_usage.ru_ixrss);
     314    else
     315      perror("contour / 5eme appel");
     316    rcus = getrusage( RUSAGE_SELF , &r_usage);
     317    ********/
    290318
    291319    return contour_list;
     
    15341562    }
    15351563}
     1564
     1565
     1566/* setting et getting de variables */
     1567/*        OP 01/2002               */
     1568
     1569void set_contour_kind(t_contour_kind in){
     1570  contour_kind = in;
     1571}
     1572
     1573t_contour_kind get_contour_kind(){
     1574  return (contour_kind);
     1575}
     1576
     1577void set_contour_levels_kind(t_contour_levels_kind in){
     1578 contour_levels_kind = in;
     1579
     1580}
     1581
     1582t_contour_levels_kind get_contour_levels_kind(){
     1583
     1584  return(contour_levels_kind);
     1585}
     1586
     1587void set_contour_levels(int num){
     1588  contour_levels = num;
     1589}
     1590
     1591int get_contour_levels(){
     1592  return(contour_levels);
     1593}
     1594void set_contour_levels_list(double *vec){
     1595
     1596  contour_levels_list=vec;
     1597}
     1598
     1599/*******
     1600void set_contour_levels_list(double *vec,int sz){
     1601  int i;
     1602  printf(" <set_contour_levels_list> sz %d \n",sz);
     1603  contour_levels_list = (double *)  malloc(sz*sizeof(double));
     1604  for (i=0 ; i<sz ; i++){
     1605    printf(" <set_contour_levels_list> i %d vec %g\n",i,vec[i]);
     1606    contour_levels_list[i] = vec[i];
     1607   
     1608  }
     1609}
     1610void free_contour_levels_list(){
     1611  if(contour_levels_list != NULL){
     1612    free(contour_levels_list);
     1613    contour_levels_list = NULL;
     1614  }
     1615}
     1616*****/
     1617double * get_contour_levels_list(){
     1618
     1619return(contour_levels_list);
     1620}
     1621 
  • trunk/SophyaPI/PIGcont/gp_contour.h

    r1844 r1857  
    7777
    7878extern char contour_format[];
    79 extern t_contour_kind contour_kind;
    80 extern t_contour_levels_kind contour_levels_kind;
    81 extern int contour_levels;
    82 extern int contour_order;
    83 extern int contour_pts;
     79/***********************************************/
     80/* VARIABLES MAINTENANT STATIQUES - OP 01/2002 */
     81/*extern t_contour_kind contour_kind;*/
     82/*extern t_contour_levels_kind contour_levels_kind;*/
     83/*extern int contour_levels;*/
     84/*extern int contour_order;*/
     85/*extern int contour_pts;*/
     86/***********************************************/
    8487
    8588/* storage for z levels to draw contours at */
     
    9497int Get_Num_Of_Z_Levels();
    9598
     99/* seting de variables OP 01/2002 */
     100
     101void set_contour_kind(t_contour_kind);
     102t_contour_kind get_contour_kind();
     103
     104void set_contour_levels_kind(t_contour_levels_kind);
     105t_contour_levels_kind get_contour_levels_kind();
     106
     107void set_contour_levels(int);
     108int get_contour_levels();
     109void set_contour_levels_list(double *);
     110double * get_contour_levels_list();
     111
     112
     113
    96114#endif /* GNUPLOT_CONTOUR_H */
  • trunk/SophyaPI/PIGcont/objlist.list

    r1844 r1857  
    22gp_axis.o
    33gp_contour.o
    4 gpc_set.o
    54picntools.o
    65pigncont.o
  • trunk/SophyaPI/PIGcont/picntools.cc

    r1838 r1857  
    1414//++
    1515// Class        PICnTools
    16 // Lib          PI
    17 // include      pidrwtools.h
     16// Lib          PIGcont
     17// include      pidcntools.h
    1818//
    1919//      Classe de fenêtre de dialogue permettant de modifier interactivement
    20 //      Les attributs graphique des "Drawer" attachés aux "PIBaseWdg".
     20//      les attributs graphique des "PIContourDrawer" ainsi que
     21//      les parametres de calcul des contours.
    2122//--
    2223// Links        Parents
     
    2728// PIDrawer
    2829// PIBaseWdg
     30// PIContourDrawer
    2931//--
    3032//++
     
    4143// void  ShowPICnTools()       
    4244//      Méthode statique permettant l'affichage de la fenêtre de contrôle des
    43 //      attributs graphiques des "Drawer". L'instance de la classe
    44 //       "PICnTools" est créée si nécessaire.
     45//      attributs graphiques des "PIContourDrawer". L'instance de la classe
     46//      "PICnTools" est créée si nécessaire. Un seul "PIContourDrawer" est gere.     
    4547// void  HidePICnTools()
    46 //      Désacative (cache) la fenêtre "PICnTools" (méthode statique).
     48//      Désactive (cache) la fenêtre "PICnTools" (méthode statique).
    4749// void  SetCurrentBaseWdg(PIBaseWdgGen* cbw)
    48 //      Méthode statique permettant de sélectionner le "PIBaseWdg" courant.
     50//      Méthode statique permettant de s'attacher au "PIBaseWdg" courant.
    4951// PIBaseWdgGen*  GetCurrentBaseWdg()
    5052//      Retourne le "PIBaseWdg" courant (méthode statique).
     53// void  SetCurrentCnDrw( PIContourDrawer* pcd)
     54//      Méthode statique permettant de s'attacher au "PIContourDrawer".
     55// PIBaseWdgGen*  :GetCurrentCnDrw()
     56//      Retourne le "PIContourDrawer" (méthode statique).
    5157//--
    5258
     
    375381cpx += bsx*1.2+spx;
    376382
    377 /******
    378 mButcf[3] = new PIButton(this, "Calc", 3200, bsx*0.8, bsyo, cpx, cpy);
    379 mButcf[3]->ActivatePress(true);
    380 mButcf[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    381 *****/
    382383cpx += bsx*0.8+spx;
    383384
     
    453454return;
    454455}
    455 
     456// Liste des differentes options de calcul
    456457static t_contour_kind crbe_algo[3]={CONTOUR_KIND_LINEAR,CONTOUR_KIND_CUBIC_SPL,CONTOUR_KIND_BSPLINE};
    457458static t_contour_levels_kind lev_kind[4]={LEVELS_AUTO,LEVELS_NUM,LEVELS_INCREMENTAL,LEVELS_DISCRETE};
  • trunk/SophyaPI/PIGcont/pigncont.cc

    r1853 r1857  
    1212#include "picntools.h"
    1313#include "pigncont.h"
     14
     15#include <sys/time.h>
     16#include <sys/resource.h>
    1417
    1518/*  A virer ?? Reza 21/12/2001
     
    369372 
    370373 struct gnuplot_contours *cntcur = _contours;
     374 /*****
    371375 struct gnuplot_contours *cntold;
    372376
    373  while(cntcur) {
     377 while(cntcur) { 
    374378   //cout << " ~GNUPlotContour() : destruction de _contours" << _contours <<endl;
    375    cntold = cntcur;
    376    cntcur = cntold->next;
    377    gp_free(cntold);
    378    cntold=NULL;
    379  }
    380  
     379   cntold = cntcur;
     380   cntcur = cntold->next;
     381   gp_free(cntold);
     382   cntold=NULL;
     383 } 
     384 *******/
     385 contour_free(cntcur);
    381386 _contours = NULL;
    382387
     
    390395
    391396void GNUPlotContour::CalcContour(){
    392  cout << " GNUPlotContour::CalcContour(): determination des contours "<<endl;
     397  //cout << " GNUPlotContour::CalcContour(): determination des contours "<<endl;
     398
     399 struct rusage r_usage;
     400 int rcus;
    393401
    394402 set_contour_kind(Contour_kind);
     
    416424  }
    417425
     426 
     427 rcus = getrusage( RUSAGE_SELF , &r_usage);
     428
     429 //if(rcus==0)
     430 //  cout << " rusage -> "<<  r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
     431 //else
     432 //  perror("1er appel");
     433
    418434 if(_contours) {
    419    //cout << " GNUPlotContour::CalcContour(): destruction des contours "<<endl;
     435   cout << " GNUPlotContour::CalcContour(): destruction des contours "<<_contours<<endl;
    420436   struct gnuplot_contours *cntcur = _contours;
    421    struct gnuplot_contours *cntold;
    422    while(cntcur) {
    423      cntold = cntcur;
    424      cntcur = cntold->next;
    425      gp_free(cntold);
    426    }
     437   /******
     438   struct gnuplot_contours *cntold;
     439   while(cntcur) {
     440   cout << " GNUPlotContour::CalcContour(): destruction des contours "<< cntcur<<endl;
     441     cntold = cntcur;
     442     cntcur = cntold->next;
     443     gp_free(cntold);
     444     cntold = NULL;
     445   }
     446   ******/
     447   contour_free(cntcur);
    427448   _contours = NULL;
    428449   
    429450 }
    430451
    431    
    432  
    433  //struct gnuplot_contours *cntcur;
     452 //struct gnuplot_contours *cntcur;
    434453 //struct gnuplot_contours *cntold;
    435454 
     455
     456 //rcus = getrusage( RUSAGE_SELF , &r_usage);
     457 //if(rcus==0)
     458 //  cout << " rusage -> "<< r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
     459 //else
     460 //  perror("2d appel");
     461
     462
    436463 _contours = contour (_nx,iso1);
     464 
     465
     466 //rcus = getrusage( RUSAGE_SELF , &r_usage);
     467 //if(rcus==0)
     468 //  cout << " rusage -> "<<  r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
     469 //else
     470 //  perror("3ieme appel");
     471
    437472 //free_contour_levels_list();
    438 
     473 
    439474 
    440475}
  • trunk/SophyaPI/PIGcont/pigncont.h

    r1844 r1857  
    1515#include "gp_contour.h"
    1616#include "gp_alloc.h"
    17 #include "gpc_set.h"
     17  //#include "gpc_set.h"
    1818}
    1919
Note: See TracChangeset for help on using the changeset viewer.