cgal
cgal copied to clipboard
conversion between surface mesh and nef_polyhedron_3
Issue Details
I can construct nef_polyhedron_3 using unclosed surface mesh. But when I convert this nef_polyhedron_3 to surface mesh, I got empty result. How can I get the original surface mesh using nef_polyhedron_3?
Source Code
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
#include "CGAL/Surface_mesh.h"
typedef CGAL::Surface_mesh<Point_3> SurfaceMesh;
#include "CGAL/Nef_polyhedron_3.h"
typedef CGAL::Nef_polyhedron_3<Kernel> NefPolyhedron;
#include "CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h"
int main(int argc, char* argv[])
{
SurfaceMesh surfaceMesh;
SurfaceMesh::Vertex_index v0 = surfaceMesh.add_vertex(Point_3(-1, 0, 0));
SurfaceMesh::Vertex_index v1 = surfaceMesh.add_vertex(Point_3(1, 0, 0));
SurfaceMesh::Vertex_index v2 = surfaceMesh.add_vertex(Point_3(0, 1, 0));
surfaceMesh.add_face(v0, v1, v2);
std::cout << "Before conversion, number_of_faces: " << surfaceMesh.number_of_faces() << std::endl;
NefPolyhedron nefPoly(surfaceMesh);
std::cout << "NefPolyhedron, number_of_faces: " << nefPoly.number_of_facets() << std::endl;
SurfaceMesh convertedSurfaceMesh;
CGAL::convert_nef_polyhedron_to_polygon_mesh(nefPoly, convertedSurfaceMesh, true);
std::cout << "After conversion, number_of_faces: " << convertedSurfaceMesh.number_of_faces() << std::endl;
return EXIT_SUCCESS;
}
Environment
- Operating system (Windows/Mac/Linux, 32/64 bits): Windows 64 bits
- Compiler: MSVC-2019-Community
- Release or debug mode: debug
- Specific flags used (if any):
- CGAL version: CGAL-5.4
- Boost version: boost_1_76_0
- Other libraries versions if used (Eigen, TBB, etc.):
Hello,
A polyhedron is closed by definition, and a 3D triangle is not closed. Maybe it is the reason?