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() \
67 mVtkObject = bbVtkObject::New();
70 //===========================================================================
71 #define BBTK_VTK_INITIALIZE_PROCESSING() \
72 mVtkObject = mVtkObject;
73 // mVtkObject = bbVtkObject::New();
75 //===========================================================================
76 #define BBTK_VTK_FINALIZE_PROCESSING() \
77 if (mVtkObject) { mVtkObject->Delete(); mVtkObject = NULL; }
80 //===========================================================================
81 #define BBTK_VTK_DELETE() \
83 for (int i=0; i<mVtkObject->GetNumberOfInputPorts();++i) \
84 mVtkObject->SetInput(i,0); \
85 bbGetOutputOut()->SetSource(NULL); \
86 int refs = mVtkObject->GetReferenceCount()-1; \
87 mVtkObject->Delete(); \
91 // bbmDescriptorPointer.reset();
92 //===========================================================================
96 //===========================================================================
97 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
98 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
100 TYPE bbGetInput##NAME () \
101 { if (mVtkObject) return mVtkObject->GetImageDataInput(0); return 0; } \
102 void bbSetInput##NAME (TYPE d) \
103 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
105 //===========================================================================
107 //===========================================================================
108 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
109 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
111 TYPE bbGetInput##NAME () \
112 { if (mVtkObject) return mVtkObject->GetPolyDataInput(0); return 0; } \
113 void bbSetInput##NAME (TYPE d) \
114 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
116 //===========================================================================
118 //===========================================================================
119 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
120 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
122 TYPE bbGetOutput##NAME () \
123 { if (mVtkObject) return mVtkObject->GetOutput(); return 0; } \
124 void bbSetOutput##NAME (TYPE d) \
126 //===========================================================================
128 //===========================================================================
129 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input
130 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
132 TYPE bbGetInput##NAME () \
133 { if (mVtkObject) return dynamic_cast<TYPE>(mVtkObject->GetInput()); \
135 void bbSetInput##NAME (TYPE d) \
136 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
138 //===========================================================================
140 //===========================================================================
141 /// Declares an AtomicBlackBox input corresponding to an
142 /// inherited vtk parameter
143 /// which was declared by vtkSetMacro/vtkGetMacro
144 /// The NAME **MUST** be the same than the vtk parameter name
145 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
147 TYPE bbGetInput##NAME () \
148 { if (mVtkObject) return mVtkObject->Get##NAME(); return 0; } \
149 void bbSetInput##NAME (TYPE d) \
150 { if (mVtkObject) mVtkObject->Set##NAME(d); \
152 //===========================================================================
154 //===========================================================================
155 /// Declares an AtomicBlackBox input corresponding to an
156 /// inherited vtk parameter
157 /// which was declared by vtkSetMacro/vtkGetMacro
158 /// The NAME **MUST** be the same than the vtk parameter name
160 #define BBTK_DECLARE_VTK_2_PARAM(NAME,TYPE) \
162 TYPE bbGetInput##NAME () \
164 TO DO : HOW TO RECOMPOSE A VECTOR ?
165 { return mVtkObject->Get##NAME(); } \
166 void bbSetInput##NAME (TYPE d) \
168 mVtkObject->Set##NAME(d[0],d[1]); \
171 //===========================================================================
174 //============================================================================
175 /// Defines the default bbUserProcess method for vtk inherited black boxes
176 /// (calls vtkParent::Update)
177 #define BBTK_VTK_PROCESS() \
179 inline void bbUserProcess() \
181 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \
183 mVtkObject->Update(); \
184 printf("EED Process %s\n", bbGetFullName().c_str() ); \
185 vtkIndent indent(2); \
186 mVtkObject->PrintSelf(std::cout, indent ); \
187 bbtkBlackBoxDebugMessage("process",2,"<** Processing" \
190 //============================================================================
193 //===========================================================================
195 //===========================================================================