changeset 1309:d3238806efcc

Port to linux.
author neelin <neelin>
date Mon, 19 Feb 2001 22:03:13 +0000
parents dc8d6dcfa2ee
children ce2c6bfc79bf
files conversion/gcomserver/convert_to_dicom.c conversion/gcomserver/open_connection.c conversion/gcomserver/project_file.c conversion/gcomserver/use_the_files.c
diffstat 4 files changed, 75 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/conversion/gcomserver/convert_to_dicom.c
+++ b/conversion/gcomserver/convert_to_dicom.c
@@ -5,7 +5,10 @@
 @CREATED    : September 12, 1997 (Peter Neelin)
 @MODIFIED   : 
  * $Log: convert_to_dicom.c,v $
- * Revision 1.12  2000-10-31 00:53:13  neelin
+ * Revision 1.13  2001-02-19 22:03:13  neelin
+ * Port to linux.
+ *
+ * Revision 1.12  2000/10/31 00:53:13  neelin
  * Changed largest and smallest pixel values to largest and smallest
  * pixel values in series.
  *
@@ -70,7 +73,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/conversion/gcomserver/convert_to_dicom.c,v 1.12 2000-10-31 00:53:13 neelin Exp $";
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/gcomserver/convert_to_dicom.c,v 1.13 2001-02-19 22:03:13 neelin Exp $";
 #endif
 
 #include <stdio.h>
@@ -85,6 +88,8 @@
 #include <acr_nema.h>
 #include <spi_element_defs.h>
 
+#define MAKE_POSITIVE_ZEROS
+
 #ifndef public
 #  define public
 #endif
@@ -172,6 +177,30 @@
 };
 
 
+#ifdef MAKE_POSITIVE_ZEROS
+/* ----------------------------- MNI Header -----------------------------------
+@NAME       : make_positive_zeros
+@INPUT      : values
+              nvalues
+@OUTPUT     : values
+@RETURNS    : (nothing)
+@DESCRIPTION: Ensures that zeros are positive (needed for linux).
+@METHOD     : 
+@GLOBALS    : 
+@CALLS      : 
+@CREATED    : January 29, 2001 (Peter Neelin)
+@MODIFIED   : 
+---------------------------------------------------------------------------- */
+private void make_positive_zeros(double values[], int nvalues)
+{
+   int i;
+
+   for (i=0; i < nvalues; i++) {
+      if (values[i] == 0.0) values[i] = 0.0;
+   }
+}
+#endif
+
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : convert_to_dicom
 @INPUT      : group_list
@@ -193,8 +222,8 @@
    Acr_Element element;
    Acr_Group group;
    double value;
-   char string[64], *ptr, *imagenum;
-   char comment[64];
+   char string[256], *ptr, *imagenum;
+   char comment[256];
    double dircos[WORLD_NDIMS][WORLD_NDIMS];
    union {
       unsigned char ch[4];
@@ -330,6 +359,9 @@
       column_world = YCOORD;
       break;
    }
