首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAL:如何像CGAL那样在折线内进行分割?

CGAL:如何像CGAL那样在折线内进行分割?
EN

Stack Overflow用户
提问于 2022-06-29 04:07:24
回答 1查看 53关注 0票数 0

我有一个表面网格,有一些尖锐的特征。我想在这些特征组成的折线内分割网格。在CGAL演示中,如图所示,“检测尖锐特征”功能可以满足我的要求。现在,我可以使用内部调用add_features_from_split_graph_into_polylines()的domain.detect_features()获得polyline。但是,我如何才能在折线内得到表面贴片并切割它们呢?CGAL演示结果

代码语言:javascript
复制
#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/Polyhedral_mesh_domain_with_features_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/IO/output_to_vtu.h>

#include <CGAL/IO/facets_in_complex_3_to_triangle_mesh.h>
#include <CGAL/Surface_mesh.h>


// Domain
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Mesh_polyhedron_3<K>::type Polyhedron;
typedef CGAL::Polyhedral_mesh_domain_with_features_3<K> Mesh_domain;
#ifdef CGAL_CONCURRENT_MESH_3
typedef CGAL::Parallel_tag Concurrency_tag;
#else
typedef CGAL::Sequential_tag Concurrency_tag;
#endif
// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain, CGAL::Default, Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<
    Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
// To avoid verbose function and named parameters call
using namespace CGAL::parameters;

//Mesh
typedef CGAL::Surface_mesh<K::Point_3> Mesh;

int main(int argc, char*argv[])
{
    const char* fname = (argc > 1) ? argv[1] : "data/fandisk.off";
    std::ifstream input(fname);
    Polyhedron polyhedron;
    input >> polyhedron;
    if (input.fail()) {
        std::cerr << "Error: Cannot read file " << fname << std::endl;
        return EXIT_FAILURE;
    }
    if (!CGAL::is_triangle_mesh(polyhedron)) {
        std::cerr << "Input geometry is not triangulated." << std::endl;
        return EXIT_FAILURE;
    }
    // Create domain
    Mesh_domain domain(polyhedron);
    // Get sharp features
    domain.detect_features();
    // Mesh criteria
    Mesh_criteria criteria(edge_size = 0.025,
        facet_angle = 25, facet_size = 0.05, facet_distance = 0.005,
        cell_radius_edge_ratio = 3, cell_size = 0.05);
    // Mesh generation
    C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
    
    // use cgal demo open vtu file can't get desired result
    // Output
    /*std::ofstream file("out.vtu");
    CGAL::output_to_vtu(file, c3t3, CGAL::IO::ASCII);*/

    //use function below can get mesh but doesn't contain segmentation info
    Mesh mesh;
    facets_in_complex_3_to_triangle_mesh(c3t3, mesh);
    std::ofstream output("mesh_smoothed.off");
    output.precision(17);
    output << mesh;


    // Could be replaced by:
    // c3t3.output_to_medit(file);
    return EXIT_SUCCESS;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-29 13:23:21

函数分段()应该做类似的事情。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72795690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档