]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 00:11:34 +0000 (19:11 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 00:11:34 +0000 (19:11 -0500)
14 files changed:
CMakeLists.txt
appli/examples/CMakeLists.txt
cmake/DetectOS.cmake [deleted file]
cmake/Functions.cmake
lib/CMakeLists.txt
lib/Instances/CMakeLists.txt
lib/Instances/fpa_DataObjects.i
lib/Instances/fpa_Filters.i
lib/fpa/Base/MinimumSpanningTree.h
lib/fpa/Base/MinimumSpanningTree.hxx
lib/fpa/Image/EndPointsFilter.hxx
lib/fpa/Image/MinimumSpanningTree.h
lib/fpa/Image/MinimumSpanningTree.hxx
plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx

index 914bfe6f8eae3800ffef4c315688f0399fcf0108..355805097c79c24f5911520158f094d18ee16377 100644 (file)
@@ -35,7 +35,6 @@ SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}")
 ## == Functions, packages and options ==
 ## =====================================
 
-INCLUDE(cmake/DetectOS.cmake)
 INCLUDE(cmake/Restrictions.cmake)
 INCLUDE(cmake/Functions.cmake)
 INCLUDE(cmake/KitwareTools.cmake)
index 861b670a30af6e85500936a6b4b107e57d615e57..5d570b6a1da39e73e23170206a78753e79e4d6ed 100644 (file)
@@ -1,4 +1,4 @@
 ADD_EXECUTABLE(fpa_examples_ImageDijkstra ImageDijkstra.cxx)
-TARGET_LINK_LIBRARIES(fpa_examples_ImageDijkstra ${ITK_LIBRARIES})
+TARGET_LINK_LIBRARIES(fpa_examples_ImageDijkstra ${ITK_LIBRARIES} ${VTK_LIBRARIES})
 
 ## eof - $RCSfile$
