37 cout <<
"Writing postscript file: " << filename << endl << endl;
41 *fps <<
"/Helvetica-Bold findfont 20 scalefont setfont" << endl;
42 *fps <<
"40 740 moveto (" << filename <<
") show" << endl;
44 ps_views(fps, symmetry_string, view, flags);
54 cout <<
"DEBUG ps_views: symmetry=" << symmetry_string <<
" flags=" << flags << endl;
56 int i, m, left(50), bottom(150), width(500), height(500), order(1);
60 int ix, iy, nx(2*h+1), ny(2*h+1), sx(h), sy(h);
61 double isx(1.0L/sx), isy(1.0L/sy);
66 double textscale(0.06), textoffset(0.02);
67 if ( n > 50 ) textscale = 3.0/n;
68 if ( textscale < 5 ) textscale = 5;
69 textoffset = textscale/3;
72 count =
new float[nx*ny];
73 for ( i=0; i<nx*ny; i++ ) count[i] = 0;
74 for ( v = view, n=m=0; v; v = v->
next ) {
75 ix = (int) (v->
x()*sx + sx);
76 iy = (int) (v->
y()*sy + sy);
79 if ( m < count[i] ) m = (int) count[i];
82 snr = 1/sqrt((
double)m);
83 if ( snr < 0.1 ) snr = 0.1;
86 *fps <<
"%%%%Page: Views 1" << endl;
87 *fps <<
"/Helvetica-Bold findfont 14 scalefont setfont" << endl;
88 *fps <<
"40 720 moveto (Symmetry: " << symmetry_string <<
") show" << endl;
89 *fps <<
"40 700 moveto (Number of views: " << n <<
") show" << endl;
90 *fps <<
"/Left " << left <<
" def\n/Bottom " << bottom <<
" def\n/Height " << height <<
" def\n/Width " << width <<
" def" << endl;
91 *fps <<
"/Scale 200 def" << endl;
93 *fps <<
"/View [" << endl;
95 *fps <<
"%x y count weight" << endl;
96 for ( i=iy=0; iy<ny; iy++ )
97 for ( ix=0; ix<nx; ix++, i++ )
98 if ( count[i] ) *fps << ix*isx - 1 <<
" " << iy*isy - 1 <<
" " << count[i] <<
" " << 1/(1+1/(snr*sqrt(count[i]))) << endl;
101 *fps <<
"%x y z a" << endl;
102 for ( v = view; v; v = v->
next )
103 *fps << v->
x() <<
" " << v->
y() <<
" " << v->
z() <<
" " << v->
angle() << endl;
105 *fps <<
"] def" << endl;
107 *fps <<
"/Geom { newpath " << endl;
108 *fps <<
" 1 0 moveto 0 0 1 0 360 arc stroke" << endl;
109 if ( symmetry_string[0] ==
'T' ) {
110 *fps <<
" 0 0 moveto 1 0 lineto" << endl;
111 *fps <<
" -0.577 0.577 moveto 0.577 -0.577 lineto stroke" << endl;
112 *fps <<
" -0.577 -0.577 moveto 0.577 0.577 lineto stroke" << endl;
113 *fps <<
" 0 1 moveto 0 0.39 0.61 90 162 arc stroke" << endl;
114 *fps <<
" -0.577 0.577 moveto -0.39 0 0.61 108 180 arc stroke" << endl;
115 *fps <<
" 1 0 moveto 0.39 0 0.61 0 72 arc stroke" << endl;
116 *fps <<
" 0.577 0.577 moveto 0 0.39 0.61 18 90 arc stroke" << endl;
117 *fps <<
" 0 -1 moveto 0 -0.39 0.61 -90 -18 arc stroke" << endl;
118 *fps <<
" 0.577 -0.577 moveto 0.39 0 0.61 -72 0 arc stroke" << endl;
119 *fps <<
" -1 0 moveto -0.39 0 0.61 180 252 arc stroke" << endl;
120 *fps <<
" -0.577 -0.577 moveto 0 -0.39 0.61 198 270 arc stroke" << endl;
121 }
else if ( symmetry_string[0] ==
'O' ) {
122 *fps <<
" -1 0 moveto 1 0 lineto" << endl;
123 *fps <<
" 0 -1 moveto 0 1 lineto" << endl;
124 *fps <<
" 0 0 moveto 0.707 0.707 lineto stroke" << endl;
125 *fps <<
" 0 0 moveto 0.707 -0.707 lineto stroke" << endl;
126 *fps <<
" -0.577 0.577 moveto -0.707 0.707 lineto stroke" << endl;
127 *fps <<
" -0.577 -0.577 moveto -0.707 -0.707 lineto stroke" << endl;
128 *fps <<
" 0.577 -0.577 moveto -0.637 0 1.344 -25.4 25.4 arc stroke" << endl;
129 *fps <<
" 0.577 0.577 moveto 0 -0.637 1.344 64.6 115.4 arc stroke" << endl;
130 *fps <<
" -0.577 0.577 moveto 0.637 0 1.344 154.6 205.4 arc stroke" << endl;
131 *fps <<
" -0.577 -0.577 moveto 0 0.637 1.344 -115.4 -64.6 arc stroke" << endl;
132 }
else if ( symmetry_string[0] ==
'I' ) {
133 if ( symmetry_string.
contains(
"I90") ) {
134 *fps <<
"-0.526 0 moveto 0.526 0 lineto" << endl;
135 *fps <<
"0 -0.357 lineto -0.526 0 lineto 0 0.357 lineto 0.526 0 lineto" << endl;
136 *fps <<
"0 0.357 moveto 0 -0.357 lineto" << endl;
137 *fps <<
"-0.851 -0.526 moveto" << endl;
138 *fps <<
"-0.526 0 lineto" << endl;
139 *fps <<
"0 -0.851 lineto" << endl;
140 *fps <<
"-0.851 -0.526 lineto" << endl;
141 *fps <<
"-0.851 0.526 lineto" << endl;
142 *fps <<
"0 0.851 lineto" << endl;
143 *fps <<
"-0.526 0 lineto" << endl;
144 *fps <<
"-0.851 0.526 lineto" << endl;
145 *fps <<
"0.851 -0.526 moveto" << endl;
146 *fps <<
"0.526 0 lineto" << endl;
147 *fps <<
"0 -0.851 lineto" << endl;
148 *fps <<
"0.851 -0.526 lineto" << endl;
149 *fps <<
"0.851 0.526 lineto" << endl;
150 *fps <<
"0 0.851 lineto" << endl;
151 *fps <<
"0.526 0 lineto" << endl;
152 *fps <<
"0.851 0.526 lineto" << endl;
154 *fps <<
"0 0 moveto 0.357 0 lineto" << endl;
155 *fps <<
"0 0.526 lineto 0 -0.526 lineto 0.357 0 lineto" << endl;
156 *fps <<
"-0.526 -0.851 moveto" << endl;
157 *fps <<
"0 -0.526 lineto" << endl;
158 *fps <<
"-0.851 0 lineto" << endl;
159 *fps <<
"-0.526 -0.851 lineto" << endl;
160 *fps <<
"0.526 -0.851 lineto" << endl;
161 *fps <<
"0.851 0 lineto" << endl;
162 *fps <<
"0 -0.526 lineto" << endl;
163 *fps <<
"0.526 -0.851 lineto" << endl;
164 *fps <<
"-0.526 0.851 moveto" << endl;
165 *fps <<
"0 0.526 lineto" << endl;
166 *fps <<
"-0.851 0 lineto" << endl;
167 *fps <<
"-0.526 0.851 lineto" << endl;
168 *fps <<
"0.526 0.851 lineto" << endl;
169 *fps <<
"0.851 0 lineto" << endl;
170 *fps <<
"0 0.526 lineto" << endl;
171 *fps <<
"0.526 0.851 lineto" << endl;
174 sscanf(&symmetry_string[1],
"%d", &order);
175 *fps <<
" 0 0 moveto 1 0 lineto" << endl;
176 for ( i=0; i<order; i++ )
177 *fps <<
" 0 0 moveto " << cos((i+0.5)*
M_PI*2.0/order) <<
" "
178 << sin((i+0.5)*
M_PI*2.0/order) <<
" lineto stroke" << endl;
180 *fps <<
" closepath } def" << endl;
182 *fps <<
"gsave" << endl;
183 *fps <<
" Width 2 div Left add Height 2 div Bottom add translate" << endl;
184 *fps <<
" Scale Scale scale" << endl;
185 *fps <<
" 0.005 setlinewidth Geom stroke" << endl;
186 *fps <<
" /Helvetica findfont " << textscale <<
" scalefont setfont" << endl;
188 *fps <<
" 0 0.1 1 {" << endl;
189 *fps <<
" /f exch def" << endl;
190 *fps <<
" 0 4 View length 4 sub {" << endl;
191 *fps <<
" /Index exch def" << endl;
192 *fps <<
" /x View Index get def" << endl;
193 *fps <<
" /y View Index 1 add get def" << endl;
194 *fps <<
" /v View Index 3 add get def" << endl;
195 *fps <<
" v f ge {" << endl;
196 *fps <<
" 1 v sub setgray" << endl;
197 *fps <<
" x y 0.01 0 360 arc fill" << endl;
198 *fps <<
" } if" << endl;
199 *fps <<
" } for stroke" << endl;
200 *fps <<
" } for" << endl;
202 *fps <<
" /n 0 def" << endl;
203 *fps <<
" 0 4 View length 4 sub {" << endl;
204 *fps <<
" /Index exch def" << endl;
205 *fps <<
" /x View Index get def" << endl;
206 *fps <<
" /y View Index 1 add get def" << endl;
207 *fps <<
" /z View Index 2 add get def" << endl;
208 *fps <<
" z 0 lt { x y 0.02 0 360 arc stroke }" << endl;
209 *fps <<
" { x y 0.01 0 360 arc fill } ifelse" << endl;
211 *fps <<
" /n n 1 add def" << endl;
212 *fps <<
" x y moveto " << textoffset <<
" " << textoffset <<
213 " rmoveto n cvi (xxxx) cvs show stroke" << endl;
215 *fps <<
" } for stroke" << endl;
217 *fps <<
"grestore" << endl;
218 *fps <<
"showpage" << endl;
238 int i(1), left(50), bottom(200), width(500), height(250);
243 if ( !view )
return -1;
248 *fps <<
"%%Page: " << i <<
" " << i << endl;
249 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
250 *fps <<
"50 755 moveto (Views: " << filename <<
") show" << endl;
251 *fps <<
"/Data [" << endl <<
"%x y" << endl;
252 for ( v = view; v; v = v->
next ) {
256 *fps << x <<
" " << y << endl;
258 *fps <<
"] def" << endl;
262 *fps <<
"showpage" << endl;
281 int i, j, k, left(50), bottom(200), width(500), height(250);
289 for ( i=1, k=0; i<=ns; i++ ) {
290 *fps <<
"%%Page: " << i <<
" " << i << endl;
291 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
292 *fps <<
"50 755 moveto (" << title <<
": " << i <<
") show" << endl;
293 *fps <<
"/Data [" << endl <<
"%x y fom" << endl;
294 for ( j=0, v=views, fmax=0; j<nv && v; j++, k++, v = v->
next ) {
298 *fps << x <<
" " << y <<
" " << fom[k] << endl;
300 if ( fmax < fom[k] ) {
306 *fps <<
"] def" << endl;
307 *fps <<
"/Best [" << vx <<
" " << vy <<
"] def" << endl;
309 *fps <<
"showpage" << endl;
336 double x, y, scale(width*1.0/
TWOPI);
339 *fps <<
"/Scale " << scale <<
" def" << endl;
340 *fps <<
"/Height " << height <<
" def" << endl <<
"/Width " << width <<
" def" << endl;
341 *fps <<
"/Frame { newpath 0 0 moveto Width 0 lineto Width Height lineto 0 Height lineto closepath } def" << endl;
343 *fps << left+width/2-10 <<
" " << bottom-30 <<
" moveto (Phi) show" << endl;
344 *fps << left-30 <<
" " << bottom+height/2-20 <<
" moveto gsave 90 rotate (Theta) show grestore" << endl;
346 *fps <<
"gsave" << endl;
347 *fps <<
" " << left <<
" " << bottom <<
" translate" << endl;
348 *fps <<
" Frame stroke" << endl;
350 *fps <<
" Scale Scale scale" << endl;
351 *fps <<
" " << 1/scale <<
" setlinewidth" << endl;
352 *fps <<
" 0.5 setgray" << endl;
353 *fps <<
" 0 " <<
M_PI_2 <<
" moveto " <<
TWOPI <<
" " <<
M_PI_2 <<
" lineto" << endl;
355 *fps <<
" " <<
M_PI <<
" 0 moveto" << endl;
356 for ( theta = 0; theta <
M_PI+0.01; theta +=
M_PI/90.0 ) {
357 x = phi * fabs(sin(theta)) +
M_PI;
359 *fps <<
" " << x <<
" " << y <<
" lineto" << endl;
362 *fps <<
" stroke" << endl;
363 *fps <<
" /Helvetica findfont 64 scalefont setfont" << endl;
364 *fps <<
" 0 setgray" << endl;
365 *fps <<
" 0 " << ncol <<
" Data length " << ncol <<
" sub { " << endl;
366 *fps <<
" /Index exch def" << endl;
367 *fps <<
" /x Data Index get def" << endl;
368 *fps <<
" /y Data Index 1 add get def" << endl;
369 *fps <<
" /f Data Index 2 add get def" << endl;
370 *fps <<
" 1 f sub setgray" << endl;
371 *fps <<
" x y 0.03 0 360 arc fill" << endl;
372 *fps <<
" } for" << endl;
373 *fps <<
" 0 setgray" << endl;
374 *fps <<
" //userdict /Best known {" << endl;
375 *fps <<
" /x Best 0 get def" << endl;
376 *fps <<
" /y Best 1 get def" << endl;
377 *fps <<
" x y 0.05 0 360 arc stroke" << endl;
378 *fps <<
" } if" << endl;
379 *fps <<
"grestore" << endl;
381 ps_scale(fps, left, bottom, left+width, bottom, -180, 180, 60, 10,
M_PI_2, 0, 12, 0);
383 ps_scale(fps, left, bottom, left, bottom+height, 0, 180, 30, 10, 0, 0, 12, 0);