我有一组2D点,每个点都有一个相关的id.(例如,如果点存储在数组中,则id是每个点0,....,n-1的索引).
现在我创建了这些点的Delaunay三角剖分,并希望列出所有有限边.对于每个边,我想要由相应的2个顶点表示的点的id.示例:如果在点0和点2之间存在边缘,则为(0,2).这可能吗?
#include <vector>
#include <CGAL\Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL\Delaunay_triangulation_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay;
typedef K::Point_2 Point;
void load_points(std::vector<Point>& rPoints)
{
rPoints.push_back(Point(10,10)); // first point
rPoints.push_back(Point(60,10)); // second point
rPoints.push_back(Point(30,40)); // third point
rPoints.push_back(Point(40,80)); // fourth point
}
void main()
{
std::vector<Point> points;
load_points(points);
Delaunay dt;
dt.insert(points.begin(),points.end());
for(Delaunay::Finite_edges_iterator it = dt.finite_edges_begin(); it != dt.finite_edges_end(); ++it)
{
}
}
Run Code Online (Sandbox Code Playgroud)
slo*_*iot 10
首先,您需要在这些示例中使用带有信息的顶点类型.然后,边是一对包含面部的手柄以及面部中与边缘相对的顶点的索引.
如果你有:
Delaunay::Edge e=*it;
Run Code Online (Sandbox Code Playgroud)
您正在寻找的指数是:
int i1= e.first->vertex( (e.second+1)%3 )->info();
int i2= e.first->vertex( (e.second+2)%3 )->info();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3913 次 |
| 最近记录: |