[英]CGAL - wrong vertices index retrieved after Delaunay Triangulation in 3d
我在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++;
}
有任何想法嗎?
更新:
奇怪的是,例如:
在testFile1中:tet索引:702 25 35 153
在我自己的迭代中,它-> vertex(i)-> point()。x()得到702 \\ 25 \\ 35 \\ 153的x坐標,但是它-> vertex(i)-> info()得到1601 \\ 1352。 ....
沿希爾伯特曲線對頂點進行排序,以加快三角剖分的構造。 如果要使迭代順序與info()字段匹配,只需對頂點進行一次迭代並設置info()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.