我正在从标题中提到的示例代码中提取从生成的网格中提取方面数据:
vector<CGAL::Mesh_complex_3_in_triangulation_3<Tr>::Facet_iterator> Facets;
for (CGAL::Mesh_complex_3_in_triangulation_3<Tr>::Facet_iterator it = c3t3.facets_begin(); it!=c3t3.facets_end() ; it++)
{
Facets.push_back(it);
}现在试图显示一些顶点坐标如下:
CGAL::Mesh_complex_3_in_triangulation_3<Tr>::Facet_iterator fct = Facets[0];
cout << "Vertex 0 has coordinate: \n";
cout << fct->first->vertex(0)->point().x() << ", "
<< fct->first->vertex(0)->point().y() << ", "
<< fct->first->vertex(0)->point().z() << endl<<endl;
cout<< "Vertex 1 has coordinate: \n";
cout << fct->first->vertex(1)->point().x() << ", "
<< fct->first->vertex(1)->point().y() << ", "
<< fct->first->vertex(1)->point().z() << endl<<endl;
cout << "Vertex 2 has coordinate: \n";
cout << fct->first->vertex(2)->point().x() << ", "
<< fct->first->vertex(2)->point().y() << ", "
<< fct->first->vertex(2)->point().z() << endl<<endl;
cout << "Vertex 3 has coordinate: \n";
cout << fct->first->vertex(3)->point().x() << ", "
<< fct->first->vertex(3)->point().y() << ", "
<< fct->first->vertex(3)->point().z() << endl<<endl<<endl;(假设我正确理解数据结构) fct指向包含( c,i)的std::结对(c,i ),这意味着:单元c中由fct表示的面和被索引的顶点I都属于单元c,并且它们满足:fct与顶点I相反。因此,我的代码应该首先显示单元fct->的顶点坐标(它是一个四面体,因此有四个顶点)。
,这是我的问题
上述代码的输出如下:
顶点0有坐标: 0.282254,-0.638274,-0.716464
顶点1有坐标: 0.408885,-0.669831,-0.621398
顶点2的坐标为: 0.24175,-0.741988,-0.625771
顶点3有坐标:-6.27744e+66,-6.27744e+66,-6.27744e+66
顶点3的坐标显然不对,我搜索过这个问题,发现-6.27744e+66通常来自于访问未初始化向量的东西。但即使是这样,我该怎么做才能得到正确的值呢?或者,有人能告诉我哪里出了问题吗?
发布于 2020-05-25 06:32:15
顶点3很可能是无限顶点。在CGAL中,三角剖分使用一个额外的无限顶点表示,该顶点连接到凸包上的所有点。您可以使用函数is_infinite()来检查这一点。
正如Alex所指出的,您应该使用一个Cell_in_complex_iterator来访问网格域的所有有限单元格。
https://stackoverflow.com/questions/61974096
复制相似问题