2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.15 $
34 =========================================================================*/
42 * \brief Defines macros for the creation of vtk object inherited black boxes
44 #ifndef __bbtkVtkBlackBoxMacros_h__
45 #define __bbtkVtkBlackBoxMacros_h__
46 #include <vtkGarbageCollector.h>
47 //#include <vtkObjectFactory.h>
48 #include <vtkDebugLeaks.h>
51 //===========================================================================
52 //============================================================================
53 // VTK Specific macros
54 //===========================================================================
55 //===========================================================================
57 //===========================================================================
58 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKOBJECT) \
59 BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX); \
60 typedef VTKOBJECT bbVtkObject; \
61 bbVtkObject* bbGetVtkObject() { return mVtkObject; } \
63 bbVtkObject *mVtkObject;
65 //===========================================================================
66 #define BBTK_VTK_SET_DEFAULT_VALUES() \
69 //===========================================================================
70 #define BBTK_VTK_INITIALIZE_PROCESSING() \
71 mVtkObject = bbVtkObject::New();
73 //===========================================================================
74 #define BBTK_VTK_FINALIZE_PROCESSING() \
75 if (mVtkObject) { mVtkObject->Delete(); mVtkObject = NULL; }
78 //===========================================================================
79 #define BBTK_VTK_DELETE() \
81 for (int i=0; i<mVtkObject->GetNumberOfInputPorts();++i) \
82 mVtkObject->SetInput(i,0); \
83 bbGetOutputOut()->SetSource(NULL); \
84 int refs = mVtkObject->GetReferenceCount()-1; \
85 mVtkObject->Delete(); \
89 // bbmDescriptorPointer.reset();
90 //===========================================================================
94 //===========================================================================
95 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
96 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
98 TYPE bbGetInput##NAME () \
99 { if (mVtkObject) return mVtkObject->GetImageDataInput(0); return 0; } \
100 void bbSetInput##NAME (TYPE d) \
101 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
103 //===========================================================================
105 //===========================================================================
106 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
107 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
109 TYPE bbGetInput##NAME () \
110 { if (mVtkObject) return mVtkObject->GetPolyDataInput(0); return 0; } \
111 void bbSetInput##NAME (TYPE d) \
112 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
114 //===========================================================================
116 //===========================================================================
117 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
118 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
120 TYPE bbGetOutput##NAME () \
121 { if (mVtkObject) return mVtkObject->GetOutput(); return 0; } \
122 void bbSetOutput##NAME (TYPE d) \
124 //===========================================================================
126 //===========================================================================
127 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input
128 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
130 TYPE bbGetInput##NAME () \
131 { if (mVtkObject) return dynamic_cast<TYPE>(mVtkObject->GetInput()); \
133 void bbSetInput##NAME (TYPE d) \
134 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
136 //===========================================================================
138 //===========================================================================
139 /// Declares an AtomicBlackBox input corresponding to an
140 /// inherited vtk parameter
141 /// which was declared by vtkSetMacro/vtkGetMacro
142 /// The NAME **MUST** be the same than the vtk parameter name
143 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
145 TYPE bbGetInput##NAME () \
146 { if (mVtkObject) return mVtkObject->Get##NAME(); return 0; } \
147 void bbSetInput##NAME (TYPE d) \
148 { if (mVtkObject) mVtkObject->Set##NAME(d); \
150 //===========================================================================
152 //===========================================================================
153 /// Declares an AtomicBlackBox input corresponding to an
154 /// inherited vtk parameter
155 /// which was declared by vtkSetMacro/vtkGetMacro
156 /// The NAME **MUST** be the same than the vtk parameter name
158 #define BBTK_DECLARE_VTK_2_PARAM(NAME,TYPE) \
160 TYPE bbGetInput##NAME () \
162 TO DO : HOW TO RECOMPOSE A VECTOR ?
163 { return mVtkObject->Get##NAME(); } \
164 void bbSetInput##NAME (TYPE d) \
166 mVtkObject->Set##NAME(d[0],d[1]); \
169 //===========================================================================
172 //============================================================================
173 /// Defines the default bbUserProcess method for vtk inherited black boxes
174 /// (calls vtkParent::Update)
175 #define BBTK_VTK_PROCESS() \
177 inline void bbUserProcess() \
179 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \
181 mVtkObject->Update(); \
182 printf("EED Process %s\n", bbGetFullName().c_str() ); \
183 vtkIndent indent(2); \
184 mVtkObject->PrintSelf(std::cout, indent ); \
185 bbtkBlackBoxDebugMessage("process",2,"<** Processing" \
188 //============================================================================
191 //===========================================================================
193 //===========================================================================