From 724236f8156e84f206c497b755135fbdd2ccb889 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 27 May 2016 14:45:36 +0200 Subject: [PATCH] #2959 BBTK Feature New Normal - new complex box RescaleSlopeIntercept_Interface.bbg --- .../bbgdcmvtkGetXCoherentInfoGdcmReader.cxx | 37 +++++++- .../src/bbgdcmvtkGetXCoherentInfoGdcmReader.h | 3 + packages/itk/src/bbitkImageReader.cxx | 7 -- packages/std/src/bbstdGetSubVector.h | 19 +++- .../boxes/RescaleSlopeIntercept_Interface.bbg | 92 +++++++++++++++++++ .../boxes/RescaleSlopeIntercept_Interface.bbs | 55 +++++++++++ 6 files changed, 197 insertions(+), 16 deletions(-) create mode 100644 packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbg create mode 100644 packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs diff --git a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx index 105e782..550148b 100644 --- a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx +++ b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx @@ -48,6 +48,35 @@ namespace bbgdcmvtk BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetXCoherentInfoGdcmReader) BBTK_BLACK_BOX_IMPLEMENTATION(GetXCoherentInfoGdcmReader,bbtk::AtomicBlackBox); + + +vtkImageData* GetXCoherentInfoGdcmReader::CreateDefaultImage() +{ + int i; + int sizeX, sizeY, sizeZ; + sizeX = 200; + sizeY = sizeX; + sizeZ = 1; + vtkImageData *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 + return newImage; +} + + #if defined USE_GDCM void GetXCoherentInfoGdcmReader::Process() { @@ -57,9 +86,10 @@ void GetXCoherentInfoGdcmReader::Process() bool res = f->Load(); if ( !res ) { - f->Delete(); - bbSetOutputOut(0); - return; + printf("EED GetXCoherentInfoGdcmReader::Process resultImage NULL\n"); + f->Delete(); + bbSetOutputOut( CreateDefaultImage() ); + return; } // Get info from the first image file int i; @@ -142,7 +172,6 @@ void GetXCoherentInfoGdcmReader::Process() if ( !res ) { delete read; - printf("EED GetXCoherentInfoGdcmReader::Process resultImage NULL\n"); bbSetOutputOut(NULL); return; } diff --git a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h index 20f8558..a37304b 100644 --- a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h +++ b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h @@ -65,6 +65,9 @@ class bbgdcmvtk_EXPORT GetXCoherentInfoGdcmReader BBTK_PROCESS(Process); void Process(); + vtkImageData* CreateDefaultImage(); + + private: #if defined USE_GDCM diff --git a/packages/itk/src/bbitkImageReader.cxx b/packages/itk/src/bbitkImageReader.cxx index 0314698..493fae9 100644 --- a/packages/itk/src/bbitkImageReader.cxx +++ b/packages/itk/src/bbitkImageReader.cxx @@ -68,9 +68,7 @@ namespace bbitk void ImageReader::Read() { -printf("EED ImageReader::Read start\n"); std::string filename = bbGetInputIn(); - itk::ImageIOBase::Pointer genericReader = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode); @@ -80,13 +78,8 @@ printf("EED ImageReader::Read start\n"); } genericReader->SetFileName(filename.c_str()); genericReader->ReadImageInformation(); - bbtk::TypeInfo typ = GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(genericReader->GetComponentTypeInfo(), genericReader->GetNumberOfDimensions()); - BBTK_TEMPLATE_ITK_IMAGE_SWITCH( typ, Read); - -printf("EED ImageReader::Read end\n"); - } diff --git a/packages/std/src/bbstdGetSubVector.h b/packages/std/src/bbstdGetSubVector.h index 639aba7..ec6e861 100644 --- a/packages/std/src/bbstdGetSubVector.h +++ b/packages/std/src/bbstdGetSubVector.h @@ -78,15 +78,24 @@ namespace bbstd template void GetSubVector::DoIt() { - int i; + int i,iStart,iEnd; + iStart = bbGetInputI(); + iEnd = bbGetInputI() + bbGetInputSize() - 1; + if (iStart<0) { iStart = 0; } + if (iEnd<0) { iEnd = 0; } + if (iStart>bbGetInputIn().size() ) { iStart = bbGetInputIn().size(); } + if (iEnd>bbGetInputIn().size() ) { iEnd = bbGetInputIn().size(); } + + + std::vector tmpVectResult; - if ( (bbGetInputI()<(int)bbGetInputIn().size()) && (bbGetInputI()>=0) && (bbGetInputSize()>=1) ) + if (bbGetInputSize()>=1) { - for ( i=0 ; i +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:TRUE +COMPLEXBOXNAME:RescaleReslopeIntercept_Interface +PACKAGENAME:vtk +COMPLEXOUTPUTS:0 +COMPLEXINPUTS:0 +BOXES:7 +BOX +wx:InputText:Box00 +ISEXEC:FALSE +-30.237120:75.209079:-900.000000 +15.337880:65.209079:-900.000000 +PORT +In:"1" +PORT +Title:"A" +FIN_BOX +BOX +wx:InputText:Box01 +ISEXEC:FALSE +11.558165:60.520810:-900.000000 +57.133165:50.520810:-900.000000 +PORT +In:"0" +PORT +Title:"B" +FIN_BOX +BOX +wx:LayoutLine:Box06 +ISEXEC:TRUE +-20.720869:-38.371979:-900.000000 +36.839131:-48.371979:-900.000000 +FIN_BOX +BOX +wx:ComboBox:Box07 +ISEXEC:FALSE +17.037159:29.469680:-900.000000 +62.612159:19.469680:-900.000000 +PORT +In:"SlopeIntercept(np=A*p+B) Invert Redimension(A=newMin;B=newMax)" +PORT +Title:"Type" +FIN_BOX +BOX +wx:ComboBox:Box08 +ISEXEC:FALSE +35.195304:11.711652:-900.000000 +80.770304:1.711652:-900.000000 +PORT +In:"Same(default) VTK_BIT VTK_CHAR VTK_UNSIGNED_CHAR VTK_INT VTK_UNSIGNED_INT VTK_SHORT VTK_UNSIGNED_SHORT VTK_LONG VTK_UNSIGNED_LONG VTK_FLOAT VTK_DOUBLE" +PORT +Title:"Format" +FIN_BOX +BOX +wx:CommandButton:Box09 +ISEXEC:FALSE +28.395265:-15.962743:-900.000000 +73.970265:-25.962743:-900.000000 +PORT +Label:"Save (*.mhd)" +FIN_BOX +BOX +vtk:RescaleSlopeIntercept:Box10 +ISEXEC:FALSE +-95.009021:6.753468:-900.000000 +-23.834021:-3.246532:-900.000000 +FIN_BOX +CONNECTIONS:5 +CONNECTION +Box00:Widget:Box06:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box01:Widget:Box06:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box07:Widget:Box06:Widget3 +NumberOfControlPoints:0 +CONNECTION +Box09:Widget:Box06:Widget5 +NumberOfControlPoints:0 +CONNECTION +Box08:Widget:Box06:Widget4 +NumberOfControlPoints:0 +APP_END diff --git a/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs b/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs new file mode 100644 index 0000000..d4279a3 --- /dev/null +++ b/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs @@ -0,0 +1,55 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) +# - /tmpEED/creaTools/creatools_source/bbtk/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs +# ---------------------------------- + +include std +include itkvtk +include wx +include vtk + +define RescaleReslopeIntercept_Interface vtk + +author "Author ??" +description "Description ??" + +category "" + +new wx:InputText Box00 + set Box00.In "1" + set Box00.Title "A" + +new wx:InputText Box01 + set Box01.In "0" + set Box01.Title "B" + +new wx:LayoutLine Box06 + +new wx:ComboBox Box07 + set Box07.In "SlopeIntercept(np=A*p+B) Invert Redimension(A=newMin;B=newMax)" + set Box07.Title "Type" + +new wx:ComboBox Box08 + set Box08.In "Same(default) VTK_BIT VTK_CHAR VTK_UNSIGNED_CHAR VTK_INT VTK_UNSIGNED_INT VTK_SHORT VTK_UNSIGNED_SHORT VTK_LONG VTK_UNSIGNED_LONG VTK_FLOAT VTK_DOUBLE" + set Box08.Title "Format" + +new wx:CommandButton Box09 + set Box09.Label "Save (*.mhd)" + +new vtk:RescaleSlopeIntercept Box10 + + +connect Box00.Widget Box06.Widget1 +connect Box01.Widget Box06.Widget2 +connect Box07.Widget Box06.Widget3 +connect Box09.Widget Box06.Widget5 +connect Box08.Widget Box06.Widget4 + +# Complex input ports + +# Complex output ports + +message 0 +exec Box06 + +endefine -- 2.47.1