]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.cxx
#3448 creaVtk Feature New Normal - ExtractComponents in vector
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkImageExtractComponents.cxx
index 2769f798ee23f5ef242bb9891f5934e2f646f518..4d274db6cce66b378c23f577613cb62f390333ab 100644 (file)
@@ -34,67 +34,95 @@ void ImageExtractComponents::Process()
        bbSetOutputOut2( NULL ); 
        bbSetOutputOut3( NULL ); 
 
-       if (bbGetInputComponent0()!=-1)
-       {
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-               IEC0->SetInput( bbGetInputIn() );
-#else
-               IEC0->SetInputData( bbGetInputIn() );
-#endif
-               IEC0->SetComponents( bbGetInputComponent0() );
-               IEC0->Update();
-               bbSetOutputOut0( IEC0->GetOutput() ); 
-       } 
-
-       if (bbGetInputComponent1()!=-1)
-       {
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-               IEC1->SetInput( bbGetInputIn() );
-#else
-               IEC1->SetInputData( bbGetInputIn() );
-#endif
-               IEC1->SetComponents( bbGetInputComponent1() );
-               IEC1->Update();
-               bbSetOutputOut1( IEC1->GetOutput() ); 
-       }
-
-       if (bbGetInputComponent2()!=-1)
-       {
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-               IEC2->SetInput( bbGetInputIn() );
-#else
-               IEC2->SetInputData( bbGetInputIn() );
-#endif
-               IEC2->SetComponents( bbGetInputComponent2() );
-               IEC2->Update();
-               bbSetOutputOut2( IEC2->GetOutput() ); 
-       }
-
-       if (bbGetInputComponent3()!=-1)
-       {
-
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
-               IEC3->SetInput( bbGetInputIn() );
-#else
-               IEC3->SetInputData( bbGetInputIn() );
-#endif
-               IEC3->SetComponents( bbGetInputComponent2() );
-               IEC3->Update();
-               bbSetOutputOut3( IEC3->GetOutput() ); 
-       }
-
+// InputComponent 0..3
+       if (bbGetInputType()==0)   
+       {    
+       
+                       if (bbGetInputComponent0()!=-1)
+                       {
+               //EED 2017-01-01 Migration VTK7
+               #if VTK_MAJOR_VERSION <= 5
+                               IEC0->SetInput( bbGetInputIn() );
+               #else
+                               IEC0->SetInputData( bbGetInputIn() );
+               #endif
+                               IEC0->SetComponents( bbGetInputComponent0() );
+                               IEC0->Update();
+                               bbSetOutputOut0( IEC0->GetOutput() ); 
+                       } 
+
+                       if (bbGetInputComponent1()!=-1)
+                       {
+               //EED 2017-01-01 Migration VTK7
+               #if VTK_MAJOR_VERSION <= 5
+                               IEC1->SetInput( bbGetInputIn() );
+               #else
+                               IEC1->SetInputData( bbGetInputIn() );
+               #endif
+                               IEC1->SetComponents( bbGetInputComponent1() );
+                               IEC1->Update();
+                               bbSetOutputOut1( IEC1->GetOutput() ); 
+                       }
+
+                       if (bbGetInputComponent2()!=-1)
+                       {
+               //EED 2017-01-01 Migration VTK7
+               #if VTK_MAJOR_VERSION <= 5
+                               IEC2->SetInput( bbGetInputIn() );
+               #else
+                               IEC2->SetInputData( bbGetInputIn() );
+               #endif
+                               IEC2->SetComponents( bbGetInputComponent2() );
+                               IEC2->Update();
+                               bbSetOutputOut2( IEC2->GetOutput() ); 
+                       }
+
+                       if (bbGetInputComponent3()!=-1)
+                       {
+               //EED 2017-01-01 Migration VTK7
+               #if VTK_MAJOR_VERSION <= 5
+                               IEC3->SetInput( bbGetInputIn() );
+               #else
+                               IEC3->SetInputData( bbGetInputIn() );
+               #endif
+                               IEC3->SetComponents( bbGetInputComponent2() );
+                               IEC3->Update();
+                               bbSetOutputOut3( IEC3->GetOutput() ); 
+                       }
+       } // Type 0
+
+// List of components
+       if (bbGetInputType()==1) 
+       {   
+               int i,size=lstIEC.size();
+               for (i=0; i<size; i++)
+               {
+                       lstIEC[i]->Delete();
+               } // for i
+               lstIEC.clear();
+               lstOut.clear();
+               int nrCmp = bbGetInputIn()->GetNumberOfScalarComponents();
+               for (i=0; i<nrCmp; i++)
+               {
+                       vtkImageExtractComponents* IEC;
+                       IEC=vtkImageExtractComponents::New();  
+                       IEC->SetInputData( bbGetInputIn() );
+                       IEC->SetComponents( bbGetInputComponent2() );
+                       IEC->Update();
+                       lstIEC.push_back( IEC);
+                       lstOut.push_back( IEC->GetOutput() );
+                       IEC->Delete();
+               } // for i
+               bbSetOutputLstOut( lstOut ); 
+       } // Type 1
 
 }
+
 //===== 
 // 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 ImageExtractComponents::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
    bbSetInputIn(NULL);
@@ -102,8 +130,9 @@ void ImageExtractComponents::bbUserSetDefaultValues()
    bbSetInputComponent1(-1);
    bbSetInputComponent2(-1);
    bbSetInputComponent3(-1);
-
+   bbSetInputType(0);
 }
+
 //===== 
 // 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)
 //===== 
@@ -125,20 +154,22 @@ void ImageExtractComponents::bbUserInitializeProcessing()
 //===== 
 void ImageExtractComponents::bbUserFinalizeProcessing()
 {
-
 //  THE FINALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should desallocate the internal/output pointers 
 //    if any
-
        IEC0->Delete();  
        IEC1->Delete();  
        IEC2->Delete();  
        IEC3->Delete();  
-
+       int i,size=lstIEC.size();
+       for (i=0; i<size; i++)
+       {
+               lstIEC[i]->Delete();
+       } // for i
+       lstIEC.clear();
 }
 
-
 }
 // EO namespace bbcreaVtk