]> 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/09 10:39:46 $
7   Version:   $Revision: 1.4 $
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 #include <vtkGarbageCollector.h>
27
28
29 //===========================================================================
30 //============================================================================
31 // VTK Specific macros
32 //===========================================================================
33 //===========================================================================
34
35
36 //===========================================================================
37 #define BBTK_VTK_DELETE()                                               \
38   void bbDelete() {                                                     \
39     bbGetOutputOut()->SetSource(NULL);                                  \
40     vtkParent::Delete();                                                \
41   }
42
43 //    bbmDescriptorPointer.reset();                                     \
44
45 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT)    \
46   BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX);                       \
47   typedef VTKPARENT vtkParent;                                          \
48   BBTK_VTK_DELETE();
49
50 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input 
51 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE)               \
52   public:                                                               \
53   TYPE bbGetInput##NAME ()                                              \
54   { return GetImageDataInput(0); /*vtkParent::GetInput();*/ }           \
55   void bbSetInput##NAME (TYPE d)                                        \
56   { vtkParent::SetInput( (vtkDataObject*) d);                           \
57     /*bbSetModifiedStatus();*/ }                                                       
58 //===========================================================================
59 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input 
60 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE)   \
61   public:                                                               \
62   TYPE bbGetInput##NAME ()                                              \
63   { return GetPolyDataInput(0); /*vtkParent::GetInput();*/ }            \
64   void bbSetInput##NAME (TYPE d)                                        \
65   { vtkParent::SetInput( (vtkDataObject*) d);                           \
66     /*bbSetModifiedStatus();*/ }                                                       
67 //===========================================================================
68
69 //===========================================================================
70 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output 
71 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE)                              \
72   public:                                                               \
73   TYPE bbGetOutput##NAME ()                                             \
74   { return vtkParent::GetOutput(); }                                    \
75   void bbSetOutput##NAME (TYPE d)                                       \
76   { /*vtkParent::GetOutput() = d;*/ }                                   
77 //===========================================================================
78
79 //===========================================================================
80 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input 
81 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE)                       \
82   public:                                                               \
83   TYPE bbGetInput##NAME ()                                              \
84   { return dynamic_cast<TYPE>(vtkParent::GetInput()); }                 \
85   void bbSetInput##NAME (TYPE d)                                        \
86   { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
87
88 //===========================================================================
89
90 //===========================================================================
91 /// Declares an AtomicBlackBox input corresponding to an 
92 /// inherited vtk parameter
93 /// which was declared by vtkSetMacro/vtkGetMacro
94 /// The NAME **MUST** be the same than the vtk parameter name
95 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE)                       \
96   public:                                                               \
97   TYPE bbGetInput##NAME ()                                              \
98   { return vtkParent::Get##NAME(); }                                    \
99   void bbSetInput##NAME (TYPE d)                                        \
100   { vtkParent::Set##NAME(d);                                            \
101     /*bbSetModifiedStatus();*/ }
102 //===========================================================================
103
104
105
106 //============================================================================
107 /// Defines the default bbUserProcess method for vtk inherited black boxes
108 /// (calls vtkParent::Update)
109 #define BBTK_VTK_PROCESS()                                              \
110   public:                                                               \
111   inline void bbUserProcess()                                           \
112   {                                                                     \
113     bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName()    \
114                      <<"]"<<std::endl);                                 \
115     vtkParent::Update();                                                \
116     bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName()    \
117                      <<"]"<<std::endl);                                 \
118   }
119 //============================================================================
120
121
122 //===========================================================================
123 /// EOF
124 //===========================================================================
125 #endif