diff --git a/cmake/DetectOS.cmake b/cmake/DetectOS.cmake
deleted file mode 100644 (file)
index bba8346..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-## =====================
-## == OS-based values ==
-## =====================
-
-SET(prj_NAME_OS "${prj_NAME}_OS_${CMAKE_SYSTEM_NAME}")
-IF("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-  SET(prj_NAME_LIB_PREFIX "lib")
-  SET(prj_NAME_LIB_EXT ".so")
-  SET(prj_NAME_ENV_SEPARATOR ":")
-  SET(prj_NAME_PATH_SEPARATOR "/")
-ELSEIF("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
-  SET(prj_NAME_LIB_PREFIX "lib")
-  SET(prj_NAME_LIB_EXT ".dylib")
-  SET(prj_NAME_ENV_SEPARATOR ":")
-  SET(prj_NAME_PATH_SEPARATOR "/")
-ELSEIF("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
-  SET(prj_NAME_LIB_PREFIX "")
-  SET(prj_NAME_LIB_EXT ".dll")
-  SET(prj_NAME_ENV_SEPARATOR ";")
-  SET(prj_NAME_PATH_SEPARATOR "\\")
-ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-
-## eof - $RCSfile$
index f5a90f3326c0895761db6d84473d604961df8631..d3d5500f28b3d806d214f9f0e54236a4cf67bfcf 100644 (file)
@@ -61,6 +61,7 @@ ENDFUNCTION()
 FUNCTION(
   CreateLib
   lib_name
+  lib_dir
   lib_type
   lib_source_files
   lib_header_files
@@ -94,7 +95,7 @@ ENDIF(Qt4_FOUND)
 ## -- Ok, compile library
 IF(_sources)
   NormPaths(_cur_binary_dir ${CMAKE_CURRENT_BINARY_DIR})
-  ADD_LIBRARY(${lib_name} SHARED ${_sources} ${_headers})
+  ADD_LIBRARY(${lib_name} ${lib_type} ${_sources} ${_headers})
   SET_TARGET_PROPERTIES(
     ${lib_name}
     PROPERTIES
@@ -117,6 +118,7 @@ ENDFUNCTION()
 FUNCTION(
   LibFromDir
   lib_name
+  lib_dir
   lib_type
   lib_source_dir
   lib_version
@@ -200,7 +202,7 @@ ENDIF(ARGN)
 
 ## -- Create library
 CreateLib(
-  ${lib_name} ${lib_type}
+  ${lib_name} ${lib_dir} ${lib_type}
   "${_sources}" "${_headers}" "${_qt_uis}"
   "${lib_version}" "${lib_short_version}"
   )
@@ -211,6 +213,7 @@ ENDFUNCTION()
 FUNCTION(
   CompileInstances
   out_lib_name
+  lib_dir
   def_file
   number_of_files
   prefix
@@ -251,7 +254,7 @@ ADD_CUSTOM_COMMAND(
 
 ## -- Create library
 CreateLib(
-  "${_lib_name}" SHARED
+  "${_lib_name}" ${lib_dir} SHARED
   "${_all_out_code}" "${_out_header}" ""
   "${version}" "${short_version}"
   )
@@ -311,7 +314,7 @@ ENDIF(_hdr_to_wrap)
 ## -- Ok, build library
 IF(_all_src)
   CreateLib(
-    ${_lib_name} SHARED
+    ${_lib_name} leo SHARED
     "${_all_src}" "${_all_hdr}" "${_qt_ui}"
     "${version}" "${short_version}"
     ${ARGN}
index f2f2463cd3a26778b803fb4c818afa263e34cb4f..efe40caa8821fc1d9e9b7e6047ee99c570fb6186 100644 (file)
@@ -4,6 +4,7 @@
 
 LibFromDir(
   fpa
+  ${PROJECT_BINARY_DIR}/lib
   SHARED
   ${CMAKE_CURRENT_SOURCE_DIR}/fpa
   "${prj_VERSION}" "${prj_SHORT_VERSION}"
index 31eb1f1062b15b3c6f7f77cef56544c84e82cd5a..0c44d026b9e5718b13a6a71a0e4ccb252ab88b65 100644 (file)
@@ -7,6 +7,7 @@ SET(_all_instances)
 FOREACH(_instance ${_instances})
   CompileInstances(
     _lib_name
+    ${PROJECT_BINARY_DIR}/lib
     ${_instance} ${cpPlugins_NUMBER_OF_FILES}
     "" "${prj_VERSION}" "${prj_SHORT_VERSION}"
     )
@@ -21,8 +22,17 @@ SET(
 ## == Links ==
 ## ===========
 
-TARGET_LINK_LIBRARIES(fpa_DataObjects ${ITK_LIBRARIES} ${cpPlugins_BaseObjects_LIB} ${cpPlugins_Images_LIB})
-TARGET_LINK_LIBRARIES(fpa_Filters fpa_DataObjects ${cpPlugins_ImageFilters_LIB})
+TARGET_LINK_LIBRARIES(
+  fpa_DataObjects
+  ${ITK_LIBRARIES} ${VTK_LIBRARIES}
+  ${cpPlugins_BaseObjects_LIB}
+  ${cpPlugins_Images_LIB} ${cpPlugins_Paths_LIB}
+  )
+TARGET_LINK_LIBRARIES(
+  fpa_Filters
+  fpa_DataObjects
+  ${cpPlugins_ImageFilters_LIB}
+  )
 
 ## ===================================
 ## == Libraries to dynamically load ==
@@ -30,7 +40,9 @@ TARGET_LINK_LIBRARIES(fpa_Filters fpa_DataObjects ${cpPlugins_ImageFilters_LIB})
 
 SET(fpa_DynLibs)
 FOREACH(_lib ${fpa_Instances})
-  LIST(APPEND fpa_DynLibs local@${_lib})
+  LIST(APPEND fpa_DynLibs "${CMAKE_INSTALL_PREFIX}/bin|${_lib}")
+  LIST(APPEND fpa_DynLibs "${CMAKE_INSTALL_PREFIX}/lib|${_lib}")
+  LIST(APPEND fpa_DynLibs "${LIBRARY_OUTPUT_PATH}|${_lib}")
 ENDFOREACH(_lib)
 FILE(WRITE ${PROJECT_BINARY_DIR}/cpPlugins_Libraries.config "")
 FOREACH(_lib ${fpa_DynLibs})
index aee14d6b1d0d46521a8644d096f7a281a337fa58..7cf6e6867e8d2394c5e1540016edf756603df027 100644 (file)
@@ -1,8 +1,9 @@
 
+i cpPlugins_Paths.h
 t fpa/Image/MinimumSpanningTree
 t fpa/Base/MinimumSpanningTree
 
-c fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-c fpa::Image::MinimumSpanningTree< #process_dims# >
+c fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
+c fpa::Image::MinimumSpanningTree< #process_dims# >
 
-** eof - $RCSfile$
\ No newline at end of file
+** eof - $RCSfile$
index 70dc94d7e770fa20f1985b45a71e86dcafdc7d5b..a72f3adb40918a0e4b3b824c4476e47084a992b6 100644 (file)
@@ -9,4 +9,4 @@ t fpa/Image/Algorithm
 c fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > >, itk::Index< #process_dims# >, #o_pixels# >
 c fpa::Image::Algorithm< itk::Image< #i_pixels#, #process_dims# >, itk::Image< #o_pixels#, #process_dims# > >
 
-** eof - $RCSfile$
\ No newline at end of file
+** eof - $RCSfile$
index de22019b3e6595ebe9aa147c1aef692cad2e1c0d..03940f140a18300af6866b9b9b1ffbb519600f48 100644 (file)
@@ -2,7 +2,6 @@
 #define __fpa__Base__MinimumSpanningTree__h__
 
 #include <fpa/Config.h>
-#include <deque>
 #include <vector>
 #include <utility>
 #include <itkObject.h>
@@ -13,7 +12,7 @@ namespace fpa
   {
     /**
      */
-    template< class _TVertex, class _TSuperclass >
+    template< class _TVertex, class _TPath, class _TSuperclass >
     class MinimumSpanningTree
       : public _TSuperclass
     {
@@ -24,7 +23,7 @@ namespace fpa
       typedef itk::SmartPointer< const Self > ConstPointer;
 
       typedef _TVertex                      TVertex;
-      typedef std::deque< _TVertex >        TVertices;
+      typedef _TPath                        TPath;
       typedef std::pair< _TVertex, bool >   TCollision;
       typedef std::vector< TCollision >     TCollisionsRow;
       typedef std::vector< TCollisionsRow > TCollisions;
@@ -46,8 +45,12 @@ namespace fpa
       virtual _TVertex GetParent( const _TVertex& v ) const = 0;
       virtual void SetParent( const _TVertex& v, const _TVertex& p ) = 0;
 
-      virtual TVertices GetPath( const _TVertex& a ) const;
-      virtual TVertices GetPath( const _TVertex& a, const _TVertex& b ) const;
+      virtual void GetPath(
+        typename _TPath::Pointer& path, const _TVertex& a
+        ) const;
+      virtual void GetPath(
+        typename _TPath::Pointer& path, const _TVertex& a, const _TVertex& b
+        ) const;
 
     protected:
       MinimumSpanningTree( );
@@ -61,7 +64,7 @@ namespace fpa
     protected:
       TCollisions m_Collisions;
       _TMatrix    m_FrontPaths;
-      TVertices   m_Seeds;
+      std::vector< _TVertex > m_Seeds;
     };
 
   } // ecapseman
index 8746005f8a776b11f8021a65a55d86341b65eea1..4bf0135bf9ac3c17f04da5b35ced4cedb2b4980a 100644 (file)
@@ -4,17 +4,19 @@
 #include <limits>
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-const typename fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
-TCollisions& fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+const typename
+fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
+TCollisions&
+fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 GetCollisions( ) const
 {
   return( this->m_Collisions );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 SetCollisions( const TCollisions& collisions )
 {
   static const unsigned long _inf =
@@ -78,8 +80,8 @@ SetCollisions( const TCollisions& collisions )
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 ClearSeeds( )
 {
   this->m_Seeds.clear( );
@@ -87,8 +89,8 @@ ClearSeeds( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-void fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 AddSeed( const _TVertex& seed )
 {
   this->m_Seeds.push_back( seed );
@@ -96,37 +98,41 @@ AddSeed( const _TVertex& seed )
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
-GetPath( const _TVertex& a ) const
+template< class _TVertex, class _TPath, class _TSuperclass >
+void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
+GetPath( typename _TPath::Pointer& path, const _TVertex& a ) const
 {
-  TVertices path;
+  std::vector< _TVertex > vertices;
   _TVertex it = a;
   _TVertex p = this->GetParent( it );
   while( it != p )
   {
-    path.push_front( it );
+    vertices.push_back( it );
     it = p;
     p = this->GetParent( it );
 
   } // elihw
-  path.push_front( it );
-  return( path );
+  vertices.push_back( it );
+
+  path = _TPath::New( );
+  for( auto v = vertices.begin( ); v != vertices.end( ); ++v )
+    path->AddVertex( *v );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-typename fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
-TVertices fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
-GetPath( const _TVertex& a, const _TVertex& b ) const
+template< class _TVertex, class _TPath, class _TSuperclass >
+void fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
+GetPath(
+  typename _TPath::Pointer& path, const _TVertex& a, const _TVertex& b
+  ) const
 {
+/*
   static const unsigned long _inf =
     std::numeric_limits< unsigned long >::max( );
 
-  TVertices path;
-  TVertices pa = this->GetPath( a );
-  TVertices pb = this->GetPath( b );
+  _TPath path;
+  _TPath pa = this->GetPath( a );
+  _TPath pb = this->GetPath( b );
   if( pa.size( ) > 0 && pb.size( ) > 0 )
   {
     // Find front identifiers
@@ -210,19 +216,20 @@ GetPath( const _TVertex& a, const _TVertex& b ) const
 
   } // fi
   return( path );
+*/
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 MinimumSpanningTree( )
   : Superclass( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TSuperclass >
-fpa::Base::MinimumSpanningTree< _TVertex, _TSuperclass >::
+template< class _TVertex, class _TPath, class _TSuperclass >
+fpa::Base::MinimumSpanningTree< _TVertex, _TPath, _TSuperclass >::
 ~MinimumSpanningTree( )
 {
 }
index fe85b5aa41db786ab10ea02bb8e962b9416f2358..e2be58ffb1b3d89fe2da7e47c6c5807f43f29fbf 100644 (file)
@@ -29,91 +29,93 @@ template< class _TDistanceMap, class _TCostMap >
 void fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
 Compute( )
 {
-  typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
-  typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
-  typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
-  typedef typename _TQueue::value_type _TQueueValue;
-
-  // Create queue
-  _TQueue queue;
-  _TDistMapIt dIt(
-    this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
-    );
-  _TCostMapIt cIt(
-    this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
-    );
-  dIt.GoToBegin( );
-  cIt.GoToBegin( );
-  for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
-  {
-    double d = double( dIt.Get( ) );
-    if( d > 0 )
-    {
-      double v = double( cIt.Get( ) ) * d;
-      queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
-
-    } // fi
-
-  } // rof
-
-  TIndices marks;
-  while( queue.size( ) > 0 )
-  {
-    auto nIt = queue.begin( );
-    auto n = *nIt;
-    queue.erase( nIt );
-
-    if( marks.find( n.second ) == marks.end( ) )
-    {
-      std::cout << queue.size( ) << " " << n.first << std::endl;
-      marks.insert( n.second );
-      this->m_EndPoints.insert( n.second );
-      auto path = this->m_MST->GetPath( n.second );
-      std::cout << path.size( ) << std::endl;
-      for( auto pIt = path.begin( ); pIt != path.end( ); ++pIt )
-      {
-        double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
-        d = std::sqrt( std::fabs( d ) );
-        typename _TCostMap::PointType center;
-        this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
-
-        std::queue< TIndex > q;
-        TIndices m;
-        q.push( *pIt );
-        while( q.size( ) > 0 )
-        {
-          TIndex idx = q.front( );
-          q.pop( );
-          if( m.find( idx ) != m.end( ) )
-            continue;
-          m.insert( idx );
-          marks.insert( idx );
-          for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
-          {
-            for( int y = -1; y <= 1; y += 2 )
-            {
-              TIndex idx2 = idx;
-              idx2[ x ] += y;
-              typename _TCostMap::PointType c;
-              this->m_CostMap->TransformIndexToPhysicalPoint( idx2, c );
-              if( this->m_CostMap->GetRequestedRegion( ).IsInside( idx2 ) )
-              {
-                if( center.EuclideanDistanceTo( c ) <= ( d * 1.5 ) )
-                  q.push( idx2 );
-
-              } // fi
-
-            } // rof
-
-          } // rof
-
-        } // elihw
-
-      } // rof
-
-    } // fi
-
-  } // elihw
+  /* TODO
+     typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
+     typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
+     typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
+     typedef typename _TQueue::value_type _TQueueValue;
+
+     // Create queue
+     _TQueue queue;
+     _TDistMapIt dIt(
+     this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
+     );
+     _TCostMapIt cIt(
+     this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
+     );
+     dIt.GoToBegin( );
+     cIt.GoToBegin( );
+     for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
+     {
+     double d = double( dIt.Get( ) );
+     if( d > 0 )
+     {
+     double v = double( cIt.Get( ) ) * d;
+     queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
+
+     } // fi
+
+     } // rof
+
+     TIndices marks;
+     while( queue.size( ) > 0 )
+     {
+     auto nIt = queue.begin( );
+     auto n = *nIt;
+     queue.erase( nIt );
+
+     if( marks.find( n.second ) == marks.end( ) )
+     {
+     std::cout << queue.size( ) << " " << n.first << std::endl;
+     marks.insert( n.second );
+     this->m_EndPoints.insert( n.second );
+     auto path = this->m_MST->GetPath( n.second );
+     std::cout << path.size( ) << std::endl;
+     for( auto pIt = path.begin( ); pIt != path.end( ); ++pIt )
+     {
+     double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
+     d = std::sqrt( std::fabs( d ) );
+     typename _TCostMap::PointType center;
+     this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
+
+     std::queue< TIndex > q;
+     TIndices m;
+     q.push( *pIt );
+     while( q.size( ) > 0 )
+     {
+     TIndex idx = q.front( );
+     q.pop( );
+     if( m.find( idx ) != m.end( ) )
+     continue;
+     m.insert( idx );
+     marks.insert( idx );
+     for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
+     {
+     for( int y = -1; y <= 1; y += 2 )
+     {
+     TIndex idx2 = idx;
+     idx2[ x ] += y;
+     typename _TCostMap::PointType c;
+     this->m_CostMap->TransformIndexToPhysicalPoint( idx2, c );
+     if( this->m_CostMap->GetRequestedRegion( ).IsInside( idx2 ) )
+     {
+     if( center.EuclideanDistanceTo( c ) <= ( d * 1.5 ) )
+     q.push( idx2 );
+
+     } // fi
+
+     } // rof
+
+     } // rof
+
+     } // elihw
+
+     } // rof
+
+     } // fi
+
+     } // elihw
+  */
 }
 
 // -------------------------------------------------------------------------
index 371664c3b10b9e7e0eca1f9b89b5f917086e70ef..4a4e0e62bbbc53ebbc4cd5830ca6ec1d005c144e 100644 (file)
@@ -2,6 +2,7 @@
 #define __fpa__Image__MinimumSpanningTree__h__
 
 #include <fpa/Base/MinimumSpanningTree.h>
+#include <cpExtensions/DataStructures/PolyLineParametricPath.h>
 #include <itkImage.h>
 
 namespace fpa
@@ -12,20 +13,17 @@ namespace fpa
      */
     template< unsigned int _VDim >
     class MinimumSpanningTree
-      : public fpa::Base::MinimumSpanningTree< itk::Index< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
+      : public fpa::Base::MinimumSpanningTree< itk::Index< _VDim >, cpExtensions::DataStructures::PolyLineParametricPath< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
     {
     public:
       typedef itk::Index< _VDim >                               TVertex;
-      typedef itk::Offset< _VDim >                              TOffset;
-      typedef itk::Image< TOffset, _VDim >                      TImage;
-      typedef fpa::Base::MinimumSpanningTree< TVertex, TImage > Superclass;
-      typedef MinimumSpanningTree                               Self;
-      typedef itk::SmartPointer< Self >                         Pointer;
-      typedef itk::SmartPointer< const Self >                   ConstPointer;
-
-      typedef typename Superclass::TVertices TVertices;
-      typedef typename TImage::PointType TPoint;
-      typedef std::deque< TPoint > TPoints;
+      typedef cpExtensions::DataStructures::PolyLineParametricPath< _VDim > TPath;
+      typedef itk::Offset< _VDim >                                     TOffset;
+      typedef itk::Image< TOffset, _VDim >                             TImage;
+      typedef fpa::Base::MinimumSpanningTree< TVertex, TPath, TImage > Superclass;
+      typedef MinimumSpanningTree                                      Self;
+      typedef itk::SmartPointer< Self >                                Pointer;
+      typedef itk::SmartPointer< const Self >                          ConstPointer;
 
     public:
       itkNewMacro( Self );
@@ -37,8 +35,12 @@ namespace fpa
       virtual TVertex GetParent( const TVertex& v ) const fpa_OVERRIDE;
       virtual void SetParent( const TVertex& v, const TVertex& p ) fpa_OVERRIDE;
 
-      TPoints GetEuclideanPath( const TVertex& a ) const;
-      TPoints GetEuclideanPath( const TVertex& a, const TVertex& b ) const;
+      virtual void GetPath(
+        typename TPath::Pointer& path, const TVertex& a
+        ) const fpa_OVERRIDE;
+      virtual void GetPath(
+        typename TPath::Pointer& path, const TVertex& a, const TVertex& b
+        ) const fpa_OVERRIDE;
 
     protected:
       MinimumSpanningTree( );
index 01c642d96f61860be178dbd1f734ff69453ea6e5..162526ce20f058d06e480750914a82ff290f0939 100644 (file)
@@ -21,38 +21,22 @@ SetParent( const TVertex& v, const TVertex& p )
 
 // -------------------------------------------------------------------------
 template< unsigned int _VDim >
-typename fpa::Image::MinimumSpanningTree< _VDim >::
-TPoints fpa::Image::MinimumSpanningTree< _VDim >::
-GetEuclideanPath( const TVertex& a ) const
+void fpa::Image::MinimumSpanningTree< _VDim >::
+GetPath( typename TPath::Pointer& path, const TVertex& a ) const
 {
-  TVertices path = this->GetPath( a );
-  TPoints points;
-  for( auto v = path.begin( ); v != path.end( ); ++v )
-  {
-    TPoint p;
-    this->TransformIndexToPhysicalPoint( *v, p );
-    points.push_back( p );
-
-  } // rof
-  return( points );
+  this->Superclass::GetPath( path, a );
+  path->SetReferenceImage( this );
 }
 
 // -------------------------------------------------------------------------
 template< unsigned int _VDim >
-typename fpa::Image::MinimumSpanningTree< _VDim >::
-TPoints fpa::Image::MinimumSpanningTree< _VDim >::
-GetEuclideanPath( const TVertex& a, const TVertex& b ) const
+void fpa::Image::MinimumSpanningTree< _VDim >::
+GetPath(
+  typename TPath::Pointer& path, const TVertex& a, const TVertex& b
+  ) const
 {
-  TVertices path = this->GetPath( a, b );
-  TPoints points;
-  for( auto v = path.begin( ); v != path.end( ); ++v )
-  {
-    TPoint p;
-    this->TransformIndexToPhysicalPoint( *v, p );
-    points.push_back( p );
-
-  } // rof
-  return( points );
+  this->Superclass::GetPath( path, a, b );
+  path->SetReferenceImage( this );
 }
 
 // -------------------------------------------------------------------------
index f6b69d19fd80610a462d6ab5beaec7d7574bbded..c80ffde353e426ab9eb89ae8727015093347bba6 100644 (file)
@@ -1,27 +1,21 @@
 #include <plugins/Plugins/ExtractPathFromMinimumSpanningTree.h>
 #include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Mesh.h>
+#include <cpPlugins/DataObjects/PolyLineParametricPath.h>
 #include <fpa_DataObjects.h>
-
-/* TODO
-   #include <vtkFloatArray.h>
-   #include <vtkPointData.h>
-*/
+#include <vtkPolyData.h>
 
 // -------------------------------------------------------------------------
 fpaPlugins::ExtractPathFromMinimumSpanningTree::
 ExtractPathFromMinimumSpanningTree( )
   : Superclass( )
 {
-  typedef cpPlugins::BaseObjects::DataObject _TData;
-  typedef cpPlugins::DataObjects::Image _TMST;
-  typedef cpPlugins::DataObjects::Mesh  _TMesh;
+  typedef cpPlugins::BaseObjects::DataObject             _TData;
+  typedef cpPlugins::DataObjects::Image                  _TMST;
+  typedef cpPlugins::DataObjects::PolyLineParametricPath _TPath;
 
   this->_ConfigureInput< _TMST >( "MST", true, false );
   this->_ConfigureInput< _TData >( "Seeds", true, false );
-  this->_ConfigureOutput< _TMesh >( "Paths" );
-
-  this->m_Parameters.ConfigureAsUintList( "Indices" );
+  this->_ConfigureOutput< _TPath >( "Paths" );
 }
 
 // -------------------------------------------------------------------------
@@ -50,17 +44,21 @@ void fpaPlugins::ExtractPathFromMinimumSpanningTree::
 _GD0( _TMST* mst )
 {
   typedef typename _TMST::IndexType _TIndex;
+  typedef typename _TMST::TPath     _TPath;
 
   // Get seeds
   std::vector< _TIndex > seeds;
   auto points = this->GetInputData< vtkPolyData >( "Seeds" );
   if( points != NULL )
   {
+    if( points->GetNumberOfPoints( ) < 2 )
+      this->_Error( "Not enough seeds (<2)." );
+
     typename _TMST::PointType pnt;
     typename _TMST::IndexType idx;
     unsigned int dim =
       ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
-    for( unsigned int i = 0; i < points->GetNumberOfPoints( ); ++i )
+    for( unsigned int i = 0; i < 2; ++i )
     {
       double buf[ 3 ];
       points->GetPoint( i, buf );
@@ -74,51 +72,9 @@ _GD0( _TMST* mst )
 
   } // fi
 
-  // Prepare result
-  auto mesh = this->_CreateVTK< vtkPolyData >( );
-  mesh->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
-  mesh->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
-  mesh->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
-  mesh->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
-  mesh->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
-  /* TODO
-     vtkSmartPointer< vtkFloatArray > data =
-     vtkSmartPointer< vtkFloatArray >::New( );
-     data->SetNumberOfComponents( 1 );
-     mesh->GetPointData( )->SetScalars( data );
-  */
-
-  // Compute
-  auto indices = this->m_Parameters.GetUintList( "Indices" );
-  for( unsigned int i = 0; i < indices.size( ); i += 2 )
-  {
-    if( i < indices.size( ) - 1 )
-    {
-      _TIndex a = seeds[ indices[ i ] ];
-      _TIndex b = seeds[ indices[ i + 1 ] ];
-
-      auto path = mst->GetEuclideanPath( a, b );
-      for( unsigned long j = 0; j < path.size( ); ++j )
-      {
-        auto p = path[ j ];
-        if( _TMST::ImageDimension == 2 )
-          mesh->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], 0 );
-        else if( _TMST::ImageDimension == 3 )
-          mesh->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], p[ 2 ] );
-        if( j > 0 )
-        {
-          mesh->GetLines( )->InsertNextCell( 2 );
-          mesh->GetLines( )->InsertCellPoint( j - 1 );
-          mesh->GetLines( )->InsertCellPoint( j );
-
-        } // fi
-
-      } // rof
-
-    } // fi
-
-  } // rof
-  this->GetOutput( "Paths" )->SetVTK( mesh );
+  typename _TPath::Pointer path;
+  mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] );
+  this->GetOutput( "Paths" )->SetITK( path );
 }
 
 // eof - $RCSfile$