CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.99k stars 1.39k forks source link

simplify combinatorial map using CGAL #3689

Closed n-m-ya closed 5 years ago

n-m-ya commented 5 years ago

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

Source Code

 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

Issue Details

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 .

Environment

lrineau commented 5 years ago

Why have you closed the issue @nourhan-m. Have you found a solution?

n-m-ya commented 5 years ago

Why have you closed the issue @nourhan-m. Have you found a solution?

@lrineau yes , I used read_off instead of load_off , it's solves the problem

lrineau commented 5 years ago

@gdamiand Do we want to keep the undocumented function load_off, in addition to read_off?

gdamiand commented 5 years ago

@lrineau Yes we want, because Combinatorial map is not directly a model of HalfedgeGraph (contrary to Polyhedron and Surface_mesh). We need to use a special item class so satisfy the constraints of these models.

Outside this special case, we can use a combinatorial map and load an off by using this function. Maybe we can change its name, and/or document it.