]> Creatis software - bbtk.git/commitdiff
mhdb
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 12 Nov 2020 10:06:53 +0000 (11:06 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 12 Nov 2020 10:06:53 +0000 (11:06 +0100)
packages/vtk/src/bbvtkMetaImageWriter.cxx

index 7478b1da0fd48a1fc6659d127ac0696c43aad320..ee36755520ce11670fa6acf0a97fc3095d9a9b0e 100644 (file)
@@ -7,6 +7,13 @@
 #include <vtkExtractVOI.h> 
 #include <vtkMetaImageWriter.h> 
 
+#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