1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
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.
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.
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,
21 Dr. David Kirkby, e-mail drkirkby at gmail.com
25 /* The program widestrip is a pre-processor for atlc. It produces bitmaps
26 of a thin strip, between two wide plates */
29 #define RATIO 4 /* W = H*RATIO+w */
38 #include "definitions.h"
39 #include "exit_codes.h"
48 extern int main(int argc, char **argv) /* Read parameters from command line here */
50 int W, H, w, size_of_image, q;
51 int user_requires_effectively_infinite_width=FALSE;
53 unsigned char *unaligned_image_vector, *aligned_image_vector;
59 while((q=get_options(argc,argv,"Cvi")) != -1)
63 print_copyright((char *) "2002");
64 exit_with_msg_and_exit_code("",OKAY);
67 user_requires_effectively_infinite_width=TRUE;
73 usage_create_bmp_for_symmetrical_stripline();
75 } /* End of the switch statement */
76 if(argc-my_optind !=4)
78 usage_create_bmp_for_symmetrical_stripline();
79 exit_with_msg_and_exit_code("",PROGRAM_CALLED_WITH_WRONG_NUMBER_OF_ARGUMENTS);
81 W=atoi(argv[my_optind]);
82 H=atoi(argv[my_optind+1])+2*BORDER;
83 if(H%2==0) /* make it odd, so that the inner can sit in the middle */
86 printf("H needs to be odd, so the inner conductor (1 pixel high) will fit\
87 centrally. Hence H has been increased to %d pixels\n",H);
89 w=atoi(argv[my_optind+2]);
90 if ((W < RATIO*H + w) && user_requires_effectively_infinite_width==TRUE)
92 fprintf(stderr,"For this to be a valid test of atlc, the width should be\n");
93 fprintf(stderr,"infinite. Since you used the -i option (indicationg you\n");
94 fprintf(stderr,"want the width W to effectively infinite, W must exceed w + %dxH.\n",RATIO);
95 fprintf(stderr,"Therefore W has been is set to %d\n",RATIO*H+w );
99 exit_with_msg_and_exit_code("W or H is under 6, which is stupid (remember these are pixels !! in this program)",W_OR_H_TOO_SMALL);
100 aligned_image_vector=ustring(0,(W+3)*3*H+100);
101 unaligned_image_vector=ustring(0,(W+3)*3*H+100);
103 if((fp=fopen(argv[my_optind+3],"wb")) == NULL)
105 exit_with_msg_and_exit_code("Error in opening file in create_bmp_for_symmetrical_stripline",CANT_OPEN_FOR_WRITING);
107 aligned_image_vector=ustring(0,(W+3)*3*H);
108 unaligned_image_vector=ustring(0,(W+3)*3*H);
111 (void) memset((void *) (aligned_image_vector),0x00,(size_t) W*H*3);
113 for(memory_location=0; memory_location < W*H*3; memory_location++)
114 aligned_image_vector[memory_location]=0;
117 /* Fill a vector with */
118 fill_image_vector_for_thin_strip(W,H,w,unaligned_image_vector);
119 size_of_image=align_bitmap_image(W, H, unaligned_image_vector,aligned_image_vector);
121 write_bitmap_out(aligned_image_vector, fp, size_of_image, W, H);
122 /* write_bitmap_out closes the file pointer */
123 Zo=calculate_symmetrical_stripline_impedance(H-2*BORDER,w);
124 if(verbose >=1 && W >= RATIO*H + w )
125 printf("Zo is theoretically %f Ohms (assuming W is infinite)\n",Zo);
126 else if (verbose >=1 && W < RATIO*H + w){
127 exit_with_msg_and_exit_code("A theoretical value for Zo can't be computed as the width W is too small",1);
129 return(OKAY); /* This does not get executed, but keeps the compiler
130 happier, as otherwise it gives a warning about control reaching the
131 end of a non-void function */