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:
ParameterMapType parameterMap;
};
typedef boost::adjacency_list< boost::listS,
boost::listS,
typedef boost::adjacency_list< boost::vecS,
boost::vecS,
boost::directedS,
ComponentPropertyType,
ConnectionPropertyType > GraphType;
......@@ -60,9 +60,9 @@ public:
void SetComponent( ComponentIndexType, ParameterMapType parameterMap );
// 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
// _before_ realease since typically we use (the developers) use blueprint
// _before_ release since typically we (the developers) will use blueprint
// interface procedurally.
// void DeleteComponent( ComponentIndexType );
......@@ -88,9 +88,11 @@ public:
// Returns the outgoing connections from a component in the graph,
// i.e. all components that reads data from given component
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:
ConnectionIndexType GetConnectionIndex( ComponentIndexType upsteam, ComponentIndexType downstream );
......
#ifndef __Blueprint_hxx
#define __Blueprint_hxx
#ifndef __Blueprint_cxx
#define __Blueprint_cxx
#include <boost/graph/graphviz.hpp>
#include "boost/graph/graphviz.hpp"
#include "elxBlueprint.h"
......@@ -147,14 +147,14 @@ Blueprint
return boost::edge( upstream, downstream, this->m_Graph).first;
}
// void
// Blueprint
// ::PrintGraph( void )
// {
// // TODO: Link to graphviz library
// boost::write_graphviz(std::cout, this->m_Graph);
// }
void
Blueprint
::WriteBlueprint( const std::string filename )
{
std::ofstream dotfile( filename.c_str() );
boost::write_graphviz( dotfile, this->m_Graph );
}
} // namespace elx
#endif // __Blueprint_hxx
\ No newline at end of file
#endif // __Blueprint_cxx
......@@ -9,4 +9,4 @@ set( ${MODULE}_SOURCE_FILES
set( ${MODULE}_LIBRARIES
${MODULE}
)
\ No newline at end of file
)
......@@ -52,8 +52,8 @@ TEST_F( BlueprintTest, SetComponent )
EXPECT_EQ( parameterMap["ComponentName"], parameterMapTest["ComponentName"] );
}
// TODO: The final line segfaults since at this point GetComponent has no way
// of checking that the index actually exist. See explanation in elxBlueprint.h
// TODO: The final line segfaults because GetComponent does not check that the index actually
// actually exist. How can we do that? See also explanation in elxBlueprint.h
// TEST_F( BlueprintTest, DeleteComponent )
// {
// BlueprintPointerType blueprint = Blueprint::New();
......@@ -155,4 +155,20 @@ TEST_F( BlueprintTest, DeleteConnection )
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
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