X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FReWrite.cxx;h=677ebdad637754c45218c8002e674b88d3123f81;hb=cffc8d7854830a1307b0dc3f0fa01e813f25265b;hp=ac672f06f28e53daebbd247d1d60cc1977404830;hpb=6431ad8820a924bfddca7707abdf8a537fef61af;p=gdcm.git diff --git a/Example/ReWrite.cxx b/Example/ReWrite.cxx index ac672f06..677ebdad 100644 --- a/Example/ReWrite.cxx +++ b/Example/ReWrite.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: ReWrite.cxx,v $ Language: C++ - Date: $Date: 2007/03/06 10:19:00 $ - Version: $Revision: 1.21 $ + Date: $Date: 2007/05/23 14:18:04 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) " [mode=write mode] [noshadow] [noseq][debug] ", " --> The following line to 'rubout' a burnt-in Patient name ", " [rubout=xBegin,xEnd,yBegin,yEnd [ruboutvalue=n (<255)] ] ", - " --> The 2 following lines, to extract a sub image withon some frames ", + " --> The 2 following lines, to extract a sub image within some frames ", " [ROI=xBegin,xEnd,yBegin,yEnd] ", " [firstframe=beg] [lastframe=end] ", " ", @@ -44,11 +44,12 @@ int main(int argc, char *argv[]) " noshadow : user doesn't want to load Private groups (odd number)", " noseq : user doesn't want to load Sequences ", " rgb : user wants to tranform LUT (if any) to RGB pixels ", + " warning : developper wants to run the program in 'warning mode'", " debug : developper wants to run the program in 'debug mode' ", FINISH_USAGE // ----- Initialize Arguments Manager ------ - gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv); + GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv); if (argc == 1 || am->ArgMgrDefined("usage")) { @@ -74,22 +75,25 @@ int main(int argc, char *argv[]) const char *mode = am->ArgMgrGetString("mode","X"); - int loadMode = gdcm::LD_ALL; + int loadMode = GDCM_NAME_SPACE::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) - loadMode |= gdcm::LD_NOSHADOWSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ; else { if ( am->ArgMgrDefined("noshadow") ) - loadMode |= gdcm::LD_NOSHADOW; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) - loadMode |= gdcm::LD_NOSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSEQ; } bool rgb = ( 0 != am->ArgMgrDefined("RGB") ); if (am->ArgMgrDefined("debug")) - gdcm::Debug::DebugOn(); - + GDCM_NAME_SPACE::Debug::DebugOn(); + + if (am->ArgMgrDefined("warning")) + GDCM_NAME_SPACE::Debug::WarningOn(); + bool fail = false; int *boundVal; int ruboutVal; @@ -142,7 +146,7 @@ int main(int argc, char *argv[]) // ----------- End Arguments Manager --------- - gdcm::File *f = gdcm::File::New(); + GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New(); f->SetLoadMode( loadMode ); f->SetFileName( fileName ); bool res = f->Load(); @@ -160,7 +164,7 @@ int main(int argc, char *argv[]) } - gdcm::FileHelper *fh = gdcm::FileHelper::New(f); + GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f); void *imageData; int dataSize; @@ -213,7 +217,7 @@ int main(int argc, char *argv[]) // Since we just ReWrite the image, we know no modification // was performed on the pixels. // We don't want this image appears as a 'Secondary Captured image' - fh->SetContentType(gdcm::UNMODIFIED_PIXELS_IMAGE); + fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE); /// \todo : think about rubbing out a part of a *multiframe* image! @@ -308,7 +312,7 @@ int main(int argc, char *argv[]) } else { - roiBoundVal = new int(4); + roiBoundVal = new int[4]; roiBoundVal[0] = 0; roiBoundVal[1] = nX-1; roiBoundVal[2] = 0; @@ -321,9 +325,9 @@ int main(int argc, char *argv[]) if (roi || beg != -1 || end != -1) { if (beg == -1) - beg = 0; + beg = 0; if (end == -1) - end = nZ; + end = nZ-1; std::ostringstream str; @@ -344,15 +348,15 @@ int main(int argc, char *argv[]) int lineOffset = roiBoundVal[0]*pixelSize * numberOfScalarComponents; - for (unsigned int frameNb=beg, frameCount=0; frameNb<=end; frameNb++, frameCount++) + for (int frameNb=beg, frameCount=0; frameNb<=end; frameNb++, frameCount++) { - for (unsigned int lineNb=roiBoundVal[2], lineCount=0; lineNb<=roiBoundVal[3]; lineNb++, lineCount++) - { + for (int lineNb=roiBoundVal[2], lineCount=0; lineNb<=roiBoundVal[3]; lineNb++, lineCount++) + { /// \todo increment data pointer, don't multiply so much! memcpy( (void *)(destCopy + frameCount*lgrSubFrame + lineCount*lgrSubLine), (void *)(srcCopy + frameNb*frameSize + lineNb*lineSize + lineOffset ), lgrSubLine); - } + } } // Set the image size @@ -441,3 +445,4 @@ int main(int argc, char *argv[]) return 0; } +