]> Creatis software - cpPlugins.git/commitdiff
..
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 29 Nov 2016 23:16:06 +0000 (18:16 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 29 Nov 2016 23:16:06 +0000 (18:16 -0500)
19 files changed:
appli/PipelineEditor/PipelineEditor.cxx
appli/PipelineEditor/PipelineEditor.h
cmake/cpPluginsConfig.cmake.in
lib/cpBaseQtApplication/MainWindow.cxx
lib/cpBaseQtApplication/MainWindow.h
lib/cpExtensions/Algorithms/SkeletonToImageFilter.h [new file with mode: 0644]
lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx [new file with mode: 0644]
lib/cpInstances/ITKNeighborhoodImageIterators.i
lib/cpPlugins/BaseObjects/Parameters.cxx
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Interface/Workspace.h
plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx [new file with mode: 0644]
plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h [new file with mode: 0644]
plugins/ITKAnisotropicSmoothing/ITKAnisotropicSmoothing.i
plugins/ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.cxx
plugins/ITKImageGenericFilters_1/ITKImageGenericFilters_1.i
plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx [new file with mode: 0644]
plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h [new file with mode: 0644]
plugins/ITKMorphology/ITKMorphology.i

index 5751a904d68f776f9a632fff29ea7a7a1da9819f..f49c2a43ad05d1f542d7da7e357c017944687740 100644 (file)
@@ -15,7 +15,6 @@ PipelineEditor( int argc, char* argv[], QWidget* parent )
     m_UI( new Ui::PipelineEditor )
 {
   // Basic configuration
-  this->m_SingleWorkspace = true;
   this->m_BaseWindowTitle = "PipelineEditor - ";
   this->m_UI->setupUi( this );
   this->setCanvas( this->m_UI->Canvas );
@@ -34,14 +33,8 @@ PipelineEditor( int argc, char* argv[], QWidget* parent )
     );
 
   // Load command-line given workspace (if any)
-  this->m_ActiveWS = "empty";
   if( argc > 1 )
-  {
     this->_loadWorkspace( argv[ 1 ] );
-    this->m_ActiveWS = argv[ 1 ];
-  }
-  else
-    this->_addWorkspace( this->m_ActiveWS );
 }
 
 // -------------------------------------------------------------------------
