+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbcreaVtksave_YZ_XZ_volume.h"
+#include "bbcreaVtkPackage.h"
+
+#include "vtkMetaImageReader.h"
+#include "vtkMetaImageWriter.h"
+#include "vtkImageData.h"
+#include "creaVtk_MACROS.h"
+
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,save_YZ_XZ_volume)
+BBTK_BLACK_BOX_IMPLEMENTATION(save_YZ_XZ_volume,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void save_YZ_XZ_volume::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+ FILE *ff = fopen(bbGetInputFileName().c_str(),"r");
+ if (ff!=NULL)
+ {
+ fclose(ff);
+ vtkMetaImageReader *reader=vtkMetaImageReader::New();
+ reader->SetFileName(bbGetInputFileName().c_str());
+ reader->Update();
+ vtkImageData *image = reader->GetOutput();
+ int dim[3];
+ int ext[6];
+ image->GetExtent(ext);
+ dim[0] = ext[1]-ext[0]+1;
+ dim[1] = ext[3]-ext[2]+1;
+ dim[2] = ext[5]-ext[4]+1;
+ double spc[3];
+ image->GetSpacing(spc);
+
+ vtkImageData *newImageYZ = vtkImageData::New();
+ newImageYZ->Initialize();
+ newImageYZ->SetSpacing( spc[1],spc[2],spc[0] );
+ newImageYZ->SetDimensions( dim[1],dim[2], dim[0] );
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ newImageYZ->SetScalarType( image->GetScalarType() );
+ newImageYZ->SetNumberOfScalarComponents(1);
+ newImageYZ->AllocateScalars();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ newImageYZ->AllocateScalars( image->GetScalarType(),1 );
+#endif
+
+ vtkImageData *newImageZX = vtkImageData::New();
+ newImageZX->Initialize();
+ newImageZX->SetSpacing( spc[0],spc[2],spc[1] );
+ newImageZX->SetDimensions( dim[0],dim[2], dim[1] );
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ newImageZX->SetScalarType( image->GetScalarType() );
+ newImageZX->SetNumberOfScalarComponents(1);
+ newImageZX->AllocateScalars();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ newImageZX->AllocateScalars( image->GetScalarType(),1 );
+#endif
+
+ DEF_POINTER_IMAGE_VTK_CREA(imageV,imageSS,imageP,imageST,image)
+ DEF_POINTER_IMAGE_VTK_CREA(newImageYZ_V,newImageYZ_SS,newImageYZ_P,newImageYZ_ST,newImageYZ)
+ DEF_POINTER_IMAGE_VTK_CREA(newImageZX_V,newImageZX_SS,newImageZX_P,newImageZX_ST,newImageZX)
+ long int newImageYZ_index;
+ long int newImageZX_index;
+
+ int i,j,k;
+// double value;
+ for (k=0;k<dim[2];k++)
+ {
+ for (j=0;j<dim[1];j++)
+ {
+ for (i=0;i<dim[0];i++)
+ {
+// value = image->GetScalarComponentAsDouble (i,j,k,0);
+ GETVALUE_VTK_CREA(imageV,imageP,imageST)
+ imageP=imageP+imageSS;
+
+// newImageYZ->SetScalarComponentFromDouble( j , dim[2]-k-1 , i , 0 , value );
+ newImageYZ_index=j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2];
+ SETVALUE2_VTK_CREA(imageV,newImageYZ_P,newImageYZ_ST,newImageYZ_index)
+
+// newImageZX->SetScalarComponentFromDouble( i , dim[2]-k-1 , j , 0 ,value );
+ newImageZX_index=i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2];
+ SETVALUE2_VTK_CREA(imageV,newImageZX_P,newImageZX_ST,newImageZX_index)
+ } // for i
+ } // for j
+ } // for k
+
+ //-- Split FileName
+ std::size_t found = bbGetInputFileName().find_last_of("/\\");
+ std::string path = bbGetInputFileName().substr(0,found+1);
+ std::string filename = bbGetInputFileName().substr(found+1);
+#ifdef _WIN32
+ path=path+"YZ_ZX\\";
+#else
+ path=path+"YZ_ZX/";
+#endif
+ std::string command_mkdir = "mkdir "+path;
+ system(command_mkdir.c_str());
+ std::string newFileNameYZ = path+filename+"_YZ.mhd";
+ std::string newFileNameZX = path+filename+"_ZX.mhd";
+
+ //-- Save _YZ
+ vtkMetaImageWriter * writerYZ = vtkMetaImageWriter::New();
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ writerYZ->SetInput(newImageYZ);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ writerYZ->SetInputData(newImageYZ);
+#endif
+ writerYZ->SetFileName(newFileNameYZ.c_str());
+ writerYZ->SetCompression( bbGetInputCompression() );
+ writerYZ->Write();
+
+ //-- Save _ZX
+ vtkMetaImageWriter * writerZX = vtkMetaImageWriter::New();
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ writerZX->SetInput(newImageZX);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ writerZX->SetInputData(newImageZX);
+#endif
+ writerZX->SetFileName(newFileNameZX.c_str());
+ writerZX->SetCompression( bbGetInputCompression() );
+ writerZX->Write();
+
+ } else {
+ printf("EED Save-YZ-XZ-planes::Process %s Not Exist!\n", bbGetInputFileName().c_str() );
+ }
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void save_YZ_XZ_volume::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputFileName("");
+ bbSetInputCompression( false );
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void save_YZ_XZ_volume::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void save_YZ_XZ_volume::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbcreaVtk
+
+