加权Voronoi的CGAL 2D APOLLONIUS图-如何生成和获取面和顶点
CGAL 2D APOLLONIUS diagram for Weighted Voronoi - How to generate and get the faces and vertices?
我正在尝试基于apollonius图生成加权voronoi。我正在使用CGAL库。我找不到如何从apollonius中获取面和顶点的好例子。我有以下类型的defs:
typedef double NT;
typedef CGAL::Cartesian< NT> KernelCartes;
typedef CGAL::Ray_2<KernelCartes> Cartes_Ray;
typedef CGAL::Line_2<KernelCartes> Cartes_Line;
typedef CGAL::Segment_2<KernelCartes> Cartes_Segment;
typedef std::list<Cartes_Ray> Cartes_RayList;
typedef std::list<Cartes_Line> Cartes_LineList;
typedef std::list<Cartes_Segment> Cartes_SegmentList;
typedef CGAL::Point_2<KernelCartes> Cartes_Point;
typedef CGAL::Apollonius_graph_traits_2<KernelCartes> ApoTraits;
typedef CGAL::Apollonius_graph_2<ApoTraits> Apo_Graph;
typedef Apo_Graph::Site_2 Apo_Site;
在下面的文章中,我将尝试创建Apolonius图。WVD是加权voronoi图(Apo_Graph)。
WVD.clear();
double Weight;
foreach(QPointF point,List_Nodes)
{
Weight = NewRandomNumber(1,10);
Apo_Site k(Cartes_Point(point.x(),point.y()),Weight);
WVD.insert(k);
}
现在,我需要知道如何访问加权voronoi和生成的面(以及每个面的顶点)。
最后我这样做了:
typedef CGAL::Apollonius_graph_traits_2<Kernel_Exact> APT;
typedef CGAL::Apollonius_site_2<Kernel_Exact> Site_2_Apo;
typedef Site_2_Apo::Point_2 Site_2_Point_2;
typedef Site_2_Apo::Weight Site_2_Weight;
typedef CGAL::Apollonius_graph_traits_2<Kernel_Exact> AGT2_K;
typedef CGAL::Apollonius_graph_2<AGT2_K> AG2;
typedef CGAL::Apollonius_graph_adaptation_traits_2<AG2> AG2_Trait;
typedef CGAL::Apollonius_graph_caching_degeneracy_removal_policy_2<AG2> AG2_Policy;
typedef CGAL::Voronoi_diagram_2<AG2,AG2_Trait,AG2_Policy> VD_AG2;
加载一些点:
std::vector<Site_2_Apo> List_Nodes;
for (int i = 0; i<= 100; i = i++)
{
for(int j = 0; j <= 100; j = j++)
{
List_Nodes.push_back(Site_2_Apo(Site_2_Point_2(i+NewRandomNumber(0,30),j+NewRandomNumber(0,30)),Site_2_Weight(NewRandomNumber(1,50))));
}
}
其余:
VD_AG2 VDA; //Voronoi Apol
///Voronoi Generation
VDA.clear();
VDA.insert(List_Nodes.begin(),List_Nodes.end());
以及访问面和顶点:
for(A_Bounded_faces_iterator f = VDA.bounded_faces_begin(); f != VDA.bounded_faces_end(); f++)
{
A_Ccb_halfedge_circulator ec_start = (f)->ccb();
A_Ccb_halfedge_circulator ec = ec_start;
poly.clear();
do {
x = ((A_Halfedge_handle)ec)->source()->point().x();
y = ((A_Halfedge_handle)ec)->source()->point().y();
poly.push_back(QPointF(x,y));
} while ( ++ec != ec_start );
List_Poly.push_back(poly);
}
这就是结果:
https://i.stack.imgur.com/Esv8c.png
模板类CGAL::Apollonius_graph_2
与CGAL 2D Delaunay三角剖分共享其大部分API。API在DelaunayGraph_2概念中得到了总结。CCD_ 2就是这个概念的一个模型。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 从 CGAL 3D 网格生成中获取顶点坐标的 -6.27744e+66:mesh_implicit_sphere示例
- CMake 在为 UWP 生成时无法获取 VCTargetsPath 的值
- 获取生成错误:错误 C2011:'ProfileSettings':'class'类型重定义
- 获取生成文件以更改输出可执行文件名称
- 获取对源文件中特定函数的所有调用并生成其他文件(使用 C、C++预处理器或脚本)
- 如何使用结构C++获取从函数中生成的最大值
- 获取 llvm::MCJIT 代码生成后的函数大小
- 如何制作 n*n 矩阵的输出文件,通过从用户那里获取 n,并成对生成的数字
- (中广)获取AABB树生成的边界立方体进行碰撞检测
- 如何在将未命名的命名空间与 MSVC 配合使用时获取可重现的生成
- 如何获取有关protobuf解析过程中生成的错误的更多详细信息?(C++)
- 在C++中生成一组整数的排列.获取分段错误
- 生成文件问题,获取"目标'rgbapixel.o'的配方失败"
- 从 boost::variant 生成分段错误中获取 int
- 加权Voronoi的CGAL 2D APOLLONIUS图-如何生成和获取面和顶点
- 正在获取生成的无需第二个查询的自动增量ID(MySQL)
- 获取或生成"C++"中的系统信息
- 在调试生成C++中获取调用堆栈失败
- 使用 rand() 获取一个数字,但该数字不能是上次生成的数字