Support touching holes

This commit is contained in:
Marc Kramer 2025-01-27 19:02:44 +01:00
parent 13d64e75a8
commit 141ade3b01
2 changed files with 8 additions and 1 deletions

View File

@ -49,11 +49,16 @@ void SweepContext::AddHole(const std::vector<Point*>& polyline)
{ {
InitEdges(polyline); InitEdges(polyline);
for (auto i : polyline) { for (auto i : polyline) {
if (point_set_.insert(i).second) {
points_.push_back(i); points_.push_back(i);
} }
}
} }
void SweepContext::AddPoint(Point* point) { void SweepContext::AddPoint(Point* point) {
if (!point_set_.insert(point).second) {
throw std::runtime_error("Point already exists");
}
points_.push_back(point); points_.push_back(point);
} }

View File

@ -34,6 +34,7 @@
#include <list> #include <list>
#include <vector> #include <vector>
#include <cstddef> #include <cstddef>
#include <unordered_set>
namespace p2t { namespace p2t {
@ -136,6 +137,7 @@ friend class Sweep;
std::vector<Triangle*> triangles_; std::vector<Triangle*> triangles_;
std::list<Triangle*> map_; std::list<Triangle*> map_;
std::vector<Point*> points_; std::vector<Point*> points_;
std::unordered_set<Point*> point_set_;
// Advancing front // Advancing front
AdvancingFront* front_; AdvancingFront* front_;