cuikplot.c
Go to the documentation of this file.
1 #include "boolean.h"
2 #include "plot2D.h"
3 #include "box.h"
4 #include "defines.h"
5 #include "filename.h"
6 
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <math.h>
11 
12 
61 int main(int argc, char **arg)
62 {
63  Tbox box;
64  Tplot plot;
65  int token;
66  FILE *PSin;
67  Tinterval *x,*y;
68  unsigned int dim_x,dim_y;
69  double min_x,max_x,min_y,max_y;
70  unsigned int nb;
71  char nx[10]; /*name for the axis to be ploted*/
72  char ny[10];
73  Tfilename fsols,fplot;
74 
75  if (argc<5)
76  {
77  fprintf(stderr,"Use:\n");
78  fprintf(stderr," cuikplot <filename> dimx dimy <plotname>\n");
79  fprintf(stderr," <filename> the input .sol file\n");
80  fprintf(stderr," dimx dimy the two dimensions to be plotted (numbered from 1)\n");
81  fprintf(stderr," <plotname> the output .fig file\n");
82  }
83  else
84  {
85  CreateFileName(NULL,arg[1],NULL,SOL_EXT,&fsols);
86 
87  /*Parse the input parameters*/
88 
89  PSin=fopen(GetFileFullName(&fsols),"r");
90  if (!PSin)
91  Error("Input file can not be opened");
92 
93  dim_x=(unsigned int)atoi(arg[2]);
94  dim_y=(unsigned int)atoi(arg[3]);
95 
96  /*Check if the dimensions are right*/
97  if ((dim_x==0)||(dim_y==0))
98  Error("Dimensions are numbered from 1\n");
99 
100  if (dim_x==dim_y)
101  Error("Plotting dimensions must be different\n");
102 
103  dim_x=dim_x-1;
104  dim_y=dim_y-1;
105 
106  CreateFileName(NULL,arg[4],NULL,PLOT2D_EXT,&fplot);
107  InitPlot(GetFileFullName(&fplot),&plot);
108 
109  SetOrigin(0.0,0.0,&plot);
110 
111  sprintf(nx,"V%u",dim_x);
112  sprintf(ny,"V%u",dim_y);
113  PlotAxis(nx,-3,3,ny,-3,3,0.5,&plot);
114 
115  nb=1;
116  do {
117  token=ReadBox(PSin,&box);
118 
119  if (token!=EOF)
120  {
121  /*Get the interval of the box in the projection dimentions*/
122  x=GetBoxInterval(dim_x,&box);
123  y=GetBoxInterval(dim_y,&box);
124 
125  /*and get the extreme of the intervals*/
126  min_x=LowerLimit(x);
127  max_x=UpperLimit(x);
128 
129  min_y=LowerLimit(y);
130  max_y=UpperLimit(y);
131 
132  PlotRectangle(min_x,max_y,max_x,min_y,&plot);
133 
134  nb++;
135 
136  DeleteBox(&box);
137  }
138  } while(token!=EOF);
139 
140  DeleteFileName(&fplot);
141  DeleteFileName(&fsols);
142  ClosePlot(&plot);
143  fclose(PSin);
144  }
145  return(EXIT_SUCCESS);
146 }
147