simplify combinatorial map using CGAL

大兔子大兔子 提交于 2019-12-25 03:02:29

问题


I want to simplify or edge collapse a mesh read from .off file as a combinatorial map using CGAL

 std::ifstream ifile(fileName.toStdString().c_str());
     if (ifile)
     {
        CGAL::load_off(lcc, ifile);
        lcc.display_characteristics(std::cout)<<", is_valid="<<CGAL::is_valid(lcc)<<std::endl;

     }
  namespace SMS = CGAL::Surface_mesh_simplification ;

    SMS::Count_stop_predicate<LCC> stop(lcc.number_of_halfedges()/2 - 1);

 int r = SMS::edge_collapse
   (lcc
    ,stop
    ,CGAL::parameters::halfedge_index_map(get(CGAL::halfedge_index, lcc))
             .vertex_index_map(get(boost::vertex_index, lcc))
             .get_cost(SMS::Edge_length_cost<LCC>())
   .get_placement(SMS::Midpoint_placement<LCC>())
    );

    std::cout << "\nFinished...\n" << r << " edges removed.\n"
               << (lcc.number_of_darts()/2) << " final edges.\n" ;

     lcc.display_characteristics(std::cout)<<", is_valid="<<CGAL::is_valid(lcc)<<std::endl;

the output :

    #Darts=16674, #0-cells=2775, #1-cells=8337, #2-cells=5558, #ccs=1, is_valid=1
Finished...
0 edges removed.
8337 final edges.
    #Darts=16674, #0-cells=2775, #1-cells=8337, #2-cells=5558, #ccs=1, is_valid=1

the method do nothing , I tried more than .off file and it's preview it properly but it cannot simplify it I appreciate any help .


回答1:


See the example given here, it works perfectly.



来源:https://stackoverflow.com/questions/54615381/simplify-combinatorial-map-using-cgal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!