IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6728


Ignore:
Timestamp:
Mar 29, 2006, 2:31:04 PM (20 years ago)
Author:
Paul Price
Message:

Adding psMetadataItemCopy; moving psRegion into its own file, adding psRegionAlloc and other support so we can put it on the metadata

Location:
branches/rel10_ifa/psLib/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psLib/src/astro/psCoord.h

    r6230 r6728  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-01-28 01:31:44 $
     13 *  @version $Revision: 1.50.4.1 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-03-30 00:31:04 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psPolynomial.h"
    2727#include "psPixels.h"
     28#include "psRegion.h"
    2829//#include "psTime.h"
    2930
  • branches/rel10_ifa/psLib/src/fits/psFitsHeader.c

    r6719 r6728  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2.4.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-03-28 23:17:18 $
     9 *  @version $Revision: 1.2.4.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-03-30 00:31:04 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    118118                    }
    119119                    // Remove trailing spaces, which are not significant, according to the FITS standard
    120                     // http://archive.stsci.edu/fits/fits_standard/node31.html#SECTION00921000000000000000
     120                    // http://archive.stsci.edu/fits/fits_standard/node31.html
    121121                    char *lastSpace = NULL; // The last space in the string
    122                     while ((lastSpace = strrchr(keyValueFixed, ' ')) && lastSpace[1] == '\0') {
     122                    while (strlen(keyValueFixed) > 1 && (lastSpace = strrchr(keyValueFixed, ' ')) &&
     123                            lastSpace[1] == '\0') {
    123124                        // This is a trailing space, not a leading space.
    124125                        lastSpace[0] = '\0'; // Truncate the string here
  • branches/rel10_ifa/psLib/src/imageops/psImageStats.c

    r6430 r6728  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.90.4.1 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-02-16 07:50:03 $
     11 *  @version $Revision: 1.90.4.2 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-03-30 00:31:04 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psPolynomial.h"
    3030#include "psImageStats.h"
     31#include "psRegion.h"
     32#include "psRegionForImage.h"
    3133#include "psConstants.h"
    3234#include "psErrorText.h"
  • branches/rel10_ifa/psLib/src/imageops/psImageStats.h

    r5137 r6728  
    99*  @author GLG, MHPCC
    1010*
    11 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-09-26 22:35:53 $
     11*  @version $Revision: 1.27.20.1 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2006-03-30 00:31:04 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psVector.h"
    2121#include "psImage.h"
     22#include "psRegion.h"
    2223#include "psStats.h"
    2324#include "psPolynomial.h"
  • branches/rel10_ifa/psLib/src/imageops/psImageStructManip.h

    r4162 r6728  
    88*  @author Robert DeSonia, MHPCC
    99*
    10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-06-08 23:40:45 $
     10*  @version $Revision: 1.3.24.1 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-03-30 00:31:04 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818
    1919#include "psImage.h"
     20#include "psRegion.h"
    2021
    2122/// @addtogroup Image
  • branches/rel10_ifa/psLib/src/math/Makefile.am

    r6305 r6728  
    1313        psMinimizePolyFit.c \
    1414        psRandom.c \
     15        psRegion.c \
     16        psRegionForImage.c \
    1517        psPolynomial.c \
    1618        psSpline.c \
     
    3133        psMinimizePolyFit.h \
    3234        psRandom.h \
     35        psRegion.h \
     36        psRegionForImage.h \
    3337        psPolynomial.h \
    3438        psSpline.h \
  • branches/rel10_ifa/psLib/src/mathtypes/psImage.c

    r6477 r6728  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.95.4.2 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-02-24 03:59:10 $
     11 *  @version $Revision: 1.95.4.3 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-03-30 00:31:04 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    103103}
    104104
    105 
    106 psRegion psRegionSet(float x0,
    107                      float x1,
    108                      float y0,
    109                      float y1)
    110 {
    111     psRegion out;
    112 
    113     out.x0 = x0;
    114     out.y0 = y0;
    115     out.x1 = x1;
    116     out.y1 = y1;
    117 
    118     return out;
    119 }
    120 
    121 psRegion psRegionFromString(const char* region)
    122 {
    123     psS32 col0;
    124     psS32 col1;
    125     psS32 row0;
    126     psS32 row1;
    127 
    128     // section should be of the form '[col0:col1,row0:row1]'
    129     if (region == NULL) {
    130         return psRegionSet(0,0,0,0);
    131     }
    132 
    133     if (sscanf(region,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
    134         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    135                 PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
    136                 region);
    137         return psRegionSet(NAN,NAN,NAN,NAN);
    138     }
    139 
    140     if (col0 > col1 || row0 > row1) {
    141         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    142                 PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
    143                 col0,col1,row0,row1);
    144         return psRegionSet(NAN,NAN,NAN,NAN);
    145     }
    146 
    147     return psRegionSet(col0-1,col1,row0-1,row1);
    148 }
    149 
    150 psString psRegionToString(const psRegion region)
    151 {
    152     char tmpText[256]; // big enough to store any region as text
    153 
    154     snprintf(tmpText,256,"[%g:%g,%g:%g]",
    155              region.x0+1, region.x1,
    156              region.y0+1, region.y1);
    157 
    158     return psStringCopy(tmpText);
    159 }
    160 
    161 
    162 // set actual region based on image parameters:
    163 // - compensate for negative upper limits
    164 // - force range to be on this image
    165 // - saturate on upper and lower limits of image
    166 // - flip x0,x1 if x0>x1
    167 // - flip y0,y1 if y0>y1
    168 // psRegion in refers to coordinates in the
    169 psRegion psRegionForImage(psImage *image,
    170                           psRegion in)
    171 {
    172 
    173     if (image == NULL) {
    174         return in;
    175     }
    176 
    177     // convert non-positive upper-limits
    178     // XXX note that the upper limit in these cases is defined relative to the subimage
    179     // also note that truncation limits to the valid subimage pixels
    180     in.x1 = (in.x1 <= 0) ? (image->col0 + image->numCols + in.x1) : in.x1;
    181     in.y1 = (in.y1 <= 0) ? (image->row0 + image->numRows + in.y1) : in.y1;
    182 
    183     // force the upper-limits to be on the image
    184     in.x1 = PS_MIN(image->col0 + image->numCols, in.x1);
    185     in.y1 = PS_MIN(image->row0 + image->numRows, in.y1);
    186 
    187     // force the lower-limits to be on the image
    188     in.x0 = PS_MAX(image->col0, in.x0);
    189     in.y0 = PS_MAX(image->row0, in.y0);
    190     in.x0 = PS_MIN(image->col0 + image->numCols, in.x0);
    191     in.y0 = PS_MIN(image->row0 + 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 
    201     return (in);
    202 }
    203 
    204 // define a square region centered on the given coordinate
    205 psRegion psRegionForSquare(double x,
    206                            double y,
    207                            double radius)
    208 {
    209     psRegion region;
    210     region = psRegionSet (x - radius, x + radius + 1,
    211                           y - radius, y + radius + 1);
    212     return (region);
    213 }
    214105
    215106bool psImageInit (psImage *image,...)
  • branches/rel10_ifa/psLib/src/mathtypes/psImage.h

    r6227 r6728  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-01-28 01:12:14 $
     13 *  @version $Revision: 1.74.4.1 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-03-30 00:31:04 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484                #define P_PSIMAGE_SET_TYPE(img,t) *(psMathType*)&img->type = t
    8585
    86                         /** Basic image region structure.
     86
     87                        /** Create an image of the specified size and type.
    8788                         *
    88                          * Struct for specifying a rectangular area in an image.
     89                         * Uses psLib memory allocation functions to create an image struct of the
     90                         * specified size and type.
     91                         *
     92                         * @return psImage* : Pointer to psImage.
    8993                         *
    9094                         */
    91                         typedef struct
    92                         {
    93                             float x0;                         ///< the first column of the region.
    94                             float x1;                         ///< the last column of the region.
    95                             float y0;                         ///< the first row of the region.
    96                             float y1;                         ///< the last row of the region.
    97                         }
    98                         psRegion;
    99 
    100 /** Create an image of the specified size and type.
    101  *
    102  * Uses psLib memory allocation functions to create an image struct of the
    103  * specified size and type.
    104  *
    105  * @return psImage* : Pointer to psImage.
    106  *
    107  */
    108 psImage* psImageAlloc(
    109     int numCols,                       ///< Number of rows in image.
    110     int numRows,                       ///< Number of columns in image.
    111     psElemType type                    ///< Type of data for image.
    112 )
    113 ;
     95                        psImage* psImageAlloc(
     96                            int numCols,                       ///< Number of rows in image.
     97                            int numRows,                       ///< Number of columns in image.
     98                            psElemType type                    ///< Type of data for image.
     99                        )
     100                        ;
    114101
    115102/** Checks the type of a particular pointer.
     
    123110);
    124111
    125 
    126 /** Create a psRegion with the specified attributes.
    127  *
    128  *  @return psRegion : a cooresponding psRegion.
    129  */
    130 psRegion psRegionSet(
    131     float x0,                          ///< the first column of the region.
    132     float x1,                          ///< the last column of the region + 1.
    133     float y0,                          ///< the first row of the region.
    134     float y1                           ///< the last row of the region + 1.
    135 );
    136 
    137 /** Create a psRegion with the attribute values given as a string.
    138  *
    139  *  Create a psRegion with the attribute values given as a string.  The format
    140  *  shall be of the standard IRAF form '[x0:x1,y0:y1]'
    141  *
    142  *  @return psRegion:  A new psRegion struct, or NULL is not successful.
    143  */
    144 psRegion psRegionFromString(
    145     const char* region                 ///< image rectangular region in the form '[x0:x1,y0:y1]'
    146 );
    147 
    148 /** Create a string of the standard IRAF form '[x0:x1,y0:y1]' from a psRegion.
    149  *
    150  *  @return psString:  A new string representing the psRegion as text, or NULL
    151  *                  is not successful.
    152  */
    153 psString psRegionToString(
    154     const psRegion region              ///< the psRegion to convert to a string
    155 );
    156 
    157 /** Sets an actual region based on image parameters.
    158  *
    159  *  An image region defined with negative upper limits may be rationalized for the bounds of a
    160  *  specific image with psRegionForImage.  The output of this function is a region with negative
    161  *  upper limits replaced by their corrected value appropriate to the given image.  In addition,
    162  *  the lower and upper limits are foced to lie within the bounds of the image.  If the lower-
    163  *  limit coordinates are lewss than the lower bound of the image, they are limited to the lower
    164  *  bound of the image.  Conversely, if the upper-limit coordinates are greater than the upper
    165  *  bound of the image, they are truncated to define only valid pixels.  If the lower-limit
    166  *  coordinates are greater than the upper bounds of the image, or the upper-limit coordinates
    167  *  are less than the lower bounds of the image, the coordinates should saturate on those limits.
    168  *
    169  *  @return psRegion:       A region with negative upper limits replaced by the corrected
    170  */
    171 psRegion psRegionForImage(
    172     psImage *image,                    ///< the image for which the region is to be set
    173     psRegion in                        ///< the image region limits
    174 );
    175 
    176 /** Defines a region corresponding to the square with center at coordinate x,y
    177  *  and with coderadius.  The width of the square is 2radius + 1.
    178  *
    179  *  @return psRegion:       the newly defined psRegion.
    180  */
    181 psRegion psRegionForSquare(
    182     double x,                           ///< x coordinate at square-center
    183     double y,                           ///< y coordinate at square-center
    184     double radius                       ///< radius of square
    185 );
    186112
    187113/** Initializes the image with the given value.
  • branches/rel10_ifa/psLib/src/pslib_strict.h

    r6306 r6728  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2006-02-02 21:11:13 $
     11*  @version $Revision: 1.14.4.1 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2006-03-30 00:31:03 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7979#include "psMinimizePolyFit.h"
    8080#include "psRandom.h"
     81#include "psRegion.h"
     82#include "psRegionForImage.h"
    8183#include "psPolynomial.h"
    8284#include "psSpline.h"
  • branches/rel10_ifa/psLib/src/sys/psType.h

    r6349 r6728  
    1010*  @author Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-02-08 00:00:35 $
     12*  @version $Revision: 1.46.4.1 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-03-30 00:31:04 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    130130    PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
    131131    PS_DATA_PROJECTION,                ///< psProjection
     132    PS_DATA_REGION,                    ///< psRegion
    132133    PS_DATA_SCALAR,                    ///< psScalar
    133134    PS_DATA_SPHERE,                    ///< psSphere
  • branches/rel10_ifa/psLib/src/types/psMetadata.c

    r6718 r6728  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.99.4.5 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-03-28 22:19:15 $
     14 *  @version $Revision: 1.99.4.6 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-03-30 00:31:04 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    293293    case     PS_DATA_POLYNOMIAL4D:              // psPolynomial4D
    294294    case     PS_DATA_PROJECTION:                // psProjection
     295    case     PS_DATA_REGION:                  // psRegion
    295296    case     PS_DATA_SCALAR:                    // psScalar
    296297    case     PS_DATA_SPHERE:                    // psSphere
     
    341342}
    342343
     344
     345psMetadataItem *psMetadataItemCopy(const psMetadataItem *in
     346                                  )
     347{
     348    PS_ASSERT_PTR_NON_NULL(in,NULL);
     349
     350    psMetadataItem *newItem = NULL;     // New metadata item, to be returned
     351
     352    #define PS_METADATA_ITEM_COPY_CASE(NAME,TYPE) \
     353case PS_DATA_##NAME: \
     354    newItem = psMetadataItemAlloc(in->name, PS_DATA_##NAME, in->comment, in->data.TYPE); \
     355    break; \
     356
     357    switch (in->type) {
     358        // Simple types
     359        PS_METADATA_ITEM_COPY_CASE(BOOL,B);
     360        PS_METADATA_ITEM_COPY_CASE(S8,S8);
     361        PS_METADATA_ITEM_COPY_CASE(S16,S16);
     362        PS_METADATA_ITEM_COPY_CASE(S32,S32);
     363        PS_METADATA_ITEM_COPY_CASE(U8,U8);
     364        PS_METADATA_ITEM_COPY_CASE(U16,U16);
     365        PS_METADATA_ITEM_COPY_CASE(U32,U32);
     366        PS_METADATA_ITEM_COPY_CASE(F32,F32);
     367        PS_METADATA_ITEM_COPY_CASE(F64,F64);
     368        PS_METADATA_ITEM_COPY_CASE(STRING,V); // This will copy the string, not point at it.
     369    case PS_DATA_VECTOR: {
     370            psVector *vecCopy = psVectorCopy(NULL, (psVector*)(in->data.V),
     371                                             ((psVector*)(in->data.V))->type.type);
     372            if (vecCopy == NULL) {
     373                psError(PS_ERR_BAD_PARAMETER_NULL, false,
     374                        "Error copying vector.  Vector skipped.\n");
     375            } else {
     376                newItem = psMetadataItemAlloc(in->name, PS_DATA_VECTOR, in->comment, vecCopy);
     377                psFree(vecCopy);    // Drop reference
     378            }
     379            break;
     380        }
     381    case PS_DATA_TIME: {
     382            psTime *timeCopy = p_psTimeCopy( (psTime*)(in->data.V) );
     383            if (timeCopy == NULL) {
     384                psError(PS_ERR_BAD_PARAMETER_NULL, false,
     385                        "Error copying time.  Time skipped.\n");
     386            } else {
     387                newItem = psMetadataItemAlloc(in->name, PS_DATA_TIME, in->comment, timeCopy);
     388                psFree(timeCopy);   // Drop reference
     389            }
     390            break;
     391        }
     392    case PS_DATA_METADATA: {
     393            // Metadata: copy the next level and stuff that in too
     394            psMetadata *metadata = psMetadataCopy(NULL, in->data.md);
     395            newItem = psMetadataItemAlloc(in->name, PS_DATA_METADATA, in->comment, metadata);
     396            psFree(metadata);       // Drop reference
     397            break;
     398        }
     399    case PS_DATA_REGION: {
     400            psRegion *region = in->data.V; // The region
     401            psRegion *new = psRegionAlloc(region->x0, region->x1, region->y0, region->y1); // Copy of the region
     402            newItem = psMetadataItemAlloc(in->name, PS_DATA_REGION, in->comment, new);
     403            psFree(new);                  // Drop reference
     404            break;
     405        }
     406    default:
     407        // Other kinds of pointers
     408        psLogMsg(__func__, PS_LOG_WARN, "Copying a pointer in the metadata item: %x\n", in->type);
     409        newItem = psMetadataItemAlloc(in->name, in->type, in->comment, in->data.V);
     410        break;
     411    }
     412
     413    return newItem;
     414}
     415
    343416psMetadata *psMetadataCopy(psMetadata *out,
    344417                           const psMetadata *in)
     
    349422        out = psMetadataAlloc();
    350423    }
    351     //    psMetadataItem *item = NULL;
    352     psMetadataIterator *iter = NULL;
    353     iter = psMetadataIteratorAlloc(*(psMetadata**)&in, PS_LIST_HEAD, NULL);
    354     /*
    355         item = psMetadataGetAndIncrement(iter);
    356         while (item != NULL) {
    357             psMetadataAddItem(out, item, PS_LIST_TAIL, 0);
    358             item = psMetadataGetAndIncrement(iter);
    359         }
    360         psFree(item);
    361         psFree(iter);
    362         return out;
    363     */
     424    psMetadataIterator *iter = psMetadataIteratorAlloc(*(psMetadata**)&in, PS_LIST_HEAD, NULL);
    364425    psMetadataItem *inItem = NULL;
    365     unsigned long numPointers = 0;      // Number of pointers we were forced to copy
    366426    while ((inItem = psMetadataGetAndIncrement(iter))) {
    367427        // Need to look for MULTI, which won't be picked up using the iterator.
     
    374434        psTrace(__func__, 5, "Copying %s (%s)...\n", inItem->name, inItem->comment);
    375435
    376 
    377         //        case PS_TYPE_##NAME:
    378         #define PS_METADATA_COPY_CASE(NAME,TYPE) \
    379     case PS_DATA_##NAME: \
    380         if (! psMetadataAdd(out, PS_LIST_TAIL, inItem->name, \
    381                             PS_DATA_##NAME | flag, inItem->comment, inItem->data.TYPE)) { \
    382             psErrorStackPrint(stderr, "Error copying %s (%s) in the metadata\n", \
    383                               inItem->name, inItem->comment); \
    384         } \
    385         break;
    386 
    387         switch (inItem->type) {
    388             // Numerical types
    389             PS_METADATA_COPY_CASE(BOOL,B);
    390             PS_METADATA_COPY_CASE(S8,S8);
    391             PS_METADATA_COPY_CASE(S16,S16);
    392             PS_METADATA_COPY_CASE(S32,S32);
    393             PS_METADATA_COPY_CASE(U8,U8);
    394             PS_METADATA_COPY_CASE(U16,U16);
    395             PS_METADATA_COPY_CASE(U32,U32);
    396             PS_METADATA_COPY_CASE(F32,F32);
    397             PS_METADATA_COPY_CASE(F64,F64);
    398 
    399         case PS_DATA_VECTOR: {
    400                 psVector *vecCopy = psVectorCopy(NULL, (psVector*)(inItem->data.V),
    401                                                  ((psVector*)(inItem->data.V))->type.type);
    402                 if (vecCopy == NULL) {
    403                     psError(PS_ERR_BAD_PARAMETER_NULL, false,
    404                             "Error copying vector.  Vector skipped.\n");
    405                 } else {
    406                     psMetadataAddVector(out, PS_LIST_TAIL, inItem->name, flag,
    407                                         inItem->comment, vecCopy);
    408                     psFree(vecCopy);
    409                 }
    410                 break;
    411             }
    412         case PS_DATA_TIME: {
    413                 psTime *timeCopy = p_psTimeCopy( (psTime*)(inItem->data.V) );
    414                 if (timeCopy == NULL) {
    415                     psError(PS_ERR_BAD_PARAMETER_NULL, false,
    416                             "Error copying time.  Time skipped.\n");
    417                 } else {
    418                     psMetadataAddTime(out, PS_LIST_TAIL, inItem->name, flag,
    419                                       inItem->comment, timeCopy);
    420                     psFree(timeCopy);
    421                 }
    422                 break;
    423             }
    424             // String: relying on the fact that this will copy the string, not point at it.
    425         case PS_DATA_STRING:
    426             psMetadataAdd(out, PS_LIST_TAIL, inItem->name, PS_DATA_STRING |
    427                           flag, inItem->comment, inItem->data.V);
    428             break;
    429             // Metadata: copy the next level and stuff that in too
    430         case PS_DATA_METADATA: {
    431                 psMetadata *metadata = psMetadataCopy(NULL, inItem->data.md);
    432                 psMetadataAdd(out, PS_LIST_TAIL, inItem->name,
    433                               PS_DATA_METADATA | flag, inItem->comment, metadata);
    434                 psFree(metadata);
    435                 break;
    436             }
    437             // Other kinds of pointers
    438         default:
    439             numPointers++;
    440             psTrace(__func__, 10, "Copying a pointer in the metadata: %x\n", inItem->type);
    441             psMetadataAdd(out, PS_LIST_TAIL, inItem->name, inItem->type | flag,
    442                           inItem->comment, inItem->data.V);
    443             break;
     436        // Copy the item and add it on
     437        psMetadataItem *newItem = psMetadataItemCopy(inItem); // Copied item
     438        if (!psMetadataAddItem(out, newItem, PS_LIST_TAIL, flag)) {
     439            psErrorStackPrint(stderr, "Error copying %s (%s) in the metadata\n", inItem->name,
     440                              inItem->comment);
    444441        }
    445442    }
    446443    psFree(iter);
    447 
    448     if (numPointers > 0) {
    449         psLogMsg(__func__, PS_LOG_WARN,
    450                  "Forced to copy %d pointers when copying metadata.  Updating the "
    451                  "copied psMetadata will affect the original!\n", numPointers);
    452     }
    453444
    454445    return out;
     
    558549                   int format,
    559550                   const char *comment,
    560                    ...)
     551                   -..)
    561552{
    562553    PS_ASSERT_PTR_NON_NULL(md,false);
  • branches/rel10_ifa/psLib/src/types/psMetadata.h

    r6714 r6728  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.74.4.2 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2006-03-28 02:17:08 $
     13*  @version $Revision: 1.74.4.3 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2006-03-30 00:31:04 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    343343);
    344344
     345/** Creates a new copy of a psMetadataItem.
     346 *
     347 * @return psMetadataItem*: the copy of the psMetadataItem
     348 */
     349psMetadataItem *psMetadataItemCopy(const psMetadataItem *in ///< metadata item to be copied
     350                                  );
     351
     352
    345353/** Creates a new copy of all the psMetadataItems in the psMetadata collection, in, and
    346354 *  returns them in out, or creates a new container if out is NULL.
  • branches/rel10_ifa/psLib/src/types/psPixels.h

    r6230 r6728  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-01-28 01:31:44 $
     9 *  @version $Revision: 1.18.4.1 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-03-30 00:31:04 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1717#include "psImage.h"
    1818#include "psVector.h"
     19#include "psRegion.h"
    1920
    2021/// @addtogroup Image
Note: See TracChangeset for help on using the changeset viewer.