c++cgal

How to refine faces associated to sharp edges in CGAL


I have an edge map from Polygon_mesh_processing::detect_sharp_edges that selects the edges of a mesh. How could I get the range of faces associated with these edges so I can refine them?

I am looking for something like Polygon_mesh_processing::connected_component, but to get faces from edges.


Solution

  • If you care strictly about the faces incident to the the edges, you can do something like this:

      [...]
    
      auto eif = get(CGAL::edge_is_feature, mesh);
      PMP::detect_sharp_edges(mesh, 90 /*angle*/, eif);
    
      std::vector<face_descriptor> faces_incident_to_sharp_edges;
      for(edge_descriptor e : edges(mesh))
      {
        if(!get(eif, e))
          continue; // edge is not sharp
    
        halfedge_descriptor h = halfedge(e, mesh);
        if(!is_border(h, mesh))
          faces_incident_to_sharp_edges.push_back(face(h, mesh));
        if(!is_border(opposite(h, mesh), mesh))
          faces_incident_to_sharp_edges.push_back(face(opposite(h, mesh), mesh));
      }
    

    If you want faces that are at least sharing a vertex with a sharp edge, then you can look into CGAL::halfedges_around_target().