]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkGetVectorElement.h
no message
[bbtk.git] / packages / vtk / src / bbvtkGetVectorElement.h
index 3bf6996d479a0f2e535107be8b6dd1fa64965496..6993b5cb8fad82ec833f2905618b70a021fb238b 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkGetVectorElement.h,v $
   Language:  C++
-  Date:      $Date: 2010/04/01 15:46:54 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2011/07/02 08:00:36 $
+  Version:   $Revision: 1.2 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -44,7 +44,8 @@ namespace bbvtk
   {  
     BBTK_TEMPLATE_BLACK_BOX_INTERFACE(GetVectorElement,bbtk::AtomicBlackBox,T);
     BBTK_DECLARE_INPUT(In,std::vector<T>);
-    BBTK_DECLARE_INPUT(I,int);    
+    BBTK_DECLARE_INPUT(I,int);
+    BBTK_DECLARE_INPUT(ErrorValue,T);    
     BBTK_DECLARE_OUTPUT(Out,T);
     BBTK_PROCESS(DoIt);
     void DoIt(); 
@@ -61,7 +62,8 @@ namespace bbvtk
   BBTK_DESCRIPTION("Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
   typedef std::vector<T> Tvector;
   BBTK_TEMPLATE_INPUT(GetVectorElement, In,"Input",Tvector);
-  BBTK_TEMPLATE_INPUT(GetVectorElement, I, "Input",int);  
+  BBTK_TEMPLATE_INPUT(GetVectorElement, I, "Input",int);
+  BBTK_TEMPLATE_INPUT(GetVectorElement, ErrorValue, "ErrorValue",T);
   BBTK_TEMPLATE_OUTPUT(GetVectorElement,Out,"Output",T);
   BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorElement);
   //=================================================================
@@ -70,8 +72,13 @@ namespace bbvtk
   template <class T>
   void GetVectorElement<T>::DoIt()
   {
-   // unsigned int i = bbGetInputI();
-    bbSetOutputOut(bbGetInputIn()[bbGetInputI()]);
+         if (( bbGetInputI() < bbGetInputIn().size() )  &&  ( bbGetInputI() >= 0 ) )
+         {
+                 bbSetOutputOut( bbGetInputIn()[bbGetInputI()] );
+         } else
+         {
+                 bbSetOutputOut( bbGetInputErrorValue() );
+         }             
   }
   //=================================================================