@@ -55,92 +48,94 @@ PipelineEditor::
 void PipelineEditor::
 _slotView( const std::string& name, bool show )
 {
-  typedef cpExtensions::QT::ActorsWidgetInterface _TViewer;
+  /* TODO
+     typedef cpExtensions::QT::ActorsWidgetInterface _TViewer;
 
-  // Get filter parameters
-  std::vector< std::string > tokens;
-  cpPlugins::Tokenize( tokens, name, "@" );
-  if( tokens.size( ) != 2 )
-    return;
-  auto filter_name = tokens[ 1 ];
-  auto output_name = tokens[ 0 ];
+     // Get filter parameters
+     std::vector< std::string > tokens;
+     cpPlugins::Tokenize( tokens, name, "@" );
+     if( tokens.size( ) != 2 )
+     return;
+     auto filter_name = tokens[ 1 ];
+     auto output_name = tokens[ 0 ];
 
-  // Process data
-  if( show )
-  {
-    try
-    {
-      auto ws = this->workspace( this->m_ActiveWS );
-      auto filter = ws->GetFilter( filter_name );
-      cpBaseQtApplication_Execute( filter->Update( ) );
-      auto image = filter->GetOutputData< vtkImageData >( output_name );
-      auto mesh = filter->GetOutputData< vtkPolyData >( output_name );
-      _TViewer* viewer = NULL;
-      if( image != NULL )
-      {
-        int dim = image->GetDataDimension( );
-        if( dim == 2 )
-          viewer =
-            this->_configureViewer< cpExtensions::QT::ImageWidget >(
-              this->m_UI->Viewer
-              );
-        else if( dim == 3 )
-          viewer =
-            this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
-              this->m_UI->Viewer
-              );
-      }
-      else if( mesh != NULL )
-      {
-        viewer =
-          this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
-            this->m_UI->Viewer
-            );
+     // Process data
+     if( show )
+     {
+     try
+     {
+     auto ws = this->workspace( this->m_ActiveWS );
+     auto filter = ws->GetFilter( filter_name );
+     cpBaseQtApplication_Execute( filter->Update( ) );
+     auto image = filter->GetOutputData< vtkImageData >( output_name );
+     auto mesh = filter->GetOutputData< vtkPolyData >( output_name );
+     _TViewer* viewer = NULL;
+     if( image != NULL )
+     {
+     int dim = image->GetDataDimension( );
+     if( dim == 2 )
+     viewer =
+     this->_configureViewer< cpExtensions::QT::ImageWidget >(
+     this->m_UI->Viewer
+     );
+     else if( dim == 3 )
+     viewer =
+     this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
+     this->m_UI->Viewer
+     );
+     }
+     else if( mesh != NULL )
+     {
+     viewer =
+     this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >(
+     this->m_UI->Viewer
+     );
 
-      } // fi
-      if(
-        dynamic_cast< QWidget* >( viewer ) !=
-        dynamic_cast< QWidget* >( this->m_UI->Viewer )
-        )
-      {
-        delete this->m_UI->Viewer;
-        this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer );
-        this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer );
-        this->setViewer( viewer );
+     } // fi
+     if(
+     dynamic_cast< QWidget* >( viewer ) !=
+     dynamic_cast< QWidget* >( this->m_UI->Viewer )
+     )
+     {
+     delete this->m_UI->Viewer;
+     this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer );
+     this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer );
+     this->setViewer( viewer );
 
-      } // fi
-      if( image != NULL )
-      {
-        this->m_Blocker.block( );
-        auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
-        auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer );
-        if( mpr != NULL )
-          mpr->SetImage( image, name );
-        else if( imv != NULL )
-          imv->SetImage( image, name );
-        this->m_Blocker.unblock( );
-      }
-      else if( mesh != NULL )
-      {
-        this->m_Blocker.block( );
-        auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
-        if( mpr != NULL )
-          mpr->Add( mesh, name );
-        this->m_Blocker.unblock( );
+     } // fi
+     if( image != NULL )
+     {
+     this->m_Blocker.block( );
+     auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
+     auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer );
+     if( mpr != NULL )
+     mpr->SetImage( image, name );
+     else if( imv != NULL )
+     imv->SetImage( image, name );
+     this->m_Blocker.unblock( );
+     }
+     else if( mesh != NULL )
+     {
+     this->m_Blocker.block( );
+     auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer );
+     if( mpr != NULL )
+     mpr->Add( mesh, name );
+     this->m_Blocker.unblock( );
 
-      } // fi
-    }
-    catch( std::exception& err )
-    {
-      QMessageBox::critical(
-        NULL,
-        QMessageBox::tr( "Error showing data" ),
-        QMessageBox::tr( err.what( ) )
-        );
+     } // fi
+     }
+     catch( std::exception& err )
+     {
+     QMessageBox::critical(
+     NULL,
+     QMessageBox::tr( "Error showing data" ),
+     QMessageBox::tr( err.what( ) )
+     );
 
-    } // yrt
+     } // yrt
 
-  } // fi
+     } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
index 3f4a68be1d6fafb27325e897f839b719945a95ff..8c8db3547fcb39f21678933bb8245201ceba1f38 100644 (file)
@@ -28,7 +28,6 @@ protected slots:
 
 private:
   Ui::PipelineEditor* m_UI;
-  std::string m_ActiveWS;
 };
 
 #endif // __PipelineEditor__h__
index 0564e9dba654a5d38c017907d614e7311cae5684..7a2c72a42cd2023c2d7f50b7676a34271b3abf09 100644 (file)
@@ -2,48 +2,56 @@
 ## == Find cpPlugins-cmake tools ==
 ## ================================
 
+SET(ITK_DIR "@ITK_DIR@")
+SET(VTK_DIR "@VTK_DIR@")
 IF("@Qt4_FOUND@" STREQUAL "TRUE")
   SET(USE_QT4 ON)
+  SET(QT_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@")
 ENDIF("@Qt4_FOUND@" STREQUAL "TRUE")
 
 ## ====================
 ## == Find libraries ==
 ## ====================
 
-SET(cpPlugins_BaseLibraries "@cpPlugins_BaseLibraries@" CACHE STRING "Internal")
-SET(cpPlugins_AllInstances "@cpPlugins_AllInstances@" CACHE STRING "Internal")
-MARK_AS_ADVANCED(FORCE cpPlugins_BaseLibraries)
+SET(
+  cpPlugins_AllInstances
+  "@cpPlugins_AllInstances@"
+  CACHE STRING "All instances from templated code"
+  )
 MARK_AS_ADVANCED(FORCE cpPlugins_AllInstances)
 
-SET(_all_libs ${cpPlugins_BaseLibraries} ${cpPlugins_AllInstances})
+SET(
+  _all_libs
+  cp_tinyxml2
+  cpExtensions
+  cpPlugins
+  cpPluginsDataObjects
+  )
+IF(USE_QT4)
+  LIST(APPEND _all_libs cp_QCustomPlot cpBaseQtApplication)
+ENDIF(USE_QT4)
+SET(cpPlugins_Libraries ${_all_libs} CACHE STRING "cpPlugins base libraries")
+MARK_AS_ADVANCED(FORCE cpPlugins_Libraries)
 
+SET(_all_libs ${cpPlugins_AllInstances} ${cpPlugins_Libraries})
 SET(_l_locations)
 FOREACH(_l ${_all_libs})
-  IF(MSVC)
-    FIND_LIBRARY(
-      ${_l}_LIB NAMES ${_l}
-      HINTS
-      @PROJECT_BINARY_DIR@/$(ConfigurationName)
-      @CMAKE_INSTALL_PREFIX@/bin
-      @CMAKE_INSTALL_PREFIX@/lib
-      )
-  ELSE(MSVC)
-    FIND_LIBRARY(
-      ${_l}_LIB NAMES ${_l}
-      HINTS
-      @PROJECT_BINARY_DIR@
-      @CMAKE_INSTALL_PREFIX@/bin
-      @CMAKE_INSTALL_PREFIX@/lib
-      )
-  ENDIF(MSVC)
+  FIND_LIBRARY(
+    ${_l}_LIB NAMES ${_l}
+    PATHS
+    @PROJECT_BINARY_DIR@
+    @CMAKE_INSTALL_PREFIX@/bin
+    @CMAKE_INSTALL_PREFIX@/lib
+    ${_l_locations}
+    )
   IF(${_l}_LIB)
     MARK_AS_ADVANCED(FORCE ${_l}_LIB)
     GET_FILENAME_COMPONENT(_dir ${${_l}_LIB} DIRECTORY)
     LIST(APPEND _l_locations ${_dir})
+    LIST(REMOVE_DUPLICATES _l_locations)
   ENDIF(${_l}_LIB)
 ENDFOREACH(_l)
 IF(_l_locations)
-  LIST(REMOVE_DUPLICATES _l_locations)
   LINK_DIRECTORIES(${_l_locations})
 ENDIF(_l_locations)
 
@@ -54,7 +62,6 @@ ENDIF(_l_locations)
 ## TODO: this is not completely correct!!!
 INCLUDE_DIRECTORIES(
   @CMAKE_INSTALL_PREFIX@/include
-  @CMAKE_INSTALL_PREFIX@/include/cpPlugins/Itk2Vtk
   @CMAKE_INSTALL_PREFIX@/include/cpPlugins/cpInstances
   @PROJECT_SOURCE_DIR@
   @PROJECT_BINARY_DIR@
@@ -77,42 +84,33 @@ SET(
   "@cpPlugins_bash_HostCreator_APP@"
   )
 
-FOREACH(_prog ${_exec_programs})
-  IF(MSVC)
-    FIND_PROGRAM(
-      ${_prog}_APP
-      NAMES ${_prog}
-      HINTS /usr /usr/local
-      PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/$(ConfigurationName)
-      PATH_SUFFIXES bin sbin
-      DOC "Where is ${_prog}?"
-      )
-  ELSE(MSVC)
-    FIND_PROGRAM(
-      ${_prog}_APP
-      NAMES ${_prog}
-      HINTS /usr /usr/local
-      PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@
-      PATH_SUFFIXES bin sbin
-      DOC "Where is ${_prog}?"
-      )
-  ENDIF(MSVC)
-  MARK_AS_ADVANCED(FORCE ${_prog}_APP)
-ENDFOREACH(_prog)
+SET(_b_locations)
+FOREACH(_p ${_exec_programs})
+  FIND_PROGRAM(
+    ${_p}_APP
+    NAMES ${_p}
+    HINTS /usr /usr/local
+    PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ ${_b_locations}
+    PATH_SUFFIXES bin sbin
+    DOC "Where is ${_prog}?"
+    )
+  IF(${_p}_APP)
+    MARK_AS_ADVANCED(FORCE ${_p}_APP)
+    GET_FILENAME_COMPONENT(_dir ${${_p}_APP} DIRECTORY)
+    LIST(APPEND _b_locations ${_dir})
+    LIST(REMOVE_DUPLICATES _b_locations)
+  ENDIF(${_p}_APP)
+ENDFOREACH(_p)
 
 ## ==========================
 ## == Configuration values ==
 ## ==========================
 
-SET(cpPlugins_CONFIG_NUMBER_OF_FILES @cpPlugins_CONFIG_NUMBER_OF_FILES@ CACHE STRING "Internal")
-SET(cpPlugins_CONFIG_INTEGER_TYPES @cpPlugins_CONFIG_INTEGER_TYPES@ CACHE STRING "Internal")
-SET(cpPlugins_CONFIG_REAL_TYPES @cpPlugins_CONFIG_REAL_TYPES@ CACHE STRING "Internal")
-SET(cpPlugins_CONFIG_PROCESS_DIMENSIONS @cpPlugins_CONFIG_PROCESS_DIMENSIONS@ CACHE STRING "Internal")
-SET(cpPlugins_CONFIG_VISUAL_DIMENSIONS @cpPlugins_CONFIG_VISUAL_DIMENSIONS@ CACHE STRING "Internal")
+SET(cpPlugins_CONFIG_NUMBER_OF_FILES "@cpPlugins_CONFIG_NUMBER_OF_FILES@" CACHE STRING "Internal")
+SET(cpPlugins_CONFIG_PROCESS_DIMENSIONS "@cpPlugins_CONFIG_PROCESS_DIMENSIONS@" CACHE STRING "Internal")
+SET(cpPlugins_CONFIG_VISUAL_DIMENSIONS "@cpPlugins_CONFIG_VISUAL_DIMENSIONS@" CACHE STRING "Internal")
 
 MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_NUMBER_OF_FILES)
-MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_INTEGER_TYPES)
-MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_REAL_TYPES)
 MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_PROCESS_DIMENSIONS)
 MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_VISUAL_DIMENSIONS)
 
index 9b16236acb94760f09af7f12bf3fb1f8d7e8c6ad..ac8858ed934da7028651f2cb0b9d7e29261a13fa 100644 (file)
@@ -16,7 +16,6 @@ MainWindow(
   )
   : Superclass( parent ),
     m_LastSaveFileName( "" ),
-    m_SingleWorkspace( false ),
     m_BaseWindowTitle( "cpBaseQtApplication" ),
     m_Canvas( NULL ),
     m_Navigator( NULL ),
@@ -34,6 +33,7 @@ MainWindow(
     QMessageBox::critical( this, "Error guessing plugins.", err.what( ) );
 
   } // yrt
+  this->_clearWorkspace( );
 }
 
 // -------------------------------------------------------------------------
@@ -45,25 +45,17 @@ cpBaseQtApplication::MainWindow::
 // -------------------------------------------------------------------------
 cpBaseQtApplication::MainWindow::
 TWorkspace* cpBaseQtApplication::MainWindow::
-workspace( const std::string& wname )
+workspace( )
 {
-  auto wIt = this->m_Workspaces.find( wname );
-  if( wIt != this->m_Workspaces.end( ) )
-    return( wIt->second.GetPointer( ) );
-  else
-    return( NULL );
+  return( this->m_Workspace );
 }
 
 // -------------------------------------------------------------------------
 const cpBaseQtApplication::MainWindow::
 TWorkspace* cpBaseQtApplication::MainWindow::
-workspace( const std::string& wname ) const
+workspace( ) const
 {
-  auto wIt = this->m_Workspaces.find( wname );
-  if( wIt != this->m_Workspaces.end( ) )
-    return( wIt->second.GetPointer( ) );
-  else
-    return( NULL );
+  return( this->m_Workspace );
 }
 
 // -------------------------------------------------------------------------
@@ -136,9 +128,8 @@ setViewer( cpExtensions::QT::ActorsWidgetInterface* v )
   if( this->m_Viewer != NULL )
   {
     auto interactors = this->m_Viewer->GetInteractors( );
-    for( auto wIt : this->m_Workspaces )
-      for( auto i : interactors )
-        wIt.second->AddInteractor( i );
+    for( auto i : interactors )
+      this->m_Workspace->AddInteractor( i );
 
   } // fi
 }
@@ -218,136 +209,39 @@ _loadPluginsFromPath( )
 
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
-_clearWorkspaces( )
-{
-  this->m_Workspaces.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_addWorkspace( const std::string& name )
+_clearWorkspace( )
 {
-  auto wIt = this->m_Workspaces.find( name );
-  if( wIt == this->m_Workspaces.end( ) )
+  this->setWindowTitle( this->m_BaseWindowTitle.c_str( ) );
+  this->m_Workspace = TWorkspace::New( );
+  if( this->m_Canvas != NULL )
   {
-    if( this->m_SingleWorkspace )
-      this->m_Workspaces.clear( );
-    this->m_Workspaces[ name ] = TWorkspace::New( );
-    if( this->m_Canvas != NULL )
-      this->m_Canvas->setWorkspace( this->m_Workspaces[ name ] );
-    if( this->m_Viewer !=  NULL )
-    {
-      auto interactors = this->m_Viewer->GetInteractors( );
-      auto wIt = this->m_Workspaces.find( name );
-      for( auto i : interactors )
-        wIt->second->AddInteractor( i );
-
-    } // fi
-    this->setWindowTitle( ( this->m_BaseWindowTitle + name ).c_str( ) );
+    this->m_Canvas->clear( );
+    this->m_Canvas->setWorkspace( this->m_Workspace );
 
   } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_addWorkspace( )
-{
-  bool ok;
-  QString text =
-    QInputDialog::getText(
-      this, "Creating a new workspace...",
-      "New workspace name: ",
-      QLineEdit::Normal,
-      "new_workspace",
-      &ok
-      );
-  if( ok && !text.isEmpty( ) )
-    this->_addWorkspace( text.toStdString( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_saveWorkspace( const std::string& wname, const std::string& fname )
-{
-  auto wIt = this->m_Workspaces.find( wname );
-  if( wIt != this->m_Workspaces.end( ) )
+  if( this->m_Viewer != NULL )
   {
-    try
-    {
-      wIt->second->Save( fname );
-      this->m_LastSaveFileName = fname;
-    }
-    catch( std::exception& err )
-    {
-      QMessageBox::critical(
-        this,
-        QMessageBox::tr( "Error saving workspace" ),
-        QMessageBox::tr( err.what( ) )
-        );
-
-    } // yrt
-  }
-  else
-    QMessageBox::critical(
-      this,
-      "Error saving workspace",
-      (
-        std::string( "Workspace \"" ) + wname +
-        std::string( "\" does not exist." )
-        ).c_str( )
-      );
+    // TODO: this->m_Viewer->clear( );
+    auto interactors = this->m_Viewer->GetInteractors( );
+    for( auto i : interactors )
+      this->m_Workspace->AddInteractor( i );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
-_saveWorkspace( const std::string& wname, bool force )
+_saveWorkspace( const std::string& fname )
 {
-  auto wIt = this->m_Workspaces.find( wname );
-  if( wIt != this->m_Workspaces.end( ) )
-  {
-    if( this->m_LastSaveFileName == "" || force )
-    {
-      QFileDialog dlg( this );
-      dlg.setFileMode( QFileDialog::AnyFile );
-      dlg.setDirectory( "." );
-      dlg.setAcceptMode( QFileDialog::AcceptSave );
-      dlg.setNameFilter(
-        QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
-        );
-      dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
-      dlg.setWindowTitle(
-        (
-          std::string( "Saving \"" ) + wIt->first + std::string( "\"..." )
-          ).c_str( )
-        );
-      if( dlg.exec( ) )
-        this->_saveWorkspace(
-          wIt->first, dlg.selectedFiles( ).begin( )->toStdString( )
-          );
-    }
-    else
-      this->_saveWorkspace( wIt->first, this->m_LastSaveFileName );
-  }
-  else
-    QMessageBox::critical(
-      this,
-      "Error saving workspace",
-      (
-        std::string( "Workspace \"" ) + wname +
-        std::string( "\" does not exist." )
-        ).c_str( )
-      );
+  this->m_LastSaveFileName = fname;
+  this->m_Workspace->Save( this->m_LastSaveFileName );
 }
 
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
 _saveWorkspace( )
 {
-  for(
-    auto wIt = this->m_Workspaces.begin( );
-    wIt != this->m_Workspaces.end( );
-    ++wIt
-    )
+  if( this->m_LastSaveFileName == "" )
   {
     QFileDialog dlg( this );
     dlg.setFileMode( QFileDialog::AnyFile );
@@ -357,17 +251,12 @@ _saveWorkspace( )
       QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
       );
     dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
-    dlg.setWindowTitle(
-      (
-        std::string( "Saving \"" ) + wIt->first + std::string( "\"..." )
-        ).c_str( )
-      );
+    dlg.setWindowTitle( "Saving workspace" );
     if( dlg.exec( ) )
-      this->_saveWorkspace(
-        wIt->first, dlg.selectedFiles( ).begin( )->toStdString( )
-        );
-
-  } // rof
+      this->_saveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+  }
+  else
+    this->_saveWorkspace( this->m_LastSaveFileName );
 }
 
 // -------------------------------------------------------------------------
@@ -376,10 +265,11 @@ _loadWorkspace( const std::string& fname )
 {
   try
   {
-    this->_addWorkspace( fname );
-    this->m_Workspaces[ fname ]->Load( fname );
+    this->_clearWorkspace( );
+    this->m_Workspace->Load( fname );
+    this->m_LastSaveFileName = "";
     if( this->m_Canvas != NULL )
-      this->m_Canvas->setWorkspace( this->m_Workspaces[ fname ] );
+      this->m_Canvas->setWorkspace( this->m_Workspace );
   }
   catch( std::exception& err )
   {
index 53aebf287d2f1abedfcf9795c569de28fefbf6d4..a29ad0fcb194c0311c8502d6e2e89893518a1e7b 100644 (file)
@@ -74,8 +74,8 @@ namespace cpBaseQtApplication
       );
     virtual ~MainWindow( );
 
-    TWorkspace* workspace( const std::string& wname );
-    const TWorkspace* workspace( const std::string& wname ) const;
+    TWorkspace* workspace( );
+    const TWorkspace* workspace( ) const;
 
     Pipeline::Canvas* canvas( );
     const Pipeline::Canvas* canvas( ) const;
@@ -105,13 +105,9 @@ namespace cpBaseQtApplication
     void _loadPluginsFromPath( const std::string& path );
     void _loadPluginsFromPath( );
 
-    void _clearWorkspaces( );
+    void _clearWorkspace( );
 
-    virtual void _addWorkspace( const std::string& name );
-    void _addWorkspace( );
-
-    void _saveWorkspace( const std::string& wname, const std::string& fname );
-    void _saveWorkspace( const std::string& wname, bool force );
+    void _saveWorkspace( const std::string& fname );
     void _saveWorkspace( );
 
     void _loadWorkspace( const std::string& fname );
@@ -120,13 +116,12 @@ namespace cpBaseQtApplication
     void _actorsProperties( );
 
   protected:
-    Blocker           m_Blocker;
-    std::string       m_RunPath;
-    TPlugins::Pointer m_Plugins;
-    std::string       m_LastSaveFileName;
-    std::map< std::string, TWorkspace::Pointer > m_Workspaces;
+    Blocker             m_Blocker;
+    std::string         m_RunPath;
+    TPlugins::Pointer   m_Plugins;
+    std::string         m_LastSaveFileName;
+    TWorkspace::Pointer m_Workspace;
 
-    bool        m_SingleWorkspace;
     std::string m_BaseWindowTitle;
 
     Pipeline::Canvas*                        m_Canvas;
diff --git a/lib/cpExtensions/Algorithms/SkeletonToImageFilter.h b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.h
new file mode 100644 (file)
index 0000000..8c9d8fe
--- /dev/null
@@ -0,0 +1,81 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __cpExtensions__Algorithms__SkeletonToImageFilter__h__
+#define __cpExtensions__Algorithms__SkeletonToImageFilter__h__
+
+#include <cpExtensions/Config.h>
+#include <itkImageSource.h>
+
+// -------------------------------------------------------------------------
+namespace cpExtensions
+{
+  namespace Algorithms
+  {
+    /**
+     */
+    template< class _TSkeleton, class _TImage >
+    class SkeletonToImageFilter
+      : public itk::ImageSource< _TImage >
+    {
+    public:
+      // Basic types
+      typedef SkeletonToImageFilter           Self;
+      typedef itk::ImageSource< _TImage >     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef _TSkeleton TSkeleton;
+      typedef _TImage    TImage;
+      typedef typename _TImage::IndexType  TIndex;
+      typedef typename _TImage::PixelType  TPixel;
+      typedef typename _TImage::PointType  TPoint;
+      typedef typename _TImage::RegionType TRegion;
+      typedef itk::ImageBase< _TImage::ImageDimension > TImageBase;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( SkeletonToImageFilter, itk::ImageSource );
+
+      itkGetConstMacro( InsideValue, TPixel );
+      itkGetConstMacro( OutsideValue, TPixel );
+
+      itkSetMacro( InsideValue, TPixel );
+      itkSetMacro( OutsideValue, TPixel );
+
+    public:
+      const TImageBase* GetTemplateImage( ) const;
+      void SetTemplateImage( const TImageBase* image );
+
+      const TSkeleton* GetSkeleton( ) const;
+      void SetSkeleton( const TSkeleton* skeleton );
+
+    protected:
+      SkeletonToImageFilter( );
+      virtual ~SkeletonToImageFilter( );
+
+      virtual void GenerateData( ) cpExtensions_OVERRIDE;
+
+    private:
+      // Purposely not implemented
+      SkeletonToImageFilter( const Self& );
+      void operator=( const Self& );
+
+    protected:
+      TPixel m_InsideValue;
+      TPixel m_OutsideValue;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+// -------------------------------------------------------------------------
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <cpExtensions/Algorithms/SkeletonToImageFilter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __cpExtensions__Algorithms__SkeletonToImageFilter__h__
+
+// eof - $RCSfile$
diff --git a/lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx
new file mode 100644 (file)
index 0000000..1f428c9
--- /dev/null
@@ -0,0 +1,119 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__
+#define __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+const typename
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+TImageBase*
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+GetTemplateImage( ) const
+{
+  return(
+    dynamic_cast< const TImageBase* >(
+      this->itk::ProcessObject::GetInput( 0 )
+      )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+void 
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+SetTemplateImage( const TImageBase* image )
+{
+  this->itk::ProcessObject::SetNthInput(
+    0, const_cast< TImageBase* >( image )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+const typename
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+TSkeleton*
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+GetSkeleton( ) const
+{
+  return(
+    dynamic_cast< const TSkeleton* >(
+      this->itk::ProcessObject::GetInput( 1 )
+      )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+void
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+SetSkeleton( const TSkeleton* skeleton )
+{
+  this->itk::ProcessObject::SetNthInput(
+    1, const_cast< TSkeleton* >( skeleton )
+    );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+SkeletonToImageFilter( )
+  : Superclass( ),
+    m_InsideValue( TPixel( 1 ) ),
+    m_OutsideValue( TPixel( 0 ) )
+{
+  this->SetNumberOfRequiredInputs( 2 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+~SkeletonToImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton, class _TImage >
+void cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >::
+GenerateData( )
+{
+  const TSkeleton* sk = this->GetSkeleton( );
+  const TImageBase* im = this->GetTemplateImage( );
+  TImage* out = this->GetOutput( 0 );
+
+  out->SetLargestPossibleRegion( im->GetLargestPossibleRegion( ) );
+  out->SetRequestedRegion( im->GetRequestedRegion( ) );
+  out->SetBufferedRegion( im->GetBufferedRegion( ) );
+  out->SetSpacing( im->GetSpacing( ) );
+  out->SetOrigin( im->GetOrigin( ) );
+  out->SetDirection( im->GetDirection( ) );
+  out->Allocate( );
+  out->FillBuffer( this->m_OutsideValue );
+
+  // Fill skeleton
+  auto mIt = sk->BeginEdgesRows( );
+  for( ; mIt != sk->EndEdgesRows( ); ++mIt )
+  {
+    auto rIt = mIt->second.begin( );
+    for( ; rIt != mIt->second.end( ); ++rIt )
+    {
+      auto eIt = rIt->second.begin( );
+      for( ; eIt != rIt->second.end( ); ++eIt )
+      {
+        auto path = *eIt;
+        for( unsigned int i = 0; i < path->GetSize( ); ++i )
+          out->SetPixel( path->GetVertex( i ), this->m_InsideValue );
+
+      } // rof
+
+    } // rof
+
+  } // rof
+}
+
+#endif // __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__
+
+// eof - $RCSfile$
index dd592ce0a4dc5c2f6c5984fa1d353c2c0473fa92..466da6186e51fcece11ca4f3dea7e5c22684701e 100644 (file)
@@ -31,4 +31,7 @@ instances itk::#it#< itk::Image< #pi#, #pdims# >, itk::#co#< itk::Image< #pi#, #
 tinclude itkNeighborhoodAlgorithm:h|hxx
 instances itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< itk::Image< #pi#, #pdims# > >
 
+tinclude itkNeighborhoodInnerProduct:h|hxx
+instances itk::NeighborhoodInnerProduct< itk::Image< #pi#, #pdims# >, #pi#, #pi# >
+
 ** eof - $RCSfile$
index 227898cddc843e4dadfd8750b4a4caf3e8822e98..cfb5f83b220aaa3b0a8488887932aa2df34c8deb 100644 (file)
@@ -197,12 +197,8 @@ void cpPlugins::BaseObjects::Parameters::
 ConfigureAsRealTypesChoices( const std::string& name )
 {
   std::vector< std::string > choices;
-#ifdef cpPlugins_CONFIG_REAL_TYPES_float
   choices.push_back( "float" );
-#endif // cpPlugins_CONFIG_REAL_TYPES_float
-#ifdef cpPlugins_CONFIG_REAL_TYPES_double
   choices.push_back( "double" );
-#endif // cpPlugins_CONFIG_REAL_TYPES_double
   this->ConfigureAsChoices( name, choices );
 }
 
@@ -211,22 +207,14 @@ void cpPlugins::BaseObjects::Parameters::
 ConfigureAsIntTypesChoices( const std::string& name )
 {
   std::vector< std::string > choices;
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
   choices.push_back( "char" );
   choices.push_back( "uchar" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
   choices.push_back( "short" );
   choices.push_back( "ushort" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
   choices.push_back( "int" );
   choices.push_back( "uint" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
   choices.push_back( "long" );
   choices.push_back( "ulong" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
   this->ConfigureAsChoices( name, choices );
 }
 
@@ -235,28 +223,16 @@ void cpPlugins::BaseObjects::Parameters::
 ConfigureAsScalarTypesChoices( const std::string& name )
 {
   std::vector< std::string > choices;
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
   choices.push_back( "char" );
   choices.push_back( "uchar" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
   choices.push_back( "short" );
   choices.push_back( "ushort" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
   choices.push_back( "int" );
   choices.push_back( "uint" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
-#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
   choices.push_back( "long" );
   choices.push_back( "ulong" );
-#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
-#ifdef cpPlugins_CONFIG_REAL_TYPES_float
   choices.push_back( "float" );
-#endif // cpPlugins_CONFIG_REAL_TYPES_float
-#ifdef cpPlugins_CONFIG_REAL_TYPES_double
   choices.push_back( "double" );
-#endif // cpPlugins_CONFIG_REAL_TYPES_double
   this->ConfigureAsChoices( name, choices );
 }
 
index 5b80a36bb9a19f392bf941be9a7c9fd4f7cd3d90..8eca62080671d2108b9bb02ec3c3faf6335bd201 100644 (file)
@@ -1,6 +1,35 @@
 #include <cpPlugins/Interface/Workspace.h>
 #include <cpPlugins/BaseObjects/Widget.h>
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+Pointer cpPlugins::Interface::Workspace::
+New( )
+{
+  Pointer smartPtr = new Self;
+  smartPtr->UnRegister( );
+  return( smartPtr );
+}
+
+// -------------------------------------------------------------------------
+itk::LightObject::Pointer cpPlugins::Interface::Workspace::
+CreateAnother( ) const
+{
+  itk::LightObject::Pointer smartPtr;
+  smartPtr = Self::New( ).GetPointer( );
+  return( smartPtr );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+Pointer cpPlugins::Interface::Workspace::
+Clone( ) const
+{
+  Pointer rval =
+    dynamic_cast< Self* >( this->InternalClone( ).GetPointer( ) );
+  return( rval );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
 Clear( )
index 73db780f9dab7dcb800d5c249d15d268b3f23053..7d76c05b13a4dbde315159d15aa677c965e2793f 100644 (file)
@@ -38,10 +38,14 @@ namespace cpPlugins
       */
 
     public:
-      itkNewMacro( Self );
       itkTypeMacro( Workspace, itk::Object );
 
     public:
+      // Factory methods
+      static Pointer New( );
+      virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE;
+      Pointer Clone( ) const;
+
       // Workspace IO
       void Load( const std::string& fname );
       void Save( const std::string& fname ) const;
@@ -72,36 +76,6 @@ namespace cpPlugins
       // Interactors
       void AddInteractor( vtkRenderWindowInteractor* iren );
 
-      // Exposed ports
-      /* TODO
-         const TExposedPorts& GetExposedInputs( ) const;
-         const TExposedPorts& GetExposedOutputs( ) const;
-         cpPlugins::BaseObjects::DataObject* GetExposedOutput(
-         const std::string& name
-         );
-         const cpPlugins::BaseObjects::DataObject* GetExposedOutput(
-         const std::string& name
-         ) const;
-         bool ExposeInput(
-         const std::string& name,
-         const std::string& filter, const std::string& filter_input
-         );
-         bool ExposeOutput(
-         const std::string& name,
-         const std::string& filter, const std::string& filter_output
-         );
-         void HideInput( const std::string& name );
-         void HideOutput( const std::string& name );
-         bool RenameExposedInput(
-         const std::string& old_name,
-         const std::string& new_name
-         );
-         bool RenameExposedOutput(
-         const std::string& old_name,
-         const std::string& new_name
-         );
-      */
-
       // Connection management
       bool Connect(
         const std::string& origin_filter,
diff --git a/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx
new file mode 100644 (file)
index 0000000..775b7c0
--- /dev/null
@@ -0,0 +1,71 @@
+#include <ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h>
+#include <cpInstances/Image.h>
+
+#include <itkCurvatureAnisotropicDiffusionImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter::
+CurvatureAnisotropicDiffusionImageFilter( )
+  : Superclass( )
+{
+  typedef cpInstances::Image _TImage;
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureOutput< _TImage >( "Output" );
+
+  this->m_Parameters.ConfigureAsUint( "NumberOfIterations", 5 );
+  this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false );
+  this->m_Parameters.ConfigureAsReal( "ConductanceParameter", 3 );
+  this->m_Parameters.ConfigureAsReal( "TimeStep", 0.0625 );
+  this->m_Parameters.ConfigureAsRealTypesChoices( "OutputResolution" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter::
+~CurvatureAnisotropicDiffusionImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "No valid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter::
+_GD0( _TImage* image )
+{
+  std::string out_res =
+    this->m_Parameters.GetSelectedChoice( "OutputResolution" );
+  if( out_res == "float" ) this->_GD1< _TImage, float >( image );
+  if( out_res == "double" ) this->_GD1< _TImage, double >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter::
+_GD1( _TImage* image )
+{
+  typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutImage;
+  typedef
+    itk::CurvatureAnisotropicDiffusionImageFilter< _TImage, _TOutImage >
+    _TFilter;
+
+  // Configure filter
+  _TFilter* filter = this->_CreateITK< _TFilter >( );
+  filter->SetInput( image );
+  filter->SetNumberOfIterations( this->m_Parameters.GetUint( "NumberOfIterations" ) );
+  filter->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) );
+  filter->SetConductanceParameter( this->m_Parameters.GetReal( "ConductanceParameter" ) );
+  filter->SetTimeStep( this->m_Parameters.GetReal( "TimeStep" ) );
+  filter->Update( );
+
+  // Connect output
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h
new file mode 100644 (file)
index 0000000..d11d39e
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__
+#define __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__
+
+#include <cpPluginsITKAnisotropicSmoothing_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsITKAnisotropicSmoothing
+{
+  /**
+   */
+  class cpPluginsITKAnisotropicSmoothing_EXPORT CurvatureAnisotropicDiffusionImageFilter
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject(
+      CurvatureAnisotropicDiffusionImageFilter,
+      cpPlugins::BaseObjects::ProcessObject,
+      ImageSmoothing
+      );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TImage, class _TScalar >
+    inline void _GD1( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__
+
+// eof - $RCSfile$
index 3077c6ad42791d42d3dd977d5791357acc1bd16a..d87073b8f8aef138b71452fd3fe539b554d7ba9d 100644 (file)
@@ -1,6 +1,6 @@
 header #define ITK_MANUAL_INSTANTIATION
 
-define functions=ScalarAnisotropicDiffusionFunction;GradientNDAnisotropicDiffusionFunction
+define functions=ScalarAnisotropicDiffusionFunction;GradientNDAnisotropicDiffusionFunction;CurvatureNDAnisotropicDiffusionFunction
 tinclude itk#functions#:h|hxx
 instances itk::#functions#< itk::Image< #scalar_types#, #pdims# > >
 
index e62f1df171c70def845edad9cc433a3163a3274a..5f5cc64827f14cf5925724aa452cc8b84cf0a20b 100644 (file)
@@ -35,6 +35,7 @@ void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
+  std::cout << o << std::endl;
   cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 )
     this->_Error( "Invalid input image dimension." );
 }
@@ -59,6 +60,7 @@ _GD1( _TImage* image )
   typedef
     itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
     _TFilter;
+  std::cout << "_Z" << typeid( _TFilter ).name( ) << std::endl;
 
   // Get parameters
   double bv = this->m_Parameters.GetReal( "BackgroundValue" );
index 29f0e0f9d7b646a918fc8e3b188d8b1bad0619e1..2fa060e6f49de1ac850b9941fd3c6fb6504e4fd5 100644 (file)
@@ -9,4 +9,7 @@ define o_scalars=#scalar_types#
 tinclude itk#filters_1#:h|hxx
 instances itk::#filters_1#< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >
 
+tinclude itkMinimumMaximumImageCalculator:h|hxx
+instances itk::MinimumMaximumImageCalculator< itk::Image< #scalar_types#, #pdims# > >
+
 ** eof - $RCSfile$
diff --git a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx
new file mode 100644 (file)
index 0000000..69bc70b
--- /dev/null
@@ -0,0 +1,120 @@
+#include <ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h>
+#include <cpInstances/Image.h>
+#include <cpInstances/Mesh.h>
+
+#include <itkImage.h>
+#include <itkMinimumMaximumImageCalculator.h>
+#include <vtkPolyData.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator::
+MinimumMaximumImageCalculator( )
+  : Superclass( )
+{
+  typedef cpInstances::Image _TImage;
+  typedef cpInstances::Mesh _TMesh;
+
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureOutput< _TMesh >( "Maximum" );
+  this->_ConfigureOutput< _TMesh >( "Minimum" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator::
+~MinimumMaximumImageCalculator( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator::
+_GD0( _TImage* input )
+{
+  typedef itk::MinimumMaximumImageCalculator< _TImage > _TFilter;
+  typedef typename _TImage::IndexType _TIndex;
+  typedef typename _TImage::PointType _TPoint;
+
+  auto filter = this->_CreateITK< _TFilter >( );
+  filter->SetImage( input );
+  filter->Compute( );
+
+  _TIndex min_idx = filter->GetIndexOfMinimum( );
+  _TIndex max_idx = filter->GetIndexOfMaximum( );
+
+  _TPoint min_pnt, max_pnt;
+  input->TransformIndexToPhysicalPoint( min_idx, min_pnt );
+  input->TransformIndexToPhysicalPoint( max_idx, max_pnt );
+
+  auto min_pd = this->GetOutputData< vtkPolyData >( "Minimum" );
+  if( min_pd == NULL )
+  {
+    auto points = vtkSmartPointer< vtkPoints >::New( );
+    auto verts = vtkSmartPointer< vtkCellArray >::New( );
+    auto lines = vtkSmartPointer< vtkCellArray >::New( );
+    auto polys = vtkSmartPointer< vtkCellArray >::New( );
+    auto strips = vtkSmartPointer< vtkCellArray >::New( );
+    auto pd = vtkSmartPointer< vtkPolyData >::New( );
+    pd->SetPoints( points );
+    pd->SetVerts( verts );
+    pd->SetLines( lines );
+    pd->SetPolys( polys );
+    pd->SetStrips( strips );
+
+    points->InsertNextPoint( 0, 0, 0 );
+    verts->InsertNextCell( 1 );
+    verts->InsertCellPoint( 0 );
+
+    this->GetOutput( "Minimum" )->SetVTK( pd );
+    min_pd = this->GetOutputData< vtkPolyData >( "Minimum" );
+
+  } // fi
+
+  if( _TImage::ImageDimension == 1 )
+    min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], 0, 0 );
+  else if( _TImage::ImageDimension == 2 )
+    min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], 0 );
+  else if( _TImage::ImageDimension > 2 )
+    min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], min_pnt[ 2 ] );
+
+  auto max_pd = this->GetOutputData< vtkPolyData >( "Maximum" );
+  if( max_pd == NULL )
+  {
+    auto points = vtkSmartPointer< vtkPoints >::New( );
+    auto verts = vtkSmartPointer< vtkCellArray >::New( );
+    auto lines = vtkSmartPointer< vtkCellArray >::New( );
+    auto polys = vtkSmartPointer< vtkCellArray >::New( );
+    auto strips = vtkSmartPointer< vtkCellArray >::New( );
+    auto pd = vtkSmartPointer< vtkPolyData >::New( );
+    pd->SetPoints( points );
+    pd->SetVerts( verts );
+    pd->SetLines( lines );
+    pd->SetPolys( polys );
+    pd->SetStrips( strips );
+
+    points->InsertNextPoint( 0, 0, 0 );
+    verts->InsertNextCell( 1 );
+    verts->InsertCellPoint( 0 );
+
+    this->GetOutput( "Maximum" )->SetVTK( pd );
+    max_pd = this->GetOutputData< vtkPolyData >( "Maximum" );
+
+  } // fi
+
+  if( _TImage::ImageDimension == 1 )
+    max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], 0, 0 );
+  else if( _TImage::ImageDimension == 2 )
+    max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], 0 );
+  else if( _TImage::ImageDimension > 2 )
+    max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], max_pnt[ 2 ] );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h
new file mode 100644 (file)
index 0000000..50519b1
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __cpPluginsITKImageGenericFilters_1__MinimumMaximumImageCalculator__h__
+#define __cpPluginsITKImageGenericFilters_1__MinimumMaximumImageCalculator__h__
+
+#include <cpPluginsITKImageGenericFilters_1_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsITKImageGenericFilters_1
+{
+  /**
+   */
+  class cpPluginsITKImageGenericFilters_1_EXPORT MinimumMaximumImageCalculator
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject(
+      MinimumMaximumImageCalculator,
+      cpPlugins::BaseObjects::ProcessObject,
+      ImageFeatures
+      );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* input );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsImageGenericFilters__MinimumMaximumImageCalculator__h__
+
+// eof - $RCSfile$
index 0ac9aab5e75cc2c75afe6dba50c44035cc8935fc..212fd21238eea306def7993230aba551f5c34e6d 100644 (file)
@@ -1,6 +1,7 @@
-header #define ITK_MANUAL_INSTANTIATION
+** TODO:
+header #undef ITK_MANUAL_INSTANTIATION
 
 tinclude itkBinaryFillholeImageFilter:h|hxx
-instances itk::BinaryFillholeImageFilter< itk::Image< #scalar_types#, #pdims# > >
+instances itk::BinaryFillholeImageFilter< itk::Image< #scalar_types#, #vdims# > >
 
 ** eof - $RCSfile$