bzr branch
http://darksoft.org/webbzr/tomo/pyhst
4
by csa
Initial import |
1 |
/* hst_calculate_limits.F -- translated by f2c (version 20000121).
|
2 |
You must link the resulting object file with the libraries:
|
|
3 |
-lf2c -lm (in that order)
|
|
4 |
*/
|
|
5 |
||
6 |
/*#include "f2c.h"
|
|
7 |
*/
|
|
8 |
#define integer int
|
|
9 |
#define real float
|
|
10 |
#define max(a,b) ((a)>(b))? (a):(b)
|
|
11 |
#define min(a,b) ((a)<(b))? (a):(b)
|
|
12 |
/* Subroutine */ int hst_calculate_limits__(num_bins__, start_x__, start_y__, |
|
13 |
num_x__, num_y__, axis_position__, y_start__, y_end__, x_starts__, |
|
14 |
x_ends__, status) |
|
15 |
integer *num_bins__, *start_x__, *start_y__, *num_x__, *num_y__; |
|
16 |
real *axis_position__; |
|
17 |
integer *y_start__, *y_end__, *x_starts__, *x_ends__, *status; |
|
18 |
{
|
|
19 |
/* System generated locals */
|
|
20 |
integer i__1, i__2, i__3; |
|
21 |
integer trim; |
|
22 |
/* Builtin functions */
|
|
23 |
double sqrt(); |
|
24 |
||
25 |
/* Local variables */
|
|
26 |
static real minx, maxx; |
|
27 |
static integer y; |
|
28 |
static real x_diff__, radiusleft, radiussmall, radiusright; |
|
29 |
||
30 |
/* Number of bins in each sinogram */
|
|
31 |
/* First X-pixel in region required by user */
|
|
32 |
/* First Y-pixel in region required by user */
|
|
33 |
/* Number of X-pixels in reconstruction region */
|
|
34 |
/* Number of Y-pixels in reconstruction region */
|
|
35 |
/* Position of rotation axis */
|
|
36 |
/* First Y-row in region to reconstruct */
|
|
37 |
/* Last Y-row in region to reconstruct */
|
|
38 |
/* First pixel to */
|
|
39 |
/* Last pixel to */
|
|
40 |
/* Loop variable for Y-direction */
|
|
41 |
/* X-difference for points on circle */
|
|
42 |
/* Parameter adjustments */
|
|
43 |
--x_ends__; |
|
44 |
--x_starts__; |
|
45 |
||
46 |
/* Function Body */
|
|
47 |
trim=1; |
|
48 |
radiusleft = *axis_position__; |
|
49 |
radiusright = (real) (*num_bins__) - *axis_position__; |
|
50 |
if (radiusleft < radiusright) { |
|
51 |
radiussmall = radiusleft; |
|
52 |
} else { |
|
53 |
radiussmall = radiusright; |
|
54 |
}
|
|
55 |
/* Calculate start and end pixels of projection */
|
|
56 |
*y_start__ = *axis_position__ - radiusright + 1; |
|
57 |
*y_end__ = *axis_position__ + radiusleft; |
|
58 |
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
|
|
59 |
/* we dont go outside users rectangle */
|
|
60 |
if (*y_start__ < *start_y__) { |
|
61 |
*y_start__ = *start_y__; |
|
62 |
}
|
|
63 |
if (*y_end__ > *start_y__ + *num_y__ -1) { |
|
64 |
*y_end__ = *start_y__ + *num_y__ -1; |
|
65 |
}
|
|
66 |
/* !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
|
|
67 |
maxx = *axis_position__ + radiussmall; |
|
68 |
if (maxx > (real) (*num_bins__)) { |
|
69 |
maxx = (real) (*num_bins__); |
|
70 |
}
|
|
71 |
minx = *axis_position__ - radiussmall + 1; |
|
72 |
if (minx < (float)1.) { |
|
73 |
minx = (float)1.; |
|
74 |
}
|
|
75 |
i__1 = *y_end__; |
|
76 |
for (y = *y_start__; y <= i__1; ++y) { |
|
77 |
if ((real) y < *axis_position__) { |
|
78 |
x_diff__ = sqrt(radiusright * radiusright - (y - *axis_position__) |
|
79 |
* (y - *axis_position__)); |
|
80 |
} else { |
|
81 |
x_diff__ = sqrt(radiusleft * radiusleft - (y - *axis_position__) * |
|
82 |
(y - *axis_position__)); |
|
83 |
}
|
|
84 |
if (x_diff__ > radiussmall) { |
|
85 |
x_diff__ = radiussmall; |
|
86 |
}
|
|
87 |
/* Computing MAX */
|
|
88 |
i__2 = 1, i__3 = (integer) (*axis_position__ - x_diff__) - *start_x__ |
|
89 |
+ 1; |
|
90 |
x_starts__[y - *start_y__ + 1] = max(i__2,i__3)+trim; |
|
91 |
/* Computing MIN */
|
|
92 |
i__2 = *num_x__, i__3 = (integer) (*axis_position__ + x_diff__) - * |
|
93 |
start_x__ + 1; |
|
94 |
x_ends__[y - *start_y__ + 1] = min(i__2,i__3) - trim; |
|
95 |
}
|
|
96 |
*y_start__ = *y_start__ - *start_y__ + 1; |
|
97 |
*y_end__ = *y_end__ - *start_y__ + 1; |
|
98 |
} /* hst_calculate_limits__ */ |
|
99 |