1 /*=========================================================================
3 Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
5 Date: $Date: 2008/10/17 08:18:14 $
6 Version: $Revision: 1.7 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
35 * \brief Defines macros for the creation of vtk object inherited black boxes
37 #ifndef __bbtkVtkBlackBoxMacros_h__
38 #define __bbtkVtkBlackBoxMacros_h__
39 //#include <vtkGarbageCollector.h>
40 //#include <vtkObjectFactory.h>
41 #include <vtkDebugLeaks.h>
44 //===========================================================================
45 //============================================================================
46 // VTK Specific macros
47 //===========================================================================
48 //===========================================================================
51 //===========================================================================
52 #define BBTK_VTK_DELETE() \
54 bbGetOutputOut()->SetSource(NULL); \
55 vtkParent::Delete(); \
58 // bbmDescriptorPointer.reset();
59 //===========================================================================
61 //===========================================================================
62 #define BBTK_VTK_NEW(CLASS,VTKPARENT) \
63 inline static Pointer New(const std::string& name) \
65 vtkDebugLeaks::ConstructClass(#VTKPARENT); \
66 bbtkDebugMessage("object",1,"##> "<<#CLASS \
67 <<"::New(\""<<name<<"\")"<<std::endl); \
68 Pointer p = MakeBlackBoxPointer(new Self(name)); \
69 bbtkDebugMessage("object",1,"<## "<<#CLASS \
70 <<"::New(\""<<name<<"\")"<<std::endl); \
73 //===========================================================================
75 //===========================================================================
76 #define BBTK_VTK_CLONE(CLASS,VTKPARENT) \
77 inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
79 vtkDebugLeaks::ConstructClass(#VTKPARENT); \
80 bbtkDebugMessage("object",1,"##> "<<#CLASS \
81 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
82 Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
83 bbtkDebugMessage("object",1,"<## "<<#CLASS \
84 <<"::bbClone(\""<<name<<"\")"<<std::endl); \
89 //===========================================================================
90 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT) \
91 BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENTBLACKBOX); \
92 typedef VTKPARENT vtkParent; \
95 BBTK_VTK_NEW(CLASS,VTKPARENT); \
96 BBTK_VTK_CLONE(CLASS,VTKPARENT);
97 //===========================================================================
99 //===========================================================================
100 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
101 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
103 TYPE bbGetInput##NAME () \
104 { return GetImageDataInput(0); /*vtkParent::GetInput();*/ } \
105 void bbSetInput##NAME (TYPE d) \
106 { vtkParent::SetInput( (vtkDataObject*) d); \
107 /*bbSetModifiedStatus();*/ }
108 //===========================================================================
110 //===========================================================================
111 /// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
112 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
114 TYPE bbGetInput##NAME () \
115 { return GetPolyDataInput(0); /*vtkParent::GetInput();*/ } \
116 void bbSetInput##NAME (TYPE d) \
117 { vtkParent::SetInput( (vtkDataObject*) d); \
118 /*bbSetModifiedStatus();*/ }
119 //===========================================================================
121 //===========================================================================
122 /// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
123 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
125 TYPE bbGetOutput##NAME () \
126 { return vtkParent::GetOutput(); } \
127 void bbSetOutput##NAME (TYPE d) \
128 { /*vtkParent::GetOutput() = d;*/ }
129 //===========================================================================
131 //===========================================================================
132 /// Declares a vtkAlgorithm-inherited AtomicBlackBox input
133 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
135 TYPE bbGetInput##NAME () \
136 { return dynamic_cast<TYPE>(vtkParent::GetInput()); } \
137 void bbSetInput##NAME (TYPE d) \
138 { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
140 //===========================================================================
142 //===========================================================================
143 /// Declares an AtomicBlackBox input corresponding to an
144 /// inherited vtk parameter
145 /// which was declared by vtkSetMacro/vtkGetMacro
146 /// The NAME **MUST** be the same than the vtk parameter name
147 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
149 TYPE bbGetInput##NAME () \
150 { return vtkParent::Get##NAME(); } \
151 void bbSetInput##NAME (TYPE d) \
152 { vtkParent::Set##NAME(d); \
153 /*bbSetModifiedStatus();*/ }
154 //===========================================================================
158 //============================================================================
159 /// Defines the default bbUserProcess method for vtk inherited black boxes
160 /// (calls vtkParent::Update)
161 #define BBTK_VTK_PROCESS() \
163 inline void bbUserProcess() \
165 bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
167 vtkParent::Update(); \
168 bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName() \
171 //============================================================================
174 //===========================================================================
176 //===========================================================================