Commit Graph

49 Commits

Author SHA1 Message Date
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
Lukáš Hejl
93b86da770 Fixed the wrong threshold in the multi-material segmentation. 2021-08-03 13:03:06 +02:00
Lukáš Hejl
da3a0c6332 Fixed a crash in the multi-material segmentation when projected lines are outside of the BoundingBox used for EdgeGrid. 2021-07-29 11:45:02 +02:00
Lukáš Hejl
37f5f12f52 Replaced unnecessary double storing of edges in a graph for the multi-material segmentation by storing indices into a shared array of arcs. 2021-07-29 11:45:02 +02:00
Lukáš Hejl
216589fdb1 Get rid of unnecessary double storage of processed input polygons in the multi-material segmentation as ExPolygons and also as Polygons. All processed input polygons are now stored as ExPolygons. 2021-07-29 11:45:02 +02:00
Lukáš Hejl
2569da95d5 Parallelized the projection of painted regions in multi-material segmentation. 2021-07-29 11:45:01 +02:00
Lukáš Hejl
7a60f1793c Fixed a possible overflowing of a painted area to an unpainted area in multi-material segmentation.
It was reworked graph generation for multi-material segmentation. Now only oriented arcs in one direction are added to the graph for input polygons. This direction matches the direction of the lines in the input polygons.
2021-07-29 11:45:01 +02:00
Vojtech Bubnik
106d9f7ca0 MMU segmentation: Implemented filtering of unprintable regions in
top/bottom propagation.
2021-07-13 14:00:21 +02:00
Vojtech Bubnik
19e3998bd0 Merge branch 'vb_mmu_top_bottom' 2021-07-13 11:08:52 +02:00
Lukáš Hejl
cb93c8ce99 Used function smooth_outward in multi-material segmentation to get rid of artifacts arisen after merging multi-volume objects. 2021-06-28 08:09:06 +02:00
Lukáš Hejl
a426093f12 Replaced boost::rtree in multi-material segmentation with much faster ClosestPointInRadiusLookup. 2021-06-28 08:09:06 +02:00
Lukáš Hejl
ce738102c6 Optimized the projection of painted triangles in multi-material segmentation. Added heuristics to skip most of the expensive calculations in cases where it is certain that performing these calculations would be useless. 2021-06-28 08:09:06 +02:00
Vojtech Bubnik
0d70a2be69 Renamed create_face_neighbors_index() to its_face_edge_ids().
Renamed its_create_neighbors_index() / its_create_neighbors_index_par() to its_face_neighbors() / its_face_neighbors_par().
New variant of its_face_edge_ids() to create edge IDs from face neighbors.
Fixed some incorrect use of _NDEBUG, it should be NDEBUG.
PrintObject::slice_support_volumes() returns newly Polygons, which are cheaper than ExPolygons.
Updated SeamPlacer and SupportMaterial to use regions defined as Polygons, not ExPolygons.
TriangleSelector::get_facets_strict() returning a patch with T-joints retriangulated.
New slice_mesh_slabs() - slicing projections of a triangle patch into top / bottom layers of slices, for MMU top / bottom segmentation.
TriangleMeshSlicer - use 64 mutexes instead of one when scattering sliced triangles into layers. This makes a big difference on modern many core desktop computers.
When applying MM segmented regions to input regions, the split regions are now re-merged with 10x higher positive offset epsilon to avoid creating gaps.
When testing for existence of paint-on supports or seam, use a more efficient has_facets() test, which does not deserialize into the expensive TriangleSelector tree structure.
GLIndexedVertexArray newly uses Eigen::AlignedBox<float, 3> for efficiency instead of our double based BoundingBoxf3.
Improved MMU painting refresh speed by optimizing generation of the vertex buffers.
Refactored MMU segmentation - projection of painted surfaces from top / bottom.
	1) Parallelized.
	2) Using the new slice_mesh_slabs() instead of projecting one triangle by the other and merging them with Clipper.
