添加一个外部属性以包含图中顶点的索引(boost)
adding an external property to include index for vertix in graph (boost)
我试图使用associative_property_map包括索引的顶点,但我得到以下错误与以下简单的代码,问题是什么?
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace std;
using namespace boost;
struct NodeData
{
int label;
};
struct EdgeData
{
int age;
};
typedef map<vecS, size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> Graph;
typedef Graph::vertex_descriptor NodeID;
typedef Graph::edge_descriptor EdgeID;
int main()
{
Graph g;
NodeID n0 = add_vertex(g); g[n0].label = -1;
NodeID n1 = add_vertex(g); g[n1].label = -1;
EdgeID edge; bool ok;
tie(edge, ok) = boost::add_edge(n0, n1, g);
if (ok) g[edge].age = 10;
int i=0;
BGL_FORALL_VERTICES(v, g, Graph)
{
put(propmapIndex, v, i++);
}
return 0;
}
错误:
c:program filescodeblocksmingwbin..libgccmingw324.4.1........includeboostproperty_mapproperty_map.hpp||In
function 'void boost::put(const boost::put_get_helper&, K, const V&)[with PropertyMap = boost::associative_property_map, std::allocator>
, Reference = unsigned int&, K = void*, V = int]':| C:UsersmemoDesktopDebugedboostGraphmain.cpp|39|instantiated from这里| c: 程序文件 codeblocks mingw bin . . lib gcc…… mingw32 4.4.1包括促进 property_map property_map.hpp | 361 |错误:在'(const boost::associative_property_map,)中'operator[]'不匹配,Std::allocator>>&)((const boost::associative_property_map,Std::allocator>>*)(&pa)) [k]"| c: 程序文件 codeblocks mingw bin . . lib gcc…… mingw32 4.4.1包括促进 property_map property_map.hpp | 498 |注意:候选者有:typenameUniquePairAssociativeContainer:: value_type:: second_type&boost:: associative_property_map::操作符[](const typenameUniquePairAssociativeContainer::key_type&) const [withuniquepairassociativcontainer = std::map, std::allocator>>]| ||===构建完成:1个错误,0个警告===|
谢谢
顶点描述符必须指定为IndexMap,所以它是map<NodeID, size_t>
而不是map<vecS, size_t>
:
<...>
typedef Graph::vertex_descriptor NodeID;
typedef map<NodeID, size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
<...>
// indexing all vertices
int i=0;
BGL_FORALL_VERTICES(v, g, Graph)
{
put(propmapIndex, v, i++);
}
- D3D11-将混合权重和索引传递到顶点着色器
- Direct3D 11 - HLSL - 获取顶点索引 ID
- 使用 glvertex4i 传递网格面索引时的顶点着色器错误
- 使用此网格函数的立方体的正确顶点和索引是什么
- DirectX11只绘制填充索引和顶点缓冲区中的一半顶点
- tiny_obj_loader到 Direct3D 顶点缓冲区和索引缓冲区数组
- 我可以将单个顶点索引与具有所有属性(位置、法线、texCoord)的顶点缓冲区一起使用吗?
- DirectX:如果绑定索引缓冲区但不绑定顶点缓冲区,会发生什么情况
- Directx 11 - 是将顶点缓冲区中的所有顶点推送到顶点着色器,还是仅编制索引
- 可以在同一 VBO 中存储不同的顶点属性和索引
- 通过查找重复顶点从 vec3 对象的向量计算索引
- 如何从顶点/索引缓冲区创建 CGAL Nef_polyhedron_3
- Directx11如何管理多个顶点/索引缓冲区
- 顶点/索引缓冲区混淆,带有OpenGL 3.3
- CGAL - 在德劳奈三角测量后检索顶点索引
- 如何从Subdiv2D Delaunay三角测量中获取顶点索引
- Boost:: Dijkstra 最短路径,如何从路径迭代器获取顶点索引
- 如何读取顶点/索引缓冲区
- (DirectX 11)动态顶点/索引缓冲区实现恒定的场景内容变化
- 将地图转换为顶点索引不起作用