首页 > 解决方案 > CGAL Mesh_3:如何使用 Polyhedral_complex_mesh_domain_3 粘附到域内的表面?

问题描述

目标

我的输入是:

我想要获得的是一个四面体网格:

  1. 填满整个域,
  2. 符合内表面和
  3. 它的边界顶点有一个对应于它们的输入补丁的 ID。

一种可能性是将输入补丁合并到一个网格中,并使用文档中的示例Remeshing a polyhedral domain withsurfaces;这很好用,但只满足要求 1 和 2。

另一种可能性是,在这里学习了如何保留补丁 ID后,修改示例以使用Polyhedral_complex_mesh_domain_3而不是使用子域Polyhedral_mesh_domain_with_features_3访问构造函数。到目前为止,我的解决方案(见下文)满足要求 2 和 3,但不满足要求1。

到目前为止的代码

作为一个简单的例子,我将文件Horizo​​ns-domain.off一分为二;第一个文件包含前 10 个,第二个文件包含剩余的 2 个三角形。

侧面关闭

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

关闭

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

子域.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

(horizo​​ns 是文档中的示例文件),四面体尝试符合内表面,保留 ID 但填充整个域:

到目前为止的结果

我也试过换行

incident_subdomains[0] = std::make_pair(0, 0);

incident_subdomains[0] = std::make_pair(1, 1);

这导致了稍微好一点的结果,但仍远未达到要求 3。

改善结果

我该如何解决?我std::pair在子域的 s 中尝试了 1 和 0 的各种组合,但没有成功。

标签: meshcgaltetrahedra

解决方案


推荐阅读