[vtkusers] saving vtkGraph to graphviz dot-files
Jeff Baumes
jeff.baumes at kitware.com
Thu Feb 7 07:29:14 EST 2013
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130207/34455cec/attachment.htm>
More information about the vtkusers
mailing list