//===== // 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 "bbcreaVtkReadMHDPlane.h" #include "bbcreaVtkPackage.h" #include "stdio.h" namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ReadMHDPlane) BBTK_BLACK_BOX_IMPLEMENTATION(ReadMHDPlane,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 ReadMHDPlane::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') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <=sz) {ok=false;} } // if if (strncmp("ElementType = MET_CHAR",mystring,22)==0) { newHeaderSize=newHeaderSize*1; } if (strncmp("ElementType = MET_UCHAR",mystring,23)==0) { newHeaderSize=newHeaderSize*1; } if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; } if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; } if (strncmp("ElementType = MET_SHORT",mystring,23)==0) { newHeaderSize=newHeaderSize*2; } if (strncmp("ElementType = MET_FLOAT",mystring,23)==0) { newHeaderSize=newHeaderSize*4; } if (strncmp("ElementType = VTK_FLOAT",mystring,23)==0) { newHeaderSize=newHeaderSize*4; } if (strncmp("Offset",mystring,6)==0) {strcpy(mystring,"Offset = 0 0 0\n");} if (strncmp("HeaderSize",mystring,10)==0) {strcpy(mystring,"");} if (strncmp("ElementDataFile",mystring,15)==0) { fprintf(ffOut,"HeaderSize = %ld\n\n", newHeaderSize ); } // if fprintf(ffOut,mystring); } // while fclose(ffIn); fclose(ffOut); if (ok==true) { vtkMetaImageReader * reader = vtkMetaImageReader::New(); reader->SetFileName( newFileName.c_str() ); reader->Update(); newImage = reader->GetOutput(); } // if ok } else { ok=false; printf("EED ERROR: Problem openin:%s\n", inputfilename.c_str() ); } if (ok==false) { int i; int sizeX, sizeY, sizeZ; sizeX = 200; sizeY = sizeX; sizeZ = 1; newImage = vtkImageData::New(); newImage->Initialize(); newImage->SetScalarTypeToUnsignedChar(); newImage->SetSpacing( 1,1,1 ); newImage->SetDimensions( sizeX,sizeY,sizeZ ); newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); newImage->SetExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); newImage->SetNumberOfScalarComponents(1); newImage->AllocateScalars(); newImage->Update(); memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 ); for (i=0; iSetScalarComponentFromDouble(i,i,0, 0, 255 ); newImage->SetScalarComponentFromDouble(i,sizeY-1-i,0, 0, 255 ); } // for i } // if ok bbSetOutputOut( newImage ); } //===== // 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 ReadMHDPlane::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputFileName(""); bbSetInputSlice(0); bbSetInputDirectionPlane("XY"); } //===== // 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 ReadMHDPlane::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 ReadMHDPlane::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk