From: Eduardo DAVILA Date: Thu, 12 Nov 2020 10:06:53 +0000 (+0100) Subject: mhdb X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d285b5ec732ee1bd21d54dcc545eb8b2ab232617;p=bbtk.git mhdb --- diff --git a/packages/vtk/src/bbvtkMetaImageWriter.cxx b/packages/vtk/src/bbvtkMetaImageWriter.cxx index 7478b1d..ee36755 100644 --- a/packages/vtk/src/bbvtkMetaImageWriter.cxx +++ b/packages/vtk/src/bbvtkMetaImageWriter.cxx @@ -7,6 +7,13 @@ #include #include +#include "vtkJSONImageWriter.h" +#include "vtkXMLImageDataWriter.h" +#include "vtkXMLDataSetWriter.h" +#include "vtkDataSetWriter.h" +#include "vtkPDataSetWriter.h" +#include "vtkXMLWriter.h" + namespace bbvtk { @@ -31,17 +38,18 @@ void MetaImageWriter::Save_mhdb( std::string filename , vtkImageData* img ,int int bsz=ceil((double)dim[2]/(double)sizeB); int voi[6]; std::string filenameBlock; + std::string filenameBlockVti; if (filename.substr(filename.size()-5) == ".mhdb") { std::string cmd; - cmd="rm -rf "+filename; +// cmd="rm -rf "+filename; system( cmd.c_str() ); cmd="mkdir "+filename; system( cmd.c_str() ); } std::string fileinfoname=filename+"/info.dat"; - FILE *ff=fopen(fileinfoname.c_str(),"r"); + FILE *ff=fopen(fileinfoname.c_str(),"w"); fprintf(ff,"SizeBlock = %d\n",sizeB); fprintf(ff,"DimSize = %d %d %d\n" , dim[0],dim[1],dim[2] ); fprintf(ff,"ElementType = %d\n", elementType ); @@ -68,14 +76,25 @@ void MetaImageWriter::Save_mhdb( std::string filename , vtkImageData* img ,int extract->UpdateWholeExtent(); extract->Modified(); extract->Update(); + filenameBlock =filename+"/mhdb-"+ std::to_string(i)+"-"+ std::to_string(j)+"-"+ std::to_string(k)+".mha"; vtkMetaImageWriter* w = vtkMetaImageWriter::New(); w->SetInputData( extract->GetOutput() ); w->SetCompression(true); w->SetFileDimensionality(bbGetInputIn()->GetDataDimension()); // NTU - filenameBlock=filename+"/mhdb-"+ std::to_string(i)+"-"+ std::to_string(j)+"-"+ std::to_string(k)+".mhd"; w->SetFileName( filenameBlock.c_str() ); w->Write(); w->Delete(); + + filenameBlockVti=filenameBlock+"-ZLib.vti"; + vtkXMLImageDataWriter *writer = vtkXMLImageDataWriter::New(); + writer->SetDataModeToBinary(); + writer->SetCompressionLevel(5); + writer->SetCompressorTypeToZLib(); + writer->SetFileName( filenameBlockVti.c_str() ); + writer->SetInputData( bbGetInputIn() ); + writer->Write(); + + extract->Delete(); } // for k } // for j