C++ CGAL-三维Delaunay三角剖分后检索到的错误顶点索引

C++ CGAL-三维Delaunay三角剖分后检索到的错误顶点索引,c++,cgal,delaunay,C++,Cgal,Delaunay,我正在VS2012中使用最新的CGAL(4.5)。在Delaunay三角剖分之后,我使用CGAL Delaunay三角剖分的默认流输出将整个四面体网格输出到“testFile1”。“testFile1”中的数据是正确的。(我可视化了网格,它是正确的) 然后我迭代所有四面体,得到顶点的索引并将它们输出到“testFile2”,但是索引与“testFile1”中的索引完全不同。我把网格想象成一团乱 我还在自己的迭代中输出每个四面体的顶点位置,它们与testFile1相同(第一个四面体的第一个顶点的坐

我正在VS2012中使用最新的CGAL(4.5)。在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++;
}
std::vector V;
V.储备(点数);
//使用索引信息将所选点推入V
对于(int i=0;iinfo();

oFileT顶点沿hilbert曲线排序,以加快三角剖分的构建。如果希望迭代顺序与info()字段匹配,只需在顶点上迭代一次并设置info()

您在比较什么?顶点信息字段中指定的索引与用于保存三角剖分的索引?文件中的索引是按顶点的迭代顺序排列的。@Slorio,那么您的意思是索引是正确的,我应该开始另一次迭代以输出顶点的索引?但是如何解释中的坐标迭代是对的?它->顶点(i)->点().x()是第702点的坐标,但它->顶点(i)->信息()不是第702点。顶点沿希尔伯特曲线排序,以加快三角剖分的构造。如果希望迭代顺序与信息()字段匹配,只需在顶点上迭代一次并设置信息()@Slorio,你说得对,谢谢。你能写下答案让我接受吗?