]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 2 Nov 2016 21:25:39 +0000 (16:25 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 2 Nov 2016 21:25:39 +0000 (16:25 -0500)
16 files changed:
appli/CMakeLists.txt
appli/PipelineEditor/CMakeLists.txt
appli/plugins/CMakeLists.txt [new file with mode: 0644]
appli/plugins/ExecutePipeline.cxx [new file with mode: 0644]
cmake/Functions.cmake
lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx
lib/cpExtensions/DataStructures/Skeleton.hxx
lib/cpPlugins/BaseObjects/Parameters.cxx
lib/cpPlugins/DataObjects/Image.d
lib/cpPlugins/DataObjects/PolyLineParametricPath.cxx
lib/cpPlugins/DataObjects/PolyLineParametricPath.d [new file with mode: 0644]
lib/cpPlugins/DataObjects/Skeleton.cxx
lib/cpPlugins/DataObjects/Skeleton.d [new file with mode: 0644]
plugins/IO/ImageJSkeletonWriter.cxx [new file with mode: 0644]
plugins/IO/ImageJSkeletonWriter.h [new file with mode: 0644]
plugins/Widgets/SeedWidget.cxx

index cc05c08e9968b6a8639a5ad5d8739cd89b781df5..ff999fe9568e122f058f91d6a64b992553483678 100644 (file)
@@ -1,5 +1,6 @@
 SUBDIRS(
   bash
+  plugins
   examples
   PipelineEditor
   )
index 0febd9740f474aa3db602c743b2274bac3aa4ae9..4b1344ff1f8ce53c398dac936dc94827f77999b8 100644 (file)
@@ -6,10 +6,12 @@ IF(Qt4_FOUND)
     ${PROJECT_BINARY_DIR}/lib
     )
   CompileAppFromDir(PipelineEditor ${CMAKE_CURRENT_SOURCE_DIR})
-  TARGET_LINK_LIBRARIES(
-    PipelineEditor
-    cpBaseQtApplication
-    )
+  IF(BUILD_PipelineEditor)
+    TARGET_LINK_LIBRARIES(
+      PipelineEditor
+      cpBaseQtApplication
+      )
+  ENDIF(BUILD_PipelineEditor)
 ENDIF(Qt4_FOUND)
 
 ## eof - $RCSfile$
