Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/11 15:30:04 $
- Version: $Revision: 1.38 $
+ Date: $Date: 2009/02/27 11:20:25 $
+ Version: $Revision: 1.39 $
=========================================================================*/
/* ---------------------------------------------------------------------
b->bbDelete();
- bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor ["<<desc.lock()<<"]"<<std::endl);
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor"<<std::endl);
if (!desc.expired())
{
Program: bbtk
Module: $RCSfile: bbtkFactory.cxx,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:13 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2009/02/27 11:20:25 $
+ Version: $Revision: 1.41 $
=========================================================================*/
/* ---------------------------------------------------------------------
void Factory::CloseAllPackages()
{
bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
- while (mPackageMap.begin() != mPackageMap.end())
- {
- PackageMapType::iterator i = mPackageMap.begin();
- ClosePackage(i);
- }
+
+ std::vector< Package::WeakPointer > mAlive;
+ do {
+ mAlive.clear();
+ while (mPackageMap.begin() != mPackageMap.end())
+ {
+ PackageMapType::iterator i = mPackageMap.begin();
+ Package::WeakPointer p = i->second;
+ ClosePackage(i);
+ if (p.lock()) mAlive.push_back(p);
+ }
+ std::vector< Package::WeakPointer >::iterator i;
+ for (i=mAlive.begin();i!=mAlive.end();++i)
+ {
+ // If not dead : reinsert
+ if (i->lock())
+ {
+ bbtkDebugMessage("Kernel",7,"Package "<<i->lock()->GetName()
+ <<" still alive"<<std::endl);
+ // InsertPackage(i->lock());
+ }
+ }
+ }
+ while (mPackageMap.size()>0);
+
bbtkDebugDecTab("Kernel",7);
}
//===================================================================
// remove the entry in the map
mPackageMap.erase(i);
// Release the package if not already destroyed
- if (p.lock()) Package::Release(p);
-
-
+ if (p.lock())
+ {
+ Package::Release(p);
+ }
bbtkDebugDecTab("Kernel",7);
}
//===================================================================
Program: bbtk
Module: $RCSfile: bbtkVtkBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:14 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2009/02/27 11:20:25 $
+ Version: $Revision: 1.8 $
=========================================================================*/
/* ---------------------------------------------------------------------
*/
#ifndef __bbtkVtkBlackBoxMacros_h__
#define __bbtkVtkBlackBoxMacros_h__
-//#include <vtkGarbageCollector.h>
+#include <vtkGarbageCollector.h>
//#include <vtkObjectFactory.h>
#include <vtkDebugLeaks.h>
//===========================================================================
//===========================================================================
+//===========================================================================
+#define BBTK_VTK_DISABLE_GARBAGE_COLLECTOR \
+ public: \
+ virtual void Register(vtkObjectBase* o) {} \
+ virtual void UnRegister(vtkObjectBase* o) {} \
+ protected: \
+ virtual void ReportReferences(vtkGarbageCollector* collector) {}
+
+/*
+
+ 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_DELETE() \
void bbDelete() { \
+ for (int i=0; i<vtkParent::GetNumberOfInputPorts();++i) \
+ vtkParent::SetInput(i,0); \
bbGetOutputOut()->SetSource(NULL); \
+ /*std::cout << "VTK : bbDelete() "<<std::endl;*/ \
+ /*std::cout << "Use count = "<<GetUseCount()<<std::endl;*/ \
+ /*std::cout << "VTK count = "<<GetReferenceCount()<<std::endl;*/ \
+ /* vtkParent::SetReferenceCount(1); GetUseCount());*/ \
+ /*delete this; */ \
vtkParent::Delete(); \
}
#define BBTK_VTK_NEW(CLASS,VTKPARENT) \
inline static Pointer New(const std::string& name) \
{ \
- vtkDebugLeaks::ConstructClass(#VTKPARENT); \
+ /*vtkDebugLeaks::ConstructClass(#VTKPARENT);*/ \
bbtkDebugMessage("object",1,"##> "<<#CLASS \
<<"::New(\""<<name<<"\")"<<std::endl); \
Pointer p = MakeBlackBoxPointer(new Self(name)); \
#define BBTK_VTK_CLONE(CLASS,VTKPARENT) \
inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
{ \
- vtkDebugLeaks::ConstructClass(#VTKPARENT); \
+ /*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; \
- } \
+ }
//===========================================================================
BBTK_VTK_DELETE(); \
public : \
BBTK_VTK_NEW(CLASS,VTKPARENT); \
- BBTK_VTK_CLONE(CLASS,VTKPARENT);
+ BBTK_VTK_CLONE(CLASS,VTKPARENT);
+
+// 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) \
{ return GetImageDataInput(0); /*vtkParent::GetInput();*/ } \
void bbSetInput##NAME (TYPE d) \
{ vtkParent::SetInput( (vtkDataObject*) d); \
- /*bbSetModifiedStatus();*/ }
+ BBTK_VTK_UNREGISTER(d);/*bbSetModifiedStatus();*/ }
//===========================================================================
//===========================================================================
{ return GetPolyDataInput(0); /*vtkParent::GetInput();*/ } \
void bbSetInput##NAME (TYPE d) \
{ vtkParent::SetInput( (vtkDataObject*) d); \
- /*bbSetModifiedStatus();*/ }
+ BBTK_VTK_UNREGISTER(d);/*bbSetModifiedStatus();*/ }
//===========================================================================
//===========================================================================
TYPE bbGetInput##NAME () \
{ return dynamic_cast<TYPE>(vtkParent::GetInput()); } \
void bbSetInput##NAME (TYPE d) \
- { vtkParent::SetInput( (vtkDataObject*) d); /*vtkParent::GetOutput() = d;*/ }
+ { vtkParent::SetInput( (vtkDataObject*) d); \
+ BBTK_VTK_UNREGISTER(d);/*vtkParent::GetOutput() = d;*/ }
//===========================================================================
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.cxx,v $
Language: C++
- Date: $Date: 2009/01/08 10:18:37 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2009/02/27 11:20:26 $
+ Version: $Revision: 1.20 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
//================================================================
- class myCallbackPlane : public vtkCommand
+ class ImagePlanes::VtkCallbackType : public vtkCommand
{
public:
- static myCallbackPlane *New()
+ static VtkCallbackType *New()
{
- return new myCallbackPlane;
+ return new VtkCallbackType;
}
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
- currentBlackBox->Process();
- currentBlackBox->bbSignalOutputModification();
+ mBlackBox->Process();
+ mBlackBox->bbSignalOutputModification();
}
- void SetCurrentBlackBox(ImagePlanes *cBB) {currentBlackBox = cBB;};
- void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
- myCallbackPlane() {};
+ void SetBlackBox(ImagePlanes *BB) { mBlackBox = BB;};
+ // void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
+ VtkCallbackType() {};
private:
- vtkPlaneWidget *planeWidget;
- ImagePlanes *currentBlackBox;
+ // vtkPlaneWidget *planeWidget;
+ ImagePlanes *mBlackBox;
};
//================================================================
picker->UnRegister(NULL);
- myCallbackPlane *_myCallback = myCallbackPlane::New();
- _myCallback->SetCurrentBlackBox(this);
- planeWidgetX->AddObserver(vtkCommand::InteractionEvent,_myCallback);
- planeWidgetY->AddObserver(vtkCommand::InteractionEvent,_myCallback);
- planeWidgetZ->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+ mVtkCallback = VtkCallbackType::New();
+ mVtkCallback->SetBlackBox(this);
+ planeWidgetX->AddObserver(vtkCommand::InteractionEvent,mVtkCallback);
+ planeWidgetY->AddObserver(vtkCommand::InteractionEvent,mVtkCallback);
+ planeWidgetZ->AddObserver(vtkCommand::InteractionEvent,mVtkCallback);
}
//---------------------------------------------------------------------
void ImagePlanes::bbUserDestructor()
{
- if (bbGetOutputPlaneX()) bbGetOutputPlaneX()->UnRegister(NULL);
- if (bbGetOutputPlaneY()) bbGetOutputPlaneY()->UnRegister(NULL);
- if (bbGetOutputPlaneZ()) bbGetOutputPlaneZ()->UnRegister(NULL);
+ if (bbGetOutputPlaneX())
+ {
+ bbGetOutputPlaneX()->SetInput(NULL);
+ bbGetOutputPlaneX()->UnRegister(NULL);
+ }
+ if (bbGetOutputPlaneY())
+ {
+ bbGetOutputPlaneY()->SetInput(NULL);
+ bbGetOutputPlaneY()->UnRegister(NULL);
+ }
+ if (bbGetOutputPlaneZ())
+ {
+ bbGetOutputPlaneZ()->SetInput(NULL);
+ bbGetOutputPlaneZ()->UnRegister(NULL);
+ }
+ mVtkCallback->Delete();
}
//---------------------------------------------------------------------
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.h,v $
Language: C++
- Date: $Date: 2009/01/08 10:18:37 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2009/02/27 11:20:26 $
+ Version: $Revision: 1.13 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
typedef std::vector<double> winLevel;
+
+
class /*BBTK_EXPORT*/ ImagePlanes : public bbtk::AtomicBlackBox
{
virtual void bbUserDestructor();
void Init();
private:
+ class VtkCallbackType;
+ VtkCallbackType* mVtkCallback;
vtkImageData* image;
};