]> Creatis software - gdcm.git/commitdiff
ENH: Adding new option in CMake: GDCM_FORCE_BIGENDIAN_EMULATION. You are now able...
authormalaterre <malaterre>
Fri, 11 Feb 2005 20:04:07 +0000 (20:04 +0000)
committermalaterre <malaterre>
Fri, 11 Feb 2005 20:04:07 +0000 (20:04 +0000)
CMakeLists.txt
gdcmConfigure.h.in
src/gdcmBinEntry.cxx
src/gdcmDocument.cxx
src/gdcmJpeg.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h

index 1493505a95dbaead3f3773760b0a7e0e6f621068..1475af9b3d8caca6f8710565bc5d2419ad1c38c6 100644 (file)
@@ -1,16 +1,6 @@
 PROJECT(GDCM)
 CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
 
-#MESSAGE("MATHIEU: ${CMAKE_VERSION_RELEASE}")
-#MESSAGE("MATHIEU: ${CMAKE_VERSION}")
-#MESSAGE("MATHIEU: ${CMAKE_CACHE_RELEASE_VERSION}")
-#IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} EQUAL 2.0)
-#  IF(${CMAKE_CACHE_RELEASE_VERSION} EQUAL "patch 5")
-#    MESSAGE("MAHTIEU FOO")
-#  ENDIF(${CMAKE_CACHE_RELEASE_VERSION} EQUAL "patch 5")
-#ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} EQUAL 2.0)
-
-
 #-----------------------------------------------------------------------------
 # GDCM version number, usefull for packaging and doxygen doc:
 SET(GDCM_MAJOR_VERSION 0)
@@ -152,6 +142,10 @@ CHECK_INCLUDE_FILE_CONCAT("netinet/in.h"   CMAKE_HAVE_NETINET_IN_H)
 CHECK_INCLUDE_FILE_CONCAT("net/if_dl.h"    CMAKE_HAVE_NET_IF_DL_H)
 CHECK_INCLUDE_FILE_CONCAT("net/if_arp.h"   CMAKE_HAVE_NET_IF_ARP_H)
 
+#-----------------------------------------------------------------------------
+# Force Big Endian emulation on little endian:
+OPTION(GDCM_FORCE_BIGENDIAN_EMULATION "Force Big Endian Emulation." OFF)
+
 CONFIGURE_FILE(${GDCM_SOURCE_DIR}/gdcmConfigure.h.in
                ${GDCM_BINARY_DIR}/gdcmConfigure.h @ONLY IMMEDIATE)
 
index 0737e4a3ebd881479facb6989cff283dcfa5a015..816416132434a802ece72e092d83c00e6f9ac2fb 100644 (file)
@@ -51,6 +51,7 @@
 #cmakedefine CMAKE_HAVE_NET_IF_ARP_H
 #cmakedefine HAVE_SA_LEN
 
+#cmakedefine GDCM_FORCE_BIGENDIAN_EMULATION
 
 /*--------------------------------------------------------------------------*/
 /* GDCM Versioning                                                          */
index 70a277807da4e5f5e2df5c5445494242bd593b70..0e677a4941651b331aba8ed6ea0c7ddf1be159aa 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 19:00:39 $
-  Version:   $Revision: 1.70 $
+  Date:      $Date: 2005/02/11 20:04:07 $
+  Version:   $Revision: 1.71 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -81,7 +81,7 @@ void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
    ///        to write image with Big Endian Transfert Syntax, 
    ///        and we are working on Little Endian Processor
 
-#ifdef GDCM_WORDS_BIGENDIAN
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
       /// \todo FIXME Right now, we only care of Pixels element
       ///       we should deal with *all* the BinEntries
       ///       well not really since we are not interpreting values read...
index f1fb5ed6653c435a5d1ea09a54b27c07d71d8877..3cf3b8bce3b8ebfd78f2918ccefb9759080d8cca 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 19:19:05 $
-  Version:   $Revision: 1.228 $
+  Date:      $Date: 2005/02/11 20:04:08 $
+  Version:   $Revision: 1.229 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <iomanip>
 #include <fstream>
 
-// For nthos:
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) 
-   #include <winsock.h>
-#endif
-
-#ifdef CMAKE_HAVE_NETINET_IN_H
-   #include <netinet/in.h>
-#endif
-
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
@@ -1728,9 +1719,7 @@ bool Document::CheckSwap()
     
    // First, compare HostByteOrder and NetworkByteOrder in order to
    // determine if we shall need to swap bytes (i.e. the Endian type).
