IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5734


Ignore:
Timestamp:
Dec 7, 2005, 10:55:18 AM (20 years ago)
Author:
magnier
Message:

re-introduced psRegionForImage fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel9_b0/psLib/src/mathtypes/psImage.c

    r5686 r5734  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-12-05 22:14:27 $
     11 *  @version $Revision: 1.92.4.1 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-12-07 20:55:18 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    163163
    164164// set actual region based on image parameters:
    165 // compensate for negative upper limits
    166 // XXX this is inconsistent: the coordindates should always be in the parent
    167 //     frame, which means the negative values should subtract from Nx,Ny of
    168 //     the parent, not the child.  but, we don't carry the dimensions of the
    169 //     parent in the psImage container.  for now, us the child Nx,Ny
    170 // force range to be on this subimage
    171 // XXX EAM : this needs to be changes to use psRegion rather than psRegion*
     165// - compensate for negative upper limits
     166// - force range to be on this image
     167// - saturate on upper and lower limits of image
     168// - flip x0,x1 if x0>x1
     169// - flip y0,y1 if y0>y1
     170// psRegion in refers to coordinates in the
    172171psRegion psRegionForImage(psImage *image,
    173172                          psRegion in)
    174173{
    175174
    176     // x0,y0, x1,y1 are in *parent* units
    177     //    PS_ASSERT_PTR_NON_NULL(in, NULL);
    178     /*
    179         if( in == NULL ) {
    180             psError(PS_ERR_BAD_PARAMETER_NULL, true, "Unallowable operation.  psRegion in is NULL.");
    181             return in;
    182         }
    183     */    /*    if (out == NULL) {
    184         //    out = psRegionAlloc(in->x0, in->x1, in->y0, in->y1);
    185             *out = psRegionSet(in->x0, in->x1, in->y0, in->y1);
    186             } else {
    187             *out = *in;
    188             }
    189         */    // XXX these are probably wrong (see above)
    190     if (in.x1 <= 0) {
    191         in.x1 = image->col0 + image->numCols + in.x1;
    192     }
    193     if (in.y1 <= 0) {
    194         in.y1 = image->row0 + image->numRows + in.y1;
    195     }
    196 
    197     // force the lower-limits to be on the child
    198     in.x0 = PS_MAX(image->col0, in.x0);
    199     in.y0 = PS_MAX(image->row0, in.y0);
    200 
    201     // force the upper-limits to be on the child
    202     in.x1 = PS_MIN(image->col0 + image->numCols, in.x1);
    203     in.y1 = PS_MIN(image->row0 + image->numRows, in.y1);
     175    if (image == NULL) {
     176        return in;
     177    }
     178
     179    // convert non-positive upper-limits
     180    in.x1 = (in.x1 <= 0) ? (image->numCols + in.x1) : in.x1;
     181    in.y1 = (in.y1 <= 0) ? (image->numRows + in.y1) : in.y1;
     182
     183    // force the upper-limits to be on the image
     184    in.x1 = PS_MIN(image->numCols, in.x1);
     185    in.y1 = PS_MIN(image->numRows, in.y1);
     186
     187    // force the lower-limits to be on the image
     188    in.x0 = PS_MAX(0, in.x0);
     189    in.y0 = PS_MAX(0, in.y0);
     190    in.x0 = PS_MIN(image->numCols, in.x0);
     191    in.y0 = PS_MIN(image->numRows, in.y0);
     192
     193    // flip start and end if out of order
     194    if (in.x0 > in.x1) {
     195        PS_SWAP (in.x0, in.x1);
     196    }
     197    if (in.y0 > in.y1) {
     198        PS_SWAP (in.y0, in.y1);
     199    }
     200
    204201    return (in);
    205202}
Note: See TracChangeset for help on using the changeset viewer.