CGAL-Bindings(Python):Mesh_3示例

时间:2015-05-21 09:11:00

标签: python swig mesh image-segmentation cgal

是否存在针对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;
    }

1 个答案:

答案 0 :(得分:0)

唯一缺少的是网格域类(类似于int *中定义的类),它可以处理分段图像。

然后,您需要更新接口文件SWIG_CGAL/Mesh_3/Mesh_domains.h并将调用复制到 declare_global_functions_domain和declare_global_functions_domain_criteria将与此网状域一起使用。