cgal绑定(Python): Mesh_3示例



是否有一个cgal-python绑定实现Mesh_3的例子,特别是http://doc.cgal.org/latest/Mesh_3/Mesh_3_2mesh_3D_image_8cpp-example.html?我一直试图开始它,但似乎不是所有的类都通过swig暴露,Exact_predicates_inexact_constructions_kernelMesh_Domain必须被定义,但不是CGAL.CGAL_Mesh_3模块的一部分。谢谢你。

mesh_3D_image.cpp:

    #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
    #ifdef CGAL_CONCURRENT_MESH_3
      typedef CGAL::Mesh_triangulation_3<
        Mesh_domain,
        CGAL::Kernel_traits<Mesh_domain>::Kernel, // Same as sequential
        CGAL::Parallel_tag                        // Tag to activate parallelism
      >::type Tr;
    #else
      typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
    #endif
    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;
    }

唯一缺少的是可以处理分割图像的网格域类(类似于SWIG_CGAL/Mesh_3/Mesh_domains.h中定义的一个)。

那么您需要更新接口文件SWIG_CGAL/Mesh_3/CGAL_Mesh_3.i并复制对的调用Declare_global_functions_domain和declare_global_functions_domain_criteria用于这个网格域。

最新更新