diff --git a/appli/plugins/CMakeLists.txt b/appli/plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d9f331f
--- /dev/null
@@ -0,0 +1,19 @@
+INCLUDE_DIRECTORIES(
+  ${PROJECT_SOURCE_DIR}/lib
+  ${PROJECT_BINARY_DIR}/lib
+  )
+SET(
+  _plugins_APPS
+  ExecutePipeline
+  )
+FOREACH(_app ${_plugins_APPS})
+  ADD_EXECUTABLE(cpPlugins_plugins_${_app} ${_app})
+  TARGET_LINK_LIBRARIES(cpPlugins_plugins_${_app} cpPlugins)
+  SET(
+    cpPlugins_plugins_${_app}_APP cpPlugins_plugins_${_app}
+    CACHE INTERNAL "bash program cpPlugins_plugins_${_app}"
+    )
+ENDFOREACH(_app)
+
+
+## eof - $RCSfile$
diff --git a/appli/plugins/ExecutePipeline.cxx b/appli/plugins/ExecutePipeline.cxx
new file mode 100644 (file)
index 0000000..a842d8d
--- /dev/null
@@ -0,0 +1,57 @@
+#include <iostream>
+#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Workspace.h>
+
+int main( int argc, char* argv[] )
+{
+  // Manage inputs
+  if( argc < 2 )
+  {
+    std::cerr
+      << "Usage: " << argv[ 0 ]
+      << " workspace [parameters]" << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Create interface and load library
+  cpPlugins::Interface::Plugins::Pointer interface =
+    cpPlugins::Interface::Plugins::New( );
+  try
+  {
+    interface->AddEnvironments( "." );
+    interface->LoadPaths( "." );
+    interface->LoadEnvironments( );
+    interface->GuessPlugins( );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr << "Error caught: " << err.what( ) << std::endl;
+    return( 1 );
+
+  } // yrt
+
+  // Workspace
+  cpPlugins::Interface::Workspace::Pointer workspace =
+    cpPlugins::Interface::Workspace::New( );
+  try
+  {
+    workspace->Load( argv[ 1 ] );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr
+      << "Error loading workspace \"" << argv[ 1 ]
+      << "\": " << err.what( ) << std::endl;
+    return( 1 );
+
+  } // yrt
+
+  // Execute filter
+  workspace->PrintExecutionOn( );
+  workspace->Execute( );
+
+  return( 0 );
+}
+
+// eof - $RCSfile$
index 02ec213e50c7334162861a890d6f6c3efd20c357..9beaaae0944581c1a8bc4545f0952b9ff207e709 100644 (file)
@@ -323,22 +323,25 @@ FUNCTION(
   app_name
   app_dir
   )
-FILE(GLOB_RECURSE _files "${app_dir}/*")
-PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN})
-INCLUDE_DIRECTORIES(
-  ${_paths}
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  ${CMAKE_CURRENT_BINARY_DIR}
-  )
-IF(_srcs)
-  SET(_app_os_target)
-  IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
-    SET(_app_os_target WIN32)
-  ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
-    SET(_app_os_target MACOSX_BUNDLE)
-  ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
-  ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs})
-ENDIF(_srcs)
+OPTION(BUILD_${app_name} "Build ${app_name}" OFF)
+IF(BUILD_${app_name})
+  FILE(GLOB_RECURSE _files "${app_dir}/*")
+  PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN})
+  INCLUDE_DIRECTORIES(
+    ${_paths}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_BINARY_DIR}
+    )
+  IF(_srcs)
+    SET(_app_os_target)
+    IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+      SET(_app_os_target WIN32)
+      ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+      SET(_app_os_target MACOSX_BUNDLE)
+    ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+    ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs})
+  ENDIF(_srcs)
+ENDIF(BUILD_${app_name})
 ENDFUNCTION()
 
 ## eof - $RCSfile$
index c3d575d4315ea1f98233ebc2c16c43f024439b7a..9eecda129f9085ecd29c9df96094a33dd2d3202f 100644 (file)
@@ -25,7 +25,7 @@ template< class _TPolyLine, class _TCurve >
 void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
 SetInput( _TPolyLine* pl )
 {
-  this->Superclass::SetInput( 0, pl );
+  this->Superclass::SetNthInput( 0, pl );
 }
 
 // -------------------------------------------------------------------------
@@ -54,7 +54,7 @@ PolyLineParametricPathToSimple3DCurve( )
   this->SetNumberOfRequiredInputs( 1 );
   this->SetNumberOfRequiredOutputs( 1 );
   typename _TCurve::Pointer curve = _TCurve::New( );
-  this->Superclass::SetOutput( 0, curve );
+  this->Superclass::SetNthOutput( 0, curve );
 }
 
 // -------------------------------------------------------------------------
index ff00cb653387cf8d9f267c5a4f461962a337d18b..e6635ae25c38c169e980bf854d22489757ce6600 100644 (file)
@@ -18,6 +18,8 @@ AddBranch( TPath* path )
     return;
 
   // Add path
+  this->SetVertex( a, a );
+  this->SetVertex( b, b );
   this->AddEdge( a, b, path );
   this->AddEdge( b, a, path );
   // TODO: this->Modified( );
