Commit Graph

47 Commits

Author SHA1 Message Date
aa8eabee88 Fix of #7235 (Dimples in external perimeter after multi-material segmentation) 2021-11-05 22:52:52 +01:00
d17a2c8897 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
4dafbd8f25 Fix of #7112 (Default color sometimes appeared between two multi-material painted areas) 2021-11-02 13:02:00 +01:00
562e08a63c Small refactoring of post-processing of the projected painted lines in multi-material segmentation. 2021-11-02 13:02:00 +01:00
688dc094de Added more debug output for multi-material segmentation for debugging projection of the painted lines. 2021-11-02 12:49:46 +01:00
08bc063f66 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
95c20dbf7d Fixed the bottom layer of multi-material painted objects sunken below the print bed (#7107). 2021-10-25 14:59:05 +02:00
8cc6c8442c Fix of #7104 (dimples in perimeters after multi-material segmentation) 2021-10-22 11:58:46 +02:00
1c626e8596 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
2f8e9f5af4 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
11247aa6ac Fixed a warning. 2021-10-07 13:36:06 +02:00
20ce0abd00 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
3cce6652dd 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
9223fe9291 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
442b999a6d Fixed the wrong threshold in the multi-material segmentation. 2021-08-03 13:03:06 +02:00
5aed500cb4 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
84d84864c9 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
a5d2919c58 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
e96a3df61c Parallelized the projection of painted regions in multi-material segmentation. 2021-07-29 11:45:01 +02:00
ee788d6a72 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
ce92075590 MMU segmentation: Implemented filtering of unprintable regions in
top/bottom propagation.
2021-07-13 14:00:21 +02:00
1a72c78934 Merge branch 'vb_mmu_top_bottom' 2021-07-13 11:08:52 +02:00
309dc55456 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
2f2d9b034e Replaced boost::rtree in multi-material segmentation with much faster ClosestPointInRadiusLookup. 2021-06-28 08:09:06 +02:00
ae27f0d853 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
69ffe12fd2 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
38ef600b7a Fixed an issue where multi-material segmentation ignored the last extruder. 2021-06-17 19:26:40 +02:00
4b82d9b280 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
843048ade8 Fixed layers with the wrong color after multi-material segmentation on objects with multiple objects. 2021-06-16 06:06:34 +02:00
e0973f6a27 Added using the move operator in some parts of multi-material segmentation. 2021-06-16 06:06:34 +02:00
0ce6e666cf 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
473644a94c Small MMU segmentation optimization 2021-06-04 08:46:02 +02:00
0ea67565d6 Cleaned up of 0a6490bab9 2021-05-28 17:36:56 +02:00
ed6bdbd07b Added cancellation to MMU segmentation. 2021-05-28 05:57:32 +02:00
aa6cc8eef7 Some fixes after preceding merge. Moved mmu_segmented_region_max_width
from PrintConfig to PrintObjectConfig.
2021-05-26 16:14:52 +02:00
4809689dcb Merge remote-tracking branch 'remotes/origin/lh_multi_material_segmentation' into vb_print_regions 2021-05-26 15:23:35 +02:00
94364508d1 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
53f6d451ff Fixed compiler warnings 2021-05-03 21:50:40 +02:00
60a1eecd6e Fixed possible warnings 2021-05-03 21:13:13 +02:00
00b369c54c 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
0f7bbd626e Parallelization of regions merging for MMU segmentation. 2021-05-03 21:01:52 +02:00
ea73c79293 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
ff250f5d36 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
8ae1d180c7 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
ea402ff871 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
3ae74a5ca8 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
08d553d411 MMU segmentation refactoring: Most of the MMU segmentation code
was extracted to its own file.
2021-04-20 15:07:05 +02:00