mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 12:35:55 +08:00
Fix triangulation check
This commit is contained in:
parent
e340fa6abe
commit
a5190a92cd
@ -46,6 +46,13 @@ inline bool has_bidirectional_constrained(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_unique(const Points &points) {
|
||||||
|
Points pts = points; // copy
|
||||||
|
std::sort(pts.begin(), pts.end());
|
||||||
|
auto it = std::adjacent_find(pts.begin(), pts.end());
|
||||||
|
return it == pts.end();
|
||||||
|
}
|
||||||
|
|
||||||
inline bool has_self_intersection(
|
inline bool has_self_intersection(
|
||||||
const Points &points,
|
const Points &points,
|
||||||
const Triangulation::HalfEdges &constrained_half_edges)
|
const Triangulation::HalfEdges &constrained_half_edges)
|
||||||
@ -80,13 +87,15 @@ Triangulation::Indices Triangulation::triangulate(const Points &points,
|
|||||||
{
|
{
|
||||||
assert(!points.empty());
|
assert(!points.empty());
|
||||||
assert(!constrained_half_edges.empty());
|
assert(!constrained_half_edges.empty());
|
||||||
// edges can NOT contain bidirectional constrained
|
|
||||||
assert(!priv::has_bidirectional_constrained(constrained_half_edges));
|
|
||||||
// constrained must be sorted
|
// constrained must be sorted
|
||||||
assert(std::is_sorted(constrained_half_edges.begin(),
|
assert(std::is_sorted(constrained_half_edges.begin(),
|
||||||
constrained_half_edges.end()));
|
constrained_half_edges.end()));
|
||||||
|
// check that there is no duplicit constrained edge
|
||||||
|
assert(std::adjacent_find(constrained_half_edges.begin(), constrained_half_edges.end()) == constrained_half_edges.end());
|
||||||
|
// edges can NOT contain bidirectional constrained
|
||||||
|
assert(!priv::has_bidirectional_constrained(constrained_half_edges));
|
||||||
// check that there is only unique poistion of points
|
// check that there is only unique poistion of points
|
||||||
assert(std::adjacent_find(points.begin(), points.end()) == points.end());
|
assert(priv::is_unique(points));
|
||||||
assert(!priv::has_self_intersection(points, constrained_half_edges));
|
assert(!priv::has_self_intersection(points, constrained_half_edges));
|
||||||
// use cgal triangulation
|
// use cgal triangulation
|
||||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user