-
-   uint32_t  x = 4;  // x : for ntohs
-   bool net2host = (x == ntohs(x));// true when HostByteOrder is the same as NetworkByteOrder
+   bool net2host = Util::IsCurrentProcessorBigEndian();
          
    // The easiest case is the one of a 'true' DICOM header, we just have
    // to look for the string "DICM" inside the file preamble.
index da85bd4bab65a0647f6c25f6f130484b9e95695e..3d11de65781c9b6cf9218726d320e50da6f18f3b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 19:00:39 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/02/11 20:04:08 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -337,7 +337,7 @@ bool JPEGFragment::ReadJPEGFile (std::ifstream *fp, void *image_buffer, int &sta
         return true;
         }
 // The ijg has no notion of big endian, therefore always swap the jpeg stream
-#if defined(GDCM_WORDS_BIGENDIAN) && (CMAKE_BITS_IN_JSAMPLE != 8)
+#if (defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)) && (CMAKE_BITS_IN_JSAMPLE != 8)
       uint16_t *buffer16 = (uint16_t*)*buffer;
       uint16_t *pimage16 = (uint16_t*)pImage;
       for(unsigned int i=0;i<rowsize/2;i++)
index 6d015ddd50c302d943bd5cc4f1cc5226e979254c..467777c5609f6510fc822a497a4c7f0680ed63cc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 19:12:40 $
-  Version:   $Revision: 1.137 $
+  Date:      $Date: 2005/02/11 20:04:08 $
+  Version:   $Revision: 1.138 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -351,7 +351,7 @@ unsigned int Util::GetCurrentProcessID()
  */
 bool Util::IsCurrentProcessorBigEndian()
 {
-#ifdef GDCM_WORDS_BIGENDIAN
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    return true;
 #else
    return false;
@@ -809,17 +809,6 @@ const std::string &Util::GetRootUID()
 }
 
 //-------------------------------------------------------------------------
-/**
- * \brief class for binary write
- * @param os ostream to write to
- * @param val val
- */ 
-template <class T>
-std::ostream &binary_write(std::ostream &os, const T &val)
-{
-   return os.write(reinterpret_cast<const char*>(&val), sizeof val);
-}
-
 /**
  * \brief binary_write binary_write
  * @param os ostream to write to 
@@ -827,7 +816,7 @@ std::ostream &binary_write(std::ostream &os, const T &val)
  */ 
 std::ostream &binary_write(std::ostream &os, const uint16_t &val)
 {
-#ifdef GDCM_WORDS_BIGENDIAN
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    uint16_t swap;
    swap = ((( val << 8 ) & 0xff00 ) | (( val >> 8 ) & 0x00ff ) );
    return os.write(reinterpret_cast<const char*>(&swap), 2);
@@ -843,7 +832,7 @@ std::ostream &binary_write(std::ostream &os, const uint16_t &val)
  */ 
 std::ostream &binary_write(std::ostream &os, const uint32_t &val)
 {
-#ifdef GDCM_WORDS_BIGENDIAN
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    uint32_t swap;
    swap = ( ((val<<24) & 0xff000000) | ((val<<8)  & 0x00ff0000) | 
             ((val>>8)  & 0x0000ff00) | ((val>>24) & 0x000000ff) );
@@ -894,7 +883,7 @@ std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len)
 // This is tricky since we are writting two bytes buffer. Be carefull with little endian
 // vs big endian. Also this other trick is to allocate a small (efficient) buffer that store
 // intermidiate result before writting it.
-#ifdef GDCM_WORDS_BIGENDIAN
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    const int BUFFER_SIZE = 4096;
    uint16_t *buffer = new uint16_t[BUFFER_SIZE/2];
    uint16_t *binArea16 = (uint16_t*)val;
index 86cee1447749c9fc7291868330446afa2d34d011..8e7ac623f5b8980813291665d1c97588f7e6d349 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 19:00:39 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2005/02/11 20:04:08 $
+  Version:   $Revision: 1.55 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -71,8 +71,6 @@ private:
    static const std::string GDCM_UID;
 };
 
-template <class T> 
-GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const T &val);
 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);