diff options
author | Remco Burema <r.burema@ultimaker.com> | 2021-11-17 18:20:21 +0300 |
---|---|---|
committer | Remco Burema <r.burema@ultimaker.com> | 2021-11-17 18:20:21 +0300 |
commit | 23515d0e24c2356e17c714712c9c1cc0259670f3 (patch) | |
tree | c9d59eb108b5d29887898e22eb3410b05bda129d | |
parent | 0a561014646dea2817cf50a52a4ecfc0d1660b49 (diff) |
Use functions that already exist instead of implementing new ones that mess up.
part of CURA-8702
-rw-r--r-- | src/infill/LightningLayer.cpp | 5 | ||||
-rw-r--r-- | src/infill/LightningTreeNode.cpp | 17 | ||||
-rw-r--r-- | src/infill/LightningTreeNode.h | 6 |
3 files changed, 4 insertions, 24 deletions
diff --git a/src/infill/LightningLayer.cpp b/src/infill/LightningLayer.cpp index 2f528a15e..94493427f 100644 --- a/src/infill/LightningLayer.cpp +++ b/src/infill/LightningLayer.cpp @@ -262,7 +262,10 @@ Polygons LightningLayer::convertToLines(const Polygons& limit_to_outline, const { // If even the furthest location in the tree is inside the polygon, the entire tree must be inside of the polygon. // (Don't take the root as that may be on the edge and cause rounding errors to register as 'outside'.) - if (limit_to_outline.inside(tree->getFurthestLocation())) + constexpr coord_t epsilon = 5; + Point should_be_inside = tree->getLocation(); + PolygonUtils::moveInside(limit_to_outline, should_be_inside, epsilon, epsilon * epsilon); + if (limit_to_outline.inside(should_be_inside)) { tree->convertToPolylines(result_lines, line_width); } diff --git a/src/infill/LightningTreeNode.cpp b/src/infill/LightningTreeNode.cpp index dee9d21cd..30cadde77 100644 --- a/src/infill/LightningTreeNode.cpp +++ b/src/infill/LightningTreeNode.cpp @@ -37,23 +37,6 @@ const Point& LightningTreeNode::getLocation() const return p; } -Point LightningTreeNode::getFurthestLocation() const -{ - Point result{ p }; - coord_t furthest_dist2 = 0; - for (const auto& child : children) - { - const Point cp{ child->getFurthestLocation() }; - const coord_t dist2 = vSize2(cp - p); - if (dist2 >= furthest_dist2) - { - furthest_dist2 = dist2; - result = cp; - } - } - return result; -} - void LightningTreeNode::setLocation(const Point& loc) { p = loc; diff --git a/src/infill/LightningTreeNode.h b/src/infill/LightningTreeNode.h index e94d4de57..97767f8b9 100644 --- a/src/infill/LightningTreeNode.h +++ b/src/infill/LightningTreeNode.h @@ -57,12 +57,6 @@ public: const Point& getLocation() const; /*! - * Get the point the furthest from the root, measured along the branches of the path to that node. - * \return The furthest position, which may be the (local) root itself if the tree has no nodes. - */ - Point getFurthestLocation() const; - - /*! * Change the position on this layer that the node represents. * \param p The position that the node needs to represent. */ |