File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
5658void 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
Original file line number Diff line number Diff line change 3434#include < list>
3535#include < vector>
3636#include < cstddef>
37+ #include < unordered_set>
3738
3839namespace p2t {
3940
@@ -136,6 +137,7 @@ friend class Sweep;
136137std::vector<Triangle*> triangles_;
137138std::list<Triangle*> map_;
138139std::vector<Point*> points_;
140+ std::unordered_set<Point*> point_set_;
139141
140142// Advancing front
141143AdvancingFront* front_;
You can’t perform that action at this time.
0 commit comments