BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MetaImageReader)
BBTK_BLACK_BOX_IMPLEMENTATION(MetaImageReader,bbtk::AtomicBlackBox);
+
+
+void MetaImageReader::Read_mhdb( std::string filename )
+{
+ printf("EED MetaImageReader::Read_mhdb \n");
+}
+
+
//=====
// 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)
//=====
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
- FILE *ff=fopen(bbGetInputIn().c_str(),"r");
- if (ff)
- {
- fclose(ff);
- vtkMetaImageReader *reader = vtkMetaImageReader::New();
- reader->SetFileName(bbGetInputIn().c_str());
- reader->Update();
- bbSetOutputOut(reader->GetOutput());
+ if (bbGetInputIn().substr(bbGetInputIn().size()-5) == ".mhdb")
+ {
+ Read_mhdb( bbGetInputIn() );
} else {
+ FILE *ff = fopen( bbGetInputIn().c_str() , "r" );
+ if (ff)
+ {
+ fclose(ff);
+ vtkMetaImageReader *reader = vtkMetaImageReader::New();
+ reader->SetFileName( bbGetInputIn().c_str() );
+ reader->Update();
+ bbSetOutputOut( reader->GetOutput() );
+ } else {
bbSetOutputOut(NULL);
- }
+ } // ff
+ }// .mhdb
}
+
//=====
// 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)
//=====
int i,j,k;
int ext[6];
int dim[3];
+ int elementType=img->GetScalarType();
+
img->GetExtent(ext);
dim[0]=ext[1]-ext[0]+1;
dim[1]=ext[3]-ext[2]+1;
- dim[2]=ext[5]-ext[4]+1;
-
+ dim[2]=ext[5]-ext[4]+1;
int bsx=ceil((double)dim[0]/(double)sizeB);
int bsy=ceil((double)dim[1]/(double)sizeB);
int bsz=ceil((double)dim[2]/(double)sizeB);
int voi[6];
std::string filenameBlock;
+ if (filename.substr(filename.size()-5) == ".mhdb")
+ {
+ std::string cmd;
+ 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");
+ 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 );
+ fclose(ff);
+
for (i=0;i<bsx;i++)
{
for (j=0;j<bsy;j++)
w->SetInputData( extract->GetOutput() );
w->SetCompression(true);
w->SetFileDimensionality(bbGetInputIn()->GetDataDimension()); // NTU
- filenameBlock=filename+"/a-"+ std::to_string(i)+"-"+ std::to_string(j)+"-"+ std::to_string(k)+".mhd";
-// printf("EED MetaImageWriter::Save_mhdb name = %s \n", filenameBlock.c_str() );
+ 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();
void MetaImageWriter::Process()
{
+printf("EED vtkMetaImageWriter::Process START\n");
+
// THE MAIN PROCESSING METHOD BODY
// Here we simply set the input 'In' value to the output 'Out'
// And print out the output value
// * TYPE is the C++ type of the input/output
// (the one provided in the attribute 'type' of the tag 'input')
-
//EED 2017-01-01 Migration VTK7
#if VTK_MAJOR_VERSION <= 5
bbGetInputIn()->Update();
#else
// ...
#endif
-
std::string userGivenName = bbGetInputFilename();
if (bbGetInputIn()!=NULL)
{
if (userGivenName.substr(userGivenName.size()-5) == ".mhdb")
{
- printf("EED vtkMetaImageWriter::Process block..ups\n");
-
- Save_mhdb( userGivenName , bbGetInputIn() , 40 );
-
+ Save_mhdb( userGivenName , bbGetInputIn() , bbGetInputSizeBlock() );
} else {
if (userGivenName.substr(userGivenName.size()-4) != ".mhd") //JPR
{
w->Delete();
} // .mhdb
} // bbGetInputIn()!=NULL
-
printf("EED vtkMetaImageWriter::Process END\n");
}
//=====
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
bbSetInputCompression(false);
-
+ bbSetInputSizeBlock(20);
}
//=====
// 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)
BBTK_DECLARE_INPUT(In,vtkImageData*);
BBTK_DECLARE_INPUT(Filename,std::string);
BBTK_DECLARE_INPUT(Compression,bool);
+ BBTK_DECLARE_INPUT(SizeBlock,int);
// BBTK_DECLARE_OUTPUT(Out,double);
BBTK_PROCESS(Process);
void Process();
BBTK_INPUT(MetaImageWriter,In,"Input image",vtkImageData*,"");
BBTK_INPUT(MetaImageWriter,Filename,"Name of the file to write",std::string,"file name");
BBTK_INPUT(MetaImageWriter,Compression,"default(false) true/false",bool,"");
+ BBTK_INPUT(MetaImageWriter,SizeBlock,"(default 50) Size block (for .mhdb format)",int,"");
//BBTK_OUTPUT(MetaImageWriter,Out,"First output",double,"");