Search code examples
cgal

Converting Surface_mesh to Nef_polyhedron_3


I'm trying to use CGAL to do some boolean operations on meshes.

How do I convert from Surface_mesh to Nef_polyhedron_3?

EDIT:
I've tried with this code, but I don't know how to continue...

#include <iostream>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>

using namespace std;

typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;

int main()
{
    Mesh m;
    auto a = m.add_vertex(K::Point_3(0,0,0));
    auto b = m.add_vertex(K::Point_3(0,0,0));
    auto c = m.add_vertex(K::Point_3(0,0,0));
    m.add_face(a,b,c);

    Mesh::Halfedge_range range = m.halfedges();
    for(Mesh::Halfedge_index hei : range)
    {
        // ??? <<--
        std::cout << hei << std::endl;
    }

    return 0;
}

Thanks


Solution

  • I think the suggested way to do this is to use the 3d polyhedral surface package instead. The Nef 3 documentation describes the conversion between Polyhedron_3 and Nef_3. The only difference between the 3d polyhedral surface package and the surface mesh package is that, it is pointer based rather than index based.