使用CGAL生成多域3D网格时的曲面平滑问题排查
使用CGAL从多域分割图像生成3D网格时曲面不平滑问题
我正在使用CGAL从包含不同域的分割图像生成3D网格:
- 当图像仅定义一个域时,能得到平滑度尚可的网格:

- 但添加多个域后,网格曲面不再平滑:

我尝试使用odt_optimize_mesh_3、lloyd_optimize_mesh_3和perturb_mesh_3提升网格质量,但多域场景下效果仍不佳。我无法理解网格质量大幅下降的原因,参考CGAL文档示例后认为自身操作存在问题,以下是我的最小可复现代码:
#include <vtkSmartPointer.h> #include <vtkXMLImageDataReader.h> #include <vtkImageData.h> #include <CGAL/Image_3.h> #include <CGAL/Labeled_mesh_domain_3.h> #include <CGAL/read_vtk_image_data.h> #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/IO/output_to_vtu.h> #include <CGAL/Mesh_criteria_3.h> #include <CGAL/make_mesh_3.h> #ifdef CGAL_CONCURRENT_MESH_3 typedef CGAL::Parallel_tag Concurrency_tag; #else typedef CGAL::Sequential_tag Concurrency_tag; #endif typedef CGAL::Image_3 Image; typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Labeled_mesh_domain_3<K> Mesh_domain; typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,Concurrency_tag>::type Tr; typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3; namespace params = CGAL::parameters; int main(int argc, char* argv[]) { // Read image from file vtkSmartPointer<vtkXMLImageDataReader> reader = vtkSmartPointer<vtkXMLImageDataReader>::New(); reader->SetFileName(argv[1]); reader->Update(); vtkImageData* imageData = reader->GetOutput(); int dims[3]; imageData->GetDimensions(dims); double spacing[3]; imageData->GetSpacing(spacing); double origin[3]; imageData->GetOrigin(origin); CGAL::Image_3 image = CGAL::read_vtk_image_data(imageData) ; // Define the mesh domain Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image); // Define meshing criteria Mesh_criteria criteria(params::facet_angle = 30, params::facet_size = 10, params::facet_distance =5, params::cell_radius_edge_ratio = 10, params::cell_size = 10); // Generate mesh C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria); // Write mesh to vtu std::ofstream vtu_file("output_mesh.vtu"); vtu_file.precision(17); CGAL::output_to_vtu(vtu_file, c3t3, CGAL::IO::BINARY); return 0; }
请问有人能指出我可能存在的错误吗?感谢您的帮助!
内容的提问来源于stack exchange,提问作者Alice
相关产品推荐
相关产品推荐