index d55278661dc18c0c6d1b77ce2b8635607b5c8c49..1c6363863830cd14e55b5da9f784ad555cf7c226 100644 (file)
@@ -447,11 +447,11 @@ AddToOpenFileNameList(
   {
     if( i->second.first == OpenFileNameList )
     {
-      auto pos = name.find_last_of( "/\\" );
+      auto pos = v.find_last_of( "/\\" );
       if( i->second.second == "" )
-        i->second.second = name.substr( 0, pos );
+        i->second.second = v.substr( 0, pos );
       i->second.second += std::string( "#" );
-      i->second.second += name.substr( pos + 1 );
+      i->second.second += v.substr( pos + 1 );
       this->Modified( );
 
     } // fi
@@ -486,11 +486,11 @@ AddToSaveFileNameList(
   {
     if( i->second.first == SaveFileNameList )
     {
-      auto pos = name.find_last_of( "/\\" );
+      auto pos = v.find_last_of( "/\\" );
       if( i->second.second == "" )
-        i->second.second = name.substr( 0, pos );
+        i->second.second = v.substr( 0, pos );
       i->second.second += std::string( "#" );
-      i->second.second += name.substr( pos + 1 );
+      i->second.second += v.substr( pos + 1 );
       this->Modified( );
 
     } // fi
index 0d8a325c9106e1c849b8a9ed4e8397fe076afd6f..165a06a4cdb9328d008c34a532eb530f3f789288 100644 (file)
@@ -13,6 +13,8 @@ DiffTensors3D itk::Image< itk::#diff_tensors#< #real_types# >, 3 >
 
 IntPixels_AllDims itk::Image< #all_ints#, #process_dims# >
 IntPixels_VisualDims itk::Image< #all_ints#, #process_dims# >
+RealPixels_AllDims itk::Image< #real_types#, #process_dims# >
+RealPixels_VisualDims itk::Image< #real_types#, #process_dims# >
 ScalarPixels_AllDims itk::Image< #scalar_pixels#, #process_dims# >
 ScalarPixels_VisualDims itk::Image< #scalar_pixels#, #visual_dims# >
 ColorPixels_AllDims itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# >
index cab593afa3ca7ecf7d608186f764649a325fa724..357f38a3d94ca8b78b8a2d247e2425fd83c92503 100644 (file)
@@ -1,32 +1,18 @@
 #include <cpPlugins/DataObjects/PolyLineParametricPath.h>
 #include <cpExtensions/Visualization/PolyLineParametricPathToPolyData.h>
+#include <cpPlugins/DataObjects/PolyLineParametricPath_Demanglers.h>
+#include <cpExtensions/DataStructures/PolyLineParametricPath.h>
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjects::PolyLineParametricPath::
 SetITK( itk::LightObject* o )
 {
-  /* TODO
-     typedef cpExtensions::DataStructures::PolyLineParametricPath< 1 > _T1;
-     typedef cpExtensions::DataStructures::PolyLineParametricPath< 2 > _T2;
-     typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _T3;
-     typedef cpExtensions::DataStructures::PolyLineParametricPath< 4 > _T4;
-
-     this->Superclass::SetITK( o );
-     auto l1 = dynamic_cast< _T1* >( o );
-     auto l2 = dynamic_cast< _T2* >( o );
-     auto l3 = dynamic_cast< _T3* >( o );
-     auto l4 = dynamic_cast< _T4* >( o );
-     if     ( l1 != NULL ) this->_ITK_2_VTK( l1 );
-     else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
-     else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
-     else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
-     else
-     {
-     this->m_VTK = NULL;
-     this->m_ITKvVTK = NULL;
-
-     } // fi
-  */
+  this->Superclass::SetITK( o );
+  cpPlugins_Demangle_PolyLineParametricPath_All_1( o, _ITK_2_VTK )
+  {
+    this->m_VTK = NULL;
+    this->m_ITKvVTK = NULL;
+  }
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/cpPlugins/DataObjects/PolyLineParametricPath.d b/lib/cpPlugins/DataObjects/PolyLineParametricPath.d
new file mode 100644 (file)
index 0000000..8fef127
--- /dev/null
@@ -0,0 +1,3 @@
+All cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >
+
+** eof - $RCSfile$
index 72a141d993e03f691cf6a1a9c2cc0506bb00a697..098595af6539ead281cb5bd45ceb3532b8fa0964 100644 (file)
@@ -1,32 +1,17 @@
 #include <cpPlugins/DataObjects/Skeleton.h>
 #include <cpExtensions/Visualization/SkeletonToPolyData.h>
+#include <cpPlugins/DataObjects/Skeleton_Demanglers.h>
+#include <cpExtensions/DataStructures/Skeleton.h>
 
 // -------------------------------------------------------------------------
 void cpPlugins::DataObjects::Skeleton::
 SetITK( itk::LightObject* o )
 {
-  /* TODO
-     typedef cpExtensions::DataStructures::Skeleton< 1 > _T1;
-     typedef cpExtensions::DataStructures::Skeleton< 2 > _T2;
-     typedef cpExtensions::DataStructures::Skeleton< 3 > _T3;
-     typedef cpExtensions::DataStructures::Skeleton< 4 > _T4;
-
-     this->Superclass::SetITK( o );
-     auto l1 = dynamic_cast< _T1* >( o );
-     auto l2 = dynamic_cast< _T2* >( o );
-     auto l3 = dynamic_cast< _T3* >( o );
-     auto l4 = dynamic_cast< _T4* >( o );
-     if     ( l1 != NULL ) this->_ITK_2_VTK( l1 );
-     else if( l2 != NULL ) this->_ITK_2_VTK( l2 );
-     else if( l3 != NULL ) this->_ITK_2_VTK( l3 );
-     else if( l4 != NULL ) this->_ITK_2_VTK( l4 );
-     else
-     {
-     this->m_VTK = NULL;
-     this->m_ITKvVTK = NULL;
-
-     } // fi
-  */
+  cpPlugins_Demangle_Skeleton_All_1( o, _ITK_2_VTK )
+  {
+    this->m_VTK = NULL;
+    this->m_ITKvVTK = NULL;
+  }
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/cpPlugins/DataObjects/Skeleton.d b/lib/cpPlugins/DataObjects/Skeleton.d
new file mode 100644 (file)
index 0000000..d709d98
--- /dev/null
@@ -0,0 +1,3 @@
+All cpExtensions::DataStructures::Skeleton< #process_dims# >
+
+** eof - $RCSfile$
diff --git a/plugins/IO/ImageJSkeletonWriter.cxx b/plugins/IO/ImageJSkeletonWriter.cxx
new file mode 100644 (file)
index 0000000..1077242
--- /dev/null
@@ -0,0 +1,109 @@
+#include <IO/ImageJSkeletonWriter.h>
+#include <cpPlugins/DataObjects/Skeleton.h>
+#include <cpPlugins/DataObjects/Skeleton_Demanglers.h>
+#include <cpPlugins/QT/SaveFileDialog.h>
+
+#include <cpExtensions/DataStructures/Skeleton.h>
+#include <cpExtensions/Utility.h>
+
+#ifdef cpPlugins_QT4
+#  include <QApplication>
+#endif // cpPlugins_QT4
+
+// -------------------------------------------------------------------------
+QDialog* cpPluginsIO::ImageJSkeletonWriter::
+CreateQDialog( )
+{
+#ifdef cpPlugins_QT4
+  cpPlugins::QT::SaveFileDialog* dlg = NULL;
+  if( QApplication::instance( ) != NULL )
+  {
+    dlg = new cpPlugins::QT::SaveFileDialog( );
+    dlg->SetParameters( &( this->m_Parameters ), "FileName" );
+
+  } // fi
+  return( dlg );
+#else // cpPlugins_QT4
+  return( NULL );
+#endif // cpPlugins_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPluginsIO::ImageJSkeletonWriter::
+ImageJSkeletonWriter( )
+  : Superclass( )
+{
+  this->_ConfigureInput< cpPlugins::DataObjects::Skeleton >( "Input", true, false );
+  this->m_Parameters.ConfigureAsSaveFileName( "FileName", "" );
+  this->m_Parameters.SetAcceptedFileExtensions(
+    "FileName",
+    "ImageJ files (*.txt)"
+    );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsIO::ImageJSkeletonWriter::
+~ImageJSkeletonWriter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsIO::ImageJSkeletonWriter::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Skeleton_All_1( o, _GD0 )
+    this->_Error( "Invalid input skeleton type." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+void cpPluginsIO::ImageJSkeletonWriter::
+_GD0( _TSkeleton* skeleton )
+{
+  std::stringstream data;
+  unsigned long id = 1;
+
+  auto mIt = skeleton->BeginEdgesRows( );
+  for( ; mIt != skeleton->EndEdgesRows( ); ++mIt )
+  {
+    /* TODO
+       mIt->first; --> this is the row index. <--
+    */
+    auto rIt = mIt->second.begin( );
+    for( ; rIt != mIt->second.end( ); ++rIt )
+    {
+      /* TODO
+         rIt->first;  --> this is the column index.
+      */
+      auto eIt = rIt->second.begin( );
+      for( ; eIt != rIt->second.end( ); ++eIt )
+      {
+        auto path = *eIt;
+        auto p0 = path->GetSmoothPoint( 0 );
+        auto p1 = path->GetSmoothPoint( 1 );
+        double length = p1.EuclideanDistanceTo( p0 );
+        data
+          << id << "\t1\t" << length << "\t"
+          << p0[ 0 ] << "\t" << p0[ 1 ] << "\t"<< p0[ 2 ] << "\t"
+          << p1[ 0 ] << "\t" << p1[ 1 ] << "\t"<< p1[ 2 ] << "\t"
+          << p1.EuclideanDistanceTo( p0 ) << std::endl;
+        id++;
+
+      } // rof
+
+    } // rof
+
+  } // rof
+
+  if(
+    !(
+      cpExtensions::Write(
+        data.str( ), this->m_Parameters.GetSaveFileName( "FileName" )
+        )
+      )
+    )
+    this->_Error( "Could not write on ImageJ file." );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/IO/ImageJSkeletonWriter.h b/plugins/IO/ImageJSkeletonWriter.h
new file mode 100644 (file)
index 0000000..6adffbf
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __cpPluginsIO__ImageJSkeletonWriter__h__
+#define __cpPluginsIO__ImageJSkeletonWriter__h__
+
+#include <cpPluginsIO_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsIO
+{
+  /**
+   */
+  class cpPluginsIO_EXPORT ImageJSkeletonWriter
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject( ImageJSkeletonWriter, cpPlugins::BaseObjects::ProcessObject, IO );
+
+  public:
+    virtual QDialog* CreateQDialog( ) cpPlugins_OVERRIDE;
+
+  protected:
+    template< class _TSkeleton >
+    inline void _GD0( _TSkeleton* skeleton );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsIO__ImageJSkeletonWriter__h__
+
+// eof - $RCSfile$
index ab38f2e4af70b68d63feb8dee1827c52fc27f446..cc589b1509679bbfb868ba70523f9262c080921b 100644 (file)
@@ -164,34 +164,38 @@ _GD0_Image( vtkImageData* image )
     std::string text = this->m_Parameters.GetString( "Text" );
     std::vector< std::string > tok1, tok2;
     cpExtensions::Tokenize( tok1, text, "#" );
-    for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 )
+    if( tok1.size( ) > seeds->GetPoints( )->GetNumberOfPoints( ) )
     {
-      if( *t1 != "" )
+      for( auto t1 = tok1.begin( ); t1 != tok1.end( ); ++t1 )
       {
-        cpExtensions::Tokenize( tok2, *t1, " " );
-        double x[ 3 ];
-        for( unsigned int d = 0; d < 3; ++d )
+        if( *t1 != "" )
         {
-          if( d < tok2.size( ) )
+          cpExtensions::Tokenize( tok2, *t1, " " );
+          double x[ 3 ];
+          for( unsigned int d = 0; d < 3; ++d )
           {
-            std::istringstream str( tok2[ d ] );
-            str >> x[ d ];
-          }
-          else
-            x[ d ] = double( 0 );
-
-        } // rof
+            if( d < tok2.size( ) )
+            {
+              std::istringstream str( tok2[ d ] );
+              str >> x[ d ];
+            }
+            else
+              x[ d ] = double( 0 );
+
+          } // rof
+
+          seeds->GetPoints( )->InsertNextPoint( x );
+          seeds->GetVerts( )->InsertNextCell( 1 );
+          seeds->GetVerts( )->InsertCellPoint(
+            seeds->GetPoints( )->GetNumberOfPoints( ) - 1
+            );
+          seeds->Modified( );
 
-        seeds->GetPoints( )->InsertNextPoint( x );
-        seeds->GetVerts( )->InsertNextCell( 1 );
-        seeds->GetVerts( )->InsertCellPoint(
-          seeds->GetPoints( )->GetNumberOfPoints( ) - 1
-          );
-        seeds->Modified( );
+        } // fi
 
-      } // fi
+      } // rof
 
-    } // rof
+    } // fi
   }
   else
   {