简体   繁体   English

CGAL-在3D中进行Delaunay三角剖分后检索到错误的顶点索引

[英]CGAL - wrong vertices index retrieved after Delaunay Triangulation in 3d

I'm using latest CGAL(4.5) with VS2012. 我在VS2012中使用最新的CGAL(4.5)。 After Delaunay triangulation, I output the whole tetrahedron mesh to "testFile1" with CGAL Delaunay triangulation's default stream output. 在Delaunay三角剖分之后,我将整个四面体网格输出到带有CGAL Delaunay三角剖分的默认流输出的“ testFile1”。 The data in "testFile1" is right.(I visualised the mesh and it is OK) “ testFile1”中的数据正确。(我看到了网格,可以)

Then I iterate through all the tetrahedrons and get the vertices' index and output them to "testFile2", but the indices is totally different with the indices in "testFile1". 然后,我遍历所有四面体并获得顶点的索引,然后将它们输出到“ testFile2”,但是索引与“ testFile1”中的索引完全不同。 I visualised the mesh and it is totally a mess. 我可视化了网格,这完全是一团糟。

I also output the vertex position of each tetrahedron in my own iterations, they are the same with testFile1(the coord of the 1st vertex of the 1st tetrahedron is the same, and so on). 我还在自己的迭代中输出了每个四面体的顶点位置,它们与testFile1相同(第一个四面体的第一个顶点的坐标相同,依此类推)。 So the tetrahedron in testFile1 and testFile2 is the same, the problem is in getting the vertex indices. 因此,testFile1和testFile2中的四面体相同,问题在于获取顶点索引。

my code: 我的代码:

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++;
}

Any ideas? 有任何想法吗?

UPDATE: 更新:

The weird thing is, for example: 奇怪的是,例如:

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

And In my own iteration, it->vertex(i)->point().x() get 702\\25\\35\\153's x coord but it->vertex(i)->info() get 1601\\1352..... 在我自己的迭代中,它-> vertex(i)-> point()。x()得到702 \\ 25 \\ 35 \\ 153的x坐标,但是它-> vertex(i)-> info()得到1601 \\ 1352。 ....

The vertices are sorted along an hilbert curve to speed up the construction of the triangulation. 沿希尔伯特曲线对顶点进行排序,以加快三角剖分的构造。 If you want to have the order of iteration matching the info() field, simply iterate over the vertices once and set the info() 如果要使迭代顺序与info()字段匹配,只需对顶点进行一次迭代并设置info()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM