PIPS
env_test.c
Go to the documentation of this file.
1 /*
2 
3  $Id: env_test.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 du calcul de l'enveloppe convexe de deux polyedres
26  *
27  * Francois Irigoin, Decembre 1989
28  */
29 
30 #ifdef HAVE_CONFIG_H
31  #include "config.h"
32 #endif
33 
34 #include <stdio.h>
35 #include <string.h>
36 
37 #include "boolean.h"
38 #include "vecteur.h"
39 #include "contrainte.h"
40 #include "sc.h"
41 
42 #include "ray_dte.h"
43 #include "sommet.h"
44 #include "sg.h"
45 
46 #include "polyedre.h"
47 
48 main(argc,argv)
49 int argc;
50 char * argv[];
51 {
52  Psysteme s1;
53  Psysteme s2;
54  Ppoly p1;
55  Ppoly p2;
56  Ppoly p_env;
57  FILE * f1;
58  FILE * f2;
59 
60  if(argc!=3) {
61  fprintf(stdout,"Usage: %s sc1 sc2\n",argv[0]);
62  exit(1);
63  }
64 
65  if((f1 = fopen(argv[1],"r")) == NULL) {
66  fprintf(stdout,"Ouverture du fichier %s impossible\n",
67  argv[1]);
68  exit(4);
69  }
70 
71  if((f2 = fopen(argv[2],"r")) == NULL) {
72  fprintf(stdout,"Ouverture du fichier %s impossible\n",
73  argv[2]);
74  exit(4);
75  }
76 
77  /* lecture du premier systeme */
78  if(sc_fscan(f1,&s1)) {
79  fprintf(stderr,"syntaxe correcte dans %s\n",argv[1]);
81  }
82  else {
83  fprintf(stderr,"erreur de syntaxe dans %s\n",argv[1]);
84  exit(1);
85  }
86 
87  /* lecture du deuxieme systeme */
88  if(sc_fscan(f2,&s2)) {
89  fprintf(stderr,"syntaxe correcte dans %s\n",argv[2]);
90  sc_fprint(stdout, s2, *variable_default_name);
91  }
92  else {
93  fprintf(stderr,"erreur de syntaxe dans %s\n",argv[2]);
94  exit(2);
95  }
96 
97  /* mise de s2 dans la base de s1. On admet que la base de s1
98  contient la base de s2 */
99  s2 = sc_translate(s2, s1->base, variable_default_name);
100 
101  /* conversion en polyedres */
102  p1 = sc_to_poly(s1);
103  p2 = sc_to_poly(s2);
104 
105  p_env = env(p1, p2);
106  poly_fprint(stdout, p_env, variable_default_name);
107 }
108 
main(int argc, argv)
test du calcul de l'enveloppe convexe de deux polyedres
Definition: env_test.c:48
static jmp_buf env
Definition: genClib.c:2473
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 f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
Psysteme sc_translate(Psysteme s, Pbase b, char *(*variable_name)())
Psysteme sc_translate(Psysteme s, Pbase b, char * (*variable_name)()): reecriture du systeme s dans l...
Definition: sc.c:99
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 ...
s1
Definition: set.c:247