/* @(#)ccopyf.c 17.1.1.1 (ESO-DMD) 01/25/02 17:40:31 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. Correspondence concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .COPYRIGHT: Copyright (c) 1994 European Southern Observatory, all rights reserved .IDENTIFIER module CCOPYF .LANGUAGE C .AUTHOR K. Banse IPG-ESO Garching .KEYWORDS .COMMENTS holds: Copywnd, Copyf, Copyf1, Copyf2, Copyi, Confil, Copyfx Fillima .ENVIRONment MIDAS #include Prototypes for MIDAS interfaces .VERSIONS 1.00 940411 from COPYF.FOR RvH 981013 ------------------------------------------------------------*/ /* Define _POSIX_SOURCE to indicate that this is a POSIX program */ #define _POSIX_SOURCE 1 #include #include /* */ /*++++++++++++++++++++++++++++++ .PURPOSE Copy parts of frame A to artifical 1dim frame B .INPUT/OUTPUT call as Fillima(flag,imno,npix,auxstr,insize,retimno) input: int flag 0 = create art. image 1 = fill image 2 = expand image 3 = get exact size of art. image int imno file id of input frame int *npix NPIX of input frame char *auxstr aux. string with subarea info in/output: int *insize IN: no. of pixels for art. image (flag = 0) OUT: current nopix of art. image (flag = 3) output: int *retimno file id of artificial 1dim image .RETURNS = 0, if o.k. < 0, if problems ------------------------------*/ int Fillima(flag,imno,npix,auxstr,insize,retimno) int flag, imno, *npix, *insize, *retimno; char *auxstr; { int first, stat, kk, iav, size, endx, endy, sublo[3], subhi[3]; register int nr, ny; static int felem, totsize; register float *apntr, *bpntr, *xpntr; char *impntr; static char *mypntr, namend; /* printf("Fillima: flag = %d, totsize = %d, felem = %d\n", flag,totsize,felem); */ if (flag == 0) /* create artificial image (allocate memory) */ { if (*insize < 1) return (-2); totsize = *insize; /* save nopix of 1-dim result image */ namend = 'y'; felem = 0; for (nr=0; nr<3; nr++) { sublo[nr] = subhi[nr] = 0; } stat = SCFCRE("middumm#y",D_R4_FORMAT,F_X_MODE,F_IMA_TYPE,totsize,retimno); if (stat == ERR_NORMAL) stat = SCFMAP(*retimno,F_X_MODE,1,totsize,&iav,&mypntr); if (stat != ERR_NORMAL) return (-1); } else if (flag == 1) /* fill artificial image */ { stat = Convcoo(1,imno,auxstr,3,&iav,sublo,subhi); if (stat != ERR_NORMAL) return (-3); endx = subhi[0] - sublo[0] + 1; endy = subhi[1] - sublo[1] + 1; size = endy * npix[0]; /* full strip */ first = (sublo[1] * npix[0]) + 1; /* 1st elem in input frame */ kk = (endx*endy); /* no. of pixels to copy */ if ((felem+kk) > totsize) return (-4); /* check for overflow */ /* get strip of input frame */ stat = SCFMAP(imno,F_I_MODE,first,size,&iav,&impntr); apntr = (float *) impntr; apntr += sublo[0]; bpntr = (float *) mypntr; bpntr += felem; for (ny=0; ny dimwB[xyz] ) dimwA[xyz] = dimwB[xyz]; } offsA = npixA[0] - dimwA[0]; offsB = npixB[0] - dimwA[0]; /* Move the pointers to start positions */ pntrA += bgnA[0] - 1 + npixA[0]*((bgnA[1] - 1) + npixA[1] * (bgnA[2] -1)); pntrB += bgnB[0] - 1 + npixB[0]*((bgnB[1] - 1) + npixB[1] * (bgnB[2] -1)); /* Copy frame A to frame B */ for (iz=0; iz 0) looplm ++; felem = 1; ksize = npix[0] * strip; for (nr=0; nr