]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Wed, 7 May 2008 07:26:49 +0000 (07:26 +0000)
committerguigues <guigues>
Wed, 7 May 2008 07:26:49 +0000 (07:26 +0000)
kernel/appli/bbfy/bbfy.cpp
kernel/src/bbtkItkBlackBoxMacros.h
kernel/src/bbtkVtkBlackBoxMacros.h
packages/itk/src/bbitkBinaryThresholdImageFilter.h
packages/itk/src/bbitkExtractImageFilter.h
packages/vtk/src/bbvtkMarchingCubes.h
packages/vtk/src/bbvtkMetaImageReader.xml

index e67bce9600757ff3c9c60d927a9cb56a9954b553..bb420978b4ec88ba69b36820dfb347958d8c77d3 100644 (file)
@@ -550,23 +550,34 @@ void bbfy::CreateHeader()
   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";
@@ -600,7 +611,6 @@ void bbfy::CreateHeader()
       else if (ioi->special=="itk input")
        {
          mFile << "  BBTK_DECLARE_ITK_INPUT(" 
-               << "itkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -610,7 +620,6 @@ void bbfy::CreateHeader()
        {
          if (mType == vtkImageAlgorithm) {
          mFile << "  BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(" 
-               << "vtkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -618,7 +627,6 @@ void bbfy::CreateHeader()
          } 
          else if (mType == vtkPolyDataAlgorithm) {
          mFile << "  BBTK_DECLARE_POLY_DATA_ALGORITHM_INPUT(" 
-               << "vtkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -628,7 +636,6 @@ void bbfy::CreateHeader()
       else if (ioi->special=="itk parameter")
        {
          mFile << "  BBTK_DECLARE_ITK_PARAM(" 
-               << "itkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -637,7 +644,6 @@ void bbfy::CreateHeader()
       else if (ioi->special=="vtk parameter")
        {
          mFile << "  BBTK_DECLARE_VTK_PARAM(" 
-               << "vtkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -668,7 +674,6 @@ void bbfy::CreateHeader()
       else if (ioi->special=="itk output")
        {
          mFile << "  BBTK_DECLARE_ITK_OUTPUT(" 
-               << "itkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -677,7 +682,6 @@ void bbfy::CreateHeader()
       else if (ioi->special=="vtk output")
        {
          mFile << "  BBTK_DECLARE_VTK_OUTPUT(" 
-               << "vtkParent,"
                << ioi->name
                << ","
                << ioi->type
@@ -703,13 +707,13 @@ void bbfy::CreateHeader()
     }
   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
index 52cd4f8c63d9085e353a5a07eeaa18e621022b48..28944657cb20ebb75bfa3b4d3f2cf3fa0c313467 100644 (file)
@@ -3,8 +3,8 @@
   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
index 4fce6738d3826d3717dc7d2c5ab4a41a06d0184d..7f5f0d73e61a0b6158638367a2fd9cc90ae12ed0 100644 (file)
@@ -3,8 +3,8 @@
   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);                                 \
+  }
+//============================================================================
 
 
 //===========================================================================
index aeea6b27d948c6997305cb165a2bda6e98a877ac..b0bf700c3f539288ee0eb627bee99393300ac153 100644 (file)
@@ -17,14 +17,14 @@ namespace bbitk
     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(); }
index b7ebbebda42a13da14bda51420cbe100b2eae9eb..a21de34bb210d35816b56607d98e158cb72d5a92 100644 (file)
@@ -21,12 +21,12 @@ namespace bbitk
                                      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();
   };
 
 
index bd4f55256af1a04bcf53ef0e3ca14cb2e9eaf0cd..083d05d206037a4f71fb64c5def4c93ed2c656de 100644 (file)
@@ -3,8 +3,8 @@
   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
@@ -50,10 +50,12 @@ namespace bbvtk
     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...
@@ -64,13 +66,7 @@ namespace bbvtk
     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();
   };
   //=======================================================================
   
index ff2fd334b3e3d91836e8a6897d6bc80b6ff00e7c..7d33af45ce13343b02703c9acfc87010ebc57b6d 100644 (file)
  
  <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>