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 );
);
// 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 );
}
// -------------------------------------------------------------------------
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
+ */
}
// -------------------------------------------------------------------------
private:
Ui::PipelineEditor* m_UI;
- std::string m_ActiveWS;
};
#endif // __PipelineEditor__h__
## == 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)
## 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@
"@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)
)
: Superclass( parent ),
m_LastSaveFileName( "" ),
- m_SingleWorkspace( false ),
m_BaseWindowTitle( "cpBaseQtApplication" ),
m_Canvas( NULL ),
m_Navigator( NULL ),
QMessageBox::critical( this, "Error guessing plugins.", err.what( ) );
} // yrt
+ this->_clearWorkspace( );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------
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
}
// -------------------------------------------------------------------------
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 );
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 );
}
// -------------------------------------------------------------------------
{
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 )
{
);
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;
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 );
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;
--- /dev/null
+// -------------------------------------------------------------------------
+// @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$
--- /dev/null
+// -------------------------------------------------------------------------
+// @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$
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$
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 );
}
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 );
}
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 );
}
#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( )
*/
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;
// 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,
--- /dev/null
+#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$
--- /dev/null
+#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$
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# > >
_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." );
}
typedef
itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
_TFilter;
+ std::cout << "_Z" << typeid( _TFilter ).name( ) << std::endl;
// Get parameters
double bv = this->m_Parameters.GetReal( "BackgroundValue" );
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$
--- /dev/null
+#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$
--- /dev/null
+#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$
-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$