[vtkusers] converting vtkGraph to boostGraph to use with OpenGraphFixedTracking from D. Doria

Dr. Roman Grothausmann grothausmann.roman at mh-hannover.de
Thu Feb 7 04:45:51 EST 2013


Dear Jeff,


Many thanks for Your reply.

On 06/02/13 15:45, Jeff Baumes wrote:
> You may want to try making an instance of this specific
> graph type and use copy_graph
> <http://www.boost.org/doc/libs/1_53_0/libs/graph/doc/copy_graph.html> to convert
> the vtkGraph to the type the library expects.

I tried the following:


   vtkGraph* graph= polyDataToGraphFilter->GetOutput();

   //vtkBoostUndirectedGraph g(graph);

   Graph g;
   boost::copy_graph(graph, g);


but it fails with:

In file included from 
/home/grothama/vtk/GraphOpening-master/GraphOpeningTrackingExample_01.cxx:29:0:
/usr/include/boost/graph/copy.hpp: In instantiation of ‘struct 
boost::detail::choose_graph_copy<vtkGraph*>’:
/usr/include/boost/graph/copy.hpp:347:7:   required from ‘void 
boost::copy_graph(const VertexListGraph&, MutableGraph&) [with VertexListGraph = 
vtkGraph*; MutableGraph = boost::adjacency_list<boost::vecS, boost::vecS, 
boost::undirectedS, boost::no_property, EdgeVisibility>]’
/home/grothama/vtk/GraphOpening-master/GraphOpeningTrackingExample_01.cxx:87:29: 
   required from here
/usr/include/boost/graph/copy.hpp:251:50: error: ‘vtkGraph*’ is not a class, 
struct, or union type

Do all these problems arise of the property EdgeVisibility (which I would not 
need at all) or am I using vtkBoostGraphAdapter.h and boost::copy_graph in the 
wrong way?

Thanks for any help or hints
Roman

If copy_graph doesn't work you may
> need to manually iterate over vertices/edges to construct the graph.
>
>
> On Wed, Feb 6, 2013 at 9:30 AM, Dr. Roman Grothausmann
> <grothausmann.roman at mh-hannover.de <mailto:grothausmann.roman at mh-hannover.de>>
> wrote:
>
>     Dear mailing list members,
>
>
>     How can I use a vtkGraph as a boostGraph which is needed for
>     OpenGraphFixedTracking from D. Doria
>     (http://www.midasjournal.org/__browse/publication/828
>     <http://www.midasjournal.org/browse/publication/828>)?
>     I looked at vtkBoostBreadthFirstSearch.cxx and included
>     vtkBoostGraphAdapter.h (see below) and copied it to the project dir (seems
>     this header-file is not installed with VTK, why?) but I still get an error:
>
>     error: invalid user-defined conversion from ‘vtkGraph*’ to ‘const Graph&
>     {aka const boost::adjacency_list<boost::__vecS, boost::vecS,
>     boost::undirectedS, boost::no_property, EdgeVisibility>&}’ [-fpermissive]
>
>     What am I missing?
>
>     Any help or hints are very much appreciated
>     Roman
>
>     ________________________________________
>
>
>     #include "vtkBoostGraphAdapter.h"
>
>     #include <vtkXMLPolyDataReader.h>//for vtp-files (cannot contain 3D cells?)
>     #include <vtkPolyDataToGraph.h>
>
>     #include <vtkGraphToPolyData.h>
>     #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
>     ...
>
>        // Read the graph
>        //Graph graph = ReadGraph(inputFileName);
>
>        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();
>
>        //vtkBoostUndirectedGraph g(graph);
>
>        //vtkUndirectedGraph *g = vtkUndirectedGraph::__SafeDownCast(graph);
>        //Graph openedGraph = OpenGraphFixedTracking(g, numberOfIterations);
>        //Graph openedGraph =
>     OpenGraphFixedTracking(boost::__graph_traits<graph>, numberOfIterations);
>        Graph openedGraph = OpenGraphFixedTracking(graph, numberOfIterations);
>        //WriteGraph(openedGraph, outputFileName);
>
>        vtkSmartPointer<__vtkGraphToPolyData> graphToPolyData=
>     vtkSmartPointer<__vtkGraphToPolyData>::New();
>        graphToPolyData->SetInput(__openedGraph);
>        graphToPolyData->Update();
>
>        vtkSmartPointer<__vtkXMLPolyDataWriter> writer=
>     vtkSmartPointer<__vtkXMLPolyDataWriter>::New();
>        //writer->SetFileName(__outputFileName);
>        writer->SetFileName(argv[2]);
>        writer->SetInputConnection(__graphToPolyData->__GetOutputPort());
>        writer->Write();
>
>
>     --
>     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 <tel:%2B49%20511%20532-9574>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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-9574



More information about the vtkusers mailing list