Program: gdcm
Module: $RCSfile: PrintFile.cxx,v $
Language: C++
- Date: $Date: 2007/09/26 08:07:42 $
- Version: $Revision: 1.86 $
+ Date: $Date: 2007/10/01 09:33:20 $
+ Version: $Revision: 1.87 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmOrientation.h"
#include <iostream>
-// TODO : code factorization, for 'single file' an 'whole directory' processing
+/// \todo : code factorization, for 'single file' an 'whole directory' processing
void ShowLutData(GDCM_NAME_SPACE::File *f);
int forceLoadNb;
uint16_t *elemsToForceLoad
= am->ArgMgrGetXInt16Enum("forceload", &forceLoadNb);
-
+
int nbP =0;
uint16_t *FourthDimLoc;
if ( am->ArgMgrDefined("4DLoc") )
// ----------- End Arguments Manager ---------
-
+
if (ddict)
{
- GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->AddDict(dict);
+ GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->AddDict(dict);
}
if ( fileName != 0 ) // ====== Deal with a single file ======
- {
+ {
GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
f->SetLoadMode(loadMode);
f->SetFileName( fileName );
for (int ri=0; ri<forceLoadNb; ri++)
{
f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri],
- (uint32_t)elemsToForceLoad[2*ri+1] );
+ (uint32_t)elemsToForceLoad[2*ri+1] );
}
// TODO : find why such a polution
-// To avoid polluting the output with messages
+// To avoid polluting the output with messages
// 'Last system error was : No such file or directory'
errno = 0;
bool res = f->Load();
// GDCM_NAME_SPACE::File::IsReadable() is no usable here, because we deal with
- // any kind of gdcm-Parsable *document*
+ // any kind of gdcm-Parsable *document*
// not only GDCM_NAME_SPACE::File (as opposed to GDCM_NAME_SPACE::DicomDir)
if ( !res )
{
std::cout << "Cannot process file [" << fileName << "]" << std::endl;
- std::cout << "Either it doesn't exist, or it's read protected "
+ std::cout << "Either it doesn't exist, or it's read protected "
<< std::endl;
- std::cout << "or it's not a Dicom File, or its 'header' is bugged"
+ std::cout << "or it's not a Dicom File, or its 'header' is bugged"
<< std::endl;
std::cout << "use 'PrintFile filein=... debug' to try to guess the pb"
<< std::endl;
f->Delete();
return 0;
}
-
+
if (nbP == 1)
f->SetFourthDimensionLocation(FourthDimLoc[0],FourthDimLoc[1]);
fh->Print();
- std::cout << "\n\n" << std::endl;
+ std::cout << "\n\n" << std::endl;
std::cout <<std::endl;
std::cout <<" dataSize " << fh->GetImageDataSize() << std::endl;
f->Delete();
fh->Delete();
}
- else // ====== Deal with a Directory ======
- {
+ // ===========================================================================
+ else // =============================== Deal with a Directory =====================
+ { // ===========================================================================
std::cout << "dirName [" << dirName << "]" << std::endl;
GDCM_NAME_SPACE::DirList dirList(dirName,rec); // gets recursively (or not) the file list
GDCM_NAME_SPACE::File *f;
bool res;
+ if (fileList.size() == 0)
+ {
+ std::cout << "No file found in : [" << dirName << "]" << std::endl;
+ }
+
for( GDCM_NAME_SPACE::DirListType::iterator it = fileList.begin();
it != fileList.end();
++it )
Program: gdcm
Module: $RCSfile: exMoveImagesToSingleSerieUID.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:05 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2007/10/01 09:33:20 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
if (am->ArgMgrDefined("debug"))
- GDCM_NAME_SPACE::Debug::DebugOn();
- int verbose = am->ArgMgrDefined("verbose");
+ GDCM_NAME_SPACE::Debug::DebugOn();
+
+ bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
std::string patName = am->ArgMgrGetString("patname", "g^PatientName");
float zSpacing = am->ArgMgrGetFloat("zSpacing", 1.0);
- const char *dirIn = am->ArgMgrGetString("dirin");
+ const char *dirIn = am->ArgMgrGetString("dirin");
const char *dirOut = am->ArgMgrGetString("dirout");
-
- int userDefinedStudy = am->ArgMgrDefined("studyUID");
+
+ bool userDefinedStudy = ( 0 != am->ArgMgrDefined("userDefinedStudy") );
const char *studyUID = am->ArgMgrGetString("studyUID");
// not described *on purpose* in the Usage !
- int userDefinedSerie = am->ArgMgrDefined("serieUID");
+ bool userDefinedSerie = ( 0 != am->ArgMgrDefined("userDefinedSerie") );
+
const char *serieUID = am->ArgMgrGetString("serieUID");
int loadMode = GDCM_NAME_SPACE::LD_ALL;
else
strStudyUID = studyUID;
-
// 'Serie Instance UID'
// The user is allowed to create his own Series,
// keeping the same 'Serie Instance UID' for various images
// The user shouldn't add any image to a 'Manufacturer Serie'
// but there is no way no to prevent him for doing that
-
+
std::string strSerieUID;
if ( !userDefinedSerie)
strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
else
strSerieUID = serieUID;
-
+
GDCM_NAME_SPACE::File *f;
GDCM_NAME_SPACE::FileHelper *fh;
std::string fullFilename, lastFilename;
if ( !f->Load() )
{
if (verbose)
- std::cout << "fail to load [" << it->c_str() << "]" << std::endl;
+ std::cout << "fail to load [" << it->c_str() << "]" << std::endl;
f->Delete();
continue;
}
- // Load the pixels in RAM.
-
- fh = GDCM_NAME_SPACE::FileHelper::New(f);
+ // Load the pixels in RAM.
+
+ fh = GDCM_NAME_SPACE::FileHelper::New(f);
+ fh->SetKeepOverlays( true );
uint8_t *imageData = fh->GetImageDataRaw(); // Don't convert (Gray Pixels + LUT) into (RGB pixels) ?!?
if (!imageData)
std::cout << "fail to read [" << it->c_str() << std::endl;
Program: gdcm
Module: $RCSfile: exSerieHelper.cxx,v $
Language: C++
- Date: $Date: 2007/06/22 11:01:57 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2007/10/01 09:33:20 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::cout << "Dir Name :[" << dirName << "]" << std::endl;
//
- // Something, using only SerieHelper is not enought !
+ // Sometimes using only SerieHelper is not enought !
// See also exXcoherentFileSet
//
Program: gdcm
Module: $RCSfile: exXCoherentFileSet.cxx,v $
Language: C++
- Date: $Date: 2007/09/28 14:08:08 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2007/10/01 09:33:20 $
+ Version: $Revision: 1.12 $
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"
-void removeSpecChar(std::string &s);
-
-void removeSpecChar(std::string &s) {
- unsigned int s_size = s.size();
- for(unsigned int i=0; i<s_size; i++)
- {
- if (
- /*while(i<s_size
- && */!( s[i] == '.' || s[i] == '%' || s[i] == '_'
- || (s[i] >= '+' && s[i] <= '-')
- || (s[i] >= 'a' && s[i] <= 'z')
- || (s[i] >= '0' && s[i] <= '9')
- || (s[i] >= 'A' && s[i] <= 'Z')))
- {
- s.replace(i, 1, "_"); // ImagePositionPatient related stuff will be more human readable
- }
- }
-
- // deal with Dicom strings trailing '\0'
- if(s[s_size-1] == '_')
- s.erase(s_size-1, 1);
-
-}
int main(int argc, char *argv[])
{
std::string xCoherentName = "";
std::string serieDirectory;
std::string lastFilename;
-
- int controlCount = 0;
+ std::string rep("_");
+ int controlCount = 0;
+
while (l) // for each 'Single SerieUID FileSet'
{
nbFiles = l->size() ;
// Why not ? Just an example, for testing!
{
serieUID = s->GetCurrentSerieUIDFileSetUID();
- removeSpecChar(serieUID);
+ GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
// --- for write
if (write)
xcm = s->SplitOnOrientation(l);
else if (pos)
xcm = s->SplitOnPosition(l);
- else if (groupelem != 0)
+ else if (groupelem != 0) {
xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] );
+ }
for (GDCM_NAME_SPACE::XCoherentFileSetmap::iterator i = xcm.begin();
i != xcm.end();
xCoherentName = (*i).first;
if (verbose)
std::cout << "xCoherentName = " << xCoherentName << std::endl;
- removeSpecChar(xCoherentName);
+ GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep);
// --- for write
if (write)
{
systemCommand = "mkdir " + xCoherentWriteDir;
system( systemCommand.c_str());
if (verbose)
- std::cout << "2 " << systemCommand << std::endl;
+ std::cout << systemCommand << std::endl;
}
}
// --- end for write