-#IF(BUILD_EXAMPLES)
-#SUBDIRS(
-#examples
-## fpaLab
-#)
-#ENDIF(BUILD_EXAMPLES)
IF(BUILD_TempAirwaysAppli)
SUBDIRS(
FIND_PACKAGE(Boost REQUIRED system filesystem program_options)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-SUBDIRS(
- MathLib
- AirwaysLib
- )
INCLUDE_DIRECTORIES(
- MathLib
- AirwaysLib
+ ${PROJECT_SOURCE_DIR}/lib/Airways/MathLib
+ ${PROJECT_SOURCE_DIR}/lib/Airways/AirwaysLib
+ ${PROJECT_BINARY_DIR}/lib/Airways/MathLib
+ ${PROJECT_BINARY_DIR}/lib/Airways/AirwaysLib
)
ADD_EXECUTABLE(TempAirwaysAppli TempAirwaysAppli.cxx)
TARGET_LINK_LIBRARIES(
TempAirwaysAppli
- ${Boost_LIBRARIES} MathLib AirwaysLib
+ ${Boost_LIBRARIES} TempAirwaysAppli_AirwaysLib
cpPlugins
${fpa_LIBRARIES}
)
#include <fpa/Image/MinimumSpanningTree.h>
#include <cpExtensions/DataStructures/ImageIndexesContainer.h>
#include <itkImage.h>
+#include <queue>
template< class TImage, class TVertex >
Node* FAVertexToNode( TVertex vertex, TImage* image )
auto distance_map =
ws.GetFilter( "dmap" )->GetOutputData( "Output" )->
GetITK< itk::Image< float, 3 > >( );
- auto branches =
+ auto sk =
w_filter->GetOutputData( "Skeleton" )->GetITK< TFASkeleton >( );
- auto sIt = branches->Get( ).begin( );
- for( ; sIt!=branches->Get( ).end( ); ++sIt )
+ const auto& branches = sk->Get( );
+ auto seed0 =
+ ws.GetFilter( "seed" )->GetOutputData( "Output" )->
+ GetITK< TVerticesFA >( )->Get( )[ 0 ];
+
+ std::queue< TVertexFA > q;
+ // TODO: std::set< TVertexFA, TVertexCompareFA > marks;
+ q.push( seed0 );
+ while( !q.empty( ) )
{
- auto srcIt = vertexMap.find( sIt->first );
+ auto sVertex = q.front( );
+ q.pop( );
+ auto sIt = branches.find( sVertex );
+ /* TODO
+ if( marks.find( sVertex ) != marks.end( ) )
+ {
+ std::cout << "MARK!!!!! : " << sVertex << std::endl;
+ }
+ marks.insert( sVertex );
+ */
+
+ // End node... do nothing
+ if( sIt == branches.end( ) )
+ continue;
+
+ // Create source node
+ auto srcIt = vertexMap.find( sVertex );
if( srcIt == vertexMap.end( ) )
srcIt = vertexMap.insert(
VertexMap::value_type(
- sIt->first, FAVertexToNode( sIt->first, input_image )
+ sVertex, FAVertexToNode( sVertex, input_image )
)
).first;
- auto eIt = sIt->second.begin( );
- for( ; eIt != sIt->second.end( ); ++eIt )
+
+ // TODO: std::cout << sVertex << " " << " " << sLevel << " " << seed0 << std::endl;
+ // Create destination nodes
+ for( auto eIt = sIt->second.begin( ); eIt != sIt->second.end( ); ++eIt )
{
auto dstIt = vertexMap.find( eIt->first );
- if( dstIt != vertexMap.end( ) )
- continue;
- dstIt = vertexMap.insert(
- VertexMap::value_type(
- eIt->first, FAVertexToNode( eIt->first, input_image )
- )
- ).first;
-
+ if( dstIt == vertexMap.end( ) )
+ dstIt = vertexMap.insert(
+ VertexMap::value_type(
+ eIt->first, FAVertexToNode( eIt->first, input_image )
+ )
+ ).first;
+
+ // Connect in the acyclic graph
dstIt->second->SetFather( srcIt->second );
srcIt->second->AddChild( dstIt->second );
+
+ // Create detailed edge
TEdgeAirways* edge = new Edge( );
+ edge->SetSource( srcIt->second );
+ edge->SetTarget( dstIt->second );
auto path = eIt->second->GetVertexList( );
for( unsigned int pIt = 0; pIt < path->Size( ); ++pIt )
{
} // rof
+ // Finish association
+ dstIt->second->SetEdge( edge );
+
+ // Put it as next candidate
+ q.push( eIt->first );
+
} // rof
- } // rof
- auto seed0 =
- ws.GetFilter( "seed" )->GetOutputData( "Output" )->
- GetITK< TVerticesFA >( )->Get( )[ 0 ];
+ } // elihw
+
AirwaysTree* tree =
new AirwaysTree( input_image, NULL, vertexMap[ seed0 ], false );
std::time(&end);
## = Set names and directories =
## =============================
-SET(lib_NAME AirwaysLib)
+SET(lib_NAME TempAirwaysAppli_AirwaysLib)
INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/appli/TempAirwaysAppli/MathLib
- ${PROJECT_SOURCE_DIR}/appli/TempAirwaysAppli/AirwaysLib
- ${PROJECT_BINARY_DIR}/appli/TempAirwaysAppli/MathLib
- ${PROJECT_BINARY_DIR}/appli/TempAirwaysAppli/AirwaysLib
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MathLib
+ ${CMAKE_CURRENT_BINARY_DIR}/../MathLib
)
## ===============
## = Source code =
## ===============
-FILE(GLOB lib_HEADERS_H "*.h")
-FILE(GLOB lib_HEADERS_HPP "*.hpp")
-FILE(GLOB lib_HEADERS_HXX "*.hxx")
-FILE(GLOB lib_SOURCES_C "*.c")
-FILE(GLOB lib_SOURCES_CPP "*.cpp")
-FILE(GLOB lib_SOURCES_CXX "*.cxx")
+FILE(GLOB lib_HEADERS_H "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+FILE(GLOB lib_HEADERS_HPP "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
+FILE(GLOB lib_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+FILE(GLOB lib_SOURCES_C "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
+FILE(GLOB lib_SOURCES_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
+FILE(GLOB lib_SOURCES_CXX "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
## =====================
## = Compilation rules =
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} MathLib ${ITK_LIBRARIES} ${VTK_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} TempAirwaysAppli_MathLib ${ITK_LIBRARIES} ${VTK_LIBRARIES})
## eof - $RCSfile$
#include "airwaysNode.h"
#include "Quaternion.h"
-#include <appli/TempAirwaysAppli/AirwaysLib/AirwaysLib_Export.h>
+#include <Airways/AirwaysLib/TempAirwaysAppli_AirwaysLib_Export.h>
/**
* @brief Airways project namespace
* This means that the edge source corresponds to the father and the target to the child. This implies that the root
* node has a NULL edge.
*/
-class AirwaysLib_EXPORT Edge
+class TempAirwaysAppli_AirwaysLib_EXPORT Edge
{
public:
/*!
#include "../MathLib/vec3.h"
#include "airwaysEdge.h"
#include "Quaternion.h"
-#include <appli/TempAirwaysAppli/AirwaysLib/AirwaysLib_Export.h>
+#include <Airways/AirwaysLib/TempAirwaysAppli_AirwaysLib_Export.h>
// Namespaces
using namespace std;
/*
* This class represents a node in a tree.
*/
-class AirwaysLib_EXPORT Node
+class TempAirwaysAppli_AirwaysLib_EXPORT Node
{
public:
#include "itkImageRegionIterator.h"
#include "itkLineIterator.h"
#include <itkImageFileWriter.h>
-#include <appli/TempAirwaysAppli/AirwaysLib/AirwaysLib_Export.h>
+#include <Airways/AirwaysLib/TempAirwaysAppli_AirwaysLib_Export.h>
namespace airways
{
*/
typedef std::vector<pair_posVox_rad> vec_pair_posVox_rad;
-class AirwaysLib_EXPORT AirwaysTree
+class TempAirwaysAppli_AirwaysLib_EXPORT AirwaysTree
{
public:
--- /dev/null
+SUBDIRS(
+ MathLib
+ AirwaysLib
+ )
+
+## eof - $RCSfile$
## = Set names and directories =
## =============================
-SET(lib_NAME MathLib)
+SET(lib_NAME TempAirwaysAppli_MathLib)
## ===============
## = Source code =
## ===============
-FILE(GLOB lib_HEADERS_H "*.h")
-FILE(GLOB lib_HEADERS_HPP "*.hpp")
-FILE(GLOB lib_HEADERS_HXX "*.hxx")
-FILE(GLOB lib_SOURCES_C "*.c")
-FILE(GLOB lib_SOURCES_CPP "*.cpp")
-FILE(GLOB lib_SOURCES_CXX "*.cxx")
+FILE(GLOB lib_HEADERS_H "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+FILE(GLOB lib_HEADERS_HPP "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
+FILE(GLOB lib_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+FILE(GLOB lib_SOURCES_C "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
+FILE(GLOB lib_SOURCES_CPP "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
+FILE(GLOB lib_SOURCES_CXX "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
## =====================
## = Compilation rules =
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-##TARGET_LINK_LIBRARIES(${lib_NAME})
## eof - $RCSfile$
//-----------------
// OWN
//-----------------
-#include <appli/TempAirwaysAppli/MathLib/MathLib_Export.h>
+#include <Airways/MathLib/TempAirwaysAppli_MathLib_Export.h>
#include "vec3.h"
// Namespaces
//------------------------------------------------------------------------------
// Class that represents a Quaterion with all its operations
//------------------------------------------------------------------------------
-class MathLib_EXPORT Quaternion
+class TempAirwaysAppli_MathLib_EXPORT Quaternion
{
public:
#ifndef VEC3_H
#define VEC3_H
-#include <appli/TempAirwaysAppli/MathLib/MathLib_Export.h>
+#include <Airways/MathLib/TempAirwaysAppli_MathLib_Export.h>
#include <cmath>
#include <iostream>
#include <limits> // std::numeric_limits
/**
* @brief The Vec3 class that represents a vector in 3D
*/
-class MathLib_EXPORT Vec3
+class TempAirwaysAppli_MathLib_EXPORT Vec3
{
private:
float x, y, z; //!< Coordinates
--- /dev/null
+#ifndef __FPA2AIRWAYS__CONVERTER__H__
+#define __FPA2AIRWAYS__CONVERTER__H__
+
+#include <itkProcessObject.h>
+#include <itkSimpleDataObjectDecorator.h>
+
+namespace fpa2Airways
+{
+ /**
+ */
+ template< class _TSkeleton, class _TAirways >
+ class Converter
+ : public itk::ProcessObject
+ {
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( Converter, itk::ProcessObject );
+
+ public:
+ SetInput( TSkeleton );
+ TAirways GetOutput( );
+
+ protected:
+ Converter( );
+ virtual ~Converter( );
+
+ virtual void GenerateData( ) ITK_OVERRIDE;
+
+ private:
+ // Purposely not implemented.
+ Converter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include <fpa2Airways/Converter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __FPA2AIRWAYS__CONVERTER__H__
+
+// eof - $RCSfile$
+IF(BUILD_TempAirwaysAppli)
+ SUBDIRS(
+ Airways
+ )
+ENDIF(BUILD_TempAirwaysAppli)
IF(BUILD_PLUGINS)
SUBDIRS(
fpa_Instances
auto vertex = qIt->second;
// 2.1. Check if the vertex has already been visited
- if( this->_Mark( vertex ) > 0 )
+ if( this->_Mark( vertex ) > 0 || this->_SkeletonMark( vertex ) > 0 )
continue;
// 2.2. Get path from front seed
bifurcations->Get( ).push_back( *pIt );
// Reorder labels
- auto coll_branch = this->m_Branches[ mark ];
- this->m_Branches[ mark ] = _TBranch( coll_branch.first, *pIt );
+ auto coll_branch = this->m_Branches[ mark - 1 ];
+ this->m_Branches[ mark - 1 ] = _TBranch( coll_branch.first, *pIt );
this->m_Branches[ label - 1 ] = _TBranch( qIt->second, *pIt );
this->m_Branches.push_back( _TBranch( *pIt, coll_branch.second ) );
pIt++;
} // elihw
+ if( pIt != path.end( ) )
+ this->_MarkSkeleton( *pIt, label );
// Force inner loop termination
pIt = path.end( );
} // rof
+ // Remove illegal branches
+ auto dIt = this->m_Branches.begin( );
+ while( dIt != this->m_Branches.end( ) )
+ {
+ if( dIt->first == dIt->second )
+ dIt = this->m_Branches.erase( dIt );
+ else
+ dIt++;
+
+ } // fi
+
+ // Finish
endpoints->SetReferenceImage( mst );
bifurcations->SetReferenceImage( mst );
collisions->SetReferenceImage( mst );
// Check if the branch already exists
bool found = false;
- auto arIt = this->Get( ).find( a );
- if( arIt != this->Get( ).end( ) )
- found = ( arIt->second.find( b ) != arIt->second.end( ) );
+ auto aIt = this->Get( ).find( a );
+ if( aIt != this->Get( ).end( ) )
+ found = ( aIt->second.find( b ) != aIt->second.end( ) );
if( found )
return;
// Assign path vertices
path->SetReferenceImage( this->m_MinimumSpanningTree );
- this->Get( )[ a ][ b ] = path;
- this->Modified( );
+
+ typedef typename TSkeleton::value_type _T1;
+ typedef typename TSkeletonRow::value_type _T2;
+
+ TSkeleton& sk = this->Get( );
+ auto sIt = sk.find( a );
+ if( sIt == sk.end( ) )
+ {
+ sIt = sk.insert( _T1( a, TSkeletonRow( ) ) ).first;
+ this->Modified( );
+
+ } // fi
+ if( sIt->second.find( b ) == sIt->second.end( ) )
+ {
+ sIt->second.insert( _T2( b, path ) );
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
{
typename _TImage::PointType pnt;
this->m_MarkImage->TransformIndexToPhysicalPoint( spIt.GetIndex( ), pnt );
- if( double( pnt.EuclideanDistanceTo( c ) ) <= rr || all )
+ /*
+ if( double( pnt.EuclideanDistanceTo( c ) ) <= rr || all )
if( spIt.Get( ) == 0 )
- spIt.Set( l );
+ */
+ spIt.Set( l );
} // rof
}