]> Creatis software - gdcm.git/commitdiff
* Bug fix due my last commit (compilation under Windows).
authorregrain <regrain>
Sat, 4 Dec 2004 08:57:19 +0000 (08:57 +0000)
committerregrain <regrain>
Sat, 4 Dec 2004 08:57:19 +0000 (08:57 +0000)
   * Example/Volume2Dicom : bug fix in the file and reformatting source code
   -- BeNous

ChangeLog
Example/Volume2Dicom.cxx
Testing/TestAllEntryVerify.cxx
src/gdcmDicomDir.cxx

index fa93a9a6cc147b1723c4ebb62a2664bfc6e2e887..ff46294c063bc72619809c0e1b85bf787ef25fc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,17 @@
+2004-12-04 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * Bug fix due my last commit (compilation under Windows).
+   * Example/Volume2Dicom : bug fix in the file and reformatting source code
+
 2004-12-03 Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
    * Huge cleanup:
      - Remove printf / sprintf
      - include iostream AFTER gdcm so we don't get warnings
-     - GDCM_NO_ANSI_STRING_STREAM shouldn't be used explitely ouside of gdcm source
-     - Also remove tons of include from header files, hopefully this should speeup the compilation time, since it was becoming a dog slow.
-     - Remove gdcm.h as it include way too many files and slow down compilation (plus it is not up to date)
+     - GDCM_NO_ANSI_STRING_STREAM shouldn't be used explitely ouside of gdcm 
+       source
+     - Also remove tons of include from header files, hopefully this should 
+       speeup the compilation time, since it was becoming a dog slow.
+     - Remove gdcm.h as it include way too many files and slow down compilation 
+       (plus it is not up to date)
      - remove 'using namespace std' this is BAD !
 
 2004-12-03 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
