<div dir="ltr">It appears graph_copy does not support the graph_traits<> template specialization to retrieve associated types for a graph, but instead relies on typedefs being defined directly in the class, which vtkGraph does not have.<div>
<br></div><div style>Looks like you may need to traverse manually to do the conversion. Something like the following:</div><div style><br></div><div style>for (vtkIdType i = 0; i < graph->GetNumberOfVertices(); ++i)</div>
<div style>{</div><div style> add_vertex(g);</div><div style>}</div><div style><br></div><div style>for (vtkIdType i = 0; i < graph->GetNumberOfEdges(); ++i)</div><div style>{</div><div style> add_edge(graph->GetSourceVertex(i), graph->GetTargetVertex(i), g);</div>
<div style>}</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 7, 2013 at 4:45 AM, Dr. Roman Grothausmann <span dir="ltr"><<a href="mailto:grothausmann.roman@mh-hannover.de" target="_blank">grothausmann.roman@mh-hannover.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Jeff,<br>
<br>
<br>
Many thanks for Your reply.<div class="im"><br>
<br>
On 06/02/13 15:45, Jeff Baumes wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
You may want to try making an instance of this specific<br>
graph type and use copy_graph<br></div>
<<a href="http://www.boost.org/doc/libs/1_53_0/libs/graph/doc/copy_graph.html" target="_blank">http://www.boost.org/doc/<u></u>libs/1_53_0/libs/graph/doc/<u></u>copy_graph.html</a>> to convert<div class="im"><br>
the vtkGraph to the type the library expects.<br>
</div></blockquote>
<br>
I tried the following:<div class="im"><br>
<br>
<br>
vtkGraph* graph= polyDataToGraphFilter-><u></u>GetOutput();<br>
<br>
//vtkBoostUndirectedGraph g(graph);<br>
<br></div>
Graph g;<br>
boost::copy_graph(graph, g);<br>
<br>
<br>
but it fails with:<br>
<br>
In file included from /home/grothama/vtk/<u></u>GraphOpening-master/<u></u>GraphOpeningTrackingExample_<u></u>01.cxx:29:0:<br>
/usr/include/boost/graph/copy.<u></u>hpp: In instantiation of ‘struct boost::detail::choose_graph_<u></u>copy<vtkGraph*>’:<br>
/usr/include/boost/graph/copy.<u></u>hpp:347:7: required from ‘void boost::copy_graph(const VertexListGraph&, MutableGraph&) [with VertexListGraph = vtkGraph*; MutableGraph = boost::adjacency_list<boost::<u></u>vecS, boost::vecS, boost::undirectedS, boost::no_property, EdgeVisibility>]’<br>
/home/grothama/vtk/<u></u>GraphOpening-master/<u></u>GraphOpeningTrackingExample_<u></u>01.cxx:87:29: required from here<br>
/usr/include/boost/graph/copy.<u></u>hpp:251:50: error: ‘vtkGraph*’ is not a class, struct, or union type<br>
<br>
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?<br>
<br>
Thanks for any help or hints<br>
Roman<div class="im"><br>
<br>
If copy_graph doesn't work you may<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
need to manually iterate over vertices/edges to construct the graph.<br>
<br>
<br>
On Wed, Feb 6, 2013 at 9:30 AM, Dr. Roman Grothausmann<br></div>
<<a href="mailto:grothausmann.roman@mh-hannover.de" target="_blank">grothausmann.roman@mh-<u></u>hannover.de</a> <mailto:<a href="mailto:grothausmann.roman@mh-hannover.de" target="_blank">grothausmann.roman@mh-<u></u>hannover.de</a>>><div class="im">
<br>
wrote:<br>
<br>
Dear mailing list members,<br>
<br>
<br>
How can I use a vtkGraph as a boostGraph which is needed for<br>
OpenGraphFixedTracking from D. Doria<br></div>
(<a href="http://www.midasjournal.org/__browse/publication/828" target="_blank">http://www.midasjournal.org/_<u></u>_browse/publication/828</a><br>
<<a href="http://www.midasjournal.org/browse/publication/828" target="_blank">http://www.midasjournal.org/<u></u>browse/publication/828</a>>)?<div class="im"><br>
I looked at vtkBoostBreadthFirstSearch.cxx and included<br>
vtkBoostGraphAdapter.h (see below) and copied it to the project dir (seems<br>
this header-file is not installed with VTK, why?) but I still get an error:<br>
<br>
error: invalid user-defined conversion from ‘vtkGraph*’ to ‘const Graph&<br></div>
{aka const boost::adjacency_list<boost::_<u></u>_vecS, boost::vecS,<div class="im"><br>
boost::undirectedS, boost::no_property, EdgeVisibility>&}’ [-fpermissive]<br>
<br>
What am I missing?<br>
<br>
Any help or hints are very much appreciated<br>
Roman<br>
<br></div>
______________________________<u></u>__________<div class="im"><br>
<br>
<br>
#include "vtkBoostGraphAdapter.h"<br>
<br>
#include <vtkXMLPolyDataReader.h>//for vtp-files (cannot contain 3D cells?)<br>
#include <vtkPolyDataToGraph.h><br>
<br>
#include <vtkGraphToPolyData.h><br>
#include <vtkXMLPolyDataWriter.h>//for vtp-files<br>
<br>
...<br>
<br>
// Read the graph<br>
//Graph graph = ReadGraph(inputFileName);<br>
<br></div>
vtkSmartPointer<__<u></u>vtkXMLPolyDataReader> reader =<br>
vtkSmartPointer<__<u></u>vtkXMLPolyDataReader>::New();<br>
<br>
//reader->SetFileName(__<u></u>inputFileName);<div class="im"><br>
reader->SetFileName(argv[1]);<br>
reader->Update();<br>
<br></div>
vtkSmartPointer<__<u></u>vtkPolyDataToGraph> polyDataToGraphFilter=<br>
vtkSmartPointer<__<u></u>vtkPolyDataToGraph>::New();<br>
polyDataToGraphFilter->__<u></u>SetInputConnection(reader->__<u></u>GetOutputPort());<br>
polyDataToGraphFilter->Update(<u></u>__);<br>
<br>
vtkGraph* graph= polyDataToGraphFilter->__<u></u>GetOutput();<br>
<br>
//vtkBoostUndirectedGraph g(graph);<br>
<br>
//vtkUndirectedGraph *g = vtkUndirectedGraph::__<u></u>SafeDownCast(graph);<div class="im"><br>
//Graph openedGraph = OpenGraphFixedTracking(g, numberOfIterations);<br>
//Graph openedGraph =<br></div>
OpenGraphFixedTracking(boost::<u></u>__graph_traits<graph>, numberOfIterations);<div class="im"><br>
Graph openedGraph = OpenGraphFixedTracking(graph, numberOfIterations);<br>
//WriteGraph(openedGraph, outputFileName);<br>
<br></div>
vtkSmartPointer<__<u></u>vtkGraphToPolyData> graphToPolyData=<br>
vtkSmartPointer<__<u></u>vtkGraphToPolyData>::New();<br>
graphToPolyData->SetInput(__<u></u>openedGraph);<br>
graphToPolyData->Update();<br>
<br>
vtkSmartPointer<__<u></u>vtkXMLPolyDataWriter> writer=<br>
vtkSmartPointer<__<u></u>vtkXMLPolyDataWriter>::New();<br>
//writer->SetFileName(__<u></u>outputFileName);<br>
writer->SetFileName(argv[2]);<br>
writer->SetInputConnection(__<u></u>graphToPolyData->__<u></u>GetOutputPort());<div class="im"><br>
writer->Write();<br>
<br>
<br>
--<br>
Dr. Roman Grothausmann<br>
<br>
Tomographie und Digitale Bildverarbeitung<br>
Tomography and Digital Image Analysis<br>
<br>
Institut für Funktionelle und Angewandte Anatomie, OE 4120<br>
Medizinische Hochschule Hannover<br>
Carl-Neuberg-Str. 1<br>
D-30625 Hannover<br>
<br></div>
Tel. <a href="tel:%2B49%20511%20532-9574" value="+495115329574" target="_blank">+49 511 532-9574</a> <tel:%2B49%20511%20532-9574><br>
<br>
______________________________<u></u>_________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><div class="im"><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_<u></u>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/<u></u>listinfo/vtkusers</a><br>
<br>
<br>
</div></blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
Dr. Roman Grothausmann<br>
<br>
Tomographie und Digitale Bildverarbeitung<br>
Tomography and Digital Image Analysis<br>
<br>
Institut für Funktionelle und Angewandte Anatomie, OE 4120<br>
Medizinische Hochschule Hannover<br>
Carl-Neuberg-Str. 1<br>
D-30625 Hannover<br>
<br>
Tel. <a href="tel:%2B49%20511%20532-9574" value="+495115329574" target="_blank">+49 511 532-9574</a><br>
</div></div></blockquote></div><br></div>