]> Creatis software - gdcm.git/blobdiff - Example/RawToDicom.cxx
Avoid segfault when Patient Name is missing
[gdcm.git] / Example / RawToDicom.cxx
index e39dc41673751ada4431adaf88445a51cbc8e306..db6f3c2c58284c45ca5974ee00e22ca01805a3ff 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: RawToDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/07/05 13:17:26 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2008/06/03 10:01:14 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
    const char *inputFileName  = am->ArgMgrGetString("filein");
    const char *outputFileName = am->ArgMgrGetString("fileout");
    
-   const char *patientName = am->ArgMgrGetString("patientname");
+  const char *patientName = am->ArgMgrGetString("patientname", "g^Fantomas");
    
    int nX = am->ArgMgrWantInt("rows", usage);
    int nY = am->ArgMgrWantInt("lines", usage);
@@ -114,14 +114,15 @@ int main(int argc, char *argv[])
       
    if (am->ArgMgrDefined("debug"))
       GDCM_NAME_SPACE::Debug::DebugOn();
+   bool userDefinedStudy = ( 0 != am->ArgMgrDefined("studyUID") );
 
-   bool userDefinedStudy = am->ArgMgrDefined("studyUID");
    const char *studyUID;
    if (userDefinedStudy)
       studyUID  = am->ArgMgrGetString("studyUID");  
 
-   // not described *on purpose* in the Usage !    
-   bool userDefinedSerie = am->ArgMgrDefined("serieUID");   
+   // not described *on purpose* in the Usage !
+   bool userDefinedSerie = ( 0 != am->ArgMgrDefined("serieUID") );       
+
    const char *serieUID;
    if(userDefinedSerie)
       serieUID = am->ArgMgrGetString("serieUID");
@@ -192,7 +193,7 @@ int main(int argc, char *argv[])
       return 1;
    }
  
-    std::string strStudyUID;
+   std::string strStudyUID;
    std::string strSerieUID;
 
    if (userDefinedStudy)
@@ -222,8 +223,6 @@ int main(int argc, char *argv[])
  
  // Get the (empty) image header.  
    GDCM_NAME_SPACE::File *fileToBuild = fileH->GetFile();
-     
-   
 
    // 'Study Instance UID'
    // The user is allowed to create his own Study,