apinit.c

00001 /*
00002 
00003 $Id: apinit.c,v 1.3 2007/03/01 12:38:26 jim Exp $
00004 
00005 */
00006 
00007 #include <stdlib.h>
00008 #include <cpl.h>
00009 #include "imcore.h"
00010 
00011 #define freespace(_p) if (_p != NULL) {cpl_free(_p); _p = NULL;}
00012 
00013 void apinit(ap_t *ap) {
00014     int maxpa;
00015 
00016     int i;
00017 
00018     maxpa = ap->lsiz / 2;               /* max possible parents */
00019     ap->lastline = cpl_calloc(ap->lsiz + 1, sizeof(short int));
00020     ap->maxip = 0;
00021     ap->maxpa = maxpa;
00022     ap->pstack = cpl_malloc(maxpa*sizeof(*ap->pstack));
00023     ap->parent = cpl_malloc(maxpa*sizeof(*(ap->parent)));
00024     for(i = 0; i < maxpa; i++) {
00025         ap->pstack[i] = i;
00026         ap->parent[i].pnop = -1;        /* mark all parents inactive */
00027         ap->parent[i].pnbp = -1;        /* mark all parents inactive */
00028     }
00029     ap->ipstack = 1;
00030     ap->maxbl = MAXBL;
00031     ap->bstack = cpl_malloc(ap->maxbl*sizeof(*ap->bstack));
00032     ap->blink = cpl_malloc(ap->maxbl*sizeof(*ap->blink));
00033     ap->plessey = cpl_malloc(ap->maxbl*sizeof(*ap->plessey));
00034     for (i = 0; i < MAXBL; i++)
00035         ap->bstack[i] = i;
00036     ap->ibstack = 2;    /* block 1 will get overwritten; don't use it */
00037     ap->nimages = 0;
00038 
00039     /* set up exponential areal-profile levels: */
00040 
00041     ap->areal[0] = 1;
00042     for (i = 1; i < 8; i++)
00043         ap->areal[i] = ap->areal[i-1]*2;
00044 
00045     /* allocate some space for a processing array */
00046 
00047     ap->npl = ap->lsiz;
00048     ap->npl_pix = 0;
00049     ap->plarray = cpl_malloc(ap->npl*sizeof(plstruct));
00050 
00051     /* set these to null values as you may not need the background structure */
00052 
00053     ap->backmap.nby = -1;
00054     ap->backmap.bvals = NULL;
00055 
00056     /* Initialise some info about the input images */
00057 
00058     ap->indata = NULL;
00059     ap->confdata = NULL;
00060 }
00061 
00062 void apreinit(ap_t *ap) {
00063     int i;
00064 
00065     for (i = 0; i < ap->lsiz+1; i++)
00066         ap->lastline[i] = 0;
00067     ap->maxip = 0;
00068     for(i = 0; i < ap->maxpa; i++) {
00069         ap->pstack[i] = i;
00070         ap->parent[i].pnop = -1;        /* mark all parents inactive */
00071         ap->parent[i].pnbp = -1;        /* mark all parents inactive */
00072     }
00073     ap->ipstack = 1;
00074     ap->ibstack = 2;    /* block 1 will get overwritten; don't use it */
00075     ap->nimages = 0;
00076     ap->npl_pix = 0;
00077 
00078 }
00079 
00080 void apclose(ap_t *ap) {
00081     int i;
00082     freespace(ap->lastline);
00083     freespace(ap->pstack);
00084     freespace(ap->parent);
00085     freespace(ap->bstack);
00086     freespace(ap->blink);
00087     freespace(ap->plessey);
00088     freespace(ap->plarray);
00089     for (i = 0; i < ap->backmap.nby; i++)
00090         freespace(ap->backmap.bvals[i]);
00091     freespace(ap->backmap.bvals);
00092 }
00093 
00094 /*
00095 
00096 $Log: apinit.c,v $
00097 Revision 1.3  2007/03/01 12:38:26  jim
00098 Small modifications after a bit of code checking
00099 
00100 Revision 1.2  2005/09/20 15:07:46  jim
00101 Fixed a few bugs and added a few things
00102 
00103 Revision 1.1  2005/09/13 13:25:27  jim
00104 Initial entry after modifications to make cpl compliant
00105 
00106 
00107 */

Generated on Sat Apr 6 04:03:06 2013 for VIRCAM Pipeline by  doxygen 1.5.1