c++ - CGAL::Polyhedron_3 使用 make_tetrahedron() 生成不需要的重复顶点,如何解决?
问题描述
我试图使用CGAL::Polyhedron_3
数据结构创建体积网格,但在进行一些测试时,我注意到该make_tetrahedron
函数复制了多面体中已经存在的顶点。
示例:共享一个共同面的两个四面体
这是我试过的代码:
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <iostream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
int main(void) {
// common points
Point_3 p( 1.0, 0.0, 0.0 );
Point_3 q( 0.0, 1.0, 0.0 );
Point_3 s( 0.0, 0.0, 0.0 );
// the other two
Point_3 r( 0.0, 0.0, 1.0 );
Point_3 d( 0.0, 0.0,-1.0 );
Polyhedron P;
P.make_tetrahedron( p, q, r, s );
P.make_tetrahedron( p, q, s, d );
CGAL::IO::set_ascii_mode( std::cout );
// printing out the vertices
for ( Vertex_iterator v = P.vertices_begin(); v != P.vertices_end(); ++v )
std::cout << v->point() << std::endl;
return 0;
}
这是我希望看到的输出:
1 0 0
0 1 0
0 0 1
0 0 0
0 0 -1
但这就是我得到的:
1 0 0
0 1 0
0 0 1
0 0 0
1 0 0
0 1 0
0 0 0
0 0 -1
现在,问题是:是否可以在使用该函数
时仅将一个点存储为顶点一次?CGAL::Polyhedron_3
make_tetrahedron
解决方案
您不能将非流形特征存储在多面体中,您需要类似线性单元复合体的东西。看这里
推荐阅读
- progressive-web-apps - 如何知道渐进式 Web 应用程序是在前台还是后台
- php - 为什么这个 if 查询语句返回 false?
- c# - 为什么我的 c# 函数只能以这种方式工作?
- chatbot - dialogflow facebook messenger 卡传递标题
- c - 无论用户输入如何,都将输入转换为 int
- android - RxJava 以序列化方式执行多个请求
- php - 在 fetchArray 调用之间修改数据是否安全?
- git - Git合并分支而不进入
- vba - VBA - 如何在同一字段上自动筛选两个以上的条件?
- sql - 如何从一个非常大的表中获取每一列的每个值的计数?