问题描述
目标
我的输入是:
- 形成域边界的几个补丁
- 域内的一个或多个表面。
我想获得的是一个四面体网格:
- 填充整个域,
- 符合内表面和
- 其边界顶点具有与其输入补丁相对应的 ID。
一种可能性是将输入补丁合并为一个网格并使用文档中的示例 Remeshing a polyhedral domain with surfaces;这很有效,但仅满足要求 1 和 2。
另一种可能性是,在这里学习了如何keep the patch IDs,修改示例以使用polyhedral_complex_mesh_domain_3
而不是polyhedral_mesh_domain_with_features_3
,以便访问constructor with subdomains。到目前为止,我的解决方案(见下文)满足了需求 2 和 3,但不是 1。
到目前为止的代码
作为一个简单的例子,我将文件 horizons-domain.off 一分为二;第一个文件包含前 10 个,第二个包含剩余的 2 个三角形。
sides.off
OFF
8 10 0
-1.1855500570497703 -0.076163891881438378 -0.8013403915768772
-1.1855500570497703 0.47597074519009164 -0.8013403915768772
0.79704321809070222 0.47597074519009164 -0.8013403915768772
0.79704321809070222 -0.076163891881438378 -0.8013403915768772
-1.1855500570497703 -0.076163891881438378 1.0953134363531141
-1.1855500570497703 0.47597074519009164 1.0953134363531141
0.79704321809070222 0.47597074519009164 1.0953134363531141
0.79704321809070222 -0.076163891881438378 1.0953134363531141
3 0 1 3
3 3 1 2
3 0 4 1
3 1 4 5
3 3 2 7
3 7 2 6
3 4 0 3
3 7 4 3
3 6 4 7
3 6 5 4
top.off
OFF
4 2 0
-1.1855500570497703 0.47597074519009164 -0.8013403915768772
0.79704321809070222 0.47597074519009164 -0.8013403915768772
-1.1855500570497703 0.47597074519009164 1.0953134363531141
0.79704321809070222 0.47597074519009164 1.0953134363531141
3 0 2 3
3 1 0 3
subdomains.cpp
#include <Cgal/Exact_predicates_inexact_constructions_kernel.h>
#include <Cgal/polyhedron_incremental_builder_3.h>
#include <Cgal/polyhedral_complex_mesh_domain_3.h>
#include <Cgal/Mesh_triangulation_3.h>
#include <Cgal/Mesh_complex_3_in_triangulation_3.h>
#include <Cgal/Mesh_criteria_3.h>
#include <Cgal/make_mesh_3.h>
typedef Cgal::Exact_predicates_inexact_constructions_kernel K;
typedef Cgal::polyhedral_complex_mesh_domain_3<K> Mesh_domain;
typedef Cgal::Mesh_polyhedron_3<K>::type polyhedron;
typedef Cgal::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef Cgal::Mesh_criteria_3<Tr> Mesh_criteria;
typedef Cgal::Mesh_complex_3_in_triangulation_3<
Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_segment_index> C3t3;
using namespace Cgal::parameters;
int main(int argc,char*argv[])
{
// Read patches
std::cout.precision(17);
std::cerr.precision(17);
std::ifstream input1(argv[1]);
std::ifstream input2(argv[2]);
std::ifstream input3(argv[3]);
std::vector<polyhedron> patches(3);
input1 >> patches[0];
input2 >> patches[1];
input3 >> patches[2];
// The first mesh is inside subdomain 0,the other two are on the boundary between subdomains 0 and 1.
std::vector<std::pair<int,int>> incident_subdomains(3);
incident_subdomains[0] = std::make_pair(0,0);
incident_subdomains[1] = std::make_pair(0,1);
incident_subdomains[2] = std::make_pair(0,1);
Mesh_domain domain(patches.begin(),patches.end(),incident_subdomains.begin(),incident_subdomains.end());
// Mesh generation
Mesh_criteria criteria(facet_distance=0.01,cell_radius_edge_ratio = 2);
C3t3 c3t3 = Cgal::make_mesh_3<C3t3>(domain,criteria,no_perturb(),no_exude());
// Output
dump_c3t3(c3t3,"out");
}
当我编译和运行时
> ./subdomains horizons.off sides.off top.off
(horizons 是文档中的示例文件),四面体尝试符合内表面,保留 ID 但不要不填充整个域:
我也试过换线
incident_subdomains[0] = std::make_pair(0,0);
到
incident_subdomains[0] = std::make_pair(1,1);
这会导致稍微好一点的结果,但仍远未达到要求 3。
我该如何解决?我在子域的 std::pair
中尝试了 1 和 0 的各种组合,但没有成功。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)