83 Commits

Author SHA1 Message Date
Lukáš Hejl
86fadfc08e SPE-2194: Split Voronoi cells generated by vertexes into two polygons of equal area instead of selecting just one of the edges based on heuristics. 2025-02-14 11:57:04 +01:00
Lukáš Hejl
36f64d9dd7 SPE-2194: Improve filtering of projected colors in multi-material segmentation. 2025-02-14 11:57:04 +01:00
Lukáš Hejl
c044b310ee SPE-2194: Snap places where there is a change in projected colors to the nearest sharp angles in multi-material segmentation. 2025-02-14 11:57:04 +01:00
Lukáš Hejl
e35766bb89 SPE-2496: Fix calculation of perimeter spacing in the multi-material segmentation when the perimeter extrusion width is set to zero. 2025-01-21 14:43:29 +01:00
Lukáš Hejl
5c7888b114 Fix crash in multi-material segmentation when there wasn't any input polygon for some layer. 2024-12-20 12:54:34 +01:00
Lukáš Hejl
4f5bd3ff5b Fix crash in multi-material segmentation when the number of extruders changed. 2024-12-20 12:54:34 +01:00
Lukáš Hejl
e97e17fac0 SPE-2586: Disable replacing the default extruder with a volume extruder during multi-material segmentation.
This partly reverts commits 84e9da9c and 3edec09a (SPE-1841) because it led to ignoring assigned extruders to modifiers.
2024-12-13 13:54:28 +01:00
Lukáš Hejl
fa2663f026 SPE-2486: Limit the depth of the painted fuzzy skin regions to make regions cover just external perimeters.
This reduces the possibility of artifacts that could happen during regions merging.
2024-11-12 15:22:58 +01:00
Lukáš Hejl
519f5eea8e SPE-2486: Extend multi-material segmentation to allow segmentation of any painted faces. 2024-11-12 15:22:57 +01:00
Lukáš Hejl
84e9da9c6c SPE-1841: Replace default extruder with volume extruder for multi-material segmentation.
Previously, the default extruder wasn't handled inside multi-material segmentation, but this could confuse users, especially for multi-volume objects.
Because with multi-volume, it could happen that in the place where two volumes were touching, there could be a change in the used extruder.
2024-11-08 10:13:34 +01:00
Lukáš Hejl
3edec09a2e SPE-1841: Use multi-material segmentation for all volumes of the model when at least one volume is painted.
For volumes that are not painted, we assume that they are entirely painted by the assigned extruder to this volume.
2024-11-08 10:13:34 +01:00
Lukáš Hejl
8d8ee31283 SPE-2202: Improve the projection algorithm to work better in cases where the sliced regions and the input model differ significantly.
This applies mainly to multipart objects.
2024-11-08 10:13:34 +01:00
Lukáš Hejl
500f3817d4 SPE-2202: Small refactoring of the projection algorithm before other improvements. 2024-11-08 10:13:34 +01:00
Lukáš Hejl
4f7c8ae83d SPE-2202: Reimplementation of the projection algorithm of painted mesh on slices inside multi-material segmentation.
This new implementation should resolve several types of artifacts with multi-material segmentation.
It should also increase the precision of projection, so sliced models should be much closer to how they were painted.

Also, the slicing of painted models should be faster than before.
2024-11-08 10:13:34 +01:00
Lukáš Hejl
a443b27895 Remove obsolete assert in the multi-material segmentation. 2024-11-01 21:30:16 +01:00
Lukáš Hejl
3e4e9835f9 SPE-2446: Trim propagated top and bottom layers by the painted bottom or top layers during top and bottom layer propagation in the multi-material segmentation.
On short objects, those propagated layers could override the painted top or bottom layers.
2024-09-19 13:53:44 +02:00
Lukáš Hejl
9397da61fc SPE-2150: Remove top and bottom surfaces that are covered during multi-material segmentation.
Co-authored-by: zhimin.zeng <zhimin.zeng@bambulab.com>
Co-authored-by: lane.wei <lane.wei@bambulab.com>
2024-09-19 13:53:44 +02:00
Martin Šach
2cac8c2c37 Fix includes 2024-09-17 11:21:29 +02:00
Martin Šach
0bf8a9b1c5 Fix includes 2024-08-14 00:04:11 +02:00
Martin Šach
919740fb3e Apply fix includes. 2024-07-08 15:37:02 +02:00
Lukáš Hejl
b425fe459d Rename EnforcerBlockerType to TriangleStateType because we no longer use it just as a blocker or an enforcer. 2024-05-14 17:16:23 +02:00
Lukáš Hejl
76435e7add SPE-1840: Rework multi-material segmentation to work directly on the Voronoi diagram without creating a copy of it.
Previous algorithms assume that they can get an invalid Voronoi diagram. Because of that, during the multi-material segmentation, a copy of the Voronoi diagram was created, and there were several attempts to fix missing vertices and edges. But as it shows, this wasn't a good enough approach and sometimes led to several issues like bleeding layers.

