1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
3 
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
19 USA.
20 
21 Dr. David Kirkby, e-mail drkirkby at gmail.com
22 
23 */
24 
25 /* The program create_bmp_for_rect_in_rect is a pre-processor for atlc. It produces bitmaps of rectangular
26 inner and rectangular outer */
27 #include "config.h"
28 
29 
30 #ifdef HAVE_STDLIB_H
31 #include <stdlib.h>
32 #endif
33 
34 #include "definitions.h"
35 #include "exit_codes.h"
36 
37 #ifdef WINDOWS
38 #pragma hrdstop
39 #include <condefs.h>
40 #endif
41 
42 double WW, HH, aa, bb, cc, dd, ww, hh, Er1, Er2;
43 int W, H, a, b, c, d, w, h, D;
44 /* The following are only needed, so I can link in two
45 convert_circ_in_circ_dimensions_to_integers.c
46 and
47 convert_create_bmp_for_rect_in_rect_dimensions_to_integers.c
48 */
49 
50 int verbose=FALSE;
51 int lowest=2500, highest=10000;
52 int fileflag=FALSE;
53 
main(int argc,char ** argv)54 extern int main(int argc, char **argv) /* Read parameters from command line here   */
55 {
56    int  bmp_size=DEFAULT_BMP_SIZE;
57    int q;
58    FILE *image_data_fp;
59    struct transmission_line_properties not_used;
60 
61    /* The following line is just to keep SGI's compiler happy. */
62    not_used.W=1;
63 
64    while((q=get_options(argc,argv,"b:f:v")) != -1)
65    switch (q)
66    {
67       case 'b':
68       bmp_size=atol(my_optarg);
69       break;
70       case 'v':
71       verbose=TRUE;
72       break;
73       case '?':
74       printf("read a ? exiting\n");
75    }
76    if(argc-my_optind ==6)
77    {
78       WW=atof(argv[my_optind]);
79       HH=atof(argv[my_optind+1]);
80       ww=atof(argv[my_optind+2]);
81       cc=atof(argv[my_optind+3]);
82       Er1=atof(argv[my_optind+4]);
83       if((image_data_fp=fopen(argv[my_optind+5],"wb"))==NULL)
84       {
85 	 fprintf(stderr,"Can't write to %s. Exiting ...\n",my_optarg);
86 	 exit_with_msg_and_exit_code("",CANT_OPEN_FOR_WRITING);
87       }
88 
89       /* To make the program easier to write, rect_cen_in_rect uses
90       the same variables as create_bmp_for_rect_in_rect. We just calculate the
91       values not given (a, b, d, h and Er1 from those given
92       (W, H, c and w) */
93 
94       aa=(WW-ww)/2.0;
95       bb=(WW-ww)/2.0;
96       dd=ww;
97       hh=(HH-cc)/2.0;
98       Er2=Er1;
99       check_parameters_of_create_bmp_for_rect_in_rect();
100       convert_create_bmp_for_rect_in_rect_dimensions_to_integers(bmp_size);
101       write_bitmap(image_data_fp, not_used);
102    }
103    else
104       usage_create_bmp_for_rect_cen_in_rect();
105    return(OKAY);
106 }
107