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

Jeff Baumes jeff.baumes at kitware.com
Wed Feb 6 09:45:24 EST 2013


The library containing OpenGraphFixedTracking has a file Types.h that
defines:

typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS
, boost::no_property, EdgeVisibility> Graph;

This means that the OpenGraphFixedTracking function requires this exact
type, as opposed to standard boost graph library algorithms that are
templated to accept arbitrary graph types. 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. 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> 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
>
> _______________________________________________
> 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/20130206/a6e877ff/attachment.htm>


More information about the vtkusers mailing list