Repository navigation
Reject the points outside the bounding box of the element in ShapeElement::contains - #154
Merged
Merged
Conversation
…ment::contains ShapeElement::contains projects the point on the element and compares it with the closest point of the element, which needs a square root for the length of the element and a call to ShapeElement::point. Shape::contains calls it on every element of the shape to check if the point is on the boundary, so for most of the elements, the point is far from them. The points of a line segment are in the bounding box of its ends, and the points of a circular arc in the bounding box of its circle, whose radius is at most |dx| + |dy|. A point farther than twice the tolerance from this bounding box is now rejected before the projection.
fontanf
force-pushed
the
element-contains-bounding-box
branch
from
November 8, 2026 16:49
9a55347 to
b99f18d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ShapeElement::containsprojects the point on the element and compares it with the closest point of the element, which needs a square root (hypot) for the length of the element and a call toShapeElement::point.Shape::containscalls it on every element of the shape to check whether the point is on the boundary, so most of these calls are for elements far from the point.The points of a line segment are in the bounding box of its ends, and the points of a circular arc in the bounding box of its circle, whose radius is at most |dx| + |dy|. A point farther than twice the tolerance from this bounding box is now rejected before the projection. The margin is twice the tolerance so that the rounding errors of
ShapeElement::pointcan't make a rejected point contained.Measurements
On the 62 no-fit polygons computed by the periodic packings of packingsolver on alma_02 (alma2025 dataset, item types of up to 153 vertices),
no_fit_polygongoes from 23.6 s to 15.7 s in total, with the same outputs (number of components and of elements of the NFP, number of feasible elements and points). Before this change,ShapeElement::containstook 54% of the time ofno_fit_polygon, mostly throughShape::containsincompute_feasible_elements_and_points.All 714 tests pass.