我想使用 CGAL 简化或边缘折叠从 .off 文件中读取的网格作为组合图
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;
输出 :
#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
该方法什么都不做,我尝试了比.off文件更多的内容,并且可以正确预览它,但无法简化它我感谢任何帮助.
请参阅此处给出的示例,它运行良好。