1 /*=========================================================================
4 Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
6 Date: $Date: 2008/07/29 07:31:13 $
7 Version: $Revision: 1.6 $
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.
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.
17 =========================================================================*/
22 * \brief Defines macros for the creation of vtk object inherited black boxes
24 #ifndef __bbtkVtkBlackBoxMacros_h__
25 #define __bbtkVtkBlackBoxMacros_h__
26 //#include <vtkGarbageCollector.h>
27 //#include <vtkObjectFactory.h>
28 #include <vtkDebugLeaks.h>
31 //===========================================================================
32 //============================================================================
33 // VTK Specific macros
34 //===========================================================================
35 //===========================================================================
38 //===========================================================================
39 #define BBTK_VTK_DELETE() \
41 bbGetOutputOut()->SetSource(NULL); \
42 vtkParent::Delete(); \
45 // bbmDescriptorPointer.reset();
46 //===========================================================================
48 //===========================================================================
49 #define BBTK_VTK_NEW(CLASS,VTKPARENT) \
50 inline static Pointer New(const std::string& name) \
52 vtkDebugLeaks::ConstructClass(#VTKPARENT); \
53 bbtkDebugMessage("object",1,"##> "<<#CLASS \
54 <<"::New(\""<<name<<"\")"<<std::endl); \
55 Pointer p = MakeBlackBoxPointer(new Self(name)); \
56 bbtkDebugMessage("object",1,"<## "<<#CLASS \
57 <<"::New(\""<<name<<"\")"<<std::endl); \
60 //===========================================================================
62 //===========================================================================
63 #define BBTK_VTK_CLONE(CLASS,VTKPARENT) \
64 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
66 vtkDebugLeaks::ConstructClass(#VTKPARENT); \
67 bbtkDebugMessage("object",1,"##> "<<#CLASS \
68 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
69 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
70 bbtkDebugMessage("object",1,"<## "<<#CLASS \
71 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
76 //===========================================================================
77 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT) \
78 BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENTBLACKBOX); \
79 typedef VTKPARENT vtkParent; \
82 BBTK_VTK_NEW(CLASS,VTKPARENT); \
83 BBTK_VTK_CLONE(CLASS,VTKPARENT);
84 //===========================================================================
86 //===========================================================================
87 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
88 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
90 TYPE bbGetInput##NAME () \
91 { return GetImageDataInput(0); /*vtkParent::GetInput();*/ } \
92 void bbSetInput##NAME (TYPE d) \
93 { vtkParent::SetInput( (vtkDataObject*) d); \
94 /*bbSetModifiedStatus();*/ }
95 //===========================================================================
97 //===========================================================================
98 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
99 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
101 TYPE bbGetInput##NAME () \
102 { return GetPolyDataInput(0); /*vtkParent::GetInput();*/ } \
103 void bbSetInput##NAME (TYPE d) \
104 { vtkParent::SetInput( (vtkDataObject*) d); \
105 /*bbSetModifiedStatus();*/ }
106 //===========================================================================
108 //===========================================================================
109 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
110 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
112 TYPE bbGetOutput##NAME () \
113 { return vtkParent::GetOutput(); } \
114 void bbSetOutput##NAME (TYPE d) \
115 { /*vtkParent::GetOutput() = d;*/ }
116 //===========================================================================
118 //===========================================================================
119 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input
120 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
122 TYPE bbGetInput##NAME () \
123 { return dynamic_cast<TYPE>(vtkParent::GetInput()); } \
124 void bbSetInput##NAME (TYPE d) \
125 { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
127 //===========================================================================
129 //===========================================================================
130 /// Declares an AtomicBlackBox input corresponding to an
131 /// inherited vtk parameter
132 /// which was declared by vtkSetMacro/vtkGetMacro
133 /// The NAME **MUST** be the same than the vtk parameter name
134 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
136 TYPE bbGetInput##NAME () \
137 { return vtkParent::Get##NAME(); } \
138 void bbSetInput##NAME (TYPE d) \
139 { vtkParent::Set##NAME(d); \
140 /*bbSetModifiedStatus();*/ }
141 //===========================================================================
145 //============================================================================
146 /// Defines the default bbUserProcess method for vtk inherited black boxes
147 /// (calls vtkParent::Update)
148 #define BBTK_VTK_PROCESS() \
150 inline void bbUserProcess() \
152 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
154 vtkParent::Update(); \
155 bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName() \
158 //============================================================================
161 //===========================================================================
163 //===========================================================================