2 // 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)
4 #include "bbcreaVtkReadMHDPlane.h"
5 #include "bbcreaVtkPackage.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ReadMHDPlane)
13 BBTK_BLACK_BOX_IMPLEMENTATION(ReadMHDPlane,bbtk::AtomicBlackBox);
15 // 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)
17 void ReadMHDPlane::Process()
20 // THE MAIN PROCESSING METHOD BODY
21 // Here we simply set the input 'In' value to the output 'Out'
22 // And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 // void bbSet{Input|Output}NAME(const TYPE&)
25 // const TYPE& bbGet{Input|Output}NAME() const
27 // * NAME is the name of the input/output
28 // (the one provided in the attribute 'name' of the tag 'input')
29 // * TYPE is the C++ type of the input/output
30 // (the one provided in the attribute 'type' of the tag 'input')
32 // bbSetOutputOut( bbGetInputIn() );
33 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
38 long int newHeaderSize;
39 std::string newFileName=bbGetInputFileName()+"-OneSlice";
44 FILE *ffOut = fopen(newFileName.c_str(),"w+");
45 FILE *ffIn = fopen(bbGetInputFileName().c_str(),"r+");
49 strcpy(mystring,"\n");
50 fgets(mystring,250,ffIn);
51 if (strncmp("NDims",mystring,5)==0) {strcpy(mystring,"NDims = 2\n");}
52 if (strncmp("DimSize",mystring,6)==0)
54 sscanf(mystring,"%s %s %d %d",strTmp, strTmp, &sx, &sy);
55 sprintf(mystring,"DimSize = %d %d\n",sx,sy);
56 newHeaderSize = sx*sy*bbGetInputSlice();
58 if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; }
59 if (strncmp("ElementType = MET_SHORT",mystring,23)==0) { newHeaderSize=newHeaderSize*2; }
60 if (strncmp("ElementType = MET_FLOAT",mystring,23)==0) { newHeaderSize=newHeaderSize*2; }
61 if (strncmp("Offset",mystring,6)==0) {strcpy(mystring,"Offset = 0 0 0\n");}
62 if (strncmp("HeaderSize",mystring,10)==0) {strcpy(mystring,"");}
63 if (strncmp("ElementDataFile",mystring,15)==0)
65 fprintf(ffOut,"HeaderSize = %ld\n\n", newHeaderSize );
67 fprintf(ffOut,mystring);
71 fprintf(ff,"ObjectType = Image\n");
72 fprintf(ff,"NDims = 2\n");
73 fprintf(ff,"BinaryData = True\n");
74 fprintf(ff,"BinaryDataByteOrderMSB = False\n");
75 fprintf(ff,"CompressedData = False\n");
76 fprintf(ff,"TransformMatrix = 1 0 0 0 1 0 0 0 1\n");
77 fprintf(ff,"CenterOfRotation = 0 0 0\n");
78 fprintf(ff,"ElementSpacing = 0.7 0.7 0.7\n");
79 fprintf(ff,"DimSize = 512 512\n");
80 fprintf(ff,"AnatomicalOrientation = ???\n");
81 fprintf(ff,"ElementType = MET_SHORT\n");
82 fprintf(ff,"ElementNumberOfChannels = 1\n");
83 fprintf(ff,"Offset = 0 0 0\n");
84 fprintf(ff,"HeaderSize = %ld\n", newHeaderSize );
85 fprintf(ff,"ElementDataFile = inspi1_ana.raw\n");
92 vtkMetaImageReader * reader = vtkMetaImageReader::New();
93 reader->SetFileName( newFileName.c_str() );
96 bbSetOutputOut( reader->GetOutput() );
101 // 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)
103 void ReadMHDPlane::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
108 bbSetInputFileName("");
113 // 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)
115 void ReadMHDPlane::bbUserInitializeProcessing()
118 // THE INITIALIZATION METHOD BODY :
120 // but this is where you should allocate the internal/output pointers
126 // 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)
128 void ReadMHDPlane::bbUserFinalizeProcessing()
131 // THE FINALIZATION METHOD BODY :
133 // but this is where you should desallocate the internal/output pointers
138 // EO namespace bbcreaVtk