-
Apologies for just having asked this same question cgal-discuss just a moment ago. Only now did I realize that the project's GitHub Discussions seem more active. I'm seeing a behavioral difference between two ways of constructing a One way to build a A small example that does the former: #include "common.hpp"
int main(int argc, char ** argv)
{
Nef_polyhedron nef_poly;
std::ifstream is("test.off", std::ios::in);
CGAL::OFF_to_nef_3(is, nef_poly);
is.close();
return 0;
} One that does the latter: #include "common.hpp"
int main(int argc, char ** argv)
{
Polyhedron poly;
std::ifstream is("test.off", std::ios::in);
bool success = CGAL::IO::read_OFF(is, poly);
is.close();
assert(success);
assert(poly.is_valid());
assert(poly.is_closed());
Nef_polyhedron nef_poly(poly); // <--- A (see below).
return 0;
} Here #pragma once
#include <iostream>
#include <fstream>
#include <cassert>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/IO/Polyhedron_OFF_iostream.h>
#include <CGAL/OFF_to_nef_3.h>
using Exact_kernel = CGAL::Exact_predicates_exact_constructions_kernel;
using Polyhedron = CGAL::Polyhedron_3<Exact_kernel>;
using Surface_mesh = CGAL::Surface_mesh<Exact_kernel::Point_3>;
using Nef_polyhedron = CGAL::Nef_polyhedron_3<Exact_kernel>; From the documentation, I would expect the two to produce the same Nef polyhedron ("same" mathematically speaking). However, I can construct some OFF files for which only the former method works, while the latter fails with
at the location labeled Here's an OFF that exhibits that behavior:
Here's one where the two approaches produce the same polyhedron, as I would expect in general:
I assume I've misunderstood something in the CGAL documentation for these classes. Is it obvious exactly what that is? As an addendum, here's a simple visualization of the edges of the OFF that breaks. Nothing too spooky going on there. The orange edges are the ones that make up the boundary of the only non-triangle surface segment. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks to @sloriot for the answer given here. More details can also be found in this SO question and its answer. |
Beta Was this translation helpful? Give feedback.
OFF_to_nef_3
is basically permissive to issues in the input (self-intersections, non-planar faces, ...).When building from a Polyhedron, it is expected that for example there is no self-intersections and that all faces are planar. In the OFF that does not have the same behavior, one face is made of two non planar triangles, which is why you have an assertion failing.