After generalization, our approach for detection and repairs of invalid Voronoi diagrams from Arachne, we could assume that multi-material segmentation gets non-invalid Voronoi diagrams.
With this assumption, we reimplement multi-materials segmentation to work directly on the Voronoi diagram. That should make multi-material segmentation more stable.

So, this should fix several issues like bleeding layers. Also, memory consumption should decrease by a lot. Also, there should be some speedup of multi-materials segmentation.
2024-02-08 15:40:20 +01:00
Lukáš Hejl
23b7c41857 Move ColoredLine struct and related boost traits into the header file of MultiMaterialSegmentation. 2024-02-08 15:40:02 +01:00
Lukáš Hejl
fb84f3113a Introduce wrapper class around boost::polygon::voronoi_diagram. 2024-02-08 15:40:02 +01:00
ps_copyright
f32859c302 final copyright headers 2023-09-01 14:49:07 +02:00
Vojtech Bubnik
b655677c95 Fix of some asserts in MM segmentation. 2023-08-29 10:58:13 +02:00
Lukáš Hejl
a469f6aaa1 SPE-1796: Made interlocking to be applied as offset computed from mmu_segmented_region_max_width.
Also, interlocking input is disabled when mmu_segmented_region_max_width is equal to zero.
2023-08-16 11:24:55 +02:00
Lukáš Hejl
9bce0fcf9b SPE-1796: Added option for enabling interlocking between segmented regions by the multimaterial painting. 2023-08-16 11:24:55 +02:00
Vojtech Bubnik
ee626eb65a WIP: Layers split into islands, islands overlapping in Z interconnected
into a graph with links to the layer above / below.

In addition:
Members of LayerRegion were made private, public interface const only.
this->m_xxx replaced with just m_xxx
SurfacesPtr was made a vector of const pointers.
2022-10-26 18:41:39 +02:00
Vojtech Bubnik
2ced762948 Integrating a C++20 like span library
https://github.com/tcbrindle/span

Replacing a homebrew const pointer wrapper const correctness helper
with the C++20 like span library.

One day when we switch to C++20 we will just use the C++20 spans instead.
2022-10-19 16:27:15 +02:00
Lukáš Hejl
5d72f18dc6 Follow-up to a4ecf2f2a6d140a25e9b76e90ae5f4cf8457bd91. Refactoring of the function for removing duplicate points. 2022-02-16 09:20:45 +01:00
Lukáš Hejl
eef741b095 Fixed a copy-paste typo that could lead to duplicate edges in MMU_Graph in the multi-material segmentation. 2022-02-16 09:20:41 +01:00
Lukáš Hejl
a4ecf2f2a6 Replaced smooth_outward in multi-material segmentation with a function that removes duplicate points with angle threshold. It should fix #7838 and #6892.
The main contribution of the smooth_outward function for multi-material segmentation was the removal of duplicate points in polygons using MutablePolygon::remove_duplicates().
But the issue with this function is that it deletes points only based on their distances, which could cause problems like in #7838.
2022-02-07 13:38:22 +01:00
Lukáš Hejl
1aac99b809 Fix of #7618 (Crash in the multi-material segmentation when a negative volume was used on painted areas of a model.) 2022-01-05 11:11:29 +01:00
Lukáš Hejl
9cac904f97 Fix of #7299 (Crash in the multi-material segmentation when some projected triangle is outside the bounding box of the current layer. 2021-11-17 11:44:32 +01:00
Lukáš Hejl
69b7fac01f Fixed a compiler warning. 2021-11-05 23:19:01 +01:00
Lukáš Hejl
f5a6e53298 Fix of #7235 (Dimples in external perimeter after multi-material segmentation) 2021-11-05 22:52:52 +01:00
Lukáš Hejl
b572588fc5 Small refactoring of storing colored polygons in multi-material segmentation.
Previously, colored polygons were stored so that each polygon had a color assigned to it, which made it difficult to perform operations like union or so on all polygons of the same color. Now polygons are stored grouped by their assigned color/extruder.
2021-11-05 22:52:52 +01:00
Lukáš Hejl
54b0ee6a4a Fix of #7112 (Default color sometimes appeared between two multi-material painted areas) 2021-11-02 13:02:00 +01:00
Lukáš Hejl
3eb4ae309a Small refactoring of post-processing of the projected painted lines in multi-material segmentation. 2021-11-02 13:02:00 +01:00
Lukáš Hejl
e04c934253 Added more debug output for multi-material segmentation for debugging projection of the painted lines. 2021-11-02 12:49:46 +01:00
Vojtech Bubnik
cf7b6fb19a Extracted MedialAxis code from Geometry.cpp/hpp, moved to its own
files to Geometry/
Moved other Voronoi files to Geometry/
2021-10-27 16:03:04 +02:00
Lukáš Hejl
3d87904e66 Fixed the bottom layer of multi-material painted objects sunken below the print bed (#7107). 2021-10-25 14:59:05 +02:00
Lukáš Hejl
0791a2b3ed Fix of #7104 (dimples in perimeters after multi-material segmentation) 2021-10-22 11:58:46 +02:00
Vojtech Bubnik
7ff76d0768 New ClipperUtils functions: opening(), closing() as an alternative
for offset2() with clear meaning.
New ClipperUtils functions: expand(), shrink() as an alternative
for offset() with clear meaning.
All offset values for the new functions are positive.

Various offsetting ClipperUtils (offset, offset2, offset2_ex) working
over Polygons were marked as unsafe, sometimes producing invalid output
if called for more than one polygon. These functions were reworked
to offset polygons one by one. The new functions working over Polygons
shall work the same way as the old safe ones working over ExPolygons,
but working with Polygons shall be computationally more efficient.

Improvements in FDM support generator:
1) For both grid and snug supports: Don't filter out supports for which
   the contacts are completely reduced by support / object XY separation.
2) Rounding / merging of supports using the closing radius parameter is
   now smoother, it does not produce sharp corners.
3) Snug supports: When calculating support interfaces, expand the projected
   support contact areas to produce wider, printable and more stable interfaces.
4) Don't reduce support interfaces for snug supports for steep overhangs,
   that would normally not need them. Snug supports often produce very
   narrow support interface regions and turning them off makes the support
   interfaces disappear.
2021-10-14 09:11:31 +02:00
Lukáš Hejl
2f9ce6bedb Fixed incorrect color assignment in multi-material segmentation caused by intersecting edges due to post-processing of Voronoi diagram.
This issue was occurring mainly on the cylinder objects.
2021-10-14 09:39:23 +02:00
Lukáš Hejl
b99be85187 Fixed a warning. 2021-10-07 13:36:06 +02:00
Lukáš Hejl
82bf9c158a Optimized multi-material segmentation to construct Voronoi diagrams only for layers that have more than one color. If the whole layer is painted using the same color, it is not needed to construct a Voronoi diagram. 2021-10-07 13:16:21 +02:00
Vojtech Bubnik
04d6b17c57 Fix of Some FDM supports fail to generate due to wrongly-translated enforcer polygons. #6739
Thanks @n8bot for finding the bug.
Also removed some dead code in MM segmentation.
2021-08-10 09:41:28 +02:00
Lukáš Hejl
b16aada962 Added clipping of finite Voronoi edges that have coordinates that don't fit inside type coord_t. 2021-08-03 13:03:06 +02:00