From: jpr Date: Mon, 20 Mar 2006 14:32:20 +0000 (+0000) Subject: Fix bug while calling new vtkGdcmWrite abilities. X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2d350674e2d48610fafc396a2f68548ca4b32afb;p=gdcm.git Fix bug while calling new vtkGdcmWrite abilities. --- diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index 15f548c2..1ba93f89 100644 --- a/vtk/vtkGdcmWriter.cxx +++ b/vtk/vtkGdcmWriter.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmWriter.cxx,v $ Language: C++ - Date: $Date: 2006/03/17 14:46:18 $ - Version: $Revision: 1.27 $ + Date: $Date: 2006/03/20 14:32:20 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -31,7 +31,7 @@ #define vtkFloatingPointType float #endif -vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.27 $") +vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.28 $") vtkStandardNewMacro(vtkGdcmWriter) //----------------------------------------------------------------------------- @@ -362,13 +362,14 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image) default : dcmFile->SetWriteTypeToDcmExplVR(); } - + + dcmFile->SetContentType((gdcm::ImageContentType)ContentType); + if(!dcmFile->Write(fileName)) { vtkErrorMacro( << "File " << this->FileName << "cannot be written by " << " the gdcm library"); } - // Clean up if( dcmFile->GetUserData() && dcmFile->GetUserDataSize()>0 ) { diff --git a/vtk/vtkWriteDicomExtended.cxx b/vtk/vtkWriteDicomExtended.cxx index 5d36725d..a22667d0 100755 --- a/vtk/vtkWriteDicomExtended.cxx +++ b/vtk/vtkWriteDicomExtended.cxx @@ -18,6 +18,7 @@ #endif #include "gdcmArgMgr.h" // for Argument Manager functions +#include "gdcmFile.h" //---------------------------------------------------------------------------- int main(int argc, char *argv[]) @@ -65,7 +66,7 @@ int main(int argc, char *argv[]) int filecontent = am->ArgMgrGetInt("filecontent", 1); char *filein = am->ArgMgrWantString("filein",usage); - char *fileout = am->ArgMgrWantString("fileout",usage); + char *fileout = (char *)(am->ArgMgrGetString("fileout","fileout")); if (am->ArgMgrDefined("debug")) gdcm::Debug::DebugOn(); @@ -80,11 +81,19 @@ int main(int argc, char *argv[]) return 0; } -// ------------------------------------------------------------ +// ------------------------------------------------------------ + std::vector cfl; + + gdcm::File *f = gdcm::File::New(); + f->SetFileName(filein); + f->Load(); + cfl.push_back(f); vtkGdcmReader *reader = vtkGdcmReader::New(); reader->AllowLookupTableOff(); - reader->SetFileName( argv[1] ); + //reader->SetFileName( filein ); + // in order not to parse twice the input file. + reader->SetCoherentFileList(&cfl); reader->Update(); vtkImageData *output; @@ -123,31 +132,38 @@ int main(int argc, char *argv[]) case 2: writer->SetContentTypeToFilteredImage(); + writer->SetGdcmFile( f ); fileName = fileName + "_FilteredImage.dcm"; break; case 3: writer->SetContentTypeToUserCreatedImage(); - fileName = fileName + "_FilteredImage.dcm"; + writer->SetGdcmFile( f ); + fileName = fileName + "_UserCreatedImage.dcm"; break; case 4: writer->SetContentTypeToUserCreatedImage(); + writer->SetGdcmFile( f ); fileName = fileName + "_UnmodifiedPixelsImage.dcm"; break; } - fileName += ".dcm"; +/// \todo : fix stupid generated image names (later : JPRx) - // For 3D - writer->SetFileDimensionality(3); - writer->SetFileName(fileName.c_str()); if(deuxD) { writer->SetFileDimensionality(2); writer->SetFilePrefix(fileout); writer->SetFilePattern("%s%d.dcm"); } + else + { + fileName += ".dcm"; + // For 3D + writer->SetFileDimensionality(3); + writer->SetFileName(fileName.c_str()); + } writer->SetInput(output); writer->Write();