2021-06-20 15:21:12 +02:00
Lukáš Hejl
684b66125e Fixed an issue where multi-material segmentation ignored the last extruder. 2021-06-17 19:26:40 +02:00
Lukáš Hejl
6ddd88e596 Fixed an issue where the color of the first extruder always replaced the default color after painting in a multi-material gizmo.
multi_material_segmentation_by_painting is now returning only the painted region. Regions with default colors that aren't painted by multi-material gizmo aren't returned.
2021-06-16 06:06:37 +02:00
Lukáš Hejl
c59cf5de40 Fixed layers with the wrong color after multi-material segmentation on objects with multiple objects. 2021-06-16 06:06:34 +02:00
Lukáš Hejl
21b38db488 Added using the move operator in some parts of multi-material segmentation. 2021-06-16 06:06:34 +02:00
Lukáš Hejl
a06e42d01f Moved debug prints out of parallel cycles, and more debug prints were added for multi-material segmentation. 2021-06-16 06:06:34 +02:00
Vojtech Bubnik
8d325008d1 Small MMU segmentation optimization 2021-06-04 08:46:02 +02:00
Lukáš Hejl
726a48383f Cleaned up of 0a6490bab9 2021-05-28 17:36:56 +02:00
Lukáš Hejl
0a6490bab9 Added cancellation to MMU segmentation. 2021-05-28 05:57:32 +02:00
Vojtech Bubnik
409e1c5cc8 Some fixes after preceding merge. Moved mmu_segmented_region_max_width
from PrintConfig to PrintObjectConfig.
2021-05-26 16:14:52 +02:00
Vojtech Bubnik
980ca195f5 Merge remote-tracking branch 'remotes/origin/lh_multi_material_segmentation' into vb_print_regions 2021-05-26 15:23:35 +02:00
Lukáš Hejl
71c60a5187 Follow-up of 168b4afbc2: Replaced forgotten lslices in the top and bottom layer propagation in MMU segmentation. 2021-05-03 22:11:04 +02:00
Lukáš Hejl
cd5fea8b42 Fixed compiler warnings 2021-05-03 21:50:40 +02:00
Lukáš Hejl
2d3eef4e84 Fixed possible warnings 2021-05-03 21:13:13 +02:00
Lukáš Hejl
fa8c319721 Fixed MMU segmentation for cases when a contour was whole colored by one color and a hole was whole colored by a different color. 2021-05-03 21:06:46 +02:00
Lukáš Hejl
5bfdaa7ac8 Parallelization of regions merging for MMU segmentation. 2021-05-03 21:01:52 +02:00
Lukáš Hejl
2e9f0d6eaf Fixed a few cases of missing colored segments in MMU segmentation.
Occasionally, some input polygons contained self-intersections that caused problems with Voronoi diagrams and consequently with the extraction of colored segments by function extract_colored_segments.
Also, occasionally input polygons contained several points very close together (distance between points is 1 or so). Such close points sometimes caused that the Voronoi diagram has self-intersecting edges around these vertices. This consequently leads to issues with the extraction of colored segments by function extract_colored_segments.
2021-05-03 20:56:39 +02:00
Lukáš Hejl
168b4afbc2 Fixed MMU segmentation for multi-volume objects.
MMU segmentation no longer works directly on lslices, instead of it works on custom merged regions. So lslices in PrintObject are no longer overwritten because of MMU segmentation.
All regions are scaled by SCALED_EPSILON before merging and shrunk back by SCALED_EPSILON after merging. That fixed issues with multi-volume objects when very close regions weren't merged.
Also, small expolygons and holes are filtered out that fixed missing segmentation at the boundary of two volumes in the case of multi-volume objects.
2021-05-03 20:37:14 +02:00
Lukáš Hejl
8a19cf9d64 Extended support of MMU segmentation backed for more than three colors.
Serialization and deserialization in TriangleSelector were extended to support up to 16 materials (3 unused states left for possible later extension). These changes also affect the encoding of data from custom supports and seams, but it is backward compatible with the previous encoding. And for custom supports and seams, it is produced exactly the same data encoding as before.
2021-04-27 00:37:49 +02:00
Lukáš Hejl
db55bd706e Fixed case in MMU segmentation when the infinity-edge in the Voronoi diagram has vertex0(), and vertex1() equals nullptr. 2021-04-27 00:36:22 +02:00
Vojtech Bubnik
38bb7d2950 1) New methods PrintObject::num_regions() and ::has_region() to make
the code more readable and to highlight where PrintObject::region_volumes
   are actually set and consumed.
2) Replaced Slic3r::clamp() with std::clamp(). They differ in the order
   of their parameters, thus hopefully no new bugs were introduced.
3) Some refactoring of MultiMaterialSegmentation for efficiency.
2021-04-22 11:41:26 +02:00
Vojtech Bubnik
4f950343c8 MMU segmentation refactoring: Most of the MMU segmentation code
was extracted to its own file.
2021-04-20 15:07:05 +02:00