我使用示例代码计算6个顶点的四面体。返回的面不仅包含输入顶点,还包含无限顶点。这在MeshLab中产生了可视化问题。我想知道如何解决这个问题?
示例代码如下
int main(int argc, char **argv)
{
std::list<Point> L;
L.push_front(Point(0,0,0));
L.push_front(Point(1,0,0));
L.push_front(Point(0,1,0));
Triangulation T(L.begin(), L.end());
int n = T.number_of_vertices();
std::vector<Point> V(3);
V[0] = Point(0,0,1);
V[1] = Point(1,1,1);
V[2] = Point(2,2,2);
n = n + T.insert(V.begin(), V.end());
assert( n == 6 );
assert( T.is_valid() );
Locate_type lt;
int li, lj;
Point p(0,0,0);
Cell_handle c = T.locate(p, lt, li, lj);
assert( lt == Triangulation::VERTEX );
assert( c->vertex(li)->point() == p );
Vertex_handle v = c->vertex( (li+1)&3 );
Cell_handle nc = c->neighbor(li);
int nli;
assert( nc->has_vertex( v, nli ) );
std::ofstream oFileT("output",std::ios::out);
oFileT << T;
Triangulation T1;
std::ifstream iFileT("output",std::ios::in);
iFileT >> T1;
assert( T1.is_valid() );
assert( T1.number_of_vertices() == T.number_of_vertices() );
assert( T1.number_of_cells() == T.number_of_cells() );
std::cout << T.number_of_vertices() << " " << T.number_of_cells() << std::endl;
return 0;
}
输出文件是
3
6
0 1 0
1 0 0
0 0 0
0 0 1
1 1 1
2 2 2
11
1 0 3 4
2 1 3 4
0 2 3 4
1 5 6 4
2 3 1 0
1 2 5 4
5 2 6 4
6 2 0 4
1 6 0 4
1 2 0 6
1 2 6 5
2 1 8 4
0 2 5 4
1 0 7 4
6 8 5 10
0 9 2 1
6 3 1 10
7 3 5 10
2 8 6 9
7 0 3 9
7 8 10 4
6 3 5 9
答案 0 :(得分:0)
在Triangulation_3类手册中 http://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__3.html 寻找I / O部分并阅读iostream的描述。
在您的示例中,有11个单元格
1 0 3 4
2 1 3 4
0 2 3 4
1 5 6 4
2 3 1 0
1 2 5 4
5 2 6 4
6 2 0 4
1 6 0 4
1 2 0 6
1 2 6 5
无限顶点的索引为0. 6个有限顶点编号为1到6.它们的坐标位于文件的顶部(从6开始)
因此,您可以过滤掉具有0作为顶点的单元格,从而为您提供5个四面体
2 1 3 4
1 5 6 4
1 2 5 4
5 2 6 4
1 2 6 5