changeset 1488:a34b597083ea

Fixes to mincresample: setting the interpolation type is now done through an enum rather than function pointers.
author jason <jason>
date Wed, 06 Nov 2002 13:31:58 +0000
parents d7a056cd692f
children ceac7687a1b8
files ChangeLog progs/mincresample/mincresample.c progs/mincresample/mincresample.h
diffstat 3 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-11-05  Jason Lerch	      <jason@bic.mni.mcgill.ca>
+
+	* progs/mincresample/mincresample.{c,h}: changed the setting of
+	the interpolation type to go through an enum rather than directly
+	to a function pointer, as that is the behaviour that ParseArgv
+	expects and also makes mincresample 64 bit safe.
+
 2002-10-30  Jason Lerch       <jason@bic.mni.mcgill.ca>
 
 	* libsrc/ParseArgv: added the ARGV_LONG argument type.
--- a/progs/mincresample/mincresample.c
+++ b/progs/mincresample/mincresample.c
@@ -11,7 +11,11 @@
 @CREATED    : February 8, 1993 (Peter Neelin)
 @MODIFIED   : 
  * $Log: mincresample.c,v $
- * Revision 6.10  2002-10-30 13:53:02  jason
+ * Revision 6.11  2002-11-06 13:32:23  jason
+ * Fixes to mincresample: setting the interpolation type is now done
+ * through an enum rather than function pointers.
+ *
+ * Revision 6.10  2002/10/30 13:53:02  jason
  * Added a ARGV_LONG argument type to ParseArgv. Used that type for the nelements variable in mincresample
  *
  * Revision 6.9  2001/08/24 19:12:50  neelin
@@ -155,7 +159,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/progs/mincresample/mincresample.c,v 6.10 2002-10-30 13:53:02 jason Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/progs/mincresample/mincresample.c,v 6.11 2002-11-06 13:32:23 jason Exp $";
 #endif
 
 #include <stdlib.h>
@@ -240,7 +244,7 @@
       FILL_DEFAULT,           /* Flag indicating that fillvalue not set */
       {NO_VALUE, NO_VALUE, NO_VALUE}, /* Flag indicating that origin not set */
       {TRUE},                 /* Verbose */
-      trilinear_interpolant,
+      {TRILINEAR},            /* use trilinear interpolation by default */
       {FALSE, NULL, NULL, 0, NULL}, /* Transformation info is empty at start.
                                  Transformation must be set before invoking
                                  argument parsing */
@@ -393,14 +397,15 @@
       {"-fillvalue", ARGV_FLOAT, (char *) 0, 
           (char *) &args.fillvalue,
           "Specify a fill value for points outside of input volume"},
-      {"-trilinear", ARGV_CONSTANT, (char *) trilinear_interpolant, 
-          (char *) &args.interpolant,
+      {"-trilinear", ARGV_CONSTANT, (char *) TRILINEAR, 
+          (char *) &args.interpolant_type,
           "Do trilinear interpolation"},
-      {"-tricubic", ARGV_CONSTANT, (char *) tricubic_interpolant, 
-          (char *) &args.interpolant,
+      {"-tricubic", ARGV_CONSTANT, (char *) TRICUBIC, 
+          (char *) &args.interpolant_type,
           "Do tricubic interpolation"},
       {"-nearest_neighbour", ARGV_CONSTANT, 
-          (char *) nearest_neighbour_interpolant, (char *) &args.interpolant,
+          (char *) N_NEIGHBOUR, 
+          (char *) &args.interpolant_type,
           "Do nearest neighbour interpolation"},
       {NULL, ARGV_END, NULL, NULL, NULL}
    };
@@ -518,7 +523,22 @@
       in_vol->volume->fillvalue = args.fillvalue;
       in_vol->volume->use_fill = (args.fillvalue != -DBL_MAX);
    }
-   in_vol->volume->interpolant = args.interpolant;
+
+   /* set the function pointer defining the type of interpolation */
+   switch (args.interpolant_type ) {
+   case TRICUBIC:
+     in_vol->volume->interpolant = tricubic_interpolant;
+     break;
+   case TRILINEAR:
+     in_vol->volume->interpolant = trilinear_interpolant;
+     break;
+   case N_NEIGHBOUR:
+     in_vol->volume->interpolant = nearest_neighbour_interpolant;
+     break;
+   default:
+     (void) fprintf(stderr, "Error determining interpolation type\n");
+     exit(EXIT_FAILURE);
+   }
 
    /* Check min/max variables */
    fp = in_vol->file;
--- a/progs/mincresample/mincresample.h
+++ b/progs/mincresample/mincresample.h
@@ -7,7 +7,11 @@
 @CREATED    : February 8, 1993 (Peter Neelin)
 @MODIFIED   : 
  * $Log: mincresample.h,v $
- * Revision 6.3  2001-04-17 18:40:23  neelin
+ * Revision 6.4  2002-11-06 13:32:23  jason
+ * Fixes to mincresample: setting the interpolation type is now done
+ * through an enum rather than function pointers.
+ *
+ * Revision 6.3  2001/04/17 18:40:23  neelin
  * Modifications to work with NetCDF 3.x
  * In particular, changed NC_LONG to NC_INT (and corresponding longs to ints).
  * Changed NC_UNSPECIFIED to NC_NAT.
@@ -136,6 +140,8 @@
 #endif
 
 /* Types used in program */
+enum Interpolant_type { TRILINEAR, TRICUBIC, N_NEIGHBOUR };
+
 typedef double Coord_Vector[WORLD_NDIMS];
 
 typedef struct {
@@ -188,7 +194,7 @@
    void *data;               /* Pointer to volume data */
    double *scale;            /* Pointer to array of scales for slices */
    double *offset;           /* Pointer to array of offsets for slices */
-   Interpolating_Function interpolant;
+   Interpolating_Function interpolant; /* Function Pointer */
 };
 
 typedef struct {
@@ -232,7 +238,7 @@
    double fillvalue;
    double origin[3];
    Program_Flags flags;
-   Interpolating_Function interpolant;
+   enum Interpolant_type interpolant_type;  /* Type of interpolation */
    Transform_Info transform_info;
    Volume_Definition volume_def;
 } Arg_Data;