]> Creatis software - bbtk.git/commitdiff
#2959 BBTK Feature New Normal - new complex box RescaleSlopeIntercept_Interface.bbg
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Fri, 27 May 2016 12:45:36 +0000 (14:45 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Fri, 27 May 2016 12:45:36 +0000 (14:45 +0200)
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h
packages/itk/src/bbitkImageReader.cxx
packages/std/src/bbstdGetSubVector.h
packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbg [new file with mode: 0644]
packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbs [new file with mode: 0644]

index 105e782da39bb023ec4b70cfa860ace18527ff23..550148b057ad8affa7f220bfa146ec2aa8611d42 100644 (file)
@@ -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; i<sizeX; i++)
+       {
+               newImage->SetScalarComponentFromDouble(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;
        }
index 20f8558cf1ebbbb85c200d834877dc299fa7b5f1..a37304beca30d6ecb9562e799de41b3667abbd05 100644 (file)
@@ -65,6 +65,9 @@ class bbgdcmvtk_EXPORT GetXCoherentInfoGdcmReader
   BBTK_PROCESS(Process);
   void Process();
   
+       vtkImageData* CreateDefaultImage();
+
+
   private:
 
 #if defined USE_GDCM
index 0314698579b7700db0c92894aab6029a90781b1b..493fae94d2bc543318e62c5a28600635d5e8afdb 100644 (file)
@@ -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");
-
   }
 
 
index 639aba70d06427f0bee82d2cb47a65b37d8cc122..ec6e861adfb20eedbefecf72675ad21a6ac5bc07 100644 (file)
@@ -78,15 +78,24 @@ namespace bbstd
   template <class T>
   void GetSubVector<T>::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<T> tmpVectResult;
-       if ( (bbGetInputI()<(int)bbGetInputIn().size())  &&  (bbGetInputI()>=0) && (bbGetInputSize()>=1) )
+       if  (bbGetInputSize()>=1) 
        {       
-               for ( i=0 ; i<bbGetInputSize() ; i++)
+               for ( i=iStart ; i<iEnd ; i++)
                {
-                       if ( bbGetInputI()+i<(int)bbGetInputIn().size() ) 
+                       if ( i<(int)bbGetInputIn().size() ) 
                        {
-                               tmpVectResult.push_back( bbGetInputIn()[bbGetInputI()+i] );
+                               tmpVectResult.push_back( bbGetInputIn()[i] );
                        } // if InputI+i
 
                }// for
diff --git a/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbg b/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbg
new file mode 100644 (file)
index 0000000..3a33805
--- /dev/null
@@ -0,0 +1,92 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /tmpEED/creaTools/creatools_source/bbtk/packages/vtk/bbs/boxes/RescaleSlopeIntercept_Interface.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+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 (file)
index 0000000..d4279a3
--- /dev/null
@@ -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 "<VOID>"
+
+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