2 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
6 * A PICTURE RECONSTRUCTION PROGRAM *
8 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10 subreg.cpp,v 1.2 2008/08/25 16:11:09 jklukowska Exp
12 Subroutine to compute rough boundary (a bounding rectangle) of
13 the specified region to reduce the search area that requires
15 Specified region is either a rectangle or an ellipse.
16 The bounding rectangle is the SMALLEST rectangle, with the same
17 orientation as the picture, that bounds the nominal rectangle defined
18 to have the same origin, axes and orientation as the specified region
19 If this bounding rectangle (AN ESTIMATION) is partially outside the
20 picture area, a WARNING message is output and the bounding rectangle
21 is clipped to the picture boundary.
22 This bounding rectangle is then passed to the DIST routine where a
23 rigorous within boundary test reduced to this area is performed.
25 Parameters are passed through COMMON /region/
29 // parameter (MXNREG=40)
42 void Eval_class::subreg(INTEGER ObjJ)
74 static BOOLEAN flgout;
75 // static BOOLEAN objdon[MXNREG]; moved to eval.h - bug112 - swr - 6/10/05
85 Region.aplus = a + (REAL) 0.0001;
86 Region.bplus = b + (REAL) 0.0001;
87 theta = Obj[ObjJ].ang * (REAL) Consts.pi/180.0;
88 cs = (REAL) cos(theta);
89 ss = (REAL) sin(theta);
91 Region.d1 = GeoPar.pixsiz * cs;
92 Region.d2 = GeoPar.pixsiz * ss;
96 // Estimate boundary of region
98 tx1 = (REAL) fabs(a * cs + b * ss);
99 tx2 = (REAL) fabs(a * cs - b * ss);
100 ty1 = (REAL) fabs(a * ss - b * cs);
101 ty2 = (REAL) fabs(a * ss + b * cs);
104 ixw = lround(xw / GeoPar.pixsiz); // changed "(INTEGER)" to "lround" to match Fortran code. Lajos, Jan 20, 2005
105 iyw = lround(yw / GeoPar.pixsiz); // changed "(INTEGER)" to "lround" to match Fortran code. Lajos, Jan 20, 2005
106 ic = GeoPar.nelem / 2;
107 icx = ic + lround(cx / GeoPar.pixsiz); // changed "(INTEGER)" to "lround" to match Fortran code. Lajos, Jan 20, 2005
108 icy = ic - lround(cy / GeoPar.pixsiz); // changed "(INTEGER)" to "lround" to match Fortran code. Lajos, Jan 20, 2005
110 Region.ix1 = icx - ixw;
111 Region.ix2 = icx + ixw;
112 Region.iy1 = icy - iyw;
113 Region.iy2 = icy + iyw;
115 // Ensure estimated boundary is within picture region
117 idone = objdon[ObjJ];
121 if((!flgout) && (idone == 0)) {
122 fprintf(output, "\n WARNING: Region %2i might not be entirely within picture", ObjJ);
123 fprintf(output, "\n Rough estimate of object boundary:");
124 fprintf(output, "\n ix1 ix2 iy1 iy2");
125 fprintf(output, "\n %3i %3i %3i %3i", Region.ix1, Region.ix2, Region.iy1, Region.iy2);
132 if(Region.ix2 > GeoPar.nelem - 1) {
133 if((!flgout) && (idone == 0)) {
134 fprintf(output, "\n WARNING: Region %2i might not be entirely within picture", ObjJ);
135 fprintf(output, "\n Rough estimate of object boundary:");
136 fprintf(output, "\n ix1 ix2 iy1 iy2");
137 fprintf(output, "\n %3i %3i %3i %3i", Region.ix1, Region.ix2, Region.iy1, Region.iy2);
140 Region.ix2 = GeoPar.nelem - 1;
144 if((!flgout) && (idone == 0)) {
145 fprintf(output, "\n WARNING: Region %2i might not be entirely within picture", ObjJ);
146 fprintf(output, "\n Rough estimate of object boundary:");
147 fprintf(output, "\n ix1 ix2 iy1 iy2");
148 fprintf(output, "\n %3i %3i %3i %3i", Region.ix1, Region.ix2, Region.iy1, Region.iy2);
154 if(Region.iy2 > GeoPar.nelem - 1) {
155 if((!flgout) && (idone == 0)) {
156 fprintf(output, "\n WARNING: Region %2i might not be entirely within picture", ObjJ);
157 fprintf(output, "\n Rough estimate of object boundary:");
158 fprintf(output, "\n ix1 ix2 iy1 iy2");
159 fprintf(output, "\n %3i %3i %3i %3i", Region.ix1, Region.ix2, Region.iy1, Region.iy2);
162 Region.iy2 = GeoPar.nelem - 1;
167 x0 = (Region.ix1 - ic) * GeoPar.pixsiz;
168 y0 = (ic - Region.iy1) * GeoPar.pixsiz;
171 Region.xd0 = xs * cs + ys * ss;
172 Region.yd0 = -xs * ss + ys * cs;