Skip to content
Snippets Groups Projects
Commit a8b1808d authored by Kasper Marstal's avatar Kasper Marstal
Browse files

ENH: ELASTIX-9 Add blueprint visualization with graphviz #comment

parent 9cb9e48f
No related branches found
No related tags found
No related merge requests found
...@@ -33,8 +33,8 @@ public: ...@@ -33,8 +33,8 @@ public:
ParameterMapType parameterMap; ParameterMapType parameterMap;
}; };
typedef boost::adjacency_list< boost::listS, typedef boost::adjacency_list< boost::vecS,
boost::listS, boost::vecS,
boost::directedS, boost::directedS,
ComponentPropertyType, ComponentPropertyType,
ConnectionPropertyType > GraphType; ConnectionPropertyType > GraphType;
...@@ -60,9 +60,9 @@ public: ...@@ -60,9 +60,9 @@ public:
void SetComponent( ComponentIndexType, ParameterMapType parameterMap ); void SetComponent( ComponentIndexType, ParameterMapType parameterMap );
// TODO: Let user delete component. Before we do this, we need a proper way of // TODO: Let user delete component. Before we do this, we need a proper way of
// checking that a vertex exist. Otherwise a call to GetComponent() on // checking that a vertex exist. Otherwise a call to GetComponent() on
// a deleted vertex will result in segfault. It is not really a in issue // a deleted vertex will result in segfault. It is not really a in issue
// _before_ realease since typically we use (the developers) use blueprint // _before_ release since typically we (the developers) will use blueprint
// interface procedurally. // interface procedurally.
// void DeleteComponent( ComponentIndexType ); // void DeleteComponent( ComponentIndexType );
...@@ -88,9 +88,11 @@ public: ...@@ -88,9 +88,11 @@ public:
// Returns the outgoing connections from a component in the graph, // Returns the outgoing connections from a component in the graph,
// i.e. all components that reads data from given component // i.e. all components that reads data from given component
OutputIteratorPairType GetOutputIterator( const ComponentIndexType index ) { OutputIteratorPairType GetOutputIterator( const ComponentIndexType index ) {
return boost::out_edges(index, this->m_Graph); return boost::out_edges( index, this->m_Graph );
} }
void WriteBlueprint( const std::string filename );
private: private:
ConnectionIndexType GetConnectionIndex( ComponentIndexType upsteam, ComponentIndexType downstream ); ConnectionIndexType GetConnectionIndex( ComponentIndexType upsteam, ComponentIndexType downstream );
......
#ifndef __Blueprint_hxx #ifndef __Blueprint_cxx
#define __Blueprint_hxx #define __Blueprint_cxx
#include <boost/graph/graphviz.hpp> #include "boost/graph/graphviz.hpp"
#include "elxBlueprint.h" #include "elxBlueprint.h"
...@@ -147,14 +147,14 @@ Blueprint ...@@ -147,14 +147,14 @@ Blueprint
return boost::edge( upstream, downstream, this->m_Graph).first; return boost::edge( upstream, downstream, this->m_Graph).first;
} }
// void void
// Blueprint Blueprint
// ::PrintGraph( void ) ::WriteBlueprint( const std::string filename )
// { {
// // TODO: Link to graphviz library std::ofstream dotfile( filename.c_str() );
// boost::write_graphviz(std::cout, this->m_Graph); boost::write_graphviz( dotfile, this->m_Graph );
// } }
} // namespace elx } // namespace elx
#endif // __Blueprint_hxx #endif // __Blueprint_cxx
\ No newline at end of file
...@@ -9,4 +9,4 @@ set( ${MODULE}_SOURCE_FILES ...@@ -9,4 +9,4 @@ set( ${MODULE}_SOURCE_FILES
set( ${MODULE}_LIBRARIES set( ${MODULE}_LIBRARIES
${MODULE} ${MODULE}
) )
\ No newline at end of file
...@@ -52,8 +52,8 @@ TEST_F( BlueprintTest, SetComponent ) ...@@ -52,8 +52,8 @@ TEST_F( BlueprintTest, SetComponent )
EXPECT_EQ( parameterMap["ComponentName"], parameterMapTest["ComponentName"] ); EXPECT_EQ( parameterMap["ComponentName"], parameterMapTest["ComponentName"] );
} }
// TODO: The final line segfaults since at this point GetComponent has no way // TODO: The final line segfaults because GetComponent does not check that the index actually
// of checking that the index actually exist. See explanation in elxBlueprint.h // actually exist. How can we do that? See also explanation in elxBlueprint.h
// TEST_F( BlueprintTest, DeleteComponent ) // TEST_F( BlueprintTest, DeleteComponent )
// { // {
// BlueprintPointerType blueprint = Blueprint::New(); // BlueprintPointerType blueprint = Blueprint::New();
...@@ -155,4 +155,20 @@ TEST_F( BlueprintTest, DeleteConnection ) ...@@ -155,4 +155,20 @@ TEST_F( BlueprintTest, DeleteConnection )
EXPECT_FALSE( blueprint->ConnectionExists( index0, index1 ) ); EXPECT_FALSE( blueprint->ConnectionExists( index0, index1 ) );
} }
TEST_F( BlueprintTest, WriteBlueprint )
{
BlueprintPointerType blueprint = Blueprint::New();
ComponentIndexType index0 = blueprint->AddComponent();
ComponentIndexType index1 = blueprint->AddComponent();
ComponentIndexType index2 = blueprint->AddComponent();
ComponentIndexType index3 = blueprint->AddComponent();
blueprint->AddConnection( index0, index1 );
blueprint->AddConnection( index0, index2 );
blueprint->AddConnection( index2, index3 );
EXPECT_NO_THROW( blueprint->WriteBlueprint( "blueprint.dot" ) );
}
} // namespace elx } // namespace elx
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment