我试图对一个病人的主动脉进行有限元分析,我有一个 3d 点云:
XYZ = array([[ 23.4929, 126.6431, 78.2083],
[ 23.505 , 123.2618, 76.1998],
[ 23.52 , 124.356 , 80.4145],
...,
[116.4752, 136.5604, 79.988 ],
[ 107.8206, 136.9329, 73.7108],
[ 154.0807, 91.6834, 91.9668]])
可视化:
为此,我需要获取以下数组:
elem = {由 4 个索引组成的四面体}
面 = {由 3 个索引组成的三角形}
但我的问题是:
如何使用 CGAL 绑定(对于 Python)获得点云的 3d 三角剖分,然后获得网格的四面体和三角形?
我已经尝试过,但生成的 3d 三角剖分的索引超出了 len(XYZ) 没有意义(结果最大索引 = 12000 与 len(XYZ) = 1949)。
如果有人已经使用 CGAL-bindings for python 可以帮助我如何将它用于这个 porpuse 或帮助我理解 CGAL Mesh Generation Examples 中的 C++ 代码,请
:(。http
://doc.cgal.org/最新/Mesh_3/index.html#Chapter_3D_Mesh_Generation
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_image_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/Image_3.h>
// Domain
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Labeled_image_mesh_domain_3<CGAL::Image_3,K> Mesh_domain;
// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
// To avoid verbose function and named parameters call
using namespace CGAL::parameters;
int main()
{
// Loads image
CGAL::Image_3 image;
image.read("data/liver.inr.gz");
// Domain
Mesh_domain domain(image);
// Mesh criteria
Mesh_criteria criteria(facet_angle=30, facet_size=6, facet_distance=4,
cell_radius_edge_ratio=3, cell_size=8);
// Meshing
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// Output
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file);
return 0;
}