mFile << "{\n";
// Interface
- mFile << " BBTK_BLACK_BOX_INTERFACE("
- << mName << ","
- << mParentBlackBox << ");\n";
- // typedef on itkfilter
+ // ITK
if (mType == itkImageToImageFilter)
{
- mFile << " typedef " <<mItkParent <<" itkParent;"<<std::endl;
- mFile << " void bbDelete() { itkParent::UnRegister(); }"<<std::endl;
+ mFile << " BBTK_ITK_BLACK_BOX_INTERFACE("
+ << mName << ","
+ << mParentBlackBox << ","
+ << mItkParent
+ << ");\n";
}
- // typedef on itkfilter
- if ( (mType == vtkImageAlgorithm) ||
+ // VTK
+ else if ( (mType == vtkImageAlgorithm) ||
(mType == vtkPolyDataAlgorithm) )
{
- mFile << " typedef " <<mVtkParent <<" vtkParent;"<<std::endl;
- mFile << " BBTK_VTK_DELETE(vtkParent);"<<std::endl;
+ mFile << " BBTK_VTK_BLACK_BOX_INTERFACE("
+ << mName << ","
+ << mParentBlackBox << ","
+ << mVtkParent
+ << ");\n";
+ }
+ // Default
+ else
+ {
+ mFile << " BBTK_BLACK_BOX_INTERFACE("
+ << mName << ","
+ << mParentBlackBox << ");\n";
}
+
for (i=mTypedef.begin(); i!=mTypedef.end(); ++i)
{
mFile << *i <<"\n";
else if (ioi->special=="itk input")
{
mFile << " BBTK_DECLARE_ITK_INPUT("
- << "itkParent,"
<< ioi->name
<< ","
<< ioi->type
{
if (mType == vtkImageAlgorithm) {
mFile << " BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT("
- << "vtkParent,"
<< ioi->name
<< ","
<< ioi->type
}
else if (mType == vtkPolyDataAlgorithm) {
mFile << " BBTK_DECLARE_POLY_DATA_ALGORITHM_INPUT("
- << "vtkParent,"
<< ioi->name
<< ","
<< ioi->type
else if (ioi->special=="itk parameter")
{
mFile << " BBTK_DECLARE_ITK_PARAM("
- << "itkParent,"
<< ioi->name
<< ","
<< ioi->type
else if (ioi->special=="vtk parameter")
{
mFile << " BBTK_DECLARE_VTK_PARAM("
- << "vtkParent,"
<< ioi->name
<< ","
<< ioi->type
else if (ioi->special=="itk output")
{
mFile << " BBTK_DECLARE_ITK_OUTPUT("
- << "itkParent,"
<< ioi->name
<< ","
<< ioi->type
else if (ioi->special=="vtk output")
{
mFile << " BBTK_DECLARE_VTK_OUTPUT("
- << "vtkParent,"
<< ioi->name
<< ","
<< ioi->type
}
else if (mType == itkImageToImageFilter)
{
- mFile << " BBTK_PROCESS(itkParent::Update);\n" ;
+ mFile << " BBTK_ITK_PROCESS();\n" ;
}
else if ((mType == vtkImageAlgorithm) ||
(mType == vtkPolyDataAlgorithm) )
{
- mFile << " BBTK_PROCESS(vtkParent::Update);\n" ;
+ mFile << " BBTK_VTK_PROCESS();\n" ;
}
// CreateWidget
Program: bbtk
Module: $RCSfile: bbtkItkBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2008/05/07 06:31:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/05/07 07:26:50 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//===========================================================================
//===========================================================================
+//===========================================================================
+#define BBTK_ITK_DELETE() \
+ void bbDelete() { \
+ itkParent::UnRegister(); }
+//===========================================================================
+
+//===========================================================================
+#define BBTK_ITK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,ITKPARENT) \
+ BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX); \
+ typedef ITKPARENT itkParent; \
+ BBTK_ITK_DELETE();
+//===========================================================================
//===========================================================================
/// Declares an itk-inherited AtomicBlackBox input
-#define BBTK_DECLARE_ITK_INPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_ITK_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return PARENT::GetInput(); } \
+ { return itkParent::GetInput(); } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::SetInput(d); \
+ { itkParent::SetInput(d); \
/*bbSetModifiedStatus();*/ }
//===========================================================================
//===========================================================================
-#define BBTK_DECLARE_ITK_OUTPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_ITK_OUTPUT(NAME,TYPE) \
public: \
TYPE bbGetOutput##NAME () \
- { return PARENT::GetOutput(); } \
+ { return itkParent::GetOutput(); } \
void bbSetOutput##NAME (TYPE d) \
{ /*PARENT::GetOutput() = d;*/ }
//===========================================================================
/// Declares an AtomicBlackBox input corresponding to an inherited itk parameter
/// which was declared by itkSetMacro/itkGetMacro
/// The NAME **MUST** be the same than the itk parameter name
-#define BBTK_DECLARE_ITK_PARAM(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_ITK_PARAM(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return PARENT::Get##NAME(); } \
+ { return itkParent::Get##NAME(); } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::Set##NAME(d); \
+ { itkParent::Set##NAME(d); \
/*bbSetModifiedStatus();*/ }
//===========================================================================
+//============================================================================
+/// Defines the default bbUserProcess method for itk inherited black boxes
+/// (calls itkParent::Update)
+#define BBTK_ITK_PROCESS() \
+ public: \
+ inline void bbUserProcess() \
+ { \
+ bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
+ itkParent::Update(); \
+ bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
+ }
+//============================================================================
//===========================================================================
/// EOF
Program: bbtk
Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2008/05/07 06:31:37 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/05/07 07:26:50 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//===========================================================================
+#define BBTK_VTK_DELETE() \
+ void bbDelete() { \
+ vtkParent::Delete(); }
-// EED sept 04 \
-// { return GetInput(); /*PARENT::GetInput();*/ } \
-// { PARENT::SetInput( /*(vtkDataObject*)*/ d); \
-
-
+#define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT) \
+ BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX); \
+ typedef VTKPARENT vtkParent; \
+ BBTK_VTK_DELETE();
/// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
-#define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return GetImageDataInput(0); /*PARENT::GetInput();*/ } \
+ { return GetImageDataInput(0); /*vtkParent::GetInput();*/ } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::SetInput( (vtkDataObject*) d); \
+ { vtkParent::SetInput( (vtkDataObject*) d); \
/*bbSetModifiedStatus();*/ }
//===========================================================================
/// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
-#define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return GetPolyDataInput(0); /*PARENT::GetInput();*/ } \
+ { return GetPolyDataInput(0); /*vtkParent::GetInput();*/ } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::SetInput( (vtkDataObject*) d); \
+ { vtkParent::SetInput( (vtkDataObject*) d); \
/*bbSetModifiedStatus();*/ }
//===========================================================================
//===========================================================================
/// Declares a vtkImageAlgorithm-inherited AtomicBlackBox output
-#define BBTK_DECLARE_VTK_OUTPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
public: \
TYPE bbGetOutput##NAME () \
- { return PARENT::GetOutput(); } \
+ { return vtkParent::GetOutput(); } \
void bbSetOutput##NAME (TYPE d) \
- { /*PARENT::GetOutput() = d;*/ }
+ { /*vtkParent::GetOutput() = d;*/ }
//===========================================================================
//===========================================================================
/// Declares a vtkAlgorithm-inherited AtomicBlackBox input
-#define BBTK_DECLARE_VTK_INPUT(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return dynamic_cast<TYPE>(PARENT::GetInput()); } \
+ { return dynamic_cast<TYPE>(vtkParent::GetInput()); } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::SetInput( (vtkDataObject*) d); /*PARENT::GetOutput() = d;*/ }
+ { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
//===========================================================================
/// inherited vtk parameter
/// which was declared by vtkSetMacro/vtkGetMacro
/// The NAME **MUST** be the same than the vtk parameter name
-#define BBTK_DECLARE_VTK_PARAM(PARENT,NAME,TYPE) \
+#define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return PARENT::Get##NAME(); } \
+ { return vtkParent::Get##NAME(); } \
void bbSetInput##NAME (TYPE d) \
- { PARENT::Set##NAME(d); \
+ { vtkParent::Set##NAME(d); \
/*bbSetModifiedStatus();*/ }
//===========================================================================
-//===========================================================================
-#define BBTK_VTK_DELETE(VTKPARENT) \
- void bbDelete() { \
- bbGetOutputOut()->SetSource(NULL); \
- VTKPARENT::Delete(); }
-//===========================================================================
+
+//============================================================================
+/// Defines the default bbUserProcess method for vtk inherited black boxes
+/// (calls vtkParent::Update)
+#define BBTK_VTK_PROCESS() \
+ public: \
+ inline void bbUserProcess() \
+ { \
+ bbtkDebugMessage("process",1,"**> Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
+ vtkParent::Update(); \
+ bbGetOutputOut()->SetSource(NULL); \
+ bbtkDebugMessage("process",2,"<** Processing ["<<bbGetFullName() \
+ <<"]"<<std::endl); \
+ }
+//============================================================================
//===========================================================================
BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
bbtk::AtomicBlackBox,T);
typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
- BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
- BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
- BBTK_DECLARE_ITK_PARAM(itkParent,UpperThreshold,typename T::PixelType);
- BBTK_DECLARE_ITK_PARAM(itkParent,InsideValue,typename T::PixelType);
- BBTK_DECLARE_ITK_PARAM(itkParent,OutsideValue,typename T::PixelType);
- BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
- BBTK_PROCESS(itkParent::Update);
- void bbDelete() { itkParent::UnRegister(); }
+ BBTK_DECLARE_ITK_INPUT(In,const T*);
+ BBTK_DECLARE_ITK_PARAM(LowerThreshold,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(UpperThreshold,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(InsideValue,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(OutsideValue,typename T::PixelType);
+ BBTK_DECLARE_ITK_OUTPUT(Out,T*);
+ BBTK_ITK_PROCESS();
+ BBTK_ITK_DELETE();
void bbUserConstructor() { Init(); }
void bbUserCopyConstructor() { Init(); }
T);
typedef itk::ExtractImageFilter<T,T> itkParent;
- BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
- BBTK_DECLARE_ITK_PARAM(itkParent,ExtractionRegion,typename T::RegionType);
- BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
- BBTK_PROCESS(itkParent::Update);
-
- void bbDelete() { itkParent::UnRegister(); }
+ BBTK_DECLARE_ITK_INPUT(In,const T*);
+ BBTK_DECLARE_ITK_PARAM(ExtractionRegion,typename T::RegionType);
+ BBTK_DECLARE_ITK_OUTPUT(Out,T*);
+
+ BBTK_ITK_PROCESS();
+ BBTK_ITK_DELETE();
};
Program: bbtk
Module: $RCSfile: bbvtkMarchingCubes.h,v $
Language: C++
- Date: $Date: 2008/05/07 06:31:37 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/05/07 07:26:51 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public bbtk::AtomicBlackBox,
public vtkMarchingCubes
{
- BBTK_BLACK_BOX_INTERFACE(MarchingCubes,bbtk::AtomicBlackBox);
-
- BBTK_DECLARE_VTK_INPUT(vtkMarchingCubes,In,vtkImageData *);
- BBTK_DECLARE_VTK_OUTPUT(vtkMarchingCubes,Out,vtkPolyData *);
+ BBTK_VTK_BLACK_BOX_INTERFACE(MarchingCubes,
+ bbtk::AtomicBlackBox,
+ vtkMarchingCubes);
+
+ BBTK_DECLARE_VTK_INPUT(In,vtkImageData *);
+ BBTK_DECLARE_VTK_OUTPUT(Out,vtkPolyData *);
// For the 'Value' parameter, the standard bbtk macro does not work
// as vtk Get/Set accessors have a parameter...
void bbSetInputValue (double d)
{ vtkMarchingCubes::SetValue(0,d); }
-
- BBTK_PROCESS(DoProcess);
- void DoProcess() { vtkMarchingCubes::Update(); }
-
- // Overload bbDelete to handle vtk reference counting
- BBTK_VTK_DELETE(vtkMarchingCubes);
- //void bbDelete() { Delete(); }
+ BBTK_VTK_PROCESS();
};
//=======================================================================
<process><PRE>
SetFileName(bbGetInputIn().c_str());
- Update();
+ vtkParent::Update();
+ // We need to disconnect the output image from its source or the
+ // vtk object will not be deleted as it
+ // will be referenced by its output image
+ bbGetOutputOut()->SetSource(NULL);
</PRE></process>
-
-<serconstructor><PRE>
-std::cout << "$$$$$$ constructing $$$$$"<<std::endl;
-</PRE></serconstructor>
-<serdestructor><PRE>
-std::cout << "$$$$$$ deleting $$$$$"<<std::endl;
-</PRE></serdestructor>
</blackbox>