00001 /*========================================================================= 00002 Program: bbtk 00003 Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $ 00004 Language: C++ 00005 Date: $Date: 2009/12/18 18:37:44 $ 00006 Version: $Revision: 1.14 $ 00007 =========================================================================*/ 00008 00009 /* --------------------------------------------------------------------- 00010 00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) 00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux 00013 * 00014 * This software is governed by the CeCILL-B license under French law and 00015 * abiding by the rules of distribution of free software. You can use, 00016 * modify and/ or redistribute the software under the terms of the CeCILL-B 00017 * license as circulated by CEA, CNRS and INRIA at the following URL 00018 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 00019 * or in the file LICENSE.txt. 00020 * 00021 * As a counterpart to the access to the source code and rights to copy, 00022 * modify and redistribute granted by the license, users are provided only 00023 * with a limited warranty and the software's author, the holder of the 00024 * economic rights, and the successive licensors have only limited 00025 * liability. 00026 * 00027 * The fact that you are presently reading this means that you have had 00028 * knowledge of the CeCILL-B license and that you accept its terms. 00029 * ------------------------------------------------------------------------ */ 00030 00031 00032 00037 #ifndef __bbtkVtkBlackBoxMacros_h__ 00038 #define __bbtkVtkBlackBoxMacros_h__ 00039 #include <vtkGarbageCollector.h> 00040 //#include <vtkObjectFactory.h> 00041 #include <vtkDebugLeaks.h> 00042 00043 00044 //=========================================================================== 00045 //============================================================================ 00046 // VTK Specific macros 00047 //=========================================================================== 00048 //=========================================================================== 00049 00050 //=========================================================================== 00051 #define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKOBJECT) \ 00052 BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX); \ 00053 typedef VTKOBJECT bbVtkObject; \ 00054 bbVtkObject* bbGetVtkObject() { return mVtkObject; } \ 00055 private: \ 00056 bbVtkObject *mVtkObject; 00057 00058 //=========================================================================== 00059 #define BBTK_VTK_SET_DEFAULT_VALUES() \ 00060 mVtkObject = NULL; 00061 00062 //=========================================================================== 00063 #define BBTK_VTK_INITIALIZE_PROCESSING() \ 00064 mVtkObject = bbVtkObject::New(); 00065 00066 //=========================================================================== 00067 #define BBTK_VTK_FINALIZE_PROCESSING() \ 00068 if (mVtkObject) { mVtkObject->Delete(); mVtkObject = NULL; } 00069 00070 /* 00071 //=========================================================================== 00072 #define BBTK_VTK_DELETE() \ 00073 int bbDelete() { \ 00074 for (int i=0; i<mVtkObject->GetNumberOfInputPorts();++i) \ 00075 mVtkObject->SetInput(i,0); \ 00076 bbGetOutputOut()->SetSource(NULL); \ 00077 int refs = mVtkObject->GetReferenceCount()-1; \ 00078 mVtkObject->Delete(); \ 00079 return refs; \ 00080 } 00081 00082 // bbmDescriptorPointer.reset(); 00083 //=========================================================================== 00084 */ 00085 00086 00087 //=========================================================================== 00089 #define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \ 00090 public: \ 00091 TYPE bbGetInput##NAME () \ 00092 { if (mVtkObject) return mVtkObject->GetImageDataInput(0); return 0; } \ 00093 void bbSetInput##NAME (TYPE d) \ 00094 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); } 00095 00096 //=========================================================================== 00097 00098 //=========================================================================== 00100 #define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \ 00101 public: \ 00102 TYPE bbGetInput##NAME () \ 00103 { if (mVtkObject) return mVtkObject->GetPolyDataInput(0); return 0; } \ 00104 void bbSetInput##NAME (TYPE d) \ 00105 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); } 00106 00107 //=========================================================================== 00108 00109 //=========================================================================== 00111 #define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \ 00112 public: \ 00113 TYPE bbGetOutput##NAME () \ 00114 { if (mVtkObject) return mVtkObject->GetOutput(); return 0; } \ 00115 void bbSetOutput##NAME (TYPE d) \ 00116 { } 00117 //=========================================================================== 00118 00119 //=========================================================================== 00121 #define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \ 00122 public: \ 00123 TYPE bbGetInput##NAME () \ 00124 { if (mVtkObject) return dynamic_cast<TYPE>(mVtkObject->GetInput()); \ 00125 return 0;} \ 00126 void bbSetInput##NAME (TYPE d) \ 00127 { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); } 00128 00129 //=========================================================================== 00130 00131 //=========================================================================== 00136 #define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \ 00137 public: \ 00138 TYPE bbGetInput##NAME () \ 00139 { if (mVtkObject) return mVtkObject->Get##NAME(); return 0; } \ 00140 void bbSetInput##NAME (TYPE d) \ 00141 { if (mVtkObject) mVtkObject->Set##NAME(d); \ 00142 } 00143 //=========================================================================== 00144 00145 //=========================================================================== 00150 /* 00151 #define BBTK_DECLARE_VTK_2_PARAM(NAME,TYPE) \ 00152 public: \ 00153 TYPE bbGetInput##NAME () \ 00154 { 00155 TO DO : HOW TO RECOMPOSE A VECTOR ? 00156 { return mVtkObject->Get##NAME(); } \ 00157 void bbSetInput##NAME (TYPE d) \ 00158 { 00159 mVtkObject->Set##NAME(d[0],d[1]); \ 00160 } 00161 */ 00162 //=========================================================================== 00163 00164 00165 //============================================================================ 00168 #define BBTK_VTK_PROCESS() \ 00169 public: \ 00170 inline void bbUserProcess() \ 00171 { \ 00172 bbtkBlackBoxDebugMessage("process",1,"**> Processing..." \ 00173 <<std::endl); \ 00174 mVtkObject->Update(); \ 00175 printf("EED Process %s\n", bbGetFullName().c_str() ); \ 00176 vtkIndent indent(2); \ 00177 mVtkObject->PrintSelf(std::cout, indent ); \ 00178 bbtkBlackBoxDebugMessage("process",2,"<** Processing" \ 00179 <<std::endl); \ 00180 } 00181 //============================================================================ 00182 00183 00184 //=========================================================================== 00186 //=========================================================================== 00187 #endif