IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25721


Ignore:
Timestamp:
Oct 1, 2009, 12:07:54 PM (17 years ago)
Author:
eugene
Message:

build the complete list of image edges before plotting (much faster)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/Ohana/src/opihi/dvo/imbox.c

    r21065 r25721  
    33int imbox (int argc, char **argv) {
    44 
    5   int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU;
     5  int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU, Npts, NPTS;
    66  Vector Xvec, Yvec;
    77  double r, d, x[4], y[4], Rmin, Rmax, Rmid;
     
    3636 
    3737  /* project this image to screen display coords */
    38   SetVector (&Xvec, OPIHI_FLT, 8);
    39   SetVector (&Yvec, OPIHI_FLT, 8);
     38  Npts = 0;
     39  NPTS = 200;
     40  SetVector (&Xvec, OPIHI_FLT, NPTS);
     41  SetVector (&Yvec, OPIHI_FLT, NPTS);
    4042
    4143  while (gfits_fread_header (f, &header)) {
     
    8284        while (r > Rmid) r-= 360.0;
    8385      }
    84       status |= RD_to_XY (&Xvec.elements.Flt[2*j], &Yvec.elements.Flt[2*j], r, d, &graphmode.coords);
     86      status |= RD_to_XY (&Xvec.elements.Flt[Npts + 2*j], &Yvec.elements.Flt[Npts + 2*j], r, d, &graphmode.coords);
    8587      if (j > 0) {
    86         Xvec.elements.Flt[2*j - 1] = Xvec.elements.Flt[2*j];
    87         Yvec.elements.Flt[2*j - 1] = Yvec.elements.Flt[2*j];
     88        Xvec.elements.Flt[Npts + 2*j - 1] = Xvec.elements.Flt[Npts + 2*j];
     89        Yvec.elements.Flt[Npts + 2*j - 1] = Yvec.elements.Flt[Npts + 2*j];
    8890      }
    8991    }
    90     Xvec.elements.Flt[7] = Xvec.elements.Flt[0];
    91     Yvec.elements.Flt[7] = Yvec.elements.Flt[0];
     92    Xvec.elements.Flt[Npts + 7] = Xvec.elements.Flt[Npts + 0];
     93    Yvec.elements.Flt[Npts + 7] = Yvec.elements.Flt[Npts + 0];
     94
    9295    InPic = FALSE;
    9396    for (j = 0; j < 8; j+=2) {
    94       if ((Xvec.elements.Flt[j] >= graphmode.xmin) &&
    95           (Xvec.elements.Flt[j] <= graphmode.xmax) &&
    96           (Yvec.elements.Flt[j] >= graphmode.ymin) &&
    97           (Yvec.elements.Flt[j] <= graphmode.ymax))
    98         InPic = TRUE;
     97      if ((Xvec.elements.Flt[Npts + j] >= graphmode.xmin) &&
     98          (Xvec.elements.Flt[Npts + j] <= graphmode.xmax) &&
     99          (Yvec.elements.Flt[Npts + j] >= graphmode.ymin) &&
     100          (Yvec.elements.Flt[Npts + j] <= graphmode.ymax))
     101        InPic = TRUE;
     102    }
     103    if (!InPic) continue;
     104
     105    Npts += 8;
     106    if (Npts + 8 >= NPTS) {  /* need to leave room for 4 point image */
     107      NPTS += 200;
     108      REALLOCATE (Xvec.elements.Flt, opihi_flt, NPTS);
     109      REALLOCATE (Yvec.elements.Flt, opihi_flt, NPTS);
    99110    }
    100111
    101     Xvec.Nelements = Yvec.Nelements = 8;
    102     if (InPic) {
    103       graphmode.style = 2; /* points */
    104       graphmode.ptype = 100; /* connect pairs of points */
    105       graphmode.etype = 0;
    106       PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
    107     }
    108112  skip:
    109113    Nskip = gfits_data_size (&header);
     
    111115    gfits_free_header (&header);
    112116  }
     117
     118  Xvec.Nelements = Yvec.Nelements = Npts;
     119  if (Npts > 0) {
     120    graphmode.style = 2; /* points */
     121    graphmode.ptype = 100; /* connect pairs of points */
     122    graphmode.etype = 0;
     123    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
     124  }
     125
    113126  fclose (f);
    114127  free (Xvec.elements.Flt);
Note: See TracChangeset for help on using the changeset viewer.