找到一个点所属的面/三角形
CGAL: Find face/triangle a point belongs to?
看了之后,我得出了这个结论:
#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 >& points)
{
points.push_back(Point(1., 1.));
points.push_back(Point(2., 1.));
points.push_back(Point(2., 2.));
points.push_back(Point(1., 2.));
}
int main()
{
std::vector< Point > points;
load_points(points);
Delaunay dt;
dt.insert(points.begin(), points.end());
std::cout << dt.number_of_vertices() << std::endl;
typedef std::vector<Delaunay::Face_handle> Faces;
Faces faces;
std::back_insert_iterator<Faces> result( faces );
result = dt.get_conflicts ( Delaunay::Point(1.5, 1.5),
std::back_inserter(faces) );
return 0;
}
应该找到其圆包含该点的面。之后,我必须使用这些三角形并使用一种方法来测试点是否在它们内部(我认为CGAL会这样做吗?我知道这很容易实现)。
不管怎样,我怎样才能把三角形从脸上去掉呢?
回答是CGAL::Triangle_2<K> f = dt.triangle(faces[0]);
std::cout << dt.triangle(faces[0]) << std::endl;
std::cout << dt.triangle(faces[1]) << std::endl;
等我不知道如何很好地使用三角形类,但至少这是一个开始。
我本来要写一个实际的答案但是stackoverflow不允许我这么做
您应该使用在这里可以找到文档的locate成员函数
相关文章:
- 为我的 c++ 类介绍制作一个三角形分类器.我有几个问题
- 以C++输出一个数字三角形
- 形成一个斐波那契三角形,使得每个数字是上面左对角线或右对角线上两个数字的总和
- 给定一个用三角形镶嵌的补丁,如何修改其新的顶点位置
- 使用 C++ 库 GLEW 在 openGl 中绘制一个红色三角形
- 创建一个绿色三角形C Directx
- 创建一个程序以输出三角形平方数的4个
- 在OpenGL中打印一个红色三角形
- 如何打印一个不相等的三角形
- 我如何对此代码进行添加以使用我的 arduino 打印一个完整的三角形
- Direct3D:尝试绘制一个三角形,但什么也没显示
- 用一个glDrawArrays命令绘制几个不同颜色的三角形
- 三角形之间的相似性;双变量是一个痛苦
- Opengl 创建一个 3D 框而不是一个简单的三角形
- 建立一个形状类三角形
- 编程难题 - 绘制一个倒三角形
- 如何在 Qwidget 的中心设计一个三角形(在 QT 中使用 OpenGl)
- openGL drawElements - 一个额外的三角形,使用索引数组
- 在 OpenGL 中创建一个围绕其 y 轴连续旋转的三角形
- 输出一个三角形