index 6fe34d43176a4290026e6766ba4db7d06e2adc83..05eeeb84f8b5a075f0523744f0474ad723eccdc5 100644 (file)
-/*=========================================================================\r
-                                                                                 \r
-  Program:   gdcm\r
-  Module:    $RCSfile: Volume2Dicom.cxx,v $\r
-  Language:  C++\r
-  Date:      $Date: 2004/12/04 08:46:10 $\r
-  Version:   $Revision: 1.1 $\r
-                                                                                 \r
-  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de\r
-  l'Image). All rights reserved. See Doc/License.txt or\r
-  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.\r
-                                                                                 \r
-     This software is distributed WITHOUT ANY WARRANTY; without even\r
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
-     PURPOSE.  See the above copyright notices for more information.\r
-                                                                                 \r
-=========================================================================*/\r
-\r
-/**\r
- * This example was proposed by Jean-Michel Rouet\r
- * It was patch by Mathieu Malaterre to remove ITK reference and be more\r
- * independant from other toolkit\r
- * It's aim is to show people how to write their data volume into DICOM slices\r
- */\r
-\r
-#include "gdcmHeader.h"\r
-#include "gdcmDocEntry.h"\r
-#include "gdcmBinEntry.h"\r
-#include "gdcmFile.h"\r
-#include "gdcmUtil.h"\r
-\r
-#define USAGE "USAGE: Input3DImage OutputDirectory"\r
-\r
-#include <time.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#ifdef WIN32\r
-#define stat _stat\r
-#endif\r
-\r
-const unsigned int Dimension = 3;\r
-\r
-void gdcmwrite(const char *inputfile, std::string directory);\r
-void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time);\r
-\r
-int main( int argc, char * argv[] )\r
-{\r
-   \r
-   if (argc < 2) \r
-   {\r
-      std::cerr << argv[0] << USAGE << std::endl;\r
-      return 1;\r
-   }    \r
-\r
-   //const char *inputfile = argv[1];\r
-   std::string directory = argv[1];\r
-//   itksys::SystemTools::ConvertToUnixSlashes( directory );\r
-   if (directory[directory.size()-1] != '/') directory += '/';\r
-\r
-   std::cout << "Converting image into dicom in " << directory << std::endl;\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // Reading input image and getting some information       //\r
-    ////////////////////////////////////////////////////////////\r
-    //std::cout << "Loading image " << inputfile << std::endl;\r
-    //PixelType* imageData = input->GetPixelContainer()->GetImportPointer();\r
-    uint8_t *imageData = new uint8_t[256*256*10];\r
-    memset( imageData, 0, 256*256*10);\r
-    std::cout << "Image Loaded." << std::endl;\r
-\r
-    int   sizex      = 256;\r
-    int   sizey      = 256;\r
-    int   sizez      = 10;\r
-    float spacing[3] = { 1.0, 1.0, 1.5 };\r
-    float orig[3]    = { 0.0, 0.0, 0.0 };\r
-    int   sliceSize  = sizex*sizey*sizeof(uint8_t);\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // compute window center and window width                 //\r
-    ////////////////////////////////////////////////////////////\r
-    uint8_t min, max; min = max = imageData[0];\r
-    for (int i=1; i<sizex*sizey*sizez; i++) \r
-    {\r
-       uint8_t val = imageData[i];\r
-       if (val > max) max = val;\r
-       if (val < min) min = val;\r
-    }\r
-    float wcenter = (max+min) / 2.;\r
-    float wwidth  = (max-min)>0 ? (max-min) : 1.;\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // Get file date and time                                 //\r
-    ////////////////////////////////////////////////////////////\r
-    std::string filedate, filetime;    \r
-    //GetFileDateAndTime(inputfile, filedate, filetime);\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // Create a new dicom header and fill in some info        //\r
-    ////////////////////////////////////////////////////////////\r
-    gdcm::Header *h1 = new gdcm::Header();\r
-\r
-    //h1->SetDateAndTime(filedate, filetime);\r
-    //h1->SetModality("CT");\r
-    //h1->SetPatientName( "TestPatient");\r
-    //h1->SetPatientID( "TestID");\r
-    //h1->SetStudyID( "1");\r
-    //h1->SetSeriesNumber( "1");\r
-    //h1->SetSliceThickness(spacing[2]);\r
-    //h1->SetSpaceBetweenSlices(spacing[2]);\r
-    //h1->SetXYSpacing( spacing[0], spacing[1]);\r
-    //h1->SetXSize(sizex);\r
-    //h1->SetYSize(sizey);\r
-    //h1->SetNbBitsAllocated(16);\r
-    //h1->SetNbBitsStored(12);\r
-    //h1->SetNbBitsStored(12);\r
-    //h1->SetPixelSigned(true);\r
-    //h1->SetCenter( wcenter);\r
-    //h1->SetWindow( wwidth);\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // Create a new dicom file object from the header         //\r
-    ////////////////////////////////////////////////////////////\r
-    gdcm::File  *f1 = new gdcm::File(h1);\r
-    uint8_t *myData = f1->GetImageData(); // Get an Image pointer\r
-    f1->SetImageData( myData, sliceSize); // This callback ensures that the internal\r
-                                          // Pixel_Data of f1 is set correctly\r
-\r
-    \r
-    ////////////////////////////////////////////////////////////\r
-    // Iterate through the slices and save them to file       //\r
-    ////////////////////////////////////////////////////////////\r
-    for (int z=0; z<sizez; z++) \r
-    {\r
-       // Set dicom relevant information for that slice\r
-       //h1->SetImageUIDFromSliceNumber(z);\r
-       //h1->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]);\r
-\r
-       // copy image slice content\r
-       memcpy(myData,imageData+z*sizex*sizey,sliceSize);\r
-\r
-       // write the image\r
-       std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z);\r
-       std::cout << "Writing file " << filename;\r
-       f1->WriteDcmExplVR(filename);\r
-       std::cout << " OK" << std::endl;\r
-    }\r
-\r
-    ////////////////////////////////////////////////////////////\r
-    // Free the allocated objects                             //\r
-    ////////////////////////////////////////////////////////////\r
-    // delete f1; // FIXME: these calls sometimes crashes under .NET ????\r
-    // delete h1;\r
-}\r
-\r
-\r
-// just an utility function to retrieve date and time of a file\r
-void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time)\r
-{\r
-   struct stat buf;    \r
-   if (stat(inputfile, &buf) == 0) \r
-   {\r
-      char tmp[512];\r
-\r
-      strftime(tmp,512,"%Y%m%d", localtime(&buf.st_mtime) );\r
-      date = tmp;\r
-\r
-      strftime(tmp,512,"%H%M%S", localtime(&buf.st_mtime) );\r
-      time = tmp;\r
-   }\r
-   else\r
-   {\r
-      date = "20040101";\r
-      time = "120000";\r
-   }\r
-}\r
-\r
+/*=========================================================================
+                                                                                 
+  Program:   gdcm
+  Module:    $RCSfile: Volume2Dicom.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/12/04 08:57:19 $
+  Version:   $Revision: 1.2 $
+                                                                                 
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                 
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                 
+=========================================================================*/
+
+/**
+ * This example was proposed by Jean-Michel Rouet
+ * It was patch by Mathieu Malaterre to remove ITK reference and be more
+ * independant from other toolkit
+ * It's aim is to show people how to write their data volume into DICOM slices
+ */
+
+#include "gdcmHeader.h"
+#include "gdcmDocEntry.h"
+#include "gdcmBinEntry.h"
+#include "gdcmFile.h"
+#include "gdcmUtil.h"
+
+#define USAGE "USAGE: Input3DImage OutputDirectory"
+
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef WIN32
+   #define stat _stat
+#endif
+
+const unsigned int Dimension = 3;
+
+void gdcmwrite(const char *inputfile, std::string directory);
+void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time);
+
+int main( int argc, char * argv[] )
+{
+   if (argc < 2) 
+   {
+      std::cerr << argv[0] << USAGE << std::endl;
+      return 1;
+   }    
+
+   //const char *inputfile = argv[1];
+   std::string directory = argv[1];
+//   itksys::SystemTools::ConvertToUnixSlashes( directory );
+   if (directory[directory.size()-1] != '/') 
+      directory += '/';
+
+   std::cout << "Converting image into dicom in " << directory << std::endl;
+
+    ////////////////////////////////////////////////////////////
+    // Reading input image and getting some information       //
+    ////////////////////////////////////////////////////////////
+    //std::cout << "Loading image " << inputfile << std::endl;
+    //PixelType* imageData = input->GetPixelContainer()->GetImportPointer();
+    uint8_t *imageData = new uint8_t[256*256*10];
+    memset( imageData, 0, 256*256*10);
+    std::cout << "Image Loaded." << std::endl;
+
+    int   sizex      = 256;
+    int   sizey      = 256;
+    int   sizez      = 10;
+    //float spacing[3] = { 1.0, 1.0, 1.5 };
+    //float orig[3]    = { 0.0, 0.0, 0.0 };
+    int   sliceSize  = sizex*sizey*sizeof(uint8_t);
+
+    ////////////////////////////////////////////////////////////
+    // compute window center and window width                 //
+    ////////////////////////////////////////////////////////////
+    uint8_t min, max; min = max = imageData[0];
+    for (int i=1; i<sizex*sizey*sizez; i++) 
+    {
+       uint8_t val = imageData[i];
+       if (val > max) 
+          max = val;
+       if (val < min) 
+          min = val;
+    }
+    float wcenter = (max+min) / 2.;
+    float wwidth  = (max-min)>0 ? (max-min) : 1.;
+
+    ////////////////////////////////////////////////////////////
+    // Get file date and time                                 //
+    ////////////////////////////////////////////////////////////
+    std::string filedate, filetime;    
+    //GetFileDateAndTime(inputfile, filedate, filetime);
+
+    ////////////////////////////////////////////////////////////
+    // Create a new dicom header and fill in some info        //
+    ////////////////////////////////////////////////////////////
+    gdcm::Header *h1 = new gdcm::Header();
+
+    //h1->SetDateAndTime(filedate, filetime);
+    //h1->SetModality("CT");
+    //h1->SetPatientName( "TestPatient");
+    //h1->SetPatientID( "TestID");
+    //h1->SetStudyID( "1");
+    //h1->SetSeriesNumber( "1");
+    //h1->SetSliceThickness(spacing[2]);
+    //h1->SetSpaceBetweenSlices(spacing[2]);
+    //h1->SetXYSpacing( spacing[0], spacing[1]);
+    //h1->SetXSize(sizex);
+    //h1->SetYSize(sizey);
+    //h1->SetNbBitsAllocated(16);
+    //h1->SetNbBitsStored(12);
+    //h1->SetNbBitsStored(12);
+    //h1->SetPixelSigned(true);
+    //h1->SetCenter( wcenter);
+    //h1->SetWindow( wwidth);
+
+    ////////////////////////////////////////////////////////////
+    // Create a new dicom file object from the header         //
+    ////////////////////////////////////////////////////////////
+    gdcm::File  *f1 = new gdcm::File(h1);
+    uint8_t *myData = f1->GetImageData(); // Get an Image pointer
+    f1->SetImageData( myData, sliceSize); // This callback ensures that the internal
+                                          // Pixel_Data of f1 is set correctly
+
+    
+    ////////////////////////////////////////////////////////////
+    // Iterate through the slices and save them to file       //
+    ////////////////////////////////////////////////////////////
+    for (int z=0; z<sizez; z++) 
+    {
+       // Set dicom relevant information for that slice
+       //h1->SetImageUIDFromSliceNumber(z);
+       //h1->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]);
+
+       // copy image slice content
+       memcpy(myData,imageData+z*sizex*sizey,sliceSize);
+
+       // write the image
+       std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z);
+       std::cout << "Writing file " << filename;
+       f1->WriteDcmExplVR(filename);
+       std::cout << " OK" << std::endl;
+    }
+
+    ////////////////////////////////////////////////////////////
+    // Free the allocated objects                             //
+    ////////////////////////////////////////////////////////////
+    // delete f1; // FIXME: these calls sometimes crashes under .NET ????
+    // delete h1;
+
+    return 0;
+}
+
+
+// just an utility function to retrieve date and time of a file
+void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time)
+{
+   struct stat buf;    
+   if (stat(inputfile, &buf) == 0) 
+   {
+      char tmp[512];
+
+      strftime(tmp,512,"%Y%m%d", localtime(&buf.st_mtime) );
+      date = tmp;
+
+      strftime(tmp,512,"%H%M%S", localtime(&buf.st_mtime) );
+      time = tmp;
+   }
+   else
+   {
+      date = "20040101";
+      time = "120000";
+   }
+}
index 089a8ad7cced084ffbd5185de01dcbf5b8247a14..3eacef55dc951b9aed0b32f81113352969ce3ec6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllEntryVerify.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/03 17:13:17 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/12/04 08:57:20 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -178,7 +178,7 @@ void ReferenceFileParser::Print()
 
 bool ReferenceFileParser::Check()
 {
-   int ret = true;
+   bool ret = true;
    for (MapFileValuesType::iterator i  = ProducedMap.begin();
                                     i != ProducedMap.end();
                                     ++i)
index 58e58b631a8692475feabaffbb23a362f5059a6d..6716aec7c5c0eb2fe94afa88e52cb9f962d2d0d9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/03 20:16:57 $
-  Version:   $Revision: 1.85 $
+  Date:      $Date: 2004/12/04 08:57:20 $
+  Version:   $Revision: 1.86 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -455,11 +455,11 @@ std::cerr<<"File : "<<it->c_str()<<std::endl;
    SetElements(tmp, list);
    CallEndMethod();
 
-   for(VectDocument::iterator it=list.begin();
-       it!=list.end();
-       ++it)
+   for(VectDocument::iterator itDoc=list.begin();
+       itDoc!=list.end();
+       ++itDoc)
    {
-      delete dynamic_cast<Header *>(*it);
+      delete dynamic_cast<Header *>(*itDoc);
    }
 }