WIP: try to avoid duplicate intersection points by eliminating those. Problem persists: intersection points may be duplicates of edges arising from AND

This commit is contained in:
Matthias Koefferlein 2019-11-18 23:14:24 +01:00
parent 24759c7174
commit 9af662a512
2 changed files with 6 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#define HDR_dbEdgeBoolean
#include "dbEdge.h"
#include "dbHash.h"
#include "dbBoxScanner.h"
#include "tlIntervalMap.h"
@ -251,7 +252,7 @@ struct EdgeBooleanClusterCollector
} else if (mp_intersections && p1 != p2) {
std::pair<bool, db::Point> ip = o1->intersect_point (*o2);
if (ip.first) {
if (ip.first && m_seen_intersections.insert (ip.second).second) {
mp_intersections->insert (db::Edge (ip.second, ip.second));
}
@ -260,6 +261,7 @@ struct EdgeBooleanClusterCollector
private:
OutputContainer *mp_intersections;
std::unordered_set<db::Point> m_seen_intersections;
};
}

View File

@ -852,6 +852,9 @@ TEST(22)
ee.insert (db::Edge (4000,-2000,-2000,-2000));
EXPECT_EQ ((e & ee).to_string (), "(400,0;-2000,0);(500,-174;400,0);(1000,0;900,-173);(4000,0;1000,0)");
EXPECT_EQ (e.intersections (ee).to_string (), "(400,0;400,0);(-2000,0;-2000,0);(1000,0;1000,0);(4000,0;4000,0);(400,0;-2000,0);(500,-174;400,0);(1000,0;900,-173);(4000,0;1000,0)");
// no particular new points with intersections - just endpoints of original edges
EXPECT_EQ (e.intersections (ee).merged ().to_string (), "(400,0;-2000,0);(500,-174;400,0);(1000,0;900,-173);(4000,0;1000,0)");
}
TEST(23)