[vtk-developers] [vtkusers] Creating the dual of a graph - planar face traversal - vtkBoostGraphAdapter

Jeff Baumes jeff.baumes at kitware.com
Wed Oct 15 09:09:40 EDT 2014


This is starting to get beyond me. Here is what I could find. If you search
for iterator_property_map in

http://www.boost.org/doc/libs/1_55_0/boost/property_map/property_map.hpp

you can see that operator[] is clearly defined. I have a feeling this may
be a const issue, or perhaps the fact that the planar_dual algorithm
assumes you can do this:

edge_to_face[e] = current_face;

while iterator_property_map may produce a map that is read-only:

http://www.boost.org/doc/libs/1_37_0/libs/property_map/iterator_property_map.html
"... converts any random access iterator into a Lvalue Property Map ..."

http://www.boost.org/doc/libs/1_37_0/libs/property_map/LvaluePropertyMap.html
"... may be mutable or non-mutable ..."

Perhaps that points you in the right direction.

Jeff







On Wed, Oct 8, 2014 at 5:27 PM, Szilárd Szalóki <szilardszaloki at gmail.com>
wrote:

> Thank you for replying so fast!
>
> I edited the vtkBoostGraphAdapter.h:
>
>   struct vtkGraphIndexMap;
>
>
>   template <>
>
>   struct property_traits<vtkGraphIndexMap>
>
>     {
>
>     typedef vtkIdType value_type;
>
>     typedef vtkIdType reference;
>
>     typedef vtkIdType key_type;
>
>     typedef readable_property_map_tag category;
>
>     };
>
>
>
>     struct vtkGraphIndexMap
>
>     {
>
>     property_traits<vtkGraphIndexMap>::reference operator[](const
> property_traits<vtkGraphIndexMap>::key_type& key)
>
>       {
>
>         return key;
>
>       }
>
>     };
>
>
>   inline property_traits<vtkGraphIndexMap>::reference
>
>   get(
>
>     vtkGraphIndexMap vtkNotUsed(arr),
>
>     property_traits<vtkGraphIndexMap>::key_type key)
>
>   {
>
>     return key;
>
>   }
>
> I deleted the lines that fill the index map also. Unfortunately I still
> get these errors:
>
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>    vtkEdgeType, std::__1::less<long long>,
>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>    vtkEdgeType, std::__1::less<long long>,
>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>    - /usr/local/boost_1_56_0/boost/*planar_dual.hpp*:38:38: No viable
>    overloaded operator[] for type 'edge_to_face_map_t' (aka
>    'iterator_property_map<typename vertex_vector_t::iterator,
>    boost::vtkGraphIndexMap>')
>
> It seems to me that there's no operator[] for the iterator_property_map.
> Am I missing something?
>
> Thanks again!
>
> Szilard
>
> 2014-10-08 21:13 GMT+02:00 Jeff Baumes <jeff.baumes at kitware.com>:
>
>> In your code, you are retrieving a vtkGraphIndexMap with:
>>
>> property_map<vtkUndirectedGraph*, edge_index_t>::type e_index =
>> get(edge_index, in);
>>
>> vtkGraphIndexMap is intended to be read-only and is already populated
>> with indices 0 through N-1, which are accessed with get(). It's actually an
>> identity map by index since indices are always in order, as you can see
>> here:
>>
>>
>> https://github.com/Kitware/VTK/blob/master/Infovis/BoostGraphAlgorithms/vtkBoostGraphAdapter.h#L1032-L1049
>>
>> So I would suggest leaving out your initialization loop on lines 43-45.
>>
>> Now, the remaining errors seem to require an operator[] on the
>> EdgeIndexMap, which is not currently implemented in vtkBoostGraphAdapter.h.
>> The needed code would be to replace the definition of vtkGraphPropertyMap
>> with something like this (not tested):
>>
>> struct vtkGraphIndexMap; // forward declaration
>>
>> template <>
>> struct property_traits<vtkGraphIndexMap>
>> {
>>   typedef vtkIdType value_type;
>>   typedef vtkIdType reference;
>>   typedef vtkIdType key_type;
>>   typedef readable_property_map_tag category;
>> };
>>
>> struct vtkGraphIndexMap
>> {
>>   property_traits<vtkGraphIndexMap>::reference operator[](const
>> property_traits<vtkGraphIndexMap>::key_type& b)
>>     {
>>     return key;
>>     }
>> };
>>
>>
>> HTH,
>> Jeff
>>
>> On Wed, Oct 8, 2014 at 2:12 PM, Szilárd Szalóki <szilardszaloki at gmail.com
>> > wrote:
>>
>>> Hi All,
>>>
>>> I'm trying to write an algorithm which creates the dual of a graph. To
>>> check whether the graph is planar or not I use the *Boyer-Myrvold
>>> planarity test* (Boost implementation) through the vtkBoostGraphAdapter.
>>> That works fine (only on vtkUndirectedGraph-s but that's OK for now).
>>> (http://www.boost.org/doc/libs/1_56_0/libs/graph/doc/boyer_myrvold.html)
>>>
>>> To create the dual I need to traverse the faces of the planar graph for
>>> which I also have a Boost tool called the planar_face_traversal_visitor.
>>> (
>>> http://www.boost.org/doc/libs/1_56_0/libs/graph/doc/planar_face_traversal.html
>>> )
>>> There's a guy, Aaron Windsor who implemented the appropriate visitor
>>> class that is able to create the dual of a graph in Boost.
>>> (https://github.com/aaw/boost_planar_graph_dual)
>>> That also works fine using only Boost but I'd like to adapt this feature
>>> as well using vtkBoostGraphAdapter.
>>>
>>> Here's my code: http://pastebin.com/g0Mtw6Ph
>>>
>>> These are my errors:
>>>
>>>    - *vtkDualGraph.cpp*:44:9: No matching function for call to 'put'
>>>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>>>    No viable overloaded operator[] for type 'const
>>>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>>>    vtkEdgeType, std::__1::less<long long>,
>>>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>>>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>>>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>>>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>>>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>>>    long, vtkEdgeType> > > &>'
>>>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>>>    No viable overloaded operator[] for type 'const
>>>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>>>    vtkEdgeType, std::__1::less<long long>,
>>>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>>>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>>>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>>>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>>>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>>>    long, vtkEdgeType> > > &>'
>>>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>>>    No viable overloaded operator[] for type 'const
>>>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>>>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>>>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>>>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>>>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>>>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>>>    No viable overloaded operator[] for type 'const
>>>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>>>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>>>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>>>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>>>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>>>    - /usr/local/boost_1_56_0/boost/*planar_dual.hpp*:38:38: No viable
>>>    overloaded operator[] for type 'edge_to_face_map_t' (aka
>>>    'iterator_property_map<typename vertex_vector_t::iterator,
>>>    boost::vtkGraphIndexMap>')
>>>
>>> It seems I cannot provide an appropriate EdgeIndexMap parameter to the
>>> put function in the 44th line. The vtkBoostGraphAdapter says that we
>>> can use VTK arrays as property maps, I tried that one as well, with no
>>> success. I've been dealing with this, reading the source code really deep
>>> and trying a couple of things in the past few days but I can't really
>>> figure out what the problem is. Is the vtkBoostGraphAdapter properly
>>> prepared for this kind of usage?
>>>
>>> Any kind of help appreciated!
>>>
>>> Thanks in advance!
>>>
>>> Szilard
>>>
>>> _______________________________________________
>>> 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://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20141015/1203dc3f/attachment-0002.html>


More information about the vtk-developers mailing list