]> Creatis software - gdcm.git/blobdiff - Example/PrintFile.cxx
Synchronize (fix comments, misstyping, re ident, etc)
[gdcm.git] / Example / PrintFile.cxx
index dfc6f6e3609ed5b3143ab9d46d458d822837c83a..2ed087c95aae4f3d5b8a75a5f59453f388b53881 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/13 13:58:40 $
-  Version:   $Revision: 1.90 $
+  Date:      $Date: 2010/09/01 14:41:48 $
+  Version:   $Revision: 1.94 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -244,13 +244,14 @@ int main(int argc, char *argv[])
       GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
       f->SetLoadMode(loadMode);
       f->SetFileName( fileName );
-   f->SetMaxSizeLoadEntry(0xffff);
+      f->SetMaxSizeLoadEntry(0xffff);
 
       for (int ri=0; ri<forceLoadNb; ri++)
       {
          f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri], 
                                 (uint32_t)elemsToForceLoad[2*ri+1] );
       }
+
 // TODO : find why such a polution
 // To avoid polluting the output with messages
 // 'Last system error was : No such file or directory'
@@ -347,11 +348,12 @@ if (!noex)
       std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
       std::cout << " ------" << std::endl;
 
+
       std::cout << "\n\n" << std::endl; 
       std::cout << "X spacing " << f->GetXSpacing() << std::endl;
       std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
       std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
-    
+   
 //------------------------------
 
       // Let's get and print some usefull fields about 'Orientation'
@@ -407,9 +409,11 @@ if (!noex)
                    << strImagePositionPatientRET << "]" << std::endl;
   
      float iop[6];
-     /*bool riop = */f->GetImageOrientationPatient(iop);  
+     //bool riop = 
+        f->GetImageOrientationPatient(iop);  
      float ipp[3];
-     /*bool ripp = */f->GetImagePositionPatient(ipp);
+     //bool ripp = 
+        f->GetImagePositionPatient(ipp);
 
      std::cout << "Image Position (0x0020,0x0032|0x0030) : "
                << ipp[0] << " , " << ipp[1] << " , "<< ipp[2]
@@ -439,6 +443,8 @@ if (!noex)
       if (ori != "\\" )
          std::cout << "Orientation [" << ori << "]" << std::endl;
       o->Delete();
+      
+      
 /*      
 std::vector <double> valueVector; 
 GDCM_NAME_SPACE::DataEntry *e_0018_5212 = f->GetDataEntry(0x0018, 0x5212);
@@ -452,7 +458,65 @@ if (resJP) {
 }
 //e_0018_5212->Delete();
 */       
-      
+
+
+/* -----------------------------
+
+// Try :
+std::cout << std::endl << std::endl << "===========Try Get Numerical ======="
+          << std::endl;
+GDCM_NAME_SPACE::DataEntry *e;
+bool res;
+std::vector<double> vd;
+
+// Transfert Syntax
+e=f->GetDataEntry(0x0002,0x0010);
+if (e){
+  res=e->GetNumerical(vd);
+  if (!res){
+    std::cout << "0x0002,0x0010 not numerical, size =" << vd.size() << std::endl;  
+  }
+}
+// Columns
+e=f->GetDataEntry(0x0028,0x0011);
+if (e){
+  res=e->GetNumerical(vd);
+  if (!res){
+    std::cout << "0x0028,0x0011 not numerical, size =" << vd.size() << std::endl;  
+  } else {
+    std::cout << "0x0028,0x0011 numerical, size =" << vd.size() << std::endl;
+    std::cout << vd[0]<< std::endl;
+  }
+}
+// Im Orient (Pat)
+e=f->GetDataEntry(0x0020,0x0032);
+if (e){
+  res=e->GetNumerical(vd);
+  if (!res){
+    std::cout << "0x0020,0x0032 not numerical, size =" << vd.size() << std::endl;  
+  } else {
+    std::cout << "0x0020,0x0032 numerical, size =" << vd.size() << std::endl;
+    for(int l=0; l<vd.size(); l++)
+      std::cout << "vd[" << l << "]=" << vd[l]<< std::endl;
+  }
+}
+
+// Pixel Spacing
+
+e=f->GetDataEntry(0x0028,0x0030);
+if (e){
+  res=e->GetNumerical(vd);
+  if (!res){
+    std::cout << "0x0028,0x0030 not numerical, size =" << vd.size() << std::endl;  
+  } else {
+    std::cout << "0x0028,0x0030 numerical, size =" << vd.size() << std::endl;
+    for(int l=0; l<vd.size(); l++)
+      std::cout << "vd[" << l << "]=" << vd[l]<< std::endl;
+  }
+}
+
+----------------------------------------------*/  
+    
 }  
 //------------------------------
 
@@ -681,8 +745,8 @@ if (!noex)
          {
             if (load)  // just to see warning messages at load time !
             {
-               uint8_t *pixels = fh->GetImageData();
-               uint32_t lgth   = fh->GetImageDataSize(); 
+               uint8_t *pixels = fh->GetImageData();     (void)pixels;
+               uint32_t lgth   = fh->GetImageDataSize(); (void)lgth;
             }         
 
             std::cout <<std::endl<<it->c_str()<<" is Readable"<<std::endl;