forked from CGAL/cgal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nef_3: Fix conversion to a FaceGraph (CGAL#6727)
## Summary of Changes Fix the case of surfaces with borders. Then they may be incident to only the unbounded volume which so far was ignored. ## Release Management * Affected package(s): Nef_polyhedron_3 * Issue(s) solved (if any): fix CGAL#6423
- Loading branch information
Showing
2 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> | ||
#include <CGAL/Nef_polyhedron_3.h> | ||
#include <CGAL/IO/Nef_polyhedron_iostream_3.h> | ||
#include <CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h> | ||
#include <CGAL/boost/graph/generators.h> | ||
#include <CGAL/Surface_mesh.h> | ||
|
||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; | ||
typedef Kernel::Point_3 Point_3; | ||
typedef CGAL::Surface_mesh<Point_3> SurfaceMesh; | ||
typedef CGAL::Nef_polyhedron_3<Kernel> NefPolyhedron; | ||
|
||
|
||
int main() | ||
{ | ||
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::Vertex_index v3 = surfaceMesh.add_vertex(Point_3(-1, 0, 1)); | ||
SurfaceMesh::Vertex_index v4 = surfaceMesh.add_vertex(Point_3(1, 0, 1)); | ||
SurfaceMesh::Vertex_index v5 = surfaceMesh.add_vertex(Point_3(0, 1, 1)); | ||
|
||
surfaceMesh.add_face(v0, v1, v2); | ||
surfaceMesh.add_face(v3, v4, v5); | ||
|
||
make_tetrahedron(Point_3(-1, 0, 10), | ||
Point_3(1, 0, 10), | ||
Point_3(0, 1, 10), | ||
Point_3(-1, 0, 11), | ||
surfaceMesh); | ||
|
||
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; | ||
std::ofstream("out.off") << convertedSurfaceMesh; | ||
assert(vertices(convertedSurfaceMesh).size()==10); | ||
assert(faces(convertedSurfaceMesh).size()==6); | ||
return EXIT_SUCCESS; | ||
} |