[vtkusers] saving vtkGraph to graphviz dot-files

Jeff Baumes jeff.baumes at kitware.com
Tue Feb 9 09:00:07 EST 2016


This is great, thanks for sharing.

On Tue, Feb 2, 2016 at 3:37 AM Grothausmann, Roman Dr. <
grothausmann.roman at mh-hannover.de> wrote:

> Just for those who stumble upon this. I got this working in both
> directions:
>
> https://github.com/romangrothausmann/VTK-CLIs/blob/master/vtp2dot.cxx
> https://github.com/romangrothausmann/VTK-CLIs/blob/master/dot2vtp.cxx
>
> On 07/02/13 13:29, Jeff Baumes wrote:
> > The problem is that vtkGraph (the superclass) is abstract and does not
> specify
> > directionality. You should determine whether vtkPolyDataToGraph outputs a
> > vtkDirectedGraph or vtkUndirectedGraph and store the output in a
> variable of
> > that type before sending it to write_graph.
> >
> > Jeff
> >
> >
> > On Thu, Feb 7, 2013 at 5:01 AM, Dr. Roman Grothausmann
> > <__grothausmann.roman at mh-hannover.de__> wrote:
> > 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__
> >
> > _______________________________________________
> > Powered by __www.kitware.com__
> >
> > Visit other Kitware open-source projects at
> > __http://www.kitware.com/opensource/opensource.html__
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > __http://www.vtk.org/Wiki/VTK_FAQ__
> >
> > Follow this link to subscribe/unsubscribe:
> > __http://www.vtk.org/mailman/listinfo/vtkusers__
> >
> >
> >
>
> --
> 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-2900
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160209/1f637f6f/attachment.html>


More information about the vtkusers mailing list