[vtkusers] saving vtkGraph to graphviz dot-files
Dr. Roman Grothausmann
grothausmann.roman at mh-hannover.de
Thu Feb 7 05:01:25 EST 2013
Dear mailing list members,
It seems there is no vtk-Filter to save a vtkGraph as a graphviz dot-file.
Therefore, I tried to create a simple program for that but it fails during
compilation with:
/usr/include/boost/graph/graphviz.hpp:297:5: required from ‘void
boost::write_graphviz(std::ostream&, const Graph&, typename
boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag,
typename boost::graph_traits<Graph>::traversal_category>::value,
boost::graph::detail::no_parameter>::type) [with Graph = vtkGraph*; std::ostream
= std::basic_ostream<char>; typename
boost::enable_if_c<boost::is_base_and_derived<boost::vertex_list_graph_tag,
typename boost::graph_traits<Graph>::traversal_category>::value,
boost::graph::detail::no_parameter>::type = boost::graph::detail::no_parameter]’
/home/grothama/vtk/graphviz-vtk/vtp2dot_01.cxx:47:38: required from here
/usr/include/boost/graph/graphviz.hpp:255:61: error: no type named
‘directed_category’ in ‘struct boost::graph_traits<vtkGraph*>’
/usr/include/boost/graph/graphviz.hpp:256:42: error: no type named
‘directed_category’ in ‘struct boost::graph_traits<vtkGraph*>’
make[2]: *** [CMakeFiles/vtp2dot_01.dir/vtp2dot_01.cxx.o] Error 1
Am I missing something in my code (see attached zip)?
Any help or hints are very much appreciated
Roman
_____
////convert a graph stored in a vtp-file to a dot-file (graphviz)
#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataReader.h>//for vtp-files
#include <vtkPolyDataToGraph.h>
#include "vtkBoostGraphAdapter.h"
#include <boost/graph/graphviz.hpp> // For writing graphs to a file
int main(int argc, char* argv[]){
if( argc != 3 )
{
std::cerr << "Usage: " << argv[0];
std::cerr << " inputMesh";
std::cerr << " outputFile";
std::cerr << std::endl;
return EXIT_FAILURE;
}
if(!(strcasestr(argv[1],".vtp"))) {
std::cout << "The input should end with .vtp" << std::endl;
return -1;
}
if(!(strcasestr(argv[2],".dot"))) {
std::cout << "The input should end with .dot" << std::endl;
return -1;
}
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
//reader->SetFileName(inputFileName);
reader->SetFileName(argv[1]);
reader->Update();
vtkSmartPointer<vtkPolyDataToGraph> polyDataToGraphFilter=
vtkSmartPointer<vtkPolyDataToGraph>::New();
polyDataToGraphFilter->SetInputConnection(reader->GetOutputPort());
polyDataToGraphFilter->Update();
vtkGraph* graph= polyDataToGraphFilter->GetOutput();
std::ofstream fout(argv[2]);
boost::write_graphviz(fout, graph);
return EXIT_SUCCESS;
}
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover
Tel. +49 511 532-9574
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graphviz-vtk.zip
Type: application/zip
Size: 9510 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130207/ce786fd5/attachment.zip>
More information about the vtkusers
mailing list