Search code examples
c++computational-geometrycgal

How to convert a triangulated hole patch to a surface mesh?


I have a triangulated hole patch with vertices and triangles. Now how do I convert this to a surface mesh?

I am trying to partially fill a hole in my mesh using two different patches. I have the vertex locations for all the points on the boundary (points with z=0). Using them I have triangulated the hole using the following code (from https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2triangulate_polyline_example_8cpp-example.html)

    std::vector<PointCGAL> polyline;
Mesh::Property_map<vertex_descriptor, std::string> name;
Mesh::Property_map<vertex_descriptor, PointCGAL> location = 
    mesh1.points();
BOOST_FOREACH(vertex_descriptor vd, mesh1.vertices()) {
    if (location[vd].z() < 0.00001)
    {
        std::cout << "on Boundary" << endl;
        polyline.push_back(PointCGAL(location[vd].x(), 
    location[vd].y(), location[vd].z()));
    }
    std::cout << location[vd] << std::endl;
}

typedef CGAL::Triple<int, int, int> Triangle_int;
std::vector<Triangle_int> patch;
patch.reserve(polyline.size() - 2); // there will be exactly n-2 
    triangles in the patch
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
    polyline,
    std::back_inserter(patch));

Solution

  • Have a look at the function polygon_soup_to_polygon_mesh()