X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vtk%2FvtkWriteDicom.cxx;h=a67cbe79058286e0c7226efea323b90048e039dc;hb=76ac46b16fd92d0fb444f786d4946424d9029315;hp=19452b26fb63411aa1b54a8ea657355c9cdd52ee;hpb=2ca09ddbc04e1ec02aa49e8815925cceb49b2402;p=gdcm.git diff --git a/vtk/vtkWriteDicom.cxx b/vtk/vtkWriteDicom.cxx index 19452b26..a67cbe79 100644 --- a/vtk/vtkWriteDicom.cxx +++ b/vtk/vtkWriteDicom.cxx @@ -20,18 +20,14 @@ //---------------------------------------------------------------------------- int main(int argc, char *argv[]) { - if( argc < 2 ) + if( argc < 3 ) + { return 0; + } vtkGdcmReader *reader = vtkGdcmReader::New(); reader->AllowLookupTableOff(); - - if( argc == 2 ) - reader->SetFileName( argv[1] ); - else - for(int i=1; i< argc; i++) - reader->AddFileName( argv[i] ); - + reader->SetFileName( argv[1] ); reader->Update(); vtkImageData *output; @@ -51,17 +47,30 @@ int main(int argc, char *argv[]) } //print debug info: - output->Print( cout ); + output->Print(cout); ////////////////////////////////////////////////////////// // WRITE... //if you wish you can export dicom to a vtk file // this file will have the add of .tmp.dcm extention - std::string fileName = argv[1]; - fileName += ".tmp.dcm"; + std::string fileName = argv[2]; + fileName += ".dcm"; vtkGdcmWriter *writer = vtkGdcmWriter::New(); + + // For 3D + writer->SetFileDimensionality(3); writer->SetFileName(fileName.c_str()); + if(argc >= 4) + { + if( strcmp(argv[3],"2D" )==0 ) + { + writer->SetFileDimensionality(2); + writer->SetFilePrefix(argv[2]); + writer->SetFilePattern("%s%d.dcm"); + } + } + writer->SetInput(output); writer->Write(); //////////////////////////////////////////////////////////