PIPS
sc_to_sg_test1.c
Go to the documentation of this file.
1 /*
2 
3  $Id: sc_to_sg_test1.c 1641 2016-03-02 08:20:19Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 /* test de la conversion d'un systeme d'equations et d'inequations en
26  * un systeme generateur
27  *
28  * Francois Irigoin, Decembre 1989
29  */
30 
31 #ifdef HAVE_CONFIG_H
32  #include "config.h"
33 #endif
34 
35 #include <stdio.h>
36 #include <string.h>
37 
38 #include "boolean.h"
39 #include "vecteur.h"
40 #include "contrainte.h"
41 #include "sc.h"
42 
43 #include "ray_dte.h"
44 #include "sommet.h"
45 #include "sg.h"
46 
47 #include "polyedre.h"
48 
49 main(argc,argv)
50 int argc;
51 char * argv[];
52 {
53  Psysteme s;
54  Spoly p;
55  /* systeme generateur sg */
56  Ptsg sg;
57  FILE * f;
58  char * filename = "stdin";
59 
60  if(argc==1) {
61  f = stdin;
62  fprintf(stderr,"Lecture sur stdin\n");
63  }
64  else if(argc==2) {
65  filename = strdup(argv[1]);
66  if((f = fopen(filename,"r")) == NULL) {
67  fprintf(stderr,"Ouverture du fichier %s impossible\n",
68  filename);
69  exit(4);
70  }
71  }
72  else {
73  fprintf(stderr,"Usage: sc_fscan_print [filename]\n");
74  exit(1);
75  }
76 
77  /* lecture du systeme */
78  if(sc_fscan(f,&s)) {
79  fprintf(stderr,"syntaxe correcte dans %s\n",filename);
81  }
82  else {
83  fprintf(stderr,"erreur de syntaxe dans %s\n",filename);
84  exit(1);
85  }
86 
87  /* conversion */
88  sg = sc_to_sg(s);
90 
91  /* construction du polyedre (sc, sg) */
92  p.sc = s;
93  p.sg = sg;
94  elim_red(p);
95  printf("apres elimination de redondance\n");
96  sg_fprint(stdout, p.sg, variable_default_name);
97 }
Ptsg sg
char * variable_default_name(Variable v)
char * variable_default_name(Variable v): returns the name of variable v
Definition: variable.c:81
#define exit(code)
Definition: misc-local.h:54
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
bool sc_fscan(FILE *f, Psysteme *ps)
bool sc_fscan(FILE * f, Psysteme * ps): construit un systeme d'inegalites et d'egalites lineaires a p...
Definition: sc_io.c:121
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
int printf()
main(int argc, argv)
test de la conversion d'un systeme d'equations et d'inequations en un systeme generateur
void sg_fprint(FILE *f, Ptsg sg, char *(*nom_var)(Variable))
void sg_fprint(FILE * f, Ptsg sg, char * (*nom_var)()): impression d'un systeme generateur
Definition: sg.c:262
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
Definition: sg-local.h:66