我使用示例代码来计算 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