]> Creatis software - bbtk.git/blob - kernel/src/bbtkVtkBlackBoxMacros.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkVtkBlackBoxMacros.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkVtkBlackBoxMacros.h,v $
5   Language:  C++
6   Date:      $Date: 2008/05/07 07:26:50 $
7   Version:   $Revision: 1.2 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19
20 /**
21  *  \file 
22  *  \brief Defines macros for the creation of vtk object inherited black boxes
23  */
24 #ifndef __bbtkVtkBlackBoxMacros_h__
25 #define __bbtkVtkBlackBoxMacros_h__
26
27 //===========================================================================
28 //============================================================================
29 // VTK Specific macros
30 //===========================================================================
31 //===========================================================================
32
33
34 //===========================================================================
35 #define BBTK_VTK_DELETE()                                               \
36   void bbDelete() {                                                     \
37     vtkParent::Delete(); }
38
39 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT)    \
40   BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX);                       \
41   typedef VTKPARENT vtkParent;                                          \
42   BBTK_VTK_DELETE();
43
44 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input 
45 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE)               \
46   public:                                                               \
47   TYPE bbGetInput##NAME ()                                              \
48   { return GetImageDataInput(0); /*vtkParent::GetInput();*/ }           \
49   void bbSetInput##NAME (TYPE d)                                        \
50   { vtkParent::SetInput( (vtkDataObject*) d);                           \
51     /*bbSetModifiedStatus();*/ }                                                       
52 //===========================================================================
53 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input 
54 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE)   \
55   public:                                                               \
56   TYPE bbGetInput##NAME ()                                              \
57   { return GetPolyDataInput(0); /*vtkParent::GetInput();*/ }            \
58   void bbSetInput##NAME (TYPE d)                                        \
59   { vtkParent::SetInput( (vtkDataObject*) d);                           \
60     /*bbSetModifiedStatus();*/ }                                                       
61 //===========================================================================
62
63 //===========================================================================
64 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output 
65 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE)                              \
66   public:                                                               \
67   TYPE bbGetOutput##NAME ()                                             \
68   { return vtkParent::GetOutput(); }                                    \
69   void bbSetOutput##NAME (TYPE d)                                       \
70   { /*vtkParent::GetOutput() = d;*/ }                                   
71 //===========================================================================
72
73 //===========================================================================
74 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input 
75 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE)                       \
76   public:                                                               \
77   TYPE bbGetInput##NAME ()                                              \
78   { return dynamic_cast<TYPE>(vtkParent::GetInput()); }                 \
79   void bbSetInput##NAME (TYPE d)                                        \
80   { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
81
82 //===========================================================================
83
84 //===========================================================================
85 /// Declares an AtomicBlackBox input corresponding to an 
86 /// inherited vtk parameter
87 /// which was declared by vtkSetMacro/vtkGetMacro
88 /// The NAME **MUST** be the same than the vtk parameter name
89 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE)                       \
90   public:                                                               \
91   TYPE bbGetInput##NAME ()                                              \
92   { return vtkParent::Get##NAME(); }                                    \
93   void bbSetInput##NAME (TYPE d)                                        \
94   { vtkParent::Set##NAME(d);                                            \
95     /*bbSetModifiedStatus();*/ }
96 //===========================================================================
97
98
99
100 //============================================================================
101 /// Defines the default bbUserProcess method for vtk inherited black boxes
102 /// (calls vtkParent::Update)
103 #define BBTK_VTK_PROCESS()                                              \
104   public:                                                               \
105   inline void bbUserProcess()                                           \
106   {                                                                     \
107     bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName()    \
108                      <<"]"<<std::endl);                                 \
109     vtkParent::Update();                                                \
110     bbGetOutputOut()->SetSource(NULL);                                  \
111     bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName()    \
112                      <<"]"<<std::endl);                                 \
113   }
114 //============================================================================
115
116
117 //===========================================================================
118 /// EOF
119 //===========================================================================
120 #endif