mirror of https://github.com/CGAL/cgal
add missing precondition check for soup + always assert in debug
This commit is contained in:
parent
45e9662fd4
commit
0064ea9f3e
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
||||
#include <CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h>
|
||||
|
||||
#include <CGAL/Compact_container.h>
|
||||
|
||||
|
|
@ -589,25 +590,23 @@ public:
|
|||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <typename PolygonMesh, typename CGAL_NP_TEMPLATE_PARAMETERS>
|
||||
bool preconditions_verified(const PolygonMesh& mesh, const CGAL_NP_CLASS& np)
|
||||
bool preconditions_verified_mesh(const PolygonMesh& mesh, const CGAL_NP_CLASS& np)
|
||||
{
|
||||
bool verified = true;
|
||||
if(CGAL::is_triangle_mesh(mesh))
|
||||
{
|
||||
verified = verified && !CGAL::Polygon_mesh_processing::does_self_intersect(mesh);
|
||||
CGAL_precondition_msg(verified,
|
||||
"Conforming_constrained_Delaunay_triangulation_3: mesh self-intersects");
|
||||
}
|
||||
else
|
||||
{
|
||||
return !CGAL::Polygon_mesh_processing::does_self_intersect(mesh, np);
|
||||
PolygonMesh trimesh;
|
||||
CGAL::copy_face_graph(mesh, trimesh, np);
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(trimesh, np);
|
||||
verified = verified && !CGAL::Polygon_mesh_processing::does_self_intersect(trimesh);
|
||||
CGAL_precondition_msg(verified,
|
||||
"Conforming_constrained_Delaunay_triangulation_3: mesh self-intersects");
|
||||
bool OK = CGAL::Polygon_mesh_processing::triangulate_faces(trimesh, np);
|
||||
if (!OK) return false;
|
||||
return !CGAL::Polygon_mesh_processing::does_self_intersect(trimesh);
|
||||
}
|
||||
return verified;
|
||||
|
||||
template <typename PointRange, typename PolygonRange, typename CGAL_NP_TEMPLATE_PARAMETERS>
|
||||
bool preconditions_verified_soup(const PointRange& points,
|
||||
const PolygonRange& polygons,
|
||||
const CGAL_NP_CLASS& np)
|
||||
{
|
||||
return CGAL::Polygon_mesh_processing::does_polygon_soup_self_intersect(points, polygons, np);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -625,8 +624,11 @@ public:
|
|||
// ----------------------------------
|
||||
const bool check_preconditions =
|
||||
parameters::choose_parameter(parameters::get_parameter(np, internal_np::check_preconditions), false);
|
||||
if(!check_preconditions || preconditions_verified(mesh, np))
|
||||
{
|
||||
|
||||
CGAL_precondition_msg(check_preconditions || preconditions_verified_mesh(mesh, np), "Conforming_constrained_Delaunay_triangulation_3: mesh self-intersects");
|
||||
|
||||
if(check_preconditions && !preconditions_verified_mesh(mesh, np)) return;
|
||||
|
||||
auto mesh_vp_map = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point),
|
||||
get(CGAL::vertex_point, mesh));
|
||||
|
||||
|
|
@ -661,7 +663,6 @@ public:
|
|||
put(v_selected_map, vb, true);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
number_of_patches = num_faces(mesh);
|
||||
}
|
||||
|
|
@ -738,7 +739,6 @@ public:
|
|||
// std::cerr << cdt_3_format("cdt_impl: {} vertices, {} cells\n", cdt_impl.number_of_vertices(),
|
||||
// cdt_impl.number_of_cells());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief creates a 3D constrained Delaunay triangulation conforming to the faces of a polygon soup,
|
||||
|
|
@ -754,6 +754,13 @@ public:
|
|||
// ----------------------------------
|
||||
// cstr... (polygon soup)
|
||||
// ----------------------------------
|
||||
const bool check_preconditions =
|
||||
parameters::choose_parameter(parameters::get_parameter(np, internal_np::check_preconditions), false);
|
||||
|
||||
CGAL_precondition_msg(check_preconditions || preconditions_verified_soup(points, polygons, np), "Conforming_constrained_Delaunay_triangulation_3: polygon soup self-intersects");
|
||||
|
||||
if(check_preconditions && !preconditions_verified_soup(points, polygons, np)) return;
|
||||
|
||||
|
||||
using PointRange_const_iterator = typename PointRange::const_iterator;
|
||||
using PointRange_value_type = typename std::iterator_traits<PointRange_const_iterator>::value_type;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ bool does_polygon_soup_self_intersect(const PointRange& points,
|
|||
// otherwise, we need to triangulate the polygons beforehand
|
||||
using Polygon = CGAL::cpp20::remove_cvref_t<decltype(*polygons.begin())>;
|
||||
std::vector<Polygon> triangles(polygons.begin(), polygons.end());
|
||||
triangulate_polygons(points, triangles, np);
|
||||
bool OK = triangulate_polygons(points, triangles, np);
|
||||
|
||||
if (!OK) return false;
|
||||
|
||||
return does_triangle_soup_self_intersect<ConcurrencyTag>(points, triangles, np);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue