bool mIsWidget;
std::string mParentBlackBox;
std::string mItkParent;
- std::string mVtkParent;
+ std::string mVtkObject;
bool mGeneric;
std::string mAuthor;
std::string mDescription;
else if (bbtype == vtkImageAlgorithmString)
{
mType = vtkImageAlgorithm;
- // Looks for <vtkparent> tag
- if (!BB.nChildNode("vtkparent"))
+ // Looks for <vtkobject> tag
+ if (!BB.nChildNode("vtkobject"))
{
throw bbfyException("Error : blackbox type '"
+vtkImageAlgorithmString
- +"' but no <vtkparent> tag found (mandatory)");
+ +"' but no <vtkobject> tag found (mandatory)");
}
- bbtk::GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
+ bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
//
}
else if (bbtype == vtkPolyDataAlgorithmString )
{
mType = vtkPolyDataAlgorithm;
- // Looks for <vtkparent> tag
- if (!BB.nChildNode("vtkparent"))
+ // Looks for <vtkobject> tag
+ if (!BB.nChildNode("vtkobject"))
{
throw bbfyException("Error : blackbox type '"
+vtkPolyDataAlgorithmString
- +"' but no <vtkparent> tag found (mandatory)");
+ +"' but no <vtkobject> tag found (mandatory)");
}
- bbtk::GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
+ bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
//
}
else
{
mFile << " public " << mItkParent <<",\n";
}
-//EED 15mai2009
-// else if ( (mType == vtkImageAlgorithm) ||
-// (mType == vtkPolyDataAlgorithm) )
-// {
-// mFile << " public " << mVtkParent <<",\n";
-// }
mFile << " public "<<mParentBlackBox << "\n";
mFile << " BBTK_VTK_BLACK_BOX_INTERFACE("
<< mName << ","
<< mParentBlackBox << ","
- << mVtkParent
+ << mVtkObject
<< ");\n";
}
mFile << *i <<"\n";
}
- // Declare user constructor / copy cons /destr
- /*
- mFile << "//=================================================================="<<std::endl;
- mFile << "/// User callback called in the box contructor"<<std::endl;
-
- mFile << "virtual void bbUserConstructor();"<<std::endl;
- mFile << "/// User callback called in the box copy constructor"<<std::endl;
- mFile << "virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);"<<std::endl;
- mFile << "/// User callback called in the box destructor"<<std::endl;
- mFile << "virtual void bbUserDestructor();"<<std::endl;
- mFile << "//=================================================================="<<std::endl;
- */
// Inputs
std::vector<IO>::iterator ioi;
mFile << "{"<<std::endl;
if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
{
- mFile << " mVtkObject = NULL;\n";
+ mFile << " BBTK_VTK_SET_DEFAULT_VALUES();\n";
}
mFile << mUserSetDefaultValues << std::endl;
mFile << "}" << std::endl;
mFile << "{"<<std::endl;
if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
{
- mFile << " mVtkObject = "<< mVtkParent <<"::New();\n";
+ mFile << " BBTK_VTK_INITIALIZE_PROCESSING();\n";
}
mFile << mUserInitializeProcessing << std::endl;
mFile << "}" << std::endl;
mFile << "{"<<std::endl;
if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
{
- mFile << " mVtkObject->Delete();\n";
+ mFile << " BBTK_VTK_FINALIZE_PROCESSING();\n";
}
mFile << mUserFinalizeProcessing << std::endl;
mFile << "}" << std::endl;
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2009/05/14 14:43:33 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2009/05/18 10:45:40 $
+ Version: $Revision: 1.17 $
=========================================================================*/
/* ---------------------------------------------------------------------
//============================================================================
#define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
- <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
+ <<"() ["<<this->bbGetFullName()<<"]"<<std::endl); \
+ bbFinalizeProcessing();
//============================================================================
CLASS::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- CLASS::bbUserFinalizeProcessing(); \
BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
} \
void CLASS::bbLockDescriptor() \
CLASS<T>::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- CLASS<T>::bbFinalizeProcessing(); \
BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
} \
template <class T> \
CLASS<T1,T2>::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
- CLASS<T1,T2>::bbFinalizeProcessing(); \
BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
} \
template <class T1, class T2> \
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2009/05/14 14:43:33 $
- Version: $Revision: 1.44 $
+ Date: $Date: 2009/05/18 10:45:40 $
+ Version: $Revision: 1.45 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=========================================================================
void BlackBox::bbInitializeProcessing()
{
+ std::cout << "INIT BEFORE TEST"<<bbGetFullName()<<std::endl;
if (!bbmInitialized)
{
std::cout << "INIT "<<bbGetFullName()<<std::endl;
Program: bbtk
Module: $RCSfile: bbtkQt.cxx,v $
Language: C++
- Date: $Date: 2009/04/08 07:56:11 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2009/05/18 10:45:41 $
+ Version: $Revision: 1.2 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=========================================================================
int argc = 1;
- char* argv = "QApp";
+ const char* argv = "QApp";
//=========================================================================
void Qt::CreateQtAppIfNeeded()
bbtkGlobalError("Qt::CreateQtAppIfNeeded() : INTERNAL ERROR ! (QCoreApplication::instance()==0) && (mgQtApp != 0)");
}
bbtkDebugMessage("qt",1," --> Creating bbtk QApplication"<<std::endl);
- mgQtApp = new QApplication(argc,&argv);
+ char* aargv = const_cast<char*>(argv);
+ mgQtApp = new QApplication(argc,&aargv);
// std::cout << ">>>> mgQtApp.exec()"<<std::endl;
Program: bbtk
Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2009/05/18 06:07:58 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2009/05/18 10:45:41 $
+ Version: $Revision: 1.12 $
=========================================================================*/
/* ---------------------------------------------------------------------
//===========================================================================
//===========================================================================
-#define BBTK_VTK_DISABLE_GARBAGE_COLLECTOR \
- public: \
- virtual void Register(vtkObjectBase* o) {} \
- virtual void UnRegister(vtkObjectBase* o) {} \
- protected: \
- virtual void ReportReferences(vtkGarbageCollector* collector) {}
+#define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKOBJECT) \
+ BBTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX); \
+ typedef VTKOBJECT bbVtkObject; \
+ bbVtkObject* bbGetVtkObject() { return mVtkObject; } \
+ private: \
+ bbVtkObject *mVtkObject;
+
+//===========================================================================
+#define BBTK_VTK_SET_DEFAULT_VALUES() \
+ mVtkObject = NULL;
+
+//===========================================================================
+#define BBTK_VTK_INITIALIZE_PROCESSING() \
+ mVtkObject = bbVtkObject::New();
-/*
-
- public: \
- virtual void Register(vtkObjectBase* o) {} \
- {
- this->RegisterInternal(o, 1);
- }
- virtual void UnRegister(vtkObjectBase* o)
- {
- this->UnRegisterInternal(o, 1);
- }
-
- protected:
-
- virtual void ReportReferences(vtkGarbageCollector* collector)
- {
- // Report references held by this object that may be in a loop.
- this->Superclass::ReportReferences(collector);
- vtkGarbageCollectorReport(collector, this->OtherObject, "Other Object");
- }
-*/
//===========================================================================
+#define BBTK_VTK_FINALIZE_PROCESSING() \
+ if (mVtkObject) { mVtkObject->Delete(); mVtkObject = NULL; }
+/*
//===========================================================================
#define BBTK_VTK_DELETE() \
int bbDelete() { \
for (int i=0; i<mVtkObject->GetNumberOfInputPorts();++i) \
- mVtkObject->SetInput(i,0); \
+ mVtkObject->SetInput(i,0); \
bbGetOutputOut()->SetSource(NULL); \
int refs = mVtkObject->GetReferenceCount()-1; \
mVtkObject->Delete(); \
// bbmDescriptorPointer.reset();
//===========================================================================
+*/
-//===========================================================================
-#define BBTK_VTK_NEW(CLASS,VTKPARENT) \
- inline static Pointer New(const std::string& name) \
- { \
- /*vtkDebugLeaks::ConstructClass(#VTKPARENT);*/ \
- bbtkDebugMessage("object",1,"##> "<<#CLASS \
- <<"::New(\""<<name<<"\")"<<std::endl); \
- Pointer p = MakeBlackBoxPointer(new Self(name)); \
- bbtkDebugMessage("object",1,"<## "<<#CLASS \
- <<"::New(\""<<name<<"\")"<<std::endl); \
- return p; \
- }
-//===========================================================================
-
-//===========================================================================
-#define BBTK_VTK_CLONE(CLASS,VTKPARENT) \
- inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
- { \
- /*vtkDebugLeaks::ConstructClass(#VTKPARENT);*/ \
- bbtkDebugMessage("object",1,"##> "<<#CLASS \
- <<"::bbClone(\""<<name<<"\")"<<std::endl); \
- Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
- bbtkDebugMessage("object",1,"<## "<<#CLASS \
- <<"::bbClone(\""<<name<<"\")"<<std::endl); \
- return p; \
- }
-
-
-//===========================================================================
-#define BBTK_VTK_BLACK_BOX_INTERFACE(CLASS,PARENTBLACKBOX,VTKPARENT) \
- BBTK_BLACK_BOX_INTERFACE_WITHOUT_NEW(CLASS,PARENTBLACKBOX); \
- typedef VTKPARENT vtkParent; \
- BBTK_VTK_DELETE(); \
- public : \
- BBTK_VTK_NEW(CLASS,VTKPARENT); \
- BBTK_VTK_CLONE(CLASS,VTKPARENT); \
- private: \
- vtkParent *mVtkObject;
-
-// BBTK_VTK_DISABLE_GARBAGE_COLLECTOR
-//===========================================================================
-
-#define BBTK_VTK_UNREGISTER(O)
-
-//O->UnRegister(this);
//===========================================================================
/// Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
#define BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return mVtkObject->GetImageDataInput(0); /*vtkParent::GetInput();*/ } \
+ { if (mVtkObject) return mVtkObject->GetImageDataInput(0); return 0; } \
void bbSetInput##NAME (TYPE d) \
- { mVtkObject->SetInput( (vtkDataObject*) d); \
- BBTK_VTK_UNREGISTER(d);/*bbSetModifiedStatus();*/ }
+ { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
+
//===========================================================================
//===========================================================================
/// Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
-#define BBTK_DECLARE_VTK_POL÷,TYPE) \
+#define BBTK_DECLARE_VTK_POLY_DATA_ALGORITHM_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return mVtkObject->GetPolyDataInput(0); /*vtkParent::GetInput();*/ } \
+ { if (mVtkObject) return mVtkObject->GetPolyDataInput(0); return 0; } \
void bbSetInput##NAME (TYPE d) \
- { mVtkObject->SetInput( (vtkDataObject*) d); \
- BBTK_VTK_UNREGISTER(d);/*bbSetModifiedStatus();*/ }
+ { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
+
//===========================================================================
//===========================================================================
#define BBTK_DECLARE_VTK_OUTPUT(NAME,TYPE) \
public: \
TYPE bbGetOutput##NAME () \
- { return mVtkObject->GetOutput(); } \
- void bbSetOutput##NAME (TYPE d) \
- { /*vtkParent::GetOutput() = d;*/ }
+ { if (mVtkObject) return mVtkObject->GetOutput(); return 0; } \
+ void bbSetOutput##NAME (TYPE d) \
+ { }
//===========================================================================
//===========================================================================
/// Declares a vtkAlgorithm-inherited AtomicBlackBox input
-#define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
+#define BBTK_DECLARE_VTK_INPUT(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return dynamic_cast<TYPE>(mVtkObject->GetInput()); } \
+ { if (mVtkObject) return dynamic_cast<TYPE>(mVtkObject->GetInput()); \
+ return 0;} \
void bbSetInput##NAME (TYPE d) \
- { mVtkObject->SetInput( (vtkDataObject*) d); \
- BBTK_VTK_UNREGISTER(d);/*vtkParent::GetOutput() = d;*/ }
+ { if (mVtkObject) mVtkObject->SetInput( (vtkDataObject*) d); }
//===========================================================================
#define BBTK_DECLARE_VTK_PARAM(NAME,TYPE) \
public: \
TYPE bbGetInput##NAME () \
- { return mVtkObject->Get##NAME(); } \
+ { if (mVtkObject) return mVtkObject->Get##NAME(); return 0; } \
void bbSetInput##NAME (TYPE d) \
- { mVtkObject->Set##NAME(d); \
+ { if (mVtkObject) mVtkObject->Set##NAME(d); \
}
//===========================================================================
Program: bbtk
Module: $RCSfile: bbitkAnyImageToTypedImage.h,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:21 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.9 $
=========================================================================*/
/* ---------------------------------------------------------------------
}
//=================================================================
+
+ //===================================================
+ template <class T1>
+ void AnyImageToTypedImage<T1>::bbUserSetDefaultValues() {}
+ template <class T1>
+ void AnyImageToTypedImage<T1>::bbUserInitializeProcessing(){}
+ template <class T1>
+ void AnyImageToTypedImage<T1>::bbUserFinalizeProcessing() {}
+ //===================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
//=================================================================
// BlackBox declaration
template <class itkImageTypePointer, class itkImageTypeConstPointer>
}
//=================================================================
+ //===================================================
+ template <class T1, class T2>
+ void AnyImageToConstTypedImage<T1,T2>::bbUserSetDefaultValues() {}
+ template <class T1, class T2>
+ void AnyImageToConstTypedImage<T1,T2>::bbUserInitializeProcessing(){}
+ template <class T1, class T2>
+ void AnyImageToConstTypedImage<T1,T2>::bbUserFinalizeProcessing() {}
+ //===================================================
+
+
+
+
+
+
+
}
#endif
Program: bbtk
Module: $RCSfile: bbitkBinaryThresholdImageFilter.cxx,v $
Language: C++
- Date: $Date: 2009/05/15 14:57:58 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.6 $
=========================================================================*/
/* ---------------------------------------------------------------------
BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
bbtk::AtomicBlackBox);
+
BBTK_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,
BinaryThresholdImageFilterGeneric);
+ void BinaryThresholdImageFilterGeneric::bbUserSetDefaultValues()
+ {
+ bbSetInputLowerThreshold(0);
+ bbSetInputUpperThreshold(100);
+ bbSetInputInsideValue(255);
+ bbSetInputOutsideValue(0);
+ }
+ void BinaryThresholdImageFilterGeneric::bbUserInitializeProcessing()
+ {
+ }
+ void BinaryThresholdImageFilterGeneric::bbUserFinalizeProcessing()
+ {
+ }
+
}
// EO namespace bbtk
Program: bbtk
Module: $RCSfile: bbitkBinaryThresholdImageFilter.h,v $
Language: C++
- Date: $Date: 2009/05/15 14:57:58 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.13 $
=========================================================================*/
/* ---------------------------------------------------------------------
namespace bbitk
{
+ //===================================================
template <class T>
class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
:
BBTK_ITK_PROCESS();
BBTK_ITK_DELETE();
-
};
+ //===================================================
+ //===================================================
BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
bbtk::AtomicBlackBox);
BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
typename T::PixelType);
BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
+ //===================================================
+
+
+ //===================================================
+ //--
+ template <class T>
+ void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
+ {
+ bbSetInputLowerThreshold(0);
+ bbSetInputUpperThreshold(100);
+ bbSetInputInsideValue(255);
+ bbSetInputOutsideValue(0);
+ }
+ template <class T>
+ void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
+ {
+ }
+ template <class T>
+ void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
+ {
+ }
+
+ //===================================================
+
+
+
+
+
+
+
+
+
+
//===================================================
// Generic "untemplatized" filter
inline void ProcessSwitch();
template <class T> void Process();
};
+ //===================================================
+
+ //===================================================
+
BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_NAME("BinaryThresholdImageFilter");
"Output image. Of the same type and dimension than the input image",
anyImagePointer,"");
BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
+ //===================================================
+
+ //===================================================
+
void BinaryThresholdImageFilterGeneric::ProcessSwitch()
{
BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
}
+ //===================================================
+
+
+ //===================================================
template <class T>
void BinaryThresholdImageFilterGeneric::Process()
bbtkDebugDecTab("Core",9);
}
+ //===================================================
+
-////--
-// template <class T>
-// void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
-// {
-// bbSetInputLowerThreshold(0);
-// bbSetInputUpperThreshold(100);
-// bbSetInputInsideValue(255);
-// bbSetInputOutsideValue(0);
-// }
-
- void BinaryThresholdImageFilterGeneric::bbUserSetDefaultValues()
- {
- bbSetInputLowerThreshold(0);
- bbSetInputUpperThreshold(100);
- bbSetInputInsideValue(255);
- bbSetInputOutsideValue(0);
- }
- //--
- template <class T>
- void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
- {
- }
-
- void BinaryThresholdImageFilterGeneric::bbUserInitializeProcessing()
- {
- }
-
-//--
-
- //--
-
- template <class T>
- void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
- {
- }
-
- void BinaryThresholdImageFilterGeneric::bbUserFinalizeProcessing()
- {
- }
+
}
Program: bbtk
Module: $RCSfile: bbitkExtractImageFilter.cxx,v $
Language: C++
- Date: $Date: 2009/05/15 14:57:58 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.6 $
=========================================================================*/
/* ---------------------------------------------------------------------
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ExtractImageFilterGeneric)
- //-----------------------------------------------------------------
- void ExtractImageFilterGeneric::bbUserSetDefaultValues()
- {
- }
-
- //-----------------------------------------------------------------
- void ExtractImageFilterGeneric::bbUserInitializeProcessing()
- {
- }
-
- //-----------------------------------------------------------------
- void ExtractImageFilterGeneric::bbUserFinalizeProcessing()
- {
- }
-
-
+
+ //===================================================
+ // Method which switches on the Process method instanciated on
+ // the type of the itk Image stored in the anyImagePointer input
+ void ExtractImageFilterGeneric::ProcessSwitch()
+ {
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
+ }
+ //===================================================
+
+
+ //-----------------------------------------------------------------
+ void ExtractImageFilterGeneric::bbUserSetDefaultValues()
+ {
+ }
+
+ //-----------------------------------------------------------------
+ void ExtractImageFilterGeneric::bbUserInitializeProcessing()
+ {
+ }
+
+ //-----------------------------------------------------------------
+ void ExtractImageFilterGeneric::bbUserFinalizeProcessing()
+ {
+ }
+
+
}
// EO namespace bbitk
Program: bbtk
Module: $RCSfile: bbitkExtractImageFilter.h,v $
Language: C++
- Date: $Date: 2008/11/12 12:47:03 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.10 $
=========================================================================*/
/* ---------------------------------------------------------------------
namespace bbitk
{
-
+ //===================================================
+ /// Template filter
template <class T>
class /*BBTK_EXPORT*/ ExtractImageFilter
:
BBTK_ITK_PROCESS();
BBTK_ITK_DELETE();
};
+ //===================================================
+ //===================================================
+ // Descriptor of template filter
BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter,
bbtk::AtomicBlackBox);
BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
BBTK_TEMPLATE_INPUT(ExtractImageFilter,ExtractionRegion,"Extraction region",typename T::RegionType);
BBTK_TEMPLATE_OUTPUT(ExtractImageFilter,Out,"Output image",T*);
BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
+ //===================================================
+
+ //===================================================
+ template <class T> void ExtractImageFilter<T>::bbUserSetDefaultValues() {}
+ template <class T> void ExtractImageFilter<T>::bbUserInitializeProcessing(){}
+ template <class T> void ExtractImageFilter<T>::bbUserFinalizeProcessing() {}
+ //===================================================
+
+
+
+
+
+
+
+
//===================================================
// Generic "untemplatized" filter
//===================================================
BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
BBTK_PROCESS(ProcessSwitch);
private :
- inline void ProcessSwitch();
+ void ProcessSwitch();
template <class T> void Process();
};
+ //===================================================
+ //===================================================
+ // Descriptor of generic filter
BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_NAME("ExtractImageFilter");
BBTK_INPUT(ExtractImageFilterGeneric,Region,"Extraction region",anyImageRegion,"");
BBTK_OUTPUT(ExtractImageFilterGeneric,Out,"Output image",anyImagePointer,"");
BBTK_END_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric);
- void ExtractImageFilterGeneric::ProcessSwitch()
- {
- BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
- }
+ //===================================================
+
+ //===================================================
+ // The main processing method is template on the itk image type
+ // which was set to the input.
+ // It is called by the ProcessSwitch method which checks the input In type
+ // and calls Process<T> where T is the right type.
template <class T>
void ExtractImageFilterGeneric::Process()
{
bbtkDebugMessageInc("Core",9,
"bbitk::ExtractImageFilterGeneric::Process<"
<<bbtk::TypeName<T>()<<">()"<<std::endl);
+ // T is the type of input image
typedef T ImageType;
+ // We define the type of the filter to use which is template
+ // on the image type
typedef ExtractImageFilter<ImageType> FilterType;
+ // Allocate the filter
typename FilterType::Pointer f = FilterType::New("Temp");
- typedef ImageType* ImageTypePointer;
- f->bbSetInputIn( this->bbGetInputIn().unsafe_get<ImageTypePointer>() );
+
+ // Set the input In of the filter
+ // Here we :
+ // 1) Get **OUR** input 'In' by bbGetInputIn()
+ // It is a anyImagePointer
+ // 2) We **KNOW** that the actual type stored by the anyImagePointer
+ // is ImageType* hence we get the value stored using the
+ // unsafe_get method (which is a template method on the return type)
+ f->bbSetInputIn( this->bbGetInputIn().unsafe_get<ImageType*>() );
+
+ // The same for the ImageRegion except that we use 'get' and not
+ // 'unsafe get' because the region dimension passed by the user may not be
+ // compatible with the image dimension.
+ // If get fails it throws an exception which must be caught outside
f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
+
+ // Execute the filter
f->bbExecute();
+ // Register its output or it will be deleted we delete the filter
f->bbGetOutputOut()->Register();
+ // Set OUR output
this->bbSetOutputOut( f->bbGetOutputOut() );
- // f->bbDelete();
+ // Delete the temporary filter
+ f->bbDelete();
bbtkDebugDecTab("Core",9);
}
+ //===================================================
}
// EO namespace bbitk
Program: bbtk
Module: $RCSfile: bbitkImage.h,v $
Language: C++
- Date: $Date: 2008/11/27 14:58:06 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/05/18 10:45:43 $
+ Version: $Revision: 1.6 $
=========================================================================*/
/* ---------------------------------------------------------------------
# define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)
# endif
# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
-# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST) \
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST) \
TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_4_##CONST##ptr,FUN,Image_uint32_t_4)
# else
# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST)
Program: bbtk
Module: $RCSfile: bbitkImageRegion.cxx,v $
Language: C++
- Date: $Date: 2009/05/15 14:57:58 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/05/18 10:45:44 $
+ Version: $Revision: 1.6 $
=========================================================================*/
/* ---------------------------------------------------------------------
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageRegionCreator);
- /*
- void ImageRegionCreator::bbUserSetDefaultValues() { }
- void ImageRegionCreator::bbUserInitializeProcessing() { }
- void ImageRegionCreator::bbUserFinalizeProcessing() { }
-
- template <unsigned int Dimension>
- void ImageRegionCreator::bbUserSetDefaultValues() { }
-
- template <unsigned int Dimension>
- void ImageRegionCreator::bbUserInitializeProcessing() { }
-
- template <unsigned int Dimension>
- void ImageRegionCreator::bbUserFinalizeProcessing() { }
- */
+
+ void ImageRegionCreator::bbUserSetDefaultValues()
+ { }
+ void ImageRegionCreator::bbUserInitializeProcessing()
+ { }
+ void ImageRegionCreator::bbUserFinalizeProcessing()
+ { }
+
void ImageRegionCreator::DoIt()
{
const std::vector<long>& index = bbGetInputIndex();
unsigned long maxs = index.size() > size.size() ? index.size() : size.size();
switch (maxs)
{
- case 2 : DoIt<2>(); break;
- case 3 : DoIt<3>(); break;
- case 4 : DoIt<4>(); break;
+ case 2 : DoItForDimension<2>(); break;
+ case 3 : DoItForDimension<3>(); break;
+ case 4 : DoItForDimension<4>(); break;
default : bbtkError("ImageRegionCreator : cannot build a region of dimension "<<maxs);
}
}
template <unsigned int Dimension>
- void ImageRegionCreator::DoIt()
+ void ImageRegionCreator::DoItForDimension()
{
std::vector<long> index = bbGetInputIndex();
std::vector<long> size = bbGetInputSize();
Program: bbtk
Module: $RCSfile: bbitkImageRegion.h,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:21 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2009/05/18 10:45:44 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
BBTK_PROCESS(DoIt);
private:
void DoIt();
- template <unsigned int Dimension> void DoIt();
+ template <unsigned int Dimension> void DoItForDimension();
};
Program: bbtk
Module: $RCSfile: bbitkResampleImageFilter.h,v $
Language: C++
- Date: $Date: 2009/05/15 14:57:58 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2009/05/18 10:45:44 $
+ Version: $Revision: 1.10 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
- class /*BBTK_EXPORT*/ ResampleImageFilter
+ //===================================================
+ class /*BBTK_EXPORT*/ ResampleImageFilter
:
public bbtk::AtomicBlackBox
{
template <class T> void Process();
itk::Object* mOutput;
};
-
- BBTK_BEGIN_DESCRIBE_BLACK_BOX(ResampleImageFilter,
+ //===================================================
+
+ //===================================================
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ResampleImageFilter,
bbtk::AtomicBlackBox);
BBTK_NAME("ResampleImageFilter");
BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
"Output image. Of the same type and dimension than the input image",
anyImagePointer,"");
BBTK_END_DESCRIBE_BLACK_BOX(ResampleImageFilter);
+ //===================================================
+
-
- void ResampleImageFilter::ProcessSwitch()
+ //===================================================
+ void ResampleImageFilter::ProcessSwitch()
{
bbtk::TypeInfo t = bbGetInputIn().type();
BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process);
}
-
- template <class T>
+ //===================================================
+
+ //===================================================
+ template <class T>
void ResampleImageFilter::Process()
{
bbtkDebugMessageInc("Core",9,
bbtkDebugDecTab("Core",9);
}
-
+ //===================================================
+
//-----------------------------------------------------------------
void ResampleImageFilter::bbUserSetDefaultValues()
Program: bbtk
Module: $RCSfile: bbitkTypedImageToAnyImage.h,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:21 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2009/05/18 10:45:44 $
+ Version: $Revision: 1.8 $
=========================================================================*/
/* ---------------------------------------------------------------------
};
//=================================================================
+ //===================================================
+ template <class T> void TypedImageToAnyImage<T>::bbUserSetDefaultValues()
+ {}
+ template <class T> void TypedImageToAnyImage<T>::bbUserInitializeProcessing()
+ {}
+ template <class T> void TypedImageToAnyImage<T>::bbUserFinalizeProcessing()
+ {}
+ //===================================================
+
+
//=================================================================
// BlackBox description
BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage,
BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage);
//=================================================================
+
}
#endif
Program: bbtk
Module: $RCSfile: bbitkvtkitkImage2vtkImageData.cxx,v $
Language: C++
- Date: $Date: 2009/05/14 16:21:15 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2009/05/18 10:45:46 $
+ Version: $Revision: 1.9 $
=========================================================================*/
/* ---------------------------------------------------------------------
mConverter = 0;
}
- void GetXCoherentInfoGdcmReader::bbUserInitializeProcessing()
+ void itkImage2vtkImageData::bbUserInitializeProcessing()
{
}
- void GetXCoherentInfoGdcmReader::bbUserFinalizeProcessing()
+ void itkImage2vtkImageData::bbUserFinalizeProcessing()
{
}
Program: bbtk
Module: $RCSfile: bbitkvtkvtkImageData2itkImage.h,v $
Language: C++
- Date: $Date: 2008/11/25 11:17:18 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2009/05/18 10:45:46 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
BBTK_DECLARE_OUTPUT(Out,bbitk::anyImagePointer);
BBTK_PROCESS(Convert);
void Convert();
- void bbUserConstructor();
- void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
- void bbUserDestructor();
private:
// Convert method : template on type of the itk image to be created
<category>mesh</category>
<include>vtkAppendPolyData.h</include>
-<vtkparent>vtkAppendPolyData</vtkparent>
+<vtkobject>vtkAppendPolyData</vtkobject>
<output name="Out" type="vtkPolyData*" special="vtk output" description="Output Mesh"/>
<input name="In1" type="vtkPolyData *" description="PolyData 1"/>
<process>
<PRE>
- mVtkObject->SetInput(bbGetInputIn1());
- mVtkObject->SetInput(bbGetInputIn2());
- mVtkObject->SetInput(bbGetInputIn3());
- mVtkObject->SetInput(bbGetInputIn4());
- mVtkObject->SetInput(bbGetInputIn5());
+ bbGetVtkObject()->SetInput(bbGetInputIn1());
+ bbGetVtkObject()->SetInput(bbGetInputIn2());
+ bbGetVtkObject()->SetInput(bbGetInputIn3());
+ bbGetVtkObject()->SetInput(bbGetInputIn4());
+ bbGetVtkObject()->SetInput(bbGetInputIn5());
- mVtkObject->Update();
+ bbGetVtkObject()->Update();
</PRE>
</process>
<category>mesh</category>
<include>vtkConeSource.h</include>
-<vtkparent>vtkConeSource</vtkparent>
+<vtkobject>vtkConeSource</vtkobject>
<output name="Out" type="vtkPolyData*" special="vtk output" description="Output Cone"/>
<input name="Radius" type="double" special="vtk parameter" description="Cone Radius"/>
<process>
<PRE>
-mVtkObject->SetCenter(bbGetInputCenterX(),
- bbGetInputCenterY(),
- bbGetInputCenterZ());
+bbGetVtkObject()->SetCenter(bbGetInputCenterX(),
+ bbGetInputCenterY(),
+ bbGetInputCenterZ());
-mVtkObject->SetDirection(bbGetInputDirectionX(),
- bbGetInputDirectionY(),
- bbGetInputDirectionZ());
+bbGetVtkObject()->SetDirection(bbGetInputDirectionX(),
+ bbGetInputDirectionY(),
+ bbGetInputDirectionZ());
-mVtkObject->SetResolution(bbGetInputResolution());
-mVtkObject->SetRadius((double)bbGetInputRadius());
-mVtkObject->Update();
+bbGetVtkObject()->SetResolution(bbGetInputResolution());
+bbGetVtkObject()->SetRadius((double)bbGetInputRadius());
+bbGetVtkObject()->Update();
</PRE>
</process>
<include>vtkImageAnisotropicDiffusion3D.h</include>
<include>vtkImageData.h</include>
-<vtkparent>vtkImageAnisotropicDiffusion3D</vtkparent>
+<vtkobject>vtkImageAnisotropicDiffusion3D</vtkobject>
<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
<description><PRE>Exports objet sizes, etc</PRE></description>
<category>image;</category>
-<vtkparent>vtkImageData</vtkparent>
<include>vtkImageData.h</include>
<input name="In" type="vtkImageData*" description="Input image"/>
<include>vtkImageDilateErode3D.h</include>
<include>vtkImageData.h</include>
-<vtkparent>vtkImageDilateErode3D</vtkparent>
+<vtkobject>vtkImageDilateErode3D</vtkobject>
<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
<process>
<PRE>
-mVtkObject->SetKernelSize(bbGetInputKernelSizeX(),
+bbGetVtkObject()->SetKernelSize(bbGetInputKernelSizeX(),
bbGetInputKernelSizeY(),
bbGetInputKernelSizeZ());
-mVtkObject->Update();
+bbGetVtkObject()->Update();
</PRE>
</process>
<include>vtkImageGaussianSmooth.h</include>
<include>vtkImageData.h</include>
-<vtkparent>vtkImageGaussianSmooth</vtkparent>
+<vtkobject>vtkImageGaussianSmooth</vtkobject>
<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
<process>
<PRE>
-mVtkObject->SetStandardDeviation(bbGetInputStdDevX(),
+bbGetVtkObject()->SetStandardDeviation(bbGetInputStdDevX(),
bbGetInputStdDevY(),
bbGetInputStdDevZ());
-mVtkObject->Update();
+bbGetVtkObject()->Update();
</PRE>
</process>
<include>vtkMetaImageReader.h</include>
<include>vtkImageData.h</include>
-<vtkparent>vtkMetaImageReader</vtkparent>
+<vtkobject>vtkMetaImageReader</vtkobject>
<input name="In" type="std::string" nature="file name" description="Name of the file to read"/>
<output name="Out" type="vtkImageData*" special="vtk output" description="Output image" />
<process><PRE>
- mVtkObject->SetFileName(bbGetInputIn().c_str());
- mVtkObject->Update();
+ bbGetVtkObject()->SetFileName(bbGetInputIn().c_str());
+ bbGetVtkObject()->Update();
</PRE></process>
</blackbox>
<category>mesh</category>
<include>vtkSphereSource.h</include>
-<vtkparent>vtkSphereSource</vtkparent>
+<vtkobject>vtkSphereSource</vtkobject>
<output name="Out" type="vtkPolyData*" description="Output Sphere" special="vtk output"/>
<input name="CenterX" type="double" description="Center X coord"/>
<process>
<PRE>
-mVtkObject->SetCenter(bbGetInputCenterX(),
+bbGetVtkObject()->SetCenter(bbGetInputCenterX(),
bbGetInputCenterY(),
bbGetInputCenterZ());
-mVtkObject->Update();
+bbGetVtkObject()->Update();
</PRE>
</process>