+#ifdef MAKE_POSITIVE_ZEROS
+   make_positive_zeros((double *) dircos, WORLD_NDIMS * WORLD_NDIMS);
+#endif
    (void) sprintf(string, "%.8g\\%.8g\\%.8g\\%.8g\\%.8g\\%.8g",
                   dircos[row_world][XCOORD],
                   dircos[row_world][YCOORD],
@@ -346,12 +378,18 @@
    field_of_view = acr_find_double(group_list, SPI_Field_of_view, 0);
    calculate_image_position(orientation, field_of_view, field_of_view, 
                             centre, dircos, position);
+#ifdef MAKE_POSITIVE_ZEROS
+   make_positive_zeros(position, WORLD_NDIMS);
+#endif
    (void) sprintf(string, "%.8g\\%.8g\\%.8g",
                   position[XCOORD], position[YCOORD], position[ZCOORD]);
    acr_insert_string(&group_list, ACR_Image_position, string);
 
    /* Add slice location */
    calculate_slice_location(orientation, position, dircos, &location);
+#ifdef MAKE_POSITIVE_ZEROS
+   make_positive_zeros(&location, 1);
+#endif
    (void) sprintf(string, "%.8g", location);
    acr_insert_string(&group_list, ACR_Slice_location, string);
 
@@ -359,6 +397,9 @@
    element = acr_find_group_element(group_list, ACR_Pixel_size);
    if (element != NULL) {
       if (acr_get_element_numeric_array(element, 1, &value) >= 1) {
+#ifdef MAKE_POSITIVE_ZEROS
+	 make_positive_zeros(&value, 1);
+#endif
          (void) sprintf(string, "%.6G\\%.6G", value, value);
          acr_insert_string(&group_list, ACR_Pixel_size, string);
       }
--- a/conversion/gcomserver/open_connection.c
+++ b/conversion/gcomserver/open_connection.c
@@ -5,7 +5,10 @@
 @CREATED    : November 22, 1993 (Peter Neelin)
 @MODIFIED   : 
  * $Log: open_connection.c,v $
- * Revision 6.1  1999-10-29 17:52:04  neelin
+ * Revision 6.2  2001-02-19 22:03:13  neelin
+ * Port to linux.
+ *
+ * Revision 6.1  1999/10/29 17:52:04  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:23:50  neelin
@@ -73,10 +76,17 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <memory.h>
-#include <dn/defs.h>
+#ifdef sgi
+#  include <dn/defs.h>
+#  define USE_4DDN
+#endif
 #include <acr_nema.h>
 #include <minc_def.h>
 
+/* Section specific to Irix 4DDN interface (includes input and 
+   output routines) */
+#ifdef USE_4DDN
+
 /* Decnet functions */
 #ifdef DNIOCTL
 #  define GCOM_IOCTL DNIOCTL
@@ -153,6 +163,8 @@
    return nwritten;
 }
 
+#endif    /* USE_4DDN */
+
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : open_connection
 @INPUT      : argc - number of command-line arguments
@@ -171,16 +183,22 @@
 public void open_connection(int argc, char *argv[], 
                             Acr_File **afpin, Acr_File **afpout)
 {
+
+#ifdef USE_4DDN
    SessionData sd;
    Io_data *io_data;
    int link;
    long maxlength;
+#endif
 
    /* If there are no arguments, then assume that we are not using
-      decnet and just use stdin and stdout */
+      irix 4DDN decnet and just use stdin and stdout */
+#ifdef USE_4DDN
    if (argc == 1) {
+#endif
       *afpin = acr_file_initialize((void *) stdin, 0, acr_stdio_read);
       *afpout = acr_file_initialize((void *) stdout, 0, acr_stdio_write);
+#ifdef USE_4DDN
    }
 
    /* Otherwise, use decnet routines */
@@ -209,6 +227,7 @@
                                     output_routine);
 
    }        /* If decnet else */
+#endif /* USE_4DDN */
 
 }
 
--- a/conversion/gcomserver/project_file.c
+++ b/conversion/gcomserver/project_file.c
@@ -8,7 +8,10 @@
 @CREATED    : February 14, 1995 (Peter Neelin)
 @MODIFIED   : 
  * $Log: project_file.c,v $
- * Revision 6.5  2000-06-14 18:24:08  neelin
+ * Revision 6.6  2001-02-19 22:03:13  neelin
+ * Port to linux.
+ *
+ * Revision 6.5  2000/06/14 18:24:08  neelin
  * Added UseSafeOrientations keyword to project files to allow forcing of
  * direction cosines to standard (safe) ones, and modified convert_to_dicom
  * so that this is no longer the default behaviour.
@@ -74,9 +77,6 @@
 #define STRCOPY(s1, s2, maxlen) \
 { (void) strncpy(s1, s2, (maxlen)-1); s1[(maxlen)-1] = '\0'; }
 
-/* Function prototypes */
-int gethostname (char *name, int namelen);
-
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : read_project_file
 @INPUT      : project_name - name to use for project file
--- a/conversion/gcomserver/use_the_files.c
+++ b/conversion/gcomserver/use_the_files.c
@@ -7,7 +7,10 @@
 @CREATED    : November 23, 1993 (Peter Neelin)
 @MODIFIED   : 
  * $Log: use_the_files.c,v $
- * Revision 6.1  1999-10-29 17:52:05  neelin
+ * Revision 6.2  2001-02-19 22:03:14  neelin
+ * Port to linux.
+ *
+ * Revision 6.1  1999/10/29 17:52:05  neelin
  * Fixed Log keyword
  *
  * Revision 6.0  1997/09/12 13:23:50  neelin
@@ -89,9 +92,6 @@
 #include <unistd.h>
 #include <gcomserver.h>
 
-/* Function prototypes */
-int gethostname (char *name, int namelen);
-
 
 /* ----------------------------- MNI Header -----------------------------------
 @NAME       : use_the_files