]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 16 Feb 2016 20:38:04 +0000 (15:38 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 16 Feb 2016 20:38:04 +0000 (15:38 -0500)
lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.h
lib/fpa/Base/ExtractBranchesFromMinimumSpanningTree.hxx
lib/fpa/Base/VectorValuesContainer.h [new file with mode: 0644]
lib/fpaPlugins/ExtractBranchesFromMinimumSpanningTree.cxx

index 183a7fa2774e5e1dcb6886574b65a69c0f32a0c8..cacc529c72ef942f3dfe0a0ae1d9f97d5f031043 100644 (file)
@@ -2,7 +2,7 @@
 #define __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__H__
 
 #include <set>
-#include <fpa/Base/MatrixValuesContainer.h>
+#include <fpa/Base/VectorValuesContainer.h>
 #include <itkProcessObject.h>
 #include <itkPolyLineParametricPath.h>
 
@@ -22,13 +22,15 @@ namespace fpa
       typedef itk::SmartPointer< Self >              Pointer;
       typedef itk::SmartPointer< const Self >        ConstPointer;
 
-      typedef T                          TMinimumSpanningTree;
-      typedef typename T::TVertex        TVertex;
-      typedef typename T::TVertexCompare TVertexCompare;
-      typedef itk::PolyLineParametricPath< TVertex::Dimension >  TPath;
-      typedef fpa::Base::MatrixValuesContainer< TVertex, typename TPath::Pointer, TVertexCompare > TBranches;
+      typedef T                                  TMinimumSpanningTree;
+      typedef typename T::TVertex                             TVertex;
+      typedef typename T::TVertexCompare               TVertexCompare;
+      typedef itk::PolyLineParametricPath< TVertex::Dimension > TPath;
+      typedef std::set< TVertex, TVertexCompare >          TEndPoints;
 
-      typedef std::set< TVertex, TVertexCompare > TEndPoints;
+      typedef
+      fpa::Base::VectorValuesContainer< typename TPath::Pointer >
+      TBranches;
 
     public:
       itkNewMacro( Self );
@@ -41,7 +43,7 @@ namespace fpa
       const T* GetInput( ) const;
       void SetInput( const T* tree );
 
-      TBranches* GetOutput( );
+      TPath* GetOutput( );
 
       void ClearEndPoints( );
       void AddEndPoint( const TVertex& v );
index 9dd96ed08afffc0e4dd18f70b28d43c068bf5fbd..5a7433f6bea67718c8bfd4e4b3d73e460ee7ded7 100644 (file)
@@ -22,11 +22,11 @@ SetInput( const T* tree )
 // -------------------------------------------------------------------------
 template< class T >
 typename fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
-TBranches* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
+TPath* fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
 GetOutput( )
 {
   return(
-    itkDynamicCastInDebugMode< TBranches* >( this->GetPrimaryOutput( ) )
+    itkDynamicCastInDebugMode< TPath* >( this->GetPrimaryOutput( ) )
     );
 }
 
@@ -76,7 +76,7 @@ ExtractBranchesFromMinimumSpanningTree( )
 {
   this->itk::ProcessObject::SetNumberOfRequiredInputs( 1 );
 
-  typename TBranches::Pointer out = TBranches::New( );
+  typename TPath::Pointer out = TPath::New( );
   this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
   this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
 }
@@ -94,35 +94,45 @@ void fpa::Base::ExtractBranchesFromMinimumSpanningTree< T >::
 GenerateData( )
 {
   auto tree = this->GetInput( );
-  auto branches = this->GetOutput( );
+  auto path = this->GetOutput( );
+
+  // TODO: this is just a temporary code
+  auto v0 = *( this->m_EndPoints.begin( ) );
+  auto v1 = *( this->m_EndPoints.rbegin( ) );
+  auto lst = tree->GetPath( v0, v1 );
+  path->Initialize( );
+  for( auto i = lst.begin( ); i != lst.end( ); ++i )
+    path->AddVertex( *i );
 
   // Find bifurcations
-  TEndPoints bifurcations, marks;
-  auto e0It = this->m_EndPoints.begin( );
-  for( ; e0It != this->m_EndPoints.end( ); ++e0It )
-  {
-    auto e1It = e0It;
-    e1It++;
-    for( ; e1It != this->m_EndPoints.end( ); ++e1It )
-    {
-      auto path = tree->GetPath( *e0It, *e1It );
-      std::cout << "path" << std::endl;
-      auto pIt = path.begin( );
-      for( ; pIt != path.end( ); ++pIt )
-      {
-        if( marks.find( *pIt ) == marks.end( ) )
-          marks.insert( *pIt );
-        else
-          bifurcations.insert( *pIt );
-
-      } // rof
-
-    } // rof
-
-  } // rof
-
-  // Construct branches
-  std::cout << bifurcations.size( ) << std::endl;
+  /* TODO: this should be the final code
+     TEndPoints bifurcations, marks;
+     auto e0It = this->m_EndPoints.begin( );
+     for( ; e0It != this->m_EndPoints.end( ); ++e0It )
+     {
+     auto e1It = e0It;
+     e1It++;
+     for( ; e1It != this->m_EndPoints.end( ); ++e1It )
+     {
+     auto path = tree->GetPath( *e0It, *e1It );
+     std::cout << "path" << std::endl;
+     auto pIt = path.begin( );
+     for( ; pIt != path.end( ); ++pIt )
+     {
+     if( marks.find( *pIt ) == marks.end( ) )
+     marks.insert( *pIt );
+     else
+     bifurcations.insert( *pIt );
+
+     } // rof
+
+     } // rof
+
+     } // rof
+
+     // Construct branches
+     std::cout << bifurcations.size( ) << std::endl;
+  */
 }
 
 #endif // __FPA__BASE__EXTRACTBRANCHESFROMMINIMUMSPANNINGTREE__HXX__
diff --git a/lib/fpa/Base/VectorValuesContainer.h b/lib/fpa/Base/VectorValuesContainer.h
new file mode 100644 (file)
index 0000000..9358c33
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef __FPA__BASE__VECTORVALUESCONTAINER__H__
+#define __FPA__BASE__VECTORVALUESCONTAINER__H__
+
+#include <vector>
+#include <itkSimpleDataObjectDecorator.h>
+#include <itkSmartPointer.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class T >
+    class VectorValuesContainer
+      : public itk::SimpleDataObjectDecorator< std::vector< T > >
+    {
+    public:
+      typedef std::vector< T >                             TDecorated;
+      typedef VectorValuesContainer                        Self;
+      typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass;
+      typedef itk::SmartPointer< Self >                    Pointer;
+      typedef itk::SmartPointer< const Self >              ConstPointer;
+
+      typedef T TValue;
+      typedef typename TDecorated::iterator          Iterator;
+      typedef typename TDecorated::const_iterator    ConstIterator;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( VectorValuesContainer, itkSimpleDataObjectDecorator );
+
+    public:
+      void PushBack( const T& v )
+        { this->Get( ).push_back( v ); this->Modified( ); }
+      void PopBack( const T& v )
+        { this->Get( ).pop_back( ); this->Modified( ); }
+      Iterator Begin( )
+        { return( this->Get( ).begin( ) ); }
+      Iterator End( )
+        { return( this->Get( ).end( ) ); }
+      ConstIterator Begin( ) const
+        { return( this->Get( ).begin( ) ); }
+      ConstIterator End( ) const
+        { return( this->Get( ).end( ) ); }
+
+    protected:
+      VectorValuesContainer( )
+        : Superclass( )
+        { }
+      virtual ~VectorValuesContainer( )
+        { }
+
+    private:
+      // Purposely not implemented
+      VectorValuesContainer( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __FPA__BASE__VECTORVALUESCONTAINER__H__
+
+// eof - $RCSfile$
index dc0799387391c16bd02248f8756eec6f1f1523f6..9c5e6af0c0524be354c16f84ba488cf67345f90a 100644 (file)
@@ -3,6 +3,7 @@
 #include <itkIndex.h>
 
 #include <cpPlugins/Interface/PointList.h>
+#include <cpPlugins/Interface/PolyLineParametricPath.h>
 #include <fpaPlugins/MinimumSpanningTree.h>
 
 #include <fpa/Base/MinimumSpanningTree.h>
@@ -15,7 +16,7 @@ ExtractBranchesFromMinimumSpanningTree( )
 {
   this->_AddInput( "MinimumSpanningTree" );
   this->_AddInput( "EndPoints" );
-  this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" );
+  this->_AddOutput< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
 }
 
 // -------------------------------------------------------------------------
@@ -69,7 +70,7 @@ _GD0( )
 
   // Connect output and finish
   auto out =
-    this->GetOutputData< cpPlugins::Interface::DataObject >( "Output" );
+    this->GetOutputData< cpPlugins::Interface::PolyLineParametricPath >( "Output" );
   out->SetITK( filter->GetOutput( ) );
   return( "" );
 }