-
-
Notifications
You must be signed in to change notification settings - Fork 918
[CURA-13024] Spike: merge thin parts of floor/roof/skin #2316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b6ddb98
10b089a
4c89034
0d3c049
e6e97ed
0822fac
4607454
c2afdec
4eab7c2
fed0513
8a1aeba
96c4150
0b159d8
0c83978
2452942
990d110
8d8c737
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1518,6 +1518,56 @@ Shape PolygonUtils::clipPolygonWithAABB(const Shape& src, const AABB& aabb) | |
| return out; | ||
| } | ||
|
|
||
| void PolygonUtils::mergeThinOverlap(const coord_t max_dist, Shape& source, Shape& destination, const bool allow_thin_areas_grow) | ||
| { | ||
| if (source.empty() || destination.empty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Get the thin areas of the destination, which we are allowed to grow over | ||
| const Shape allow_grow_area = getThinAreas(destination, max_dist); | ||
| if (allow_grow_area.empty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // If necessary, remove the thin parts of the source to not allow them to grow | ||
| const Shape source_grow_part = allow_thin_areas_grow ? source : getWideAreas(source, max_dist); | ||
| if (source_grow_part.empty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Now calculate the actual growing area, which is the intersection of the offset source with the allowed growing area | ||
| const Shape actual_grow_area = source_grow_part.offset(max_dist).intersection(allow_grow_area).offset(EPSILON); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since both
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I like the idea, but I think that would defeat the purpose of this offset. If I do it before the intersection, the final shape will not go outside the |
||
| if (actual_grow_area.empty()) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Finally, append the growing area to the source and remove it from the destination | ||
| source = source.unionPolygons(actual_grow_area); | ||
| destination = destination.difference(actual_grow_area); | ||
| } | ||
|
|
||
| Shape PolygonUtils::getThinAreas(const Shape& shape, const coord_t max_width) | ||
| { | ||
| // Extract the wide areas, then do a difference to actually keep only the thin areas | ||
| return shape.difference(getRawWideAreas(shape, max_width, EPSILON)); | ||
|
casperlamboo marked this conversation as resolved.
|
||
| } | ||
|
|
||
| Shape PolygonUtils::getWideAreas(const Shape& shape, const coord_t min_width) | ||
| { | ||
| // Extract the raw wide areas, then do an intersection to keep them inside the original shape | ||
| return shape.intersection(getRawWideAreas(shape, min_width, EPSILON)); | ||
|
casperlamboo marked this conversation as resolved.
|
||
| } | ||
|
|
||
| Shape PolygonUtils::getRawWideAreas(const Shape& shape, const coord_t min_width, const coord_t extra_widen) | ||
| { | ||
| return shape.offset(-min_width / 2).offset(min_width / 2 + extra_widen); | ||
| } | ||
|
|
||
| std::tuple<ClosedLinesSet, coord_t> | ||
| PolygonUtils::generateCirculatOutset(const Point2LL& center, const coord_t inner_radius, const coord_t outer_radius, coord_t line_width, const size_t circle_definition) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[nitpick]]
total_prefix is a bit nugatoryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is somehow a "total" in the sense that it contains 2 united areas. Would an other wording make more sense to you ?