00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <stdlib.h>
00004
00005 #include <polylib/polylib.h>
00006
00007
00008 void Union_Read( Polyhedron **P, Polyhedron **C, char ***param_name )
00009 {
00010 Matrix *pm;
00011 Polyhedron *ptmp;
00012 unsigned NbRows, NbColumns;
00013 char s[1025], param[1025];
00014 int i, j, c, f;
00015
00016 *P = NULL;
00017 pm = Matrix_Read();
00018 f=1;
00019 while( f )
00020 {
00021 do
00022 {
00023 if( fgets(s, 1024, stdin) == 0 )
00024 f=0;
00025 }
00026 while ( (*s=='#' || *s=='\n') && f );
00027
00028 if( f && sscanf(s, "%d %d", &NbRows, &NbColumns)==2 )
00029 {
00030
00031 if( *P )
00032 if( pm->NbColumns != ((*P)->Dimension)+2 )
00033 {
00034 fprintf( stderr,
00035 "Polyhedra must be in the same dimension space !\n");
00036 exit(0);
00037 }
00038 ptmp = Constraints2Polyhedron(pm, 200);
00039 ptmp->next = *P;
00040 *P = ptmp;
00041 Matrix_Free(pm);
00042
00043
00044 pm = Matrix_Alloc(NbRows, NbColumns);
00045 Matrix_Read_Input( pm );
00046 }
00047 else
00048 break;
00049 }
00050
00051
00052 *C = Constraints2Polyhedron(pm, 200);
00053 Matrix_Free(pm);
00054
00055
00056 if( f )
00057 {
00058
00059 *param_name = (char **)malloc( (*C)->Dimension*sizeof(char *) );
00060 c = 0;
00061 for( i=0 ; i<(*C)->Dimension ; ++i )
00062 {
00063 j=0;
00064 for( ; ; ++c )
00065 {
00066 if( s[c]==' ' || s[c]=='\n' || s[c]==0 ) {
00067 if( j==0 )
00068 continue;
00069 else
00070 break;
00071 }
00072 param[j++] = s[c];
00073 }
00074
00075
00076 if( j==0 )
00077 break;
00078 param[j] = 0;
00079 (*param_name)[i] = (char *)malloc( j );
00080 strcpy( (*param_name)[i], param );
00081 }
00082 if( i != (*C)->Dimension )
00083 {
00084 free( *param_name );
00085 *param_name = Read_ParamNames(NULL,(*C)->Dimension);
00086 }
00087 }
00088 else
00089 *param_name = Read_ParamNames(NULL,(*C)->Dimension);
00090
00091 }
00092
00093
00094
00095 int main( int argc, char **argv)
00096 {
00097 Polyhedron *P, *C;
00098 char **param_name;
00099 Enumeration *e, *en;
00100
00101 if( argc != 1 )
00102 {
00103 fprintf( stderr, " Usage : %s [< file]\n", argv[0] );
00104 return( -1 );
00105 }
00106
00107 Union_Read( &P, &C, ¶m_name );
00108
00109 e = Domain_Enumerate( P, C, 200, param_name );
00110
00111 for( en=e ; en ; en=en->next )
00112 {
00113 Print_Domain(stdout,en->ValidityDomain, param_name);
00114 print_evalue(stdout,&en->EP, param_name);
00115 printf( "\n-----------------------------------\n" );
00116 }
00117
00118 return( 0 );
00119 }
00120
00121
00122