]> Creatis software - FrontAlgorithms.git/commitdiff
Plugins updated
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 14 Dec 2015 22:04:19 +0000 (17:04 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 14 Dec 2015 22:04:19 +0000 (17:04 -0500)
CMakeLists.txt
lib/CMakeLists.txt
lib/fpa/Base/Algorithm.h
lib/fpa/Base/Algorithm.hxx
lib/fpaPlugins/CMakeLists.txt
lib/fpaPlugins/Host.cxx [deleted file]
lib/fpaPlugins/ImageRegionGrow.cxx [new file with mode: 0644]
lib/fpaPlugins/ImageRegionGrow.h [new file with mode: 0644]

index b8b86f3ab1163afd44aaa7e1d243d6f636e6cd22..a38eef5ebf5b4ad8c9873eff48cbe422c8ee17d9 100644 (file)
@@ -35,6 +35,7 @@ SET(
 
 OPTION(BUILD_EXAMPLES "Build examples" OFF)
 OPTION(BUILD_SHARED_LIBS "Build shared libs" OFF)
+OPTION(BUILD_PLUGINS "Build plugins" OFF)
 
 IF(BUILD_SHARED_LIBS)
   SET(LIB_TYPE SHARED)
index 721d61fba076f82d94c3b01a3e54f7729ee92b2f..70502530c66502608416ff37258b2dcbe2ded814 100644 (file)
@@ -101,10 +101,10 @@ INSTALL(
   DESTINATION include/fpa
   )
 
-IF(${USE_cpPlugins})
+IF(BUILD_PLUGINS)
   SUBDIRS(
     fpaPlugins
     )
-ENDIF(${USE_cpPlugins})
+ENDIF(BUILD_PLUGINS)
 
 ## eof - $RCSfile$
index 132c61057c696e47dc18c33e99220a5776757577..62973da2023b0bfb9017ecba60102d05606c0e8d 100644 (file)
@@ -85,7 +85,9 @@ namespace fpa
       typedef std::map< TVertex, _TNode, TVertexCompare > _TNodes;
 
     public:
-      typedef fpa::Base::MinimumSpanningTree< TVertex, _TCollisions, TVertexCompare > TMinimumSpanningTree;
+      typedef
+      fpa::Base::MinimumSpanningTree< V, _TCollisions, VC >
+      TMinimumSpanningTree;
 
     public:
       itkTypeMacro( Algorithm, B );
index aa1c283a8864a370fa5c47948dd3256abc16783e..5629af77c9436373f3ec5512ea0d6b0f89e0a0f8 100644 (file)
@@ -29,7 +29,9 @@ GetMinimumSpanningTree( )
 {
   return(
     dynamic_cast< TMinimumSpanningTree* >(
-      this->itk::ProcessObject::GetOutput( 1 )
+      this->itk::ProcessObject::GetOutput(
+        this->m_MinimumSpanningTreeIndex
+        )
       )
     );
 }
@@ -42,7 +44,9 @@ GetMinimumSpanningTree( ) const
 {
   return(
     dynamic_cast< const TMinimumSpanningTree* >(
-      this->itk::ProcessObject::GetOutput( 1 )
+      this->itk::ProcessObject::GetOutput(
+        this->m_MinimumSpanningTreeIndex
+        )
       )
     );
 }
@@ -54,7 +58,7 @@ GraftMinimumSpanningTree( itk::DataObject* obj )
 {
   TMinimumSpanningTree* mst = dynamic_cast< TMinimumSpanningTree* >( obj );
   if( mst != NULL )
-    this->GraftNthOutput( 1, mst );
+    this->GraftNthOutput( this->m_MinimumSpanningTreeIndex, mst );
 }
 
 // -------------------------------------------------------------------------
index 5b2d62ffbf5de60b5cf11cd8f834a880510cc969..ec3c96dcc1f41f424848308867ea8ad6515819c8 100644 (file)
@@ -15,9 +15,16 @@ FILE(GLOB LIB_SOURCES_CXX "*.cxx")
 ## = Compilation rules =
 ## =====================
 
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${LIBRARY_NAME}_Host.cxx
+  DEPENDS ${cpPlugins_createHost_APP} ${LIB_HEADERS_H}
+  COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx fpaPlugins ${LIB_HEADERS_H}
+  )
+
 ADD_LIBRARY(
   ${LIBRARY_NAME}
   SHARED
+  ${LIBRARY_NAME}_Host.cxx
   ${LIB_SOURCES_C}
   ${LIB_SOURCES_CPP}
   ${LIB_SOURCES_CXX}
@@ -29,21 +36,20 @@ GENERATE_EXPORT_HEADER(
   EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/fpaPlugins/${LIBRARY_NAME}_Export.h
   STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC
   )
-#TARGET_LINK_LIBRARIES(
-#  ${LIBRARY_NAME}
-#  cpExtensions
-#  cpPlugins_Interface
-#  )
+TARGET_LINK_LIBRARIES(
+  ${LIBRARY_NAME}
+  ${cpPlugins_Interface_LIBRARY}
+  )
 
 ## ========================
 ## -- Installation rules --
 ## ========================
 
-#INSTALL(
-#  TARGETS ${LIBRARY_NAME}
-#  RUNTIME DESTINATION bin
-# LIBRARY DESTINATION lib
-#  ARCHIVE DESTINATION lib/static
-#  )
+INSTALL(
+  TARGETS ${LIBRARY_NAME}
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib/static
+  )
 
 ## eof - $RCSfile$
diff --git a/lib/fpaPlugins/Host.cxx b/lib/fpaPlugins/Host.cxx
deleted file mode 100644 (file)
index d264e45..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <Pluma/Connector.hpp>
-/*
-  #include <cpPlugins/Plugins/ImageReader.h>
-  #include <cpPlugins/Plugins/ImageWriter.h>
-  #include <cpPlugins/Plugins/MeshReader.h>
-  #include <cpPlugins/Plugins/MeshWriter.h>
-  #include <cpPlugins/Plugins/MarchingCubes.h>
-  #include <cpPlugins/Plugins/OtsuThresholdImageFilter.h>
-  #include <cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h>
-  #include <cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h>
-  #include <cpPlugins/Plugins/BinaryThresholdImageFilter.h>
-*/
-
-/// TODO: doc
-PLUMA_CONNECTOR
-bool connect( pluma::Host& host )
-{
-  /*
-    using namespace cpPlugins::Plugins;
-
-    host.add( new ImageReaderProvider( ) );
-    host.add( new ImageWriterProvider( ) );
-    host.add( new MeshReaderProvider( ) );
-    host.add( new MeshWriterProvider( ) );
-    host.add( new MarchingCubesProvider( ) );
-    host.add( new OtsuThresholdImageFilterProvider( ) );
-    host.add( new RGBImageToOtherChannelsFilterProvider( ) );
-    host.add( new SecondRankDiffusionTensorToPolyDataProvider( ) );
-    host.add( new BinaryThresholdImageFilterProvider( ) );
-  */
-  return( true );
-}
-
-// eof - $RCSfile$
diff --git a/lib/fpaPlugins/ImageRegionGrow.cxx b/lib/fpaPlugins/ImageRegionGrow.cxx
new file mode 100644 (file)
index 0000000..6429765
--- /dev/null
@@ -0,0 +1,116 @@
+#include "ImageRegionGrow.h"
+
+#include <cpPlugins/Interface/Image.h>
+#include <fpa/Image/RegionGrow.h>
+#include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::ImageRegionGrow::
+ImageRegionGrow( )
+  : Superclass( )
+{
+  this->_AddInput( "Input" );
+  this->_AddInput( "GrowFunction" );
+  this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+
+  this->m_Parameters->ConfigureAsBool( "VisualDebug", false );
+  this->m_Parameters->ConfigureAsBool( "StopAtOneFront", false );
+  this->m_Parameters->ConfigureAsReal( "InsideValue", 1 );
+  this->m_Parameters->ConfigureAsReal( "OutsideValue", 0 );
+  this->m_Parameters->ConfigureAsPointList( "Seeds" );
+
+  std::vector< std::string > orders;
+  orders.push_back( "1" );
+  orders.push_back( "2" );
+  this->m_Parameters->ConfigureAsChoices( "NeighborhoodOrder", orders );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::ImageRegionGrow::
+~ImageRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string fpaPlugins::ImageRegionGrow::
+_GenerateData( )
+{
+  cpPlugins::Interface::Image* input =
+    this->GetInput< cpPlugins::Interface::Image >( "Input" );
+  if( input == NULL )
+    return( "fpaPlugins::ImageRegionGrow: No input image." );
+
+  itk::DataObject* image = NULL;
+  std::string r = "";
+  cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 );
+  else cpPlugins_Image_Demangle_AllScalarTypes( 3, input, image, r, _GD0 );
+  else r = "fpaPlugins::ImageRegionGrow: Input image type not supported.";
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string fpaPlugins::ImageRegionGrow::
+_GD0( itk::DataObject* data )
+{
+  typedef unsigned char                               _TOutPixel;
+  typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut;
+  typedef fpa::Image::RegionGrow< I, _TOut >          _TFilter;
+  typedef typename _TFilter::TGrowingFunction         _TFunctor;
+
+  I* image = dynamic_cast< I* >( data );
+
+  // Create filter and connect input
+  _TFilter* filter = this->_CreateITK< _TFilter >( );
+  filter->SetInput( image );
+
+  // Connect grow functor (or create a tautology)
+  typename _TFunctor::Pointer functor;
+  cpPlugins::Interface::DataObject* functor_wrapper =
+    this->GetInput< cpPlugins::Interface::DataObject >( "GrowFunction" );
+  if( functor_wrapper != NULL )
+    functor = functor_wrapper->GetITK< _TFunctor >( );
+  if( functor.IsNull( ) )
+    functor =
+      fpa::Image::Functors::RegionGrowAllBelongsFunction< I >::New( );
+
+  // Set numeric parameters
+  Superclass::TParameters* params = this->m_Parameters;
+  std::string order = params->GetSelectedChoice( "NeighborhoodOrder" );
+  filter->SetNeighborhoodOrder( order[ 0 ] - '0' );
+  filter->SetStopAtOneFront( params->GetBool( "StopAtOneFront" ) );
+  filter->SetInsideValue( _TOutPixel( params->GetReal( "InsideValue" ) ) );
+  filter->SetOutsideValue( _TOutPixel( params->GetReal( "OutsideValue" ) ) );
+
+  // Assign seeds
+  std::vector< typename I::PointType > seeds;
+  params->GetPointList( seeds, "Seeds", I::ImageDimension );
+  for( auto sIt = seeds.begin( ); sIt != seeds.end( ); ++sIt )
+  {
+    typename I::IndexType idx;
+    if( image->TransformPhysicalPointToIndex( *sIt, idx ) )
+      filter->AddSeed( idx, 0 );
+
+  } // rof
+
+  // Connect visual debugger
+  /* TODO
+     this->m_Parameters->ConfigureAsBool( "VisualDebug", false );
+   */
+
+  // Go!!!
+  filter->Update( );
+
+  // Connect output
+  cpPlugins::Interface::Image* out =
+    this->GetOutput< cpPlugins::Interface::Image >( "Output" );
+  if( out != NULL )
+  {
+    out->SetITK< _TOut >( filter->GetOutput( ) );
+    return( "" );
+  }
+  else
+    return( "fpaPlugins::ImageRegionGrow: output not correctly created." );
+}
+
+// eof - $RCSfile$
diff --git a/lib/fpaPlugins/ImageRegionGrow.h b/lib/fpaPlugins/ImageRegionGrow.h
new file mode 100644 (file)
index 0000000..e653755
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __FPAPLUGINS__IMAGEREGIONGROW__H__
+#define __FPAPLUGINS__IMAGEREGIONGROW__H__
+
+#include <fpaPlugins/fpaPlugins_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+namespace fpaPlugins
+{
+  /**
+   */
+  class fpaPlugins_EXPORT ImageRegionGrow
+    : public cpPlugins::Interface::ImageToImageFilter
+  {
+  public:
+    typedef ImageRegionGrow                          Self;
+    typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+    typedef itk::SmartPointer< Self >                Pointer;
+    typedef itk::SmartPointer< const Self >          ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro(
+      ImageRegionGrow, cpPlugins::Interface::ImageToImageFilter
+      );
+    cpPlugins_Id_Macro(
+      fpaPlugins::ImageRegionGrow, "FrontPropagationImageAlgorithms"
+      );
+
+  protected:
+    ImageRegionGrow( );
+    virtual ~ImageRegionGrow( );
+
+    virtual std::string _GenerateData( );
+
+    template< class I >
+      std::string _GD0( itk::DataObject* data );
+
+  private:
+    // Purposely not implemented.
+    ImageRegionGrow( const Self& other );
+    Self& operator=( const Self& other );
+  };
+
+  // ---------------------------------------------------------------------
+  CPPLUGINS_INHERIT_PROVIDER( ImageRegionGrow );
+
+} // ecapseman
+
+#endif // __FPAPLUGINS__IMAGEREGIONGROW__H__
+
+// eof - $RCSfile$