Program: gdcm
Module: $RCSfile: testBruker2Dicom.cxx,v $
Language: C++
- Date: $Date: 2009/05/27 10:43:07 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2009/06/19 15:51:44 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmArgMgr.h"
#include "bruker2dicom.h"
+#include "brukerexception.h"
// ===================================================================================================
/**
// b2d.day : unused ...
b2d.day = am->ArgMgrGetString("day", "You_forget_the_Day");
-
+ delete am; // we don't need Argument Manager any longer
// ----------- End Arguments Manager ---------
}
*/
+ catch (BrukerHopelessException &e)
+ {
+ std::cout << "And Hopless Exception was thrown (" << e.what() << ") " << std::endl;
+ }
- delete am; // we don't need Argument Manager any longer
}
if (verbose)
printf ("outputDirName [%s]\n", outputDirName);
-
- DealWithNiveau1(*it, outputDirName);
+ try {
+ DealWithNiveau1(*it, outputDirName);
+ }
+ catch (BrukerHopelessException &e)
+ {
+ std::cout << "And Exception was thrown in DealWithNiveau1 (" << e.what() << ") " << std::endl;
+ continue;
+ }
}
} // end of : for (GDCM_NAME_SPACE::DirListType::iterator it
}
canOpen = br_method.LoadFile(strMethod);
if (!canOpen)
{
- std::cout << "Hopeless! neither 'method' nor 'imnd' found" << std::endl;
- throw ( BrukerHopelessException ("Hopeless! neither 'method' nor 'imnd' found "));
+ std::cout << "Hopeless! neither 'method' nor 'imnd' found in ["
+ << level1Directory << "]; we skip it!" << std::endl;
+ continue;
+ //throw ( BrukerHopelessException ("Hopeless! neither 'method' nor 'imnd' found "));
//exit(0); /// \TODO throw an exception !
}
}
##$PVM_SPackArrNSlices=( 2 )
7 1
*/
- DealWithNiveau2(*it,outputDirName );
+ try {
+ DealWithNiveau2(*it,outputDirName );
+ }
+ catch (BrukerHopelessException &e)
+ {
+ std::cout << "And Exception was thrown in DealWithNiveau2 (" << e.what() << ") " << std::endl;
+ continue;
+ }
}
}
}
GDCM_NAME_SPACE::GDCM_FILESEPARATOR,
GDCM_NAME_SPACE::Util::GetName(*it).c_str(),
str_isa_func_name.c_str());
- }
- DealWithNiveau3(*it, outputDirName);
+ }
+ try {
+ DealWithNiveau3(*it, outputDirName);
+ }
+ catch (BrukerHopelessException &e)
+ {
+ std::cout << "And Exception was thrown in DealWithNiveau3 (" << e.what() << "); "
+ << " We skip [" << level2Directory << "]" << std::endl;
+ continue;
+ }
}
}
}
}
catch (BrukerInitException& e)
{
- std::cout << "Exception " << e.what() << std::endl;
- return;
+ std::cout << "an Exception was throw in CreateImageSet ( ); " << e.what()
+ << "catched in DealWithNiveau3" << std::endl;
+ //return;
+ throw (e);
}
serieNumber++;
fp = fopen ( (*it).c_str(), "rb");
if (!fp){
std::cout << "Cannot open [" << *it << "] for reading" << std::endl;
-
+ throw ( BrukerHopelessException ("Level 1 Unable to open 'carto' file "));
}
fread(buffer_carto, NX*NY*sizeof(double), nbSlices, fp);
{
if (verbose)
std::cout << "KO : not a dir : [" << OutputDirName << "] (creation failure ?)" << std::endl;
- return 0;
- /// \todo : THROW AN EXCEPTION
+ //return 0;
+ throw ( BrukerHopelessException ("Level 1 output directory creation failure "));
}
else
{
fileH->SetImageData((uint8_t *)tabPixels, X*Y*nbFrames*pixelSize);
fileH->SetWriteModeToRaw();
fileH->SetWriteTypeToDcmExplVR();
- if( !fileH->Write(dcmImageName))
+ if( !fileH->Write(dcmImageName)) {
std::cout << "Failed for [" << dcmImageName << "]\n"
- << " File is unwrittable" << std::endl;
-
+ << " File is unwrittable" << std::endl;
+ file->Delete();
+ fileH->Delete();
+ throw ( BrukerHopelessException ("Level 1 Unable to write Dicom file "));
+ }
if (verbose)
file->Print();