【问题标题】:CGAL-Bindings (Python): Mesh_3 examplesCGAL 绑定 (Python):Mesh_3 示例
【发布时间】:2015-05-21 09:10:59
【问题描述】:

是否有 Mesh_3 示例的 cgal-python-bindings 实现,尤其是 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;
    }

【问题讨论】:

    标签: python swig mesh image-segmentation cgal


    【解决方案1】:

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

    然后你需要更新接口文件SWIG_CGAL/Mesh_3/CGAL_Mesh_3.i并将调用复制到 declare_global_functions_domain 和 declare_global_functions_domain_criteria 用于此网格域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多