From c3306582bf85fe723b4ef6f7cce7a09bf3c1db15 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Wed, 9 Sep 2020 23:37:34 -0700 Subject: [PATCH] Added voronoi colorExterior case where one external vertex coincides with a point of an input segment. --- src/Mod/Path/App/VoronoiPyImp.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/App/VoronoiPyImp.cpp b/src/Mod/Path/App/VoronoiPyImp.cpp index 119408b67e..474d0e7da1 100644 --- a/src/Mod/Path/App/VoronoiPyImp.cpp +++ b/src/Mod/Path/App/VoronoiPyImp.cpp @@ -173,6 +173,7 @@ Py::List VoronoiPy::getCells(void) const { } typedef std::map exterior_map_t; +typedef std::map > coordinate_map_t; #define VORONOI_USE_EXTERIOR_CACHE 1 @@ -215,7 +216,8 @@ PyObject* VoronoiPy::colorExterior(PyObject *args) { Voronoi *vo = getVoronoiPtr(); vo->colorExterior(color); if (callback) { - exterior_map_t cache; + exterior_map_t cache; + coordinate_map_t pts; for (auto e = vo->vd->edges().begin(); e != vo->vd->edges().end(); ++e) { if (e->is_finite() && e->color() == 0) { const Voronoi::diagram_type::vertex_type *v0 = e->vertex0(); @@ -223,6 +225,17 @@ PyObject* VoronoiPy::colorExterior(PyObject *args) { bool bail = false; if (callbackWithVertex(vo->vd, callback, v0, bail, cache) && callbackWithVertex(vo->vd, callback, v1, bail, cache)) { vo->colorExterior(&(*e), color); + } else if (!bail && callbackWithVertex(vo->vd, callback, v1, bail, cache)) { + if (pts.empty()) { + for (auto s = vo->vd->segments.begin(); s != vo->vd->segments.end(); ++s) { + pts[low(*s).x()].insert(low(*s).y()); + pts[high(*s).x()].insert(high(*s).y()); + } + } + auto ys = pts.find(int32_t(v0->x())); + if (ys != pts.end() && ys->second.find(v0->y()) != ys->second.end()) { + vo->colorExterior(&(*e), color); + } } if (bail) { return NULL;