Skip to content

Commit 141ade3

Browse files
author
Marc Kramer
committed
Support touching holes
1 parent 13d64e7 commit 141ade3

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

poly2tri/sweep/sweep_context.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ void SweepContext::AddHole(const std::vector<Point*>& polyline)
4949
{
5050
InitEdges(polyline);
5151
for (auto i : polyline) {
52-
points_.push_back(i);
52+
if (point_set_.insert(i).second) {
53+
points_.push_back(i);
54+
}
5355
}
5456
}
5557

5658
void SweepContext::AddPoint(Point* point) {
59+
if (!point_set_.insert(point).second) {
60+
throw std::runtime_error("Point already exists");
61+
}
5762
points_.push_back(point);
5863
}
5964

poly2tri/sweep/sweep_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <list>
3535
#include <vector>
3636
#include <cstddef>
37+
#include <unordered_set>
3738

3839
namespace p2t {
3940

@@ -136,6 +137,7 @@ friend class Sweep;
136137
std::vector<Triangle*> triangles_;
137138
std::list<Triangle*> map_;
138139
std::vector<Point*> points_;
140+
std::unordered_set<Point*> point_set_;
139141

140142
// Advancing front
141143
AdvancingFront* front_;

0 commit comments

Comments
 (0)