【问题标题】:CGAL - wrong vertices index retrieved after Delaunay Triangulation in 3dCGAL - 在 3d 中的 Delaunay 三角剖分后检索到错误的顶点索引
【发布时间】:2014-12-23 22:10:54
【问题描述】:

我正在使用最新的 CGAL(4.5) 和 VS2012。在 Delaunay 三角剖分之后,我使用 CGAL Delaunay 三角剖分的默认流输出将整个四面体网格输出到“testFile1”。 “testFile1”中的数据是对的。(我把网格可视化了,没问题)

然后我遍历所有四面体并获取顶点的索引并将它们输出到“testFile2”,但索引与“testFile1”中的索引完全不同。我可视化了网格,它完全是一团糟。

我在自己的迭代中也输出了每个四面体的顶点位置,它们与testFile1相同(第一个四面体的第一个顶点的坐标相同,依此类推)。所以testFile1和testFile2中的四面体是一样的,问题在于获取顶点索引。

我的代码:

std::vector<std::pair<Point,int>> V;
V.reserve(pointCount);
//push selected point into V with index info
for(int i=0;i<pointCount;i++)
{
    int id = randomNumbers[i];
    V.push_back(std::make_pair(Point(
        points[id]._p[0], 
        points[id]._p[1], 
        points[id]._p[2]), i));
}

Delaunay T;
T.insert(V.begin(), V.end());

//output vertices position and vertices index and cell neighbor index to testFile1
//data in testFile1 is right
std::ofstream oFileT("testFile1",std::ios::out);
oFileT << T;        



//output indices to testFile2 by my own iteration
std::ofstream oFileT("testFile2",std::ios::out);
int index = 0;
Delaunay::Finite_cells_iterator it;
for(it = T.finite_cells_begin(); it!=T.finite_cells_end(); ++it)
{
    for(int i=0;i<4;i++)
    {
        //here the coord is right 
        float testCoord = T.tetrahedron(it).vertex(i).x();

        //but the index here is totally different with testFile1
        int info = 0;
        if(!T.is_infinite(it->vertex(i)))
            info = it->vertex(i)->info();

        oFileT<<info<<" ";  //output vertices index to testFile2
    }
    oFileT<<std::endl;
    index++;
}

有什么想法吗?

更新:

奇怪的是,例如:

在 testFile1 中:tet 索引:702 25 35 153

在我自己的迭代中,it->vertex(i)->point().x() 得到 702\25\35\153 的 x 坐标,但 it->vertex(i)->info() 得到 1601 \1352.....

【问题讨论】:

  • 你在比较什么?在顶点的信息字段中分配给用于保存三角剖分的索引的索引?文件中的索引按照顶点的迭代顺序。
  • @sloriot ,所以你的意思是索引是正确的,我应该开始另一个迭代来输出顶点的索引?但是如何解释迭代中的坐标是对的呢? it->vertex(i)->point().x() 是第 702 个点的坐标,但 it->vertex(i)->info() 不是 702
  • 顶点沿希尔伯特曲线排序以加快三角剖分的构建。如果您想让迭代顺序与 info() 字段匹配,只需遍历顶点一次并设置 info()。
  • @sloriot,你是对的,谢谢,你能把答案写出来让我接受吗?

标签: c++ cgal delaunay


【解决方案1】:

顶点沿希尔伯特曲线排序以加快三角剖分的构建。如果您想让迭代顺序与 info() 字段匹配,只需遍历顶点一次并设置 info()

【讨论】:

    猜你喜欢
    • 2013-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 2020-05-06
    • 2020-08-05
    • 2018-12-23
    • 2012-03-29
    相关资源
    最近更新 更多