从edge_iterator获取vertex_handle

发布于 2024-10-14 21:30:02 字数 989 浏览 3 评论 0原文

我在获取 Delaunay 三角剖分中边的每个端点的 vertex_handle 时遇到了相当大的困难。由于我为此苦苦挣扎了几个小时,我想也许你们中的一个人可以帮助我解决这个看似微不足道的问题:

#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>

using namespace std;

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex;

int main(){
  Point p;
  Triangulation t;
  while(cin >> p)
    t.insert(p);

  // Iterate over edges
  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Vertex vs = ei->source();
  }
}

根据取消引用 Edge_iterator 的文档,我应该得到一个 Edge_handle ,而 Edge_handle 应该有成员 source() 和 target( )来简单地获取端点,但它不会编译并且似乎是错误的。像上面那样取消引用会给我一对<>它没有这些成员函数。

知道我做错了什么吗?

I'm having quite some difficulty getting a vertex_handle for each of the end points of an edge in a Delaunay triangulation. Since I hammered my head against this for several hours I thought maybe one of you guys could help me out with this apparently trivial problem:

#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>

using namespace std;

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex;

int main(){
  Point p;
  Triangulation t;
  while(cin >> p)
    t.insert(p);

  // Iterate over edges
  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Vertex vs = ei->source();
  }
}

According to the documentation dereferencing an Edge_iterator I should get an Edge_handle and Edge_handle should have members source() and target() to simply get the endpoints, but it won't compile and seems to be wrong. Derefencing like above will give me a pair<> which doesn't have those member functions.

Any idea what I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…红帽 2024-10-21 21:30:02

取消引用 Edge_iterator 将根据 文档

Edge 定义如下: typedef std::pair; Edge;

取消引用 Face_handle 将为您提供一个

边连接的两个顶点可以通过以下方式访问:

  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Triangulation::Face& f = *(ei->first);
    int i = ei->second;
    Vertex vs = f.vertex(f.cw(i));
    Vertex vt = f.vertex(f.ccw(i));
  }

我不知道这对您的任务是否有帮助,但可以访问这样的点:

for (Edge_iterator it = m_tri.edges_begin(); it != m_tri.edges_end(); ++it)
{
    Triangulation::Segment seg = m_tri.segment( *it );

    Triangulation::Point p0 = seg.point(0);
    Triangulation::Point p1 = seg.point(1);
    // ...
}

CGAL 文档让我感到困惑...我很好奇您在哪里找到了eh->source()eh->target() 调用,我找不到它:-)

Dereferencing an Edge_iterator will give you an Edge according to the documentation.

Edge is definded as follows: typedef std::pair<Face_handle,int> Edge;

Dereferencing the Face_handle will give you a Face.

The two vertices that the edge joins can be accessed by:

  for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
    // Get a vertex from the edge
    Triangulation::Face& f = *(ei->first);
    int i = ei->second;
    Vertex vs = f.vertex(f.cw(i));
    Vertex vt = f.vertex(f.ccw(i));
  }

I don't know if it is helpful for you quest, but is access the points like this:

for (Edge_iterator it = m_tri.edges_begin(); it != m_tri.edges_end(); ++it)
{
    Triangulation::Segment seg = m_tri.segment( *it );

    Triangulation::Point p0 = seg.point(0);
    Triangulation::Point p1 = seg.point(1);
    // ...
}

The CGAL documentation is confusing to me... I am curious where you found the eh->source() and eh->target() calls, I could not find it :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文