 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 long i(0), width(0), height(0), left(50), bottom(50), nmg(0), nmark(0);
27 double min_shift(1e10);
38 cout <<
"Generating file with marker errors" << endl << endl;
42 for ( mg=field->
mg; mg; mg=mg->
next ) {
46 if ( shift.
length() < min_shift ) {
47 min_shift = shift.
length();
51 error_show(
"Error in ps_marker_errors", __FILE__, __LINE__);
52 cerr <<
"Micrograph " << mg->
fmg <<
" not found" << endl;
55 if ( width < p->sizeX() ) width = p->
sizeX();
56 if ( height < p->sizeY() ) height = p->
sizeY();
63 cout <<
"DEBUG ps_marker_errors: width=" << width <<
" height=" << height << endl;
65 for ( nmark=0, mark=mg_ref->
mark; mark; mark=mark->
next, nmark++ ) ;
67 double scale(500.0/width);
68 if ( scale > 600.0/height ) scale = 600.0/height;
70 long plot_width(scale*width);
71 long plot_height(scale*height);
73 double mark_rad(2.5/scale);
74 double mark_diam(2*mark_rad);
75 double err_scale(5/scale);
77 *fps << setprecision(4) <<
"/Scale " << scale <<
" def" << endl;
78 *fps <<
"/Height " << plot_height <<
" def\n/Width " << plot_width <<
" def" << endl;
79 *fps <<
"/Frame { newpath 0 0 moveto Width 0 lineto Width Height lineto 0 Height lineto closepath } def" << endl;
83 *fps <<
"/Axis { newpath " << mark_rad/2 <<
" setlinewidth [10 10] 0 setdash "
87 << mg_ref->
origin[1]*(1 + sin(mg_ref->
tilt_axis)) <<
" lineto closepath} def" << endl;
89 *fps <<
"/Ori { newpath " << mg_ref->
origin[0] <<
" " << mg_ref->
origin[1] <<
" 10 0 360 arc fill closepath} def" << endl;
92 *fps <<
"%%Page: " << i+1 <<
" " << i+1 << endl;
93 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
94 *fps <<
"50 755 moveto (" << title <<
": " << field->
id <<
") show" << endl;
95 *fps <<
"50 735 moveto (Marker traces) show" << endl;
97 *fps <<
"/Pos [" << endl <<
"%mg";
98 for ( mark=mg_ref->
mark; mark; mark=mark->
next )
99 *fps <<
" " << mark->
id <<
"x " << mark->
id <<
"y";
101 for ( mg=field->
mg; mg; mg=mg->
next ) {
104 for ( mark=mg->
mark; mark; mark=mark->
next )
105 *fps <<
" " << mark->
loc[0] + shift[0] <<
" " << mark->
loc[1] + shift[1];
108 *fps <<
"] def" << endl;
110 *fps <<
"gsave" << endl;
111 *fps <<
" " << left <<
" " << bottom <<
" translate" << endl;
112 *fps <<
" Frame stroke" << endl;
113 *fps <<
" Scale Scale scale" << endl;
114 *fps <<
" /Helvetica findfont " << width/50 <<
" scalefont setfont" << endl;
115 *fps <<
" Ori stroke" << endl;
116 *fps <<
" Axis stroke" << endl;
117 *fps <<
" 1 setlinewidth [] 0 setdash" << endl;
118 *fps <<
" /nm 1 def" << endl;
119 *fps <<
" 1 1 " << nmark <<
" { " << endl;
120 *fps <<
" /Index exch def" << endl;
121 *fps <<
" /id Index def" << endl;
122 *fps <<
" /x Pos nm get def" << endl;
123 *fps <<
" /y Pos nm 1 add get def" << endl;
124 *fps <<
" x y moveto " << mark_diam <<
" " << mark_diam <<
" rmoveto id cvi (xxxx) cvs show stroke" << endl;
125 *fps <<
" x y " << mark_rad <<
" 0 360 arc closepath fill" << endl;
126 *fps <<
" x y moveto" << endl;
127 *fps <<
" " << 2*nmark+1 <<
" " << 2*nmark+1 <<
" Pos length " << 2*nmark+1 <<
" sub { " << endl;
128 *fps <<
" /Index2 exch def" << endl;
129 *fps <<
" /x Pos Index2 nm add get def" << endl;
130 *fps <<
" /y Pos Index2 nm add 1 add get def" << endl;
131 *fps <<
" x y lineto" << endl;
132 *fps <<
" } for stroke" << endl;
133 *fps <<
" x y " << mark_rad <<
" 0 360 arc closepath stroke" << endl;
134 *fps <<
" /nm nm 2 add def" << endl;
135 *fps <<
" } for" << endl;
136 *fps <<
"grestore" << endl;
138 *fps <<
"showpage" << endl;
142 *fps <<
"%%Page: " << i+1 <<
" " << i+1 << endl;
143 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
144 *fps <<
"50 755 moveto (" << title <<
": " << field->
id <<
") show" << endl;
145 *fps <<
"50 735 moveto (Marker errors (x" << err_scale <<
")) show" << endl;
147 *fps <<
"/Loc [\n%id x y" << endl;
148 for ( nmark=0, mark=mg_ref->
mark; mark; mark=mark->
next, nmark++ )
149 *fps << mark->
id <<
" " << mark->
loc[0] <<
" " << mark->
loc[1] << endl;
150 *fps <<
"] def" << endl;
152 *fps <<
"/Err [" << endl <<
"%mg";
153 for ( mark=mg_ref->
mark; mark; mark=mark->
next )
154 *fps <<
" " << mark->
id <<
"x " << mark->
id <<
"y";
156 for ( mg=field->
mg; mg; mg=mg->
next ) {
158 for ( mark=mg->
mark; mark; mark=mark->
next )
159 *fps <<
" " << mark->
err[0] <<
" " << mark->
err[1];
162 *fps <<
"] def" << endl;
164 *fps <<
"gsave" << endl;
165 *fps <<
" " << left <<
" " << bottom <<
" translate" << endl;
166 *fps <<
" Frame stroke" << endl;
167 *fps <<
" Scale Scale scale" << endl;
168 *fps <<
" /Helvetica findfont " << width/50 <<
" scalefont setfont" << endl;
169 *fps <<
" Ori stroke" << endl;
170 *fps <<
" Axis stroke" << endl;
171 *fps <<
" 1 setlinewidth [] 0 setdash" << endl;
172 *fps <<
" /nm -1 def" << endl;
173 *fps <<
" 0 3 Loc length 3 sub { " << endl;
174 *fps <<
" /Index exch def" << endl;
175 *fps <<
" /id Loc Index get def" << endl;
176 *fps <<
" /x Loc Index 1 add get def" << endl;
177 *fps <<
" /y Loc Index 2 add get def" << endl;
178 *fps <<
" /nm nm 2 add def" << endl;
179 *fps <<
" x y moveto " << mark_diam <<
" " << mark_diam <<
" rmoveto id cvi (xxxx) cvs show stroke" << endl;
180 *fps <<
" x y " << mark_rad <<
" 0 360 arc closepath fill" << endl;
181 *fps <<
" x y moveto" << endl;
182 *fps <<
" 0 " << 2*nmark+1 <<
" Err length " << 2*nmark+1 <<
" sub { " << endl;
183 *fps <<
" /Index2 exch def" << endl;
184 *fps <<
" /ex Err Index2 nm add get " << err_scale <<
" mul x add def" << endl;
185 *fps <<
" /ey Err Index2 nm add 1 add get " << err_scale <<
" mul y add def" << endl;
186 *fps <<
" ex ey lineto" << endl;
187 *fps <<
" } for stroke" << endl;
188 *fps <<
" } for" << endl;
189 *fps <<
"grestore" << endl;
191 *fps <<
"showpage" << endl;
196 *fps <<
"%%Page: " << i+1 <<
" " << i+1 << endl;
197 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
198 *fps <<
"50 755 moveto (" << title <<
": " << rec->
id <<
") show" << endl;
199 *fps <<
"50 735 moveto (Marker error sum vectors) show" << endl;
201 *fps <<
"/Vec [" << endl <<
"%id x y ex ey" << endl;
202 for ( mark=rec->
mark; mark; mark=mark->
next )
203 *fps << mark->
id <<
" " << mark->
loc[0] <<
" " <<
204 mark->
loc[1] <<
" " << mark->
err[0] <<
" " << mark->
err[1] << endl;
205 *fps <<
"] def" << endl;
207 *fps <<
"gsave" << endl;
208 *fps <<
" " << left <<
" " << bottom <<
" translate" << endl;
209 *fps <<
" Frame stroke" << endl;
210 *fps <<
" Scale Scale scale" << endl;
211 *fps <<
" /Helvetica findfont " << width/50 <<
" scalefont setfont" << endl;
212 *fps <<
" Ori stroke" << endl;
213 *fps <<
" Axis stroke" << endl;
214 *fps <<
" 1 setlinewidth [] 0 setdash" << endl;
215 *fps <<
" 0 5 Vec length 5 sub { " << endl;
216 *fps <<
" /Index exch def" << endl;
217 *fps <<
" /id Vec Index get def" << endl;
218 *fps <<
" /x Vec Index 1 add get def" << endl;
219 *fps <<
" /y Vec Index 2 add get def" << endl;
220 *fps <<
" /ex Vec Index 3 add get x add def" << endl;
221 *fps <<
" /ey Vec Index 4 add get y add def" << endl;
222 *fps <<
" /d ex x sub ey y sub add def" << endl;
223 *fps <<
" x y moveto " << mark_diam <<
" " << mark_diam <<
" rmoveto id cvi (xxxx) cvs show stroke" << endl;
224 *fps <<
" x y " << mark_rad <<
" 0 360 arc closepath fill" << endl;
225 *fps <<
" d 0 ne {" << endl;
226 *fps <<
" x y ex ey arrowline" << endl;
228 *fps <<
" } if" << endl;
229 *fps <<
" } for" << endl;
230 *fps <<
"grestore" << endl;
232 *fps <<
"showpage" << endl;
256 cout <<
"DEBUG ps_marker_errors: Creating " << filename << endl;
258 Bstring title(
"Matched deviations");
262 *fps <<
"/Helvetica-Bold findfont 18 scalefont setfont" << endl;
263 *fps <<
"40 770 moveto (" << filename <<
": " << title <<
") show" << endl;
275 if ( !set1 || !set2 ) {
276 cerr <<
"Error: The two sets must have the same number of points!" << endl;
281 double xdev(0), ydev(0);
288 for ( m1=set1, m2=set2; m1; m1=m1->
next, m2=m2->
next ) {
295 xdev += m2->
err[0]*m2->
err[0];
296 ydev += m2->
err[1]*m2->
err[1];
299 xdev = sqrt(xdev/num);
300 ydev = sqrt(ydev/num);
304 double scale = 650.0/h;
307 cout <<
"DEBUG ps_marker_errors: xdev " << xdev <<
" ydev " << ydev << endl;
309 *fps <<
"/Helvetica-Bold findfont 10 scalefont setfont" << endl;
310 *fps <<
"40 60 moveto (Shift: " << t.
trans[0] <<
" " << t.
trans[1] <<
") show" << endl;
311 *fps <<
"40 45 moveto (Scale: " << t.
scale[0] <<
" " << t.
scale[1] <<
") show" << endl;
312 *fps <<
"40 30 moveto (Angle: " << t.
angle*180.0/
M_PI <<
") show" << endl;
313 *fps <<
"40 15 moveto (Deviation: " << xdev <<
" " << ydev <<
" (scaled by " << err_scale <<
")) show" << endl;
314 *fps <<
"/x_Origin 100 def \n/y_Origin 100 def \n/Height " << h <<
" def \n/Width " << w <<
" def" << endl;
315 *fps <<
"/Scale " << scale <<
" def" << endl;
316 *fps <<
"/err_scale " << err_scale <<
" def" << endl;
317 *fps <<
"/Frame { newpath 0 0 moveto 0 Height lineto Width Height lineto Width 0 lineto closepath } def" << endl;
319 *fps <<
"/Data [" << endl;
320 for ( m2=set2; m2; m2=m2->
next )
321 *fps << m2->
loc[0] <<
" " << m2->
loc[1] <<
" " << m2->
err[0] <<
" " << m2->
err[1] << endl;
322 *fps <<
"] def\n" << endl;
324 *fps <<
"300 80 moveto (x axis) show" << endl;
325 *fps <<
"80 300 moveto gsave 90 rotate (y axis) show grestore" << endl;
326 *fps <<
"100 80 moveto 0 (xxxxx) cvs show\n 80 100 moveto 0 (xxxxx) cvs show" << endl;
327 *fps << w*scale+80 <<
" 80 moveto Width (xxxxx) cvs show" << endl;
328 *fps <<
"60 " << h*scale+100 <<
" moveto Height (xxxxx) cvs show" << endl;
329 *fps <<
"x_Origin y_Origin translate\nScale Scale scale" << endl;
330 *fps <<
"gsave \n\t5 setlinewidth \n\tFrame stroke \n\t1 setlinewidth" << endl;
331 *fps <<
"\t0 4 Data length 1 sub { \n\t\t/Index exch def" << endl;
332 *fps <<
"\t\tData Index get Data Index 1 add get err_scale 2 div 0 360 arc fill" << endl;
333 *fps <<
"\t\tData Index get Data Index 1 add get moveto" << endl;
334 *fps <<
"\t\tData Index 2 add get err_scale mul Data Index 3 add get err_scale mul rlineto stroke" << endl;
335 *fps <<
"\t} for \ngrestore" << endl;
337 *fps <<
"showpage" << endl;
353 if ( !set1 || !set2 ) {
354 cerr <<
"Error: The two sets must have the same number of points!" << endl;
365 for ( m1=set1, m2=set2; m1; m1=m1->
next, m2=m2->
next ) {
371 long w = (long) (max[0] - min[0]);
372 long h = (long) (max[1] - min[1]);
374 double scale = 540.0/w;
376 Bstring title(
"Matched Features");
379 *fps <<
"/Helvetica-Bold findfont 18 scalefont setfont" << endl;
380 *fps <<
"40 770 moveto \n(Matched Features) show" << endl;
381 *fps <<
"/x_Origin 50 def \n/y_Origin 50 def \n/Height " << h <<
" def \n/Width " << w <<
" def" << endl;
382 *fps <<
"/Frame { newpath 0 0 moveto 0 Height lineto Width Height lineto Width 0 lineto closepath } def" << endl;
383 *fps <<
"/Dot { newpath 0 0 moveto 0 0 5 0 360 arc fill closepath} def" << endl;
384 *fps <<
"/Ring { newpath 0 0 moveto 0 0 5 0 360 arc stroke closepath} def" << endl;
385 *fps <<
"/Scale " << scale <<
" def" << endl;
387 *fps <<
"/Data [" << endl;
388 for ( m1=set1, m2=set2; m1; m1=m1->
next, m2=m2->
next )
389 *fps << m1->
loc[0] <<
" " << m1->
loc[1] <<
" " << m2->
loc[0] <<
" " << m2->
loc[1] << endl;
390 *fps <<
"] def\n" << endl;
392 *fps <<
"300 20 moveto (x axis) show" << endl;
393 *fps <<
"30 350 moveto gsave 90 rotate (y axis) show grestore" << endl;
394 *fps <<
"50 20 moveto 0 (xxxx) cvs show\n 30 50 moveto 0 (xxxx) cvs show" << endl;
395 *fps << w*scale <<
" 20 moveto " << w <<
" (xxxx) cvs show" << endl;
396 *fps <<
"10 " << h*scale <<
" moveto " << h <<
" (xxxx) cvs show" << endl;
397 *fps <<
"x_Origin y_Origin translate\nScale Scale scale" << endl;
398 *fps <<
"gsave \n\t5 setlinewidth \n\tFrame stroke \n\t1 setlinewidth" << endl;
399 *fps <<
"\t0 4 Data length 1 sub { \n\t\t/Index exch def" << endl;
400 *fps <<
"\t\tData Index get Data Index 1 add get moveto" << endl;
401 *fps <<
"\t\tData Index 2 add get Data Index 3 add get lineto stroke" << endl;
402 *fps <<
"\t\tgsave \n\t\t\tData Index get Data Index 1 add get translate \n\t\t\tDot stroke" << endl;
403 *fps <<
"\t\tgrestore" << endl;
404 *fps <<
"\t\tgsave \n\t\t\tData Index 2 add get Data Index 3 add get translate \n\t\t\tRing stroke" << endl;
405 *fps <<
"\t\tgrestore \n\t} for \ngrestore" << endl;
407 *fps <<
"showpage" << endl;
433 Bstring x_label(
"X coordinate");
434 Bstring y_label(
"Y coordinate");
435 Bstring z_label(
"Z coordinate");
440 for ( npt=0, mark1 = rec1->
mark; mark1; mark1 = mark1->
next )
if ( mark1->
sel ) {
441 for ( mark2 = rec2->
mark; mark2 && mark2->
id != mark1->
id; mark2 = mark2->
next ) ;
442 if ( mark2 && mark2->
sel ) npt++;
446 cout <<
"Generating plot " << filename << endl << endl;
448 Bstring title(
"Comparing dual tilt marker positions");
452 for ( i=0, mark1 = rec1->
mark; mark1; mark1 = mark1->
next )
if ( mark1->
sel ) {
453 for ( mark2 = rec2->
mark; mark2 && mark2->
id != mark1->
id; mark2 = mark2->
next ) ;
454 if ( mark2 && mark2->
sel ) {
455 cmin = cmin.
min(mark1->
loc);
456 cmin = cmin.
min(mark2->
loc);
457 cmax = cmax.
max(mark1->
loc);
458 cmax = cmax.
max(mark2->
loc);
459 (*plot)[i] = mark1->
loc[0];
460 (*plot)[i+npt] = mark1->
loc[1];
461 (*plot)[i+2*npt] = mark1->
loc[2];
462 (*plot)[i+3*npt] = mark2->
loc[0];
463 (*plot)[i+4*npt] = mark2->
loc[1];
464 (*plot)[i+5*npt] = mark2->
loc[2];
469 for ( i=0; i<3; i++ ) {
Header file for postscript tools dealing with Bmarkers.
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
int ps_define_arrowline(ofstream *fps)
Generates an arrow and line.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Header file for postscript output functions.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
int ps_close(ofstream *fps)
Closes a postscript file.
ofstream * ps_open_and_init(Bstring filename, Bstring title, int npages, int width, int height)
Opens and initializes a postscript file.
int ps_dual_zcompare(Bstring &filename, Bproject *project)
Generates a PostScript file that displays X by X, Y by Y, and Z by Z plots for diagnostic purposes.
int ps_marker_errors(Bstring &filename, Bmarker *set1, Bmarker *set2, Transform t, Vector3< long > size, double err_scale)
Output a postscript file that graphs the deviations of points in a Bmarker from their predicted locat...
General image parameter class.
int ps_marker_plots(ofstream *fps, Bstring &title, Bproject *project)
Postscript plot of the errors associated with fiducial markers.
Header file for general utilities.
int ps_marker_match(Bmarker *set1, Bmarker *set2, Bstring &filename)
Output a postscript file that draws a line between matching features in a pair of coordinate sets.
Header file for generalized linked list functions.