Merge branch 'master' into fs_fixSupportPointProjectionOntoMesh

This commit is contained in:
LAPTOP-R2AR8CRT\filip 2021-02-01 11:28:29 +01:00
commit 212c871af6
51 changed files with 2671 additions and 854 deletions

View File

@ -20,7 +20,7 @@ variants = 0.4
technology = FFF technology = FFF
family = KOSSEL family = KOSSEL
bed_model = AKLP_Bed.stl bed_model = AKLP_Bed.stl
bed_texture = AK.png bed_texture = AK.svg
default_materials = Generic PLA @AKOSSEL; Generic PETG @AKOSSEL; Generic ABS @AKOSSEL default_materials = Generic PLA @AKOSSEL; Generic PETG @AKOSSEL; Generic ABS @AKOSSEL
[printer_model:AK] [printer_model:AK]
@ -29,7 +29,7 @@ variants = 0.4
technology = FFF technology = FFF
family = KOSSEL family = KOSSEL
bed_model = AK_Bed.stl bed_model = AK_Bed.stl
bed_texture = AK.png bed_texture = AK.svg
default_materials = Generic PLA @AKOSSEL; Generic PETG @AKOSSEL; Generic ABS @AKOSSEL default_materials = Generic PLA @AKOSSEL; Generic PETG @AKOSSEL; Generic ABS @AKOSSEL
[printer_model:MEGA0] [printer_model:MEGA0]

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,4 +1,5 @@
min_slic3r_version = 2.3.0-rc2 min_slic3r_version = 2.3.0-rc2
0.0.13 Optimized start and end g-code. General improvements.
0.0.12 Added Ender-3V2 and filament profiles. 0.0.12 Added Ender-3V2 and filament profiles.
min_slic3r_version = 2.3.0-beta2 min_slic3r_version = 2.3.0-beta2
0.0.11 Updated machine limits for Ender 5 and Ender 5 Plus. 0.0.11 Updated machine limits for Ender 5 and Ender 5 Plus.

View File

@ -5,7 +5,7 @@
name = Creality name = Creality
# Configuration version of this file. Config file will only be installed, if the config_version differs. # Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the PrusaSlicer configuration to be downgraded. # This means, the server may force the PrusaSlicer configuration to be downgraded.
config_version = 0.0.12 config_version = 0.0.13
# Where to get the updates from? # Where to get the updates from?
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/Creality/ config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/Creality/
# changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1% # changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1%
@ -21,7 +21,7 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = ender3.svg bed_texture = ender3.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:ENDER3V2] [printer_model:ENDER3V2]
name = Creality Ender-3 V2 name = Creality Ender-3 V2
@ -30,7 +30,7 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = ender3.svg bed_texture = ender3.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:ENDER3BLTOUCH] [printer_model:ENDER3BLTOUCH]
name = Creality Ender-3 BLTouch name = Creality Ender-3 BLTouch
@ -39,7 +39,7 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = ender3.svg bed_texture = ender3.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:ENDER5] [printer_model:ENDER5]
name = Creality Ender-5 name = Creality Ender-5
@ -48,7 +48,7 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = ender3.svg bed_texture = ender3.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:ENDER5PLUS] [printer_model:ENDER5PLUS]
name = Creality Ender-5 Plus name = Creality Ender-5 Plus
@ -57,7 +57,7 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender5plus_bed.stl bed_model = ender5plus_bed.stl
bed_texture = ender5plus.svg bed_texture = ender5plus.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:ENDER2] [printer_model:ENDER2]
name = Creality Ender-2 name = Creality Ender-2
@ -66,7 +66,16 @@ technology = FFF
family = ENDER family = ENDER
bed_model = ender2_bed.stl bed_model = ender2_bed.stl
bed_texture = ender2.svg bed_texture = ender2.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
#[printer_model:CR6SE]
#name = Creality CR-6 SE
#variants = 0.4
#technology = FFF
#family = CR
#bed_model = ender3_bed.stl
#bed_texture = cr20.svg
#default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10MINI] [printer_model:CR10MINI]
name = Creality CR-10 Mini name = Creality CR-10 Mini
@ -75,7 +84,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10mini_bed.stl bed_model = cr10mini_bed.stl
bed_texture = cr10mini.svg bed_texture = cr10mini.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10] [printer_model:CR10]
name = Creality CR-10 name = Creality CR-10
@ -84,7 +93,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10_bed.stl bed_model = cr10_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10V2] [printer_model:CR10V2]
name = Creality CR-10 V2 name = Creality CR-10 V2
@ -93,7 +102,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10v2_bed.stl bed_model = cr10v2_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10V3] [printer_model:CR10V3]
name = Creality CR-10 V3 name = Creality CR-10 V3
@ -102,7 +111,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10v2_bed.stl bed_model = cr10v2_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10S] [printer_model:CR10S]
name = Creality CR-10 S name = Creality CR-10 S
@ -111,7 +120,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10_bed.stl bed_model = cr10_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10SPRO] [printer_model:CR10SPRO]
name = Creality CR-10 S Pro name = Creality CR-10 S Pro
@ -120,7 +129,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10v2_bed.stl bed_model = cr10v2_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10SPROV2] [printer_model:CR10SPROV2]
name = Creality CR-10 S Pro V2 name = Creality CR-10 S Pro V2
@ -129,7 +138,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10v2_bed.stl bed_model = cr10v2_bed.stl
bed_texture = cr10.svg bed_texture = cr10.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10S4] [printer_model:CR10S4]
name = Creality CR-10 S4 name = Creality CR-10 S4
@ -138,7 +147,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10s4_bed.stl bed_model = cr10s4_bed.stl
bed_texture = cr10s4.svg bed_texture = cr10s4.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR10S5] [printer_model:CR10S5]
name = Creality CR-10 S5 name = Creality CR-10 S5
@ -147,7 +156,7 @@ technology = FFF
family = CR family = CR
bed_model = cr10s5_bed.stl bed_model = cr10s5_bed.stl
bed_texture = cr10s5.svg bed_texture = cr10s5.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR20] [printer_model:CR20]
name = Creality CR-20 name = Creality CR-20
@ -156,7 +165,7 @@ technology = FFF
family = CR family = CR
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = cr20.svg bed_texture = cr20.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
[printer_model:CR20PRO] [printer_model:CR20PRO]
name = Creality CR-20 Pro name = Creality CR-20 Pro
@ -165,7 +174,7 @@ technology = FFF
family = CR family = CR
bed_model = ender3_bed.stl bed_model = ender3_bed.stl
bed_texture = cr20.svg bed_texture = cr20.svg
default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA (Galaxy) @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 123-3D Jupiter PLA @CREALITY
# All presets starting with asterisk, for example *common*, are intermediate and they will # All presets starting with asterisk, for example *common*, are intermediate and they will
# not make it into the user interface. # not make it into the user interface.
@ -349,7 +358,14 @@ compatible_printers_condition = printer_model=~/(ENDER|CR).*/ and nozzle_diamete
inherits = *0.28mm* inherits = *0.28mm*
compatible_printers_condition = printer_model=~/(ENDER|CR).*/ and nozzle_diameter[0]==0.4 compatible_printers_condition = printer_model=~/(ENDER|CR).*/ and nozzle_diameter[0]==0.4
# Common filament preset # When submitting new filaments please print the following temperature tower at 0.1mm layer height:
# https://www.thingiverse.com/thing:2615842
# Pay particular attention to bridging, overhangs and retractions.
# Also print the following bed adhesion test at 0.1 layer height as well:
# https://www.prusaprinters.org/prints/4634-bed-adhesion-warp-test
# At least for PLA, please keep bed temp at 60, as many Creality printers do not have any ABL
# So having some leeway to get good bed adhesion is not a luxury for many users
[filament:*common*] [filament:*common*]
cooling = 0 cooling = 0
compatible_printers = compatible_printers =
@ -702,15 +718,17 @@ end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2,
inherits = Creality Ender-3 inherits = Creality Ender-3
renamed_from = "Creality Ender-3V2" renamed_from = "Creality Ender-3V2"
printer_model = ENDER3V2 printer_model = ENDER3V2
printer_variant = 0.4
bed_shape = 0x0,220x0,220x220,0x220 bed_shape = 0x0,220x0,220x220,0x220
# Intended for printers with a smaller bed, like the Ender-3 series
[printer:*fastabl*] [printer:*fastabl*]
start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S120 ; set extruder temp for auto bed leveling\nM140 S[first_layer_bed_temperature] ; set bed temp\nG4 S10 ; wait for partial warmup\nG28 ; home all\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S[first_layer_temperature] ; set extruder temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; intro line\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; intro line\nG92 E0 start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S120 ; set extruder temp for auto bed leveling\nM140 S[first_layer_bed_temperature] ; set bed temp\nG4 S10 ; wait for partial warmup\nG28 ; home all\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S[first_layer_temperature] ; set extruder temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; intro line\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; intro line\nG92 E0
# Intended for printers with a larger bed, like the CR-10 series
[printer:*slowabl*] [printer:*slowabl*]
start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S120 ; set extruder temp for auto bed leveling\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nG28 ; home all\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S[first_layer_temperature] ; set extruder temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; intro line\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; intro line\nG92 E0 start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S120 ; set extruder temp for auto bed leveling\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nG28 ; home all\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S[first_layer_temperature] ; set extruder temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; intro line\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; intro line\nG92 E0
# Intended for printers where the Z-axis lowers the print bed during printing, like the Ender-5 series
[printer:*invertedz*] [printer:*invertedz*]
end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600{endif} ; Move print bed down\nG1 X50 Y50 F{travel_speed*60} ; present print\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+max_print_height-10} F600{endif} ; Move print bed down further down\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600{endif} ; Move print bed down\nG1 X50 Y50 F{travel_speed*60} ; present print\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+max_print_height-10} F600{endif} ; Move print bed down further down\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors
@ -749,6 +767,11 @@ printer_model = ENDER2
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER2\nPRINTER_HAS_BOWDEN printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER2\nPRINTER_HAS_BOWDEN
max_print_height = 200 max_print_height = 200
#[printer:Creality CR-6 SE]
#inherits = Creality Ender-3; *fastabl*
#printer_model = CR6SE
#printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_CR6SE\nPRINTER_HAS_BOWDEN
[printer:Creality CR-10 Mini] [printer:Creality CR-10 Mini]
inherits = Creality Ender-3 inherits = Creality Ender-3
retract_length = 6 retract_length = 6

View File

@ -1483,8 +1483,8 @@ bool EdgeGrid::Grid::has_intersecting_edges() const
void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path, size_t scale) void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path, size_t scale)
{ {
unsigned int w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution; coord_t w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution;
unsigned int h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution; coord_t h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution;
std::vector<uint8_t> pixels(w * h * 3, 0); std::vector<uint8_t> pixels(w * h * 3, 0);

View File

@ -88,10 +88,10 @@ public:
assert(m_bbox.contains(p2)); assert(m_bbox.contains(p2));
p1 -= m_bbox.min; p1 -= m_bbox.min;
p2 -= m_bbox.min; p2 -= m_bbox.min;
assert(p1.x() >= 0 && p1.x() < m_cols * m_resolution); assert(p1.x() >= 0 && size_t(p1.x()) < m_cols * m_resolution);
assert(p1.y() >= 0 && p1.y() < m_rows * m_resolution); assert(p1.y() >= 0 && size_t(p1.y()) < m_rows * m_resolution);
assert(p2.x() >= 0 && p2.x() < m_cols * m_resolution); assert(p2.x() >= 0 && size_t(p2.x()) < m_cols * m_resolution);
assert(p2.y() >= 0 && p2.y() < m_rows * m_resolution); assert(p2.y() >= 0 && size_t(p2.y()) < m_rows * m_resolution);
// Get the cells of the end points. // Get the cells of the end points.
coord_t ix = p1(0) / m_resolution; coord_t ix = p1(0) / m_resolution;
coord_t iy = p1(1) / m_resolution; coord_t iy = p1(1) / m_resolution;
@ -245,12 +245,10 @@ public:
return; return;
} }
std::pair<std::vector<std::pair<size_t, size_t>>::const_iterator, std::vector<std::pair<size_t, size_t>>::const_iterator> cell_data_range(coord_t row, coord_t col) const std::pair<std::vector<std::pair<size_t, size_t>>::const_iterator, std::vector<std::pair<size_t, size_t>>::const_iterator> cell_data_range(coord_t row, coord_t col) const
{ {
assert(row >= 0); assert(row >= 0 && size_t(row) < m_rows);
assert(row < m_rows); assert(col >= 0 && size_t(col) < m_cols);
assert(col >= 0);
assert(col < m_cols);
const EdgeGrid::Grid::Cell &cell = m_cells[row * m_cols + col]; const EdgeGrid::Grid::Cell &cell = m_cells[row * m_cols + col];
return std::make_pair(m_cell_data.begin() + cell.begin, m_cell_data.begin() + cell.end); return std::make_pair(m_cell_data.begin() + cell.begin, m_cell_data.begin() + cell.end);
} }

View File

@ -512,7 +512,6 @@ void Layer::make_ironing()
}; };
std::vector<IroningParams> by_extruder; std::vector<IroningParams> by_extruder;
bool extruder_dont_care = this->object()->config().wipe_into_objects;
double default_layer_height = this->object()->config().layer_height; double default_layer_height = this->object()->config().layer_height;
for (LayerRegion *layerm : m_regions) for (LayerRegion *layerm : m_regions)

View File

@ -160,66 +160,66 @@ bool triangle_AABB_intersects(const Vector &a, const Vector &b, const Vector &c,
return true; return true;
} }
static double dist2_to_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, const Vec3d &p) // static double dist2_to_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, const Vec3d &p)
{ // {
double out = std::numeric_limits<double>::max(); // double out = std::numeric_limits<double>::max();
const Vec3d v1 = b - a; // const Vec3d v1 = b - a;
auto l1 = v1.squaredNorm(); // auto l1 = v1.squaredNorm();
const Vec3d v2 = c - b; // const Vec3d v2 = c - b;
auto l2 = v2.squaredNorm(); // auto l2 = v2.squaredNorm();
const Vec3d v3 = a - c; // const Vec3d v3 = a - c;
auto l3 = v3.squaredNorm(); // auto l3 = v3.squaredNorm();
// Is the triangle valid? // // Is the triangle valid?
if (l1 > 0. && l2 > 0. && l3 > 0.) // if (l1 > 0. && l2 > 0. && l3 > 0.)
{ // {
// 1) Project point into the plane of the triangle. // // 1) Project point into the plane of the triangle.
const Vec3d n = v1.cross(v2); // const Vec3d n = v1.cross(v2);
double d = (p - a).dot(n); // double d = (p - a).dot(n);
const Vec3d foot_pt = p - n * d / n.squaredNorm(); // const Vec3d foot_pt = p - n * d / n.squaredNorm();
// 2) Maximum projection of n. // // 2) Maximum projection of n.
int proj_axis; // int proj_axis;
n.array().cwiseAbs().maxCoeff(&proj_axis); // n.array().cwiseAbs().maxCoeff(&proj_axis);
// 3) Test whether the foot_pt is inside the triangle. // // 3) Test whether the foot_pt is inside the triangle.
{ // {
auto inside_triangle = [](const Vec2d& v1, const Vec2d& v2, const Vec2d& v3, const Vec2d& pt) { // auto inside_triangle = [](const Vec2d& v1, const Vec2d& v2, const Vec2d& v3, const Vec2d& pt) {
const double d1 = cross2(v1, pt); // const double d1 = cross2(v1, pt);
const double d2 = cross2(v2, pt); // const double d2 = cross2(v2, pt);
const double d3 = cross2(v3, pt); // const double d3 = cross2(v3, pt);
// Testing both CCW and CW orientations. // // Testing both CCW and CW orientations.
return (d1 >= 0. && d2 >= 0. && d3 >= 0.) || (d1 <= 0. && d2 <= 0. && d3 <= 0.); // return (d1 >= 0. && d2 >= 0. && d3 >= 0.) || (d1 <= 0. && d2 <= 0. && d3 <= 0.);
}; // };
bool inside; // bool inside;
switch (proj_axis) { // switch (proj_axis) {
case 0: // case 0:
inside = inside_triangle({v1.y(), v1.z()}, {v2.y(), v2.z()}, {v3.y(), v3.z()}, {foot_pt.y(), foot_pt.z()}); break; // inside = inside_triangle({v1.y(), v1.z()}, {v2.y(), v2.z()}, {v3.y(), v3.z()}, {foot_pt.y(), foot_pt.z()}); break;
case 1: // case 1:
inside = inside_triangle({v1.z(), v1.x()}, {v2.z(), v2.x()}, {v3.z(), v3.x()}, {foot_pt.z(), foot_pt.x()}); break; // inside = inside_triangle({v1.z(), v1.x()}, {v2.z(), v2.x()}, {v3.z(), v3.x()}, {foot_pt.z(), foot_pt.x()}); break;
default: // default:
assert(proj_axis == 2); // assert(proj_axis == 2);
inside = inside_triangle({v1.x(), v1.y()}, {v2.x(), v2.y()}, {v3.x(), v3.y()}, {foot_pt.x(), foot_pt.y()}); break; // inside = inside_triangle({v1.x(), v1.y()}, {v2.x(), v2.y()}, {v3.x(), v3.y()}, {foot_pt.x(), foot_pt.y()}); break;
} // }
if (inside) // if (inside)
return (p - foot_pt).squaredNorm(); // return (p - foot_pt).squaredNorm();
} // }
// 4) Find minimum distance to triangle vertices and edges. // // 4) Find minimum distance to triangle vertices and edges.
out = std::min((p - a).squaredNorm(), std::min((p - b).squaredNorm(), (p - c).squaredNorm())); // out = std::min((p - a).squaredNorm(), std::min((p - b).squaredNorm(), (p - c).squaredNorm()));
auto t = (p - a).dot(v1); // auto t = (p - a).dot(v1);
if (t > 0. && t < l1) // if (t > 0. && t < l1)
out = std::min(out, (a + v1 * (t / l1) - p).squaredNorm()); // out = std::min(out, (a + v1 * (t / l1) - p).squaredNorm());
t = (p - b).dot(v2); // t = (p - b).dot(v2);
if (t > 0. && t < l2) // if (t > 0. && t < l2)
out = std::min(out, (b + v2 * (t / l2) - p).squaredNorm()); // out = std::min(out, (b + v2 * (t / l2) - p).squaredNorm());
t = (p - c).dot(v3); // t = (p - c).dot(v3);
if (t > 0. && t < l3) // if (t > 0. && t < l3)
out = std::min(out, (c + v3 * (t / l3) - p).squaredNorm()); // out = std::min(out, (c + v3 * (t / l3) - p).squaredNorm());
} // }
return out; // return out;
} // }
// Ordering of children cubes. // Ordering of children cubes.
static const std::array<Vec3d, 8> child_centers { static const std::array<Vec3d, 8> child_centers {
@ -690,7 +690,8 @@ static void add_hook(
// Trim the hook start by the infill line it will connect to. // Trim the hook start by the infill line it will connect to.
Point hook_start; Point hook_start;
bool intersection_found = intersection.intersect_line->intersection(
[[maybe_unused]] bool intersection_found = intersection.intersect_line->intersection(
create_offset_line(*intersection.closest_line, intersection, scaled_offset), create_offset_line(*intersection.closest_line, intersection, scaled_offset),
&hook_start); &hook_start);
assert(intersection_found); assert(intersection_found);
@ -703,7 +704,7 @@ static void add_hook(
Vector hook_vector = ((hook_length + 1.16 * scaled_trim_distance) * hook_vector_norm).cast<coord_t>(); Vector hook_vector = ((hook_length + 1.16 * scaled_trim_distance) * hook_vector_norm).cast<coord_t>();
Line hook_forward(hook_start, hook_start + hook_vector); Line hook_forward(hook_start, hook_start + hook_vector);
auto filter_itself = [&intersection, &lines_src](const auto &item) { return item.second != intersection.intersect_line - lines_src.data(); }; auto filter_itself = [&intersection, &lines_src](const auto &item) { return item.second != (long unsigned int)(intersection.intersect_line - lines_src.data()); };
std::vector<std::pair<rtree_segment_t, size_t>> hook_intersections; std::vector<std::pair<rtree_segment_t, size_t>> hook_intersections;
rtree.query(bgi::intersects(mk_rtree_seg(hook_forward)) && bgi::satisfies(filter_itself), std::back_inserter(hook_intersections)); rtree.query(bgi::intersects(mk_rtree_seg(hook_forward)) && bgi::satisfies(filter_itself), std::back_inserter(hook_intersections));
@ -1178,7 +1179,8 @@ static Polylines connect_lines_using_hooks(Polylines &&lines, const ExPolygon &b
rtree.query( rtree.query(
bgi::intersects(mk_rtree_seg(first_i_point, nearest_i_point)) && bgi::intersects(mk_rtree_seg(first_i_point, nearest_i_point)) &&
bgi::satisfies([&first_i, &nearest_i, &lines_src](const auto &item) bgi::satisfies([&first_i, &nearest_i, &lines_src](const auto &item)
{ return item.second != first_i.intersect_line - lines_src.data() && item.second != nearest_i.intersect_line - lines_src.data(); }), { return item.second != (long unsigned int)(first_i.intersect_line - lines_src.data())
&& item.second != (long unsigned int)(nearest_i.intersect_line - lines_src.data()); }),
std::back_inserter(closest)); std::back_inserter(closest));
could_connect = closest.empty(); could_connect = closest.empty();
#if 0 #if 0
@ -1252,7 +1254,7 @@ static Polylines connect_lines_using_hooks(Polylines &&lines, const ExPolygon &b
} }
#ifdef ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT #ifdef ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
++ iStep; ++ iStep;
#endif ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT #endif // ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
first_i.used = true; first_i.used = true;
} }
} }
@ -1410,15 +1412,15 @@ void Filler::_fill_surface_single(
#endif /* ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT */ #endif /* ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT */
} }
static double bbox_max_radius(const BoundingBoxf3 &bbox, const Vec3d &center) //static double bbox_max_radius(const BoundingBoxf3 &bbox, const Vec3d &center)
{ //{
const auto p = (bbox.min - center); // const auto p = (bbox.min - center);
const auto s = bbox.size(); // const auto s = bbox.size();
double r2max = 0.; // double r2max = 0.;
for (int i = 0; i < 8; ++ i) // for (int i = 0; i < 8; ++ i)
r2max = std::max(r2max, (p + Vec3d(s.x() * double(i & 1), s.y() * double(i & 2), s.z() * double(i & 4))).squaredNorm()); // r2max = std::max(r2max, (p + Vec3d(s.x() * double(i & 1), s.y() * double(i & 2), s.z() * double(i & 4))).squaredNorm());
return sqrt(r2max); // return sqrt(r2max);
} //}
static std::vector<CubeProperties> make_cubes_properties(double max_cube_edge_length, double line_spacing) static std::vector<CubeProperties> make_cubes_properties(double max_cube_edge_length, double line_spacing)
{ {
@ -1513,8 +1515,10 @@ void Octree::insert_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, Cub
assert(current_cube); assert(current_cube);
assert(depth > 0); assert(depth > 0);
--depth;
// Squared radius of a sphere around the child cube. // Squared radius of a sphere around the child cube.
const double r2_cube = Slic3r::sqr(0.5 * this->cubes_properties[-- depth].height + EPSILON); // const double r2_cube = Slic3r::sqr(0.5 * this->cubes_properties[depth].height + EPSILON);
for (size_t i = 0; i < 8; ++ i) { for (size_t i = 0; i < 8; ++ i) {
const Vec3d &child_center_dir = child_centers[i]; const Vec3d &child_center_dir = child_centers[i];
@ -1532,6 +1536,7 @@ void Octree::insert_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, Cub
} }
Vec3d child_center = current_cube->center + (child_center_dir * (this->cubes_properties[depth].edge_length / 2.)); Vec3d child_center = current_cube->center + (child_center_dir * (this->cubes_properties[depth].edge_length / 2.));
//if (dist2_to_triangle(a, b, c, child_center) < r2_cube) { //if (dist2_to_triangle(a, b, c, child_center) < r2_cube) {
// dist2_to_triangle and r2_cube are commented out too.
if (triangle_AABB_intersects(a, b, c, bbox)) { if (triangle_AABB_intersects(a, b, c, bbox)) {
if (! current_cube->children[i]) if (! current_cube->children[i])
current_cube->children[i] = this->pool.construct(child_center); current_cube->children[i] = this->pool.construct(child_center);

View File

@ -59,7 +59,7 @@ public:
~Filler() override {} ~Filler() override {}
protected: protected:
Fill* clone() const override { return new Filler(*this); }; Fill* clone() const override { return new Filler(*this); }
void _fill_surface_single( void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
@ -73,7 +73,7 @@ protected:
bool no_sort() const override { return false; } bool no_sort() const override { return false; }
}; };
}; // namespace FillAdaptive } // namespace FillAdaptive
} // namespace Slic3r } // namespace Slic3r
#endif // slic3r_FillAdaptive_hpp_ #endif // slic3r_FillAdaptive_hpp_

View File

@ -1170,15 +1170,15 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
// Add these points to the destination contour. // Add these points to the destination contour.
const Polyline &infill_line = infill_ordered[it->second / 2]; const Polyline &infill_line = infill_ordered[it->second / 2];
const Point &pt = (it->second & 1) ? infill_line.points.back() : infill_line.points.front(); const Point &pt = (it->second & 1) ? infill_line.points.back() : infill_line.points.front();
#ifndef NDEBUG //#ifndef NDEBUG
{ // {
const Vec2d pt1 = ipt.cast<double>(); // const Vec2d pt1 = ipt.cast<double>();
const Vec2d pt2 = (idx_point + 1 == contour_src.size() ? contour_src.points.front() : contour_src.points[idx_point + 1]).cast<double>(); // const Vec2d pt2 = (idx_point + 1 == contour_src.size() ? contour_src.points.front() : contour_src.points[idx_point + 1]).cast<double>();
const Vec2d ptx = lerp(pt1, pt2, it->first.t); // const Vec2d ptx = lerp(pt1, pt2, it->first.t);
assert(std::abs(pt.x() - pt.x()) < SCALED_EPSILON); // assert(std::abs(ptx.x() - pt.x()) < SCALED_EPSILON);
assert(std::abs(pt.y() - pt.y()) < SCALED_EPSILON); // assert(std::abs(ptx.y() - pt.y()) < SCALED_EPSILON);
} // }
#endif // NDEBUG //#endif // NDEBUG
size_t idx_tjoint_pt = 0; size_t idx_tjoint_pt = 0;
if (idx_point + 1 < contour_src.size() || pt != contour_dst.front()) { if (idx_point + 1 < contour_src.size() || pt != contour_dst.front()) {
if (pt != contour_dst.back()) if (pt != contour_dst.back())
@ -1261,8 +1261,6 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
std::vector<ConnectionCost> connections_sorted; std::vector<ConnectionCost> connections_sorted;
connections_sorted.reserve(infill_ordered.size() * 2 - 2); connections_sorted.reserve(infill_ordered.size() * 2 - 2);
for (size_t idx_chain = 1; idx_chain < infill_ordered.size(); ++ idx_chain) { for (size_t idx_chain = 1; idx_chain < infill_ordered.size(); ++ idx_chain) {
const Polyline &pl1 = infill_ordered[idx_chain - 1];
const Polyline &pl2 = infill_ordered[idx_chain];
const ContourIntersectionPoint *cp1 = &map_infill_end_point_to_boundary[(idx_chain - 1) * 2 + 1]; const ContourIntersectionPoint *cp1 = &map_infill_end_point_to_boundary[(idx_chain - 1) * 2 + 1];
const ContourIntersectionPoint *cp2 = &map_infill_end_point_to_boundary[idx_chain * 2]; const ContourIntersectionPoint *cp2 = &map_infill_end_point_to_boundary[idx_chain * 2];
if (cp1->contour_idx != boundary_idx_unconnected && cp1->contour_idx == cp2->contour_idx) { if (cp1->contour_idx != boundary_idx_unconnected && cp1->contour_idx == cp2->contour_idx) {
@ -1396,7 +1394,6 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
if (! contour_point.consumed && contour_point.contour_idx != boundary_idx_unconnected) { if (! contour_point.consumed && contour_point.contour_idx != boundary_idx_unconnected) {
const Points &contour = boundary[contour_point.contour_idx]; const Points &contour = boundary[contour_point.contour_idx];
const std::vector<double> &contour_params = boundary_params[contour_point.contour_idx]; const std::vector<double> &contour_params = boundary_params[contour_point.contour_idx];
const size_t contour_pt_idx = contour_point.point_idx;
double lprev = contour_point.could_connect_prev() ? double lprev = contour_point.could_connect_prev() ?
path_length_along_contour_ccw(contour_point.prev_on_contour, &contour_point, contour_params.back()) : path_length_along_contour_ccw(contour_point.prev_on_contour, &contour_point, contour_params.back()) :

View File

@ -515,8 +515,7 @@ static inline bool intersection_on_prev_next_vertical_line_valid(
const SegmentedIntersectionLine &vline_other = segs[side == SegmentIntersection::Side::Right ? (iVerticalLine + 1) : (iVerticalLine - 1)]; const SegmentedIntersectionLine &vline_other = segs[side == SegmentIntersection::Side::Right ? (iVerticalLine + 1) : (iVerticalLine - 1)];
const SegmentIntersection &it_other = vline_other.intersections[iIntersectionOther]; const SegmentIntersection &it_other = vline_other.intersections[iIntersectionOther];
assert(it_other.is_inner()); assert(it_other.is_inner());
assert(iIntersectionOther > 0); assert(iIntersectionOther > 0 && size_t(iIntersectionOther + 1) < vline_other.intersections.size());
assert(iIntersectionOther + 1 < vline_other.intersections.size());
// Is iIntersectionOther at the boundary of a vertical segment? // Is iIntersectionOther at the boundary of a vertical segment?
const SegmentIntersection &it_other2 = vline_other.intersections[it_other.is_low() ? iIntersectionOther - 1 : iIntersectionOther + 1]; const SegmentIntersection &it_other2 = vline_other.intersections[it_other.is_low() ? iIntersectionOther - 1 : iIntersectionOther + 1];
if (it_other2.is_inner()) if (it_other2.is_inner())
@ -1176,8 +1175,7 @@ static void pinch_contours_insert_phony_outer_intersections(std::vector<Segmente
assert(it->type == SegmentIntersection::OUTER_LOW); assert(it->type == SegmentIntersection::OUTER_LOW);
++ it; ++ it;
} else { } else {
auto lo = it; assert(it->type == SegmentIntersection::INNER_LOW);
assert(lo->type == SegmentIntersection::INNER_LOW);
auto hi = ++ it; auto hi = ++ it;
assert(hi->type == SegmentIntersection::INNER_HIGH); assert(hi->type == SegmentIntersection::INNER_HIGH);
auto lo2 = ++ it; auto lo2 = ++ it;
@ -1186,11 +1184,11 @@ static void pinch_contours_insert_phony_outer_intersections(std::vector<Segmente
// In that case one shall insert a phony OUTER_HIGH / OUTER_LOW pair. // In that case one shall insert a phony OUTER_HIGH / OUTER_LOW pair.
int up = hi->vertical_up(); int up = hi->vertical_up();
int dn = lo2->vertical_down(); int dn = lo2->vertical_down();
#ifndef _NDEBUG
assert(up == -1 || up > 0); assert(up == -1 || up > 0);
assert(dn == -1 || dn >= 0); assert(dn == -1 || dn >= 0);
assert((up == -1 && dn == -1) || (dn + 1 == up)); assert((up == -1 && dn == -1) || (dn + 1 == up));
#endif // _NDEBUG
bool pinched = dn + 1 != up; bool pinched = dn + 1 != up;
if (pinched) { if (pinched) {
// hi is not connected with its inner contour to lo2. // hi is not connected with its inner contour to lo2.
@ -1267,10 +1265,6 @@ static const SegmentIntersection& end_of_vertical_run_raw(const SegmentIntersect
} }
return *it; return *it;
} }
static SegmentIntersection& end_of_vertical_run_raw(SegmentIntersection &start)
{
return const_cast<SegmentIntersection&>(end_of_vertical_run_raw(std::as_const(start)));
}
// Find the last INNER_HIGH intersection starting with INNER_LOW, that is followed by OUTER_HIGH intersection, traversing vertical up contours if enabled. // Find the last INNER_HIGH intersection starting with INNER_LOW, that is followed by OUTER_HIGH intersection, traversing vertical up contours if enabled.
// Such intersection shall always exist. // Such intersection shall always exist.
@ -1383,7 +1377,7 @@ static void traverse_graph_generate_polylines(
bool try_connect = false; bool try_connect = false;
if (going_up) { if (going_up) {
assert(! it->consumed_vertical_up); assert(! it->consumed_vertical_up);
assert(i_intersection + 1 < vline.intersections.size()); assert(size_t(i_intersection + 1) < vline.intersections.size());
// Step back to the beginning of the vertical segment to mark it as consumed. // Step back to the beginning of the vertical segment to mark it as consumed.
if (it->is_inner()) { if (it->is_inner()) {
assert(i_intersection > 0); assert(i_intersection > 0);
@ -1395,7 +1389,7 @@ static void traverse_graph_generate_polylines(
it->consumed_vertical_up = true; it->consumed_vertical_up = true;
++ it; ++ it;
++ i_intersection; ++ i_intersection;
assert(i_intersection < vline.intersections.size()); assert(size_t(i_intersection) < vline.intersections.size());
} while (it->type != SegmentIntersection::OUTER_HIGH); } while (it->type != SegmentIntersection::OUTER_HIGH);
if ((it - 1)->is_inner()) { if ((it - 1)->is_inner()) {
// Step back. // Step back.
@ -1815,7 +1809,7 @@ static std::vector<MonotonicRegion> generate_montonous_regions(std::vector<Segme
return false; return false;
}; };
#else #else
auto test_overlap = [](int, int, int) { return false; }; [[maybe_unused]] auto test_overlap = [](int, int, int) { return false; };
#endif #endif
for (int i_vline_seed = 0; i_vline_seed < int(segs.size()); ++ i_vline_seed) { for (int i_vline_seed = 0; i_vline_seed < int(segs.size()); ++ i_vline_seed) {
@ -2033,8 +2027,7 @@ static void connect_monotonic_regions(std::vector<MonotonicRegion> &regions, con
map_intersection_to_region_end.emplace_back(&segs[region.right.vline].intersections[region.right.low], &region); map_intersection_to_region_end.emplace_back(&segs[region.right.vline].intersections[region.right.low], &region);
} }
auto intersections_lower = [](const MapType &l, const MapType &r){ return l.first < r.first ; }; auto intersections_lower = [](const MapType &l, const MapType &r){ return l.first < r.first ; };
auto intersections_equal = [](const MapType &l, const MapType &r){ return l.first == r.first ; }; std::sort(map_intersection_to_region_start.begin(), map_intersection_to_region_start.end(), intersections_lower);
std::sort(map_intersection_to_region_start.begin(), map_intersection_to_region_start.end(), intersections_lower);
std::sort(map_intersection_to_region_end.begin(), map_intersection_to_region_end.end(), intersections_lower); std::sort(map_intersection_to_region_end.begin(), map_intersection_to_region_end.end(), intersections_lower);
// Scatter links to neighboring regions. // Scatter links to neighboring regions.
@ -2185,15 +2178,15 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
float best_path_length = std::numeric_limits<float>::max(); float best_path_length = std::numeric_limits<float>::max();
struct NextCandidate { struct NextCandidate {
MonotonicRegion *region; MonotonicRegion *region = nullptr;
AntPath *link; AntPath *link;
AntPath *link_flipped; AntPath *link_flipped;
float probability; float probability;
bool dir; bool dir = false;
}; };
std::vector<NextCandidate> next_candidates; std::vector<NextCandidate> next_candidates;
auto validate_unprocessed = [[maybe_unused]]auto validate_unprocessed =
#ifdef NDEBUG #ifdef NDEBUG
[]() { return true; }; []() { return true; };
#else #else
@ -2222,7 +2215,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
} else { } else {
// Some left neihgbor should not be processed yet. // Some left neihgbor should not be processed yet.
assert(left_neighbors_unprocessed[i] > 1); assert(left_neighbors_unprocessed[i] > 1);
size_t num_predecessors_unprocessed = 0; int32_t num_predecessors_unprocessed = 0;
bool has_left_last_on_path = false; bool has_left_last_on_path = false;
for (const MonotonicRegion* left : region.left_neighbors) { for (const MonotonicRegion* left : region.left_neighbors) {
size_t iprev = left - regions.data(); size_t iprev = left - regions.data();
@ -2290,8 +2283,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
NextCandidate next_candidate; NextCandidate next_candidate;
next_candidate.probability = 0; next_candidate.probability = 0;
for (MonotonicRegion *next : region.right_neighbors) { for (MonotonicRegion *next : region.right_neighbors) {
int &unprocessed = left_neighbors_unprocessed[next - regions.data()]; assert(left_neighbors_unprocessed[next - regions.data()] > 1);
assert(unprocessed > 1);
if (left_neighbors_unprocessed[next - regions.data()] == 2) { if (left_neighbors_unprocessed[next - regions.data()] == 2) {
// Dependencies of the successive blocks are satisfied. // Dependencies of the successive blocks are satisfied.
AntPath &path1 = path_matrix(region, dir, *next, false); AntPath &path1 = path_matrix(region, dir, *next, false);
@ -2325,6 +2317,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
queue.pop_back(); queue.pop_back();
} }
// Extend the path. // Extend the path.
assert(next_candidate.region);
MonotonicRegion *next_region = next_candidate.region; MonotonicRegion *next_region = next_candidate.region;
bool next_dir = next_candidate.dir; bool next_dir = next_candidate.dir;
total_length += next_region->length(next_dir) + path_matrix(*path_end.region, path_end.flipped, *next_region, next_dir).length; total_length += next_region->length(next_dir) + path_matrix(*path_end.region, path_end.flipped, *next_region, next_dir).length;
@ -2844,8 +2837,6 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface *surface, FillPar
coord_t line_spacing = coord_t(scale_(this->spacing) / params.density); coord_t line_spacing = coord_t(scale_(this->spacing) / params.density);
std::pair<float, Point> rotate_vector = this->_infill_direction(surface); std::pair<float, Point> rotate_vector = this->_infill_direction(surface);
for (const SweepParams &sweep : sweep_params) { for (const SweepParams &sweep : sweep_params) {
size_t n_fill_lines_initial = fill_lines.size();
// Rotate polygons so that we can work with vertical lines here // Rotate polygons so that we can work with vertical lines here
double angle = rotate_vector.first + sweep.angle_base; double angle = rotate_vector.first + sweep.angle_base;
ExPolygonWithOffset poly_with_offset(poly_with_offset_base, - angle); ExPolygonWithOffset poly_with_offset(poly_with_offset_base, - angle);

View File

@ -50,11 +50,6 @@ const std::string GCodeProcessor::Width_Tag = "WIDTH:";
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:"; const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:";
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
static bool is_valid_extrusion_role(int value)
{
return (static_cast<int>(erNone) <= value) && (value <= static_cast<int>(erMixed));
}
static void set_option_value(ConfigOptionFloats& option, size_t id, float value) static void set_option_value(ConfigOptionFloats& option, size_t id, float value)
{ {
if (id < option.values.size()) if (id < option.values.size())
@ -2343,7 +2338,7 @@ void GCodeProcessor::process_T(const GCodeReader::GCodeLine& line)
void GCodeProcessor::process_T(const std::string_view command) void GCodeProcessor::process_T(const std::string_view command)
{ {
if (command.length() > 1) { if (command.length() > 1) {
int eid; int eid = 0;
if (! parse_number(command.substr(1), eid) || eid < 0 || eid > 255) { if (! parse_number(command.substr(1), eid) || eid < 0 || eid > 255) {
// T-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools) see https://github.com/prusa3d/PrusaSlicer/issues/5677 // T-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools) see https://github.com/prusa3d/PrusaSlicer/issues/5677
if ((m_flavor != gcfRepRapFirmware && m_flavor != gcfRepRapSprinter) || eid != -1) if ((m_flavor != gcfRepRapFirmware && m_flavor != gcfRepRapSprinter) || eid != -1)

View File

@ -59,7 +59,7 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollec
const PrintRegionConfig &region_config = this->region()->config(); const PrintRegionConfig &region_config = this->region()->config();
// This needs to be in sync with PrintObject::_slice() slicing_mode_normal_below_layer! // This needs to be in sync with PrintObject::_slice() slicing_mode_normal_below_layer!
bool spiral_vase = print_config.spiral_vase && bool spiral_vase = print_config.spiral_vase &&
(this->layer()->id() >= region_config.bottom_solid_layers.value && (this->layer()->id() >= size_t(region_config.bottom_solid_layers.value) &&
this->layer()->print_z >= region_config.bottom_solid_min_thickness - EPSILON); this->layer()->print_z >= region_config.bottom_solid_min_thickness - EPSILON);
PerimeterGenerator g( PerimeterGenerator g(

View File

@ -166,7 +166,7 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
(float)perimeter_generator.layer_height); (float)perimeter_generator.layer_height);
// get overhang paths by checking what parts of this loop fall // get overhang paths by checking what parts of this loop fall
// outside the grown lower slices (thus where the distance between // outside the grown lower slices (thus where the distance between
// the loop centerline and original lower slices is >= half nozzle diameter // the loop centerline and original lower slices is >= half nozzle diameter
extrusion_paths_append( extrusion_paths_append(
paths, paths,
@ -396,8 +396,8 @@ void PerimeterGenerator::process()
} }
// fuzzy skin configuration // fuzzy skin configuration
double fuzzy_skin_thickness; double fuzzy_skin_thickness = scale_(this->object_config->fuzzy_skin_thickness);
double fuzzy_skin_point_dist; double fuzzy_skin_point_dist = scale_(this->object_config->fuzzy_skin_point_dist);
//FuzzyShape fuzzy_skin_shape; //FuzzyShape fuzzy_skin_shape;
if (this->object_config->fuzzy_skin_perimeter_mode != FuzzySkinPerimeterMode::None) { if (this->object_config->fuzzy_skin_perimeter_mode != FuzzySkinPerimeterMode::None) {
/* /*
@ -419,8 +419,6 @@ void PerimeterGenerator::process()
break; break;
} }
*/ */
fuzzy_skin_thickness = scale_(this->object_config->fuzzy_skin_thickness);
fuzzy_skin_point_dist = scale_(this->object_config->fuzzy_skin_point_dist);
} }
// we need to process each island separately because we might have different // we need to process each island separately because we might have different

View File

@ -417,7 +417,7 @@ namespace boost { namespace polygon {
typedef coord_t coordinate_type; typedef coord_t coordinate_type;
static inline coordinate_type get(const Slic3r::Point& point, orientation_2d orient) { static inline coordinate_type get(const Slic3r::Point& point, orientation_2d orient) {
return (coordinate_type)point((orient == HORIZONTAL) ? 0 : 1); return static_cast<coordinate_type>(point((orient == HORIZONTAL) ? 0 : 1));
} }
}; };

View File

@ -800,10 +800,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
compatible_printers_condition = compatible_printers_condition_values[1]; compatible_printers_condition = compatible_printers_condition_values[1];
compatible_prints_condition = compatible_prints_condition_values.front(); compatible_prints_condition = compatible_prints_condition_values.front();
Preset *loaded = nullptr; Preset *loaded = nullptr;
if (is_external) { if (is_external)
auto [aloaded, modified] = this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config); loaded = this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config).first;
loaded = aloaded; else {
} else {
// called from Config Wizard. // called from Config Wizard.
loaded= &this->filaments.load_preset(this->filaments.path_from_name(name), name, config); loaded= &this->filaments.load_preset(this->filaments.path_from_name(name), name, config);
loaded->save(); loaded->save();
@ -1145,33 +1144,26 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
for (const auto &section : tree) { for (const auto &section : tree) {
PresetCollection *presets = nullptr; PresetCollection *presets = nullptr;
std::vector<std::string> *loaded = nullptr;
std::string preset_name; std::string preset_name;
PhysicalPrinterCollection *ph_printers = nullptr; PhysicalPrinterCollection *ph_printers = nullptr;
std::string ph_printer_name; std::string ph_printer_name;
if (boost::starts_with(section.first, "print:")) { if (boost::starts_with(section.first, "print:")) {
presets = &this->prints; presets = &this->prints;
loaded = &loaded_prints;
preset_name = section.first.substr(6); preset_name = section.first.substr(6);
} else if (boost::starts_with(section.first, "filament:")) { } else if (boost::starts_with(section.first, "filament:")) {
presets = &this->filaments; presets = &this->filaments;
loaded = &loaded_filaments;
preset_name = section.first.substr(9); preset_name = section.first.substr(9);
} else if (boost::starts_with(section.first, "sla_print:")) { } else if (boost::starts_with(section.first, "sla_print:")) {
presets = &this->sla_prints; presets = &this->sla_prints;
loaded = &loaded_sla_prints;
preset_name = section.first.substr(10); preset_name = section.first.substr(10);
} else if (boost::starts_with(section.first, "sla_material:")) { } else if (boost::starts_with(section.first, "sla_material:")) {
presets = &this->sla_materials; presets = &this->sla_materials;
loaded = &loaded_sla_materials;
preset_name = section.first.substr(13); preset_name = section.first.substr(13);
} else if (boost::starts_with(section.first, "printer:")) { } else if (boost::starts_with(section.first, "printer:")) {
presets = &this->printers; presets = &this->printers;
loaded = &loaded_printers;
preset_name = section.first.substr(8); preset_name = section.first.substr(8);
} else if (boost::starts_with(section.first, "physical_printer:")) { } else if (boost::starts_with(section.first, "physical_printer:")) {
ph_printers = &this->physical_printers; ph_printers = &this->physical_printers;
loaded = &loaded_physical_printers;
ph_printer_name = section.first.substr(17); ph_printer_name = section.first.substr(17);
} else if (section.first == "presets") { } else if (section.first == "presets") {
// Load the names of the active presets. // Load the names of the active presets.

View File

@ -2143,6 +2143,16 @@ std::vector<ExPolygons> PrintObject::slice_support_volumes(const ModelVolumeType
return this->slice_volumes(zs, SlicingMode::Regular, volumes); return this->slice_volumes(zs, SlicingMode::Regular, volumes);
} }
//FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it.
static void fix_mesh_connectivity(TriangleMesh &mesh)
{
auto nr_degenerated = mesh.stl.stats.degenerate_facets;
stl_check_facets_exact(&mesh.stl);
if (nr_degenerated != mesh.stl.stats.degenerate_facets)
// stl_check_facets_exact() removed some newly degenerated faces. Some faces could become degenerate after some mesh transformation.
stl_generate_shared_vertices(&mesh.stl, mesh.its);
}
std::vector<ExPolygons> PrintObject::slice_volumes( std::vector<ExPolygons> PrintObject::slice_volumes(
const std::vector<float> &z, const std::vector<float> &z,
SlicingMode mode, size_t slicing_mode_normal_below_layer, SlicingMode mode_below, SlicingMode mode, size_t slicing_mode_normal_below_layer, SlicingMode mode_below,
@ -2155,10 +2165,8 @@ std::vector<ExPolygons> PrintObject::slice_volumes(
TriangleMesh mesh(volumes.front()->mesh()); TriangleMesh mesh(volumes.front()->mesh());
mesh.transform(volumes.front()->get_matrix(), true); mesh.transform(volumes.front()->get_matrix(), true);
assert(mesh.repaired); assert(mesh.repaired);
if (volumes.size() == 1 && mesh.repaired) { if (volumes.size() == 1 && mesh.repaired)
//FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it. fix_mesh_connectivity(mesh);
stl_check_facets_exact(&mesh.stl);
}
for (size_t idx_volume = 1; idx_volume < volumes.size(); ++ idx_volume) { for (size_t idx_volume = 1; idx_volume < volumes.size(); ++ idx_volume) {
const ModelVolume &model_volume = *volumes[idx_volume]; const ModelVolume &model_volume = *volumes[idx_volume];
TriangleMesh vol_mesh(model_volume.mesh()); TriangleMesh vol_mesh(model_volume.mesh());
@ -2191,10 +2199,8 @@ std::vector<ExPolygons> PrintObject::slice_volume(const std::vector<float> &z, S
//FIXME better to split the mesh into separate shells, perform slicing over each shell separately and then to use a Boolean operation to merge them. //FIXME better to split the mesh into separate shells, perform slicing over each shell separately and then to use a Boolean operation to merge them.
TriangleMesh mesh(volume.mesh()); TriangleMesh mesh(volume.mesh());
mesh.transform(volume.get_matrix(), true); mesh.transform(volume.get_matrix(), true);
if (mesh.repaired) { if (mesh.repaired)
//FIXME The admesh repair function may break the face connectivity, rather refresh it here as the slicing code relies on it. fix_mesh_connectivity(mesh);
stl_check_facets_exact(&mesh.stl);
}
if (mesh.stl.stats.number_of_facets > 0) { if (mesh.stl.stats.number_of_facets > 0) {
mesh.transform(m_trafo, true); mesh.transform(m_trafo, true);
// apply XY shift // apply XY shift

View File

@ -319,8 +319,6 @@ void SupportPointGenerator::add_support_points(SupportPointGenerator::Structure
float tp = m_config.tear_pressure(); float tp = m_config.tear_pressure();
float current = s.supports_force_total(); float current = s.supports_force_total();
static constexpr float DANGL_DAMPING = .5f;
static constexpr float SLOPE_DAMPING = .1f;
if (s.islands_below.empty()) { if (s.islands_below.empty()) {
// completely new island - needs support no doubt // completely new island - needs support no doubt

View File

@ -21,7 +21,7 @@ template<typename EndPointType, typename KDTreeType, typename CouldReverseFunc>
std::vector<std::pair<size_t, bool>> chain_segments_closest_point(std::vector<EndPointType> &end_points, KDTreeType &kdtree, CouldReverseFunc &could_reverse_func, EndPointType &first_point) std::vector<std::pair<size_t, bool>> chain_segments_closest_point(std::vector<EndPointType> &end_points, KDTreeType &kdtree, CouldReverseFunc &could_reverse_func, EndPointType &first_point)
{ {
assert((end_points.size() & 1) == 0); assert((end_points.size() & 1) == 0);
size_t num_segments = end_points.size() / 2; size_t num_segments = end_points.size() / 2;
assert(num_segments >= 2); assert(num_segments >= 2);
for (EndPointType &ep : end_points) for (EndPointType &ep : end_points)
ep.chain_id = 0; ep.chain_id = 0;
@ -1553,9 +1553,8 @@ static inline void reorder_by_two_exchanges_with_segment_flipping(std::vector<Fl
size_t crossover1_pos_final = std::numeric_limits<size_t>::max(); size_t crossover1_pos_final = std::numeric_limits<size_t>::max();
size_t crossover2_pos_final = std::numeric_limits<size_t>::max(); size_t crossover2_pos_final = std::numeric_limits<size_t>::max();
size_t crossover_flip_final = 0; size_t crossover_flip_final = 0;
for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) { for (const std::pair<double, size_t>& first_crossover_candidate : connection_lengths) {
double longest_connection_length = first_crossover_candidate.first; size_t longest_connection_idx = first_crossover_candidate.second;
size_t longest_connection_idx = first_crossover_candidate.second;
connection_tried[longest_connection_idx] = true; connection_tried[longest_connection_idx] = true;
// Find the second crossover connection with the lowest total chain cost. // Find the second crossover connection with the lowest total chain cost.
size_t crossover_pos_min = std::numeric_limits<size_t>::max(); size_t crossover_pos_min = std::numeric_limits<size_t>::max();
@ -1630,12 +1629,10 @@ static inline void reorder_by_three_exchanges_with_segment_flipping(std::vector<
size_t crossover2_pos_final = std::numeric_limits<size_t>::max(); size_t crossover2_pos_final = std::numeric_limits<size_t>::max();
size_t crossover3_pos_final = std::numeric_limits<size_t>::max(); size_t crossover3_pos_final = std::numeric_limits<size_t>::max();
size_t crossover_flip_final = 0; size_t crossover_flip_final = 0;
for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) { for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) {
double longest_connection_length = first_crossover_candidate.first; size_t longest_connection_idx = first_crossover_candidate.second;
size_t longest_connection_idx = first_crossover_candidate.second; connection_tried[longest_connection_idx] = true;
connection_tried[longest_connection_idx] = true;
// Find the second crossover connection with the lowest total chain cost. // Find the second crossover connection with the lowest total chain cost.
size_t crossover_pos_min = std::numeric_limits<size_t>::max();
double crossover_cost_min = connections.back().cost; double crossover_cost_min = connections.back().cost;
for (size_t j = 1; j < connections.size(); ++ j) for (size_t j = 1; j < connections.size(); ++ j)
if (! connection_tried[j]) { if (! connection_tried[j]) {
@ -1789,12 +1786,10 @@ static inline void reorder_by_three_exchanges_with_segment_flipping2(std::vector
#else /* NDEBUG */ #else /* NDEBUG */
Matrixd segment_end_point_distance_matrix = Matrixd::Constant(4 * 4, 4 * 4, std::numeric_limits<double>::max()); Matrixd segment_end_point_distance_matrix = Matrixd::Constant(4 * 4, 4 * 4, std::numeric_limits<double>::max());
#endif /* NDEBUG */ #endif /* NDEBUG */
for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) { for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) {
double longest_connection_length = first_crossover_candidate.first; size_t longest_connection_idx = first_crossover_candidate.second;
size_t longest_connection_idx = first_crossover_candidate.second; connection_tried[longest_connection_idx] = true;
connection_tried[longest_connection_idx] = true; // Find the second crossover connection with the lowest total chain cost.
// Find the second crossover connection with the lowest total chain cost.
size_t crossover_pos_min = std::numeric_limits<size_t>::max();
double crossover_cost_min = connections.back().cost; double crossover_cost_min = connections.back().cost;
for (size_t j = 1; j < connections.size(); ++ j) for (size_t j = 1; j < connections.size(); ++ j)
if (! connection_tried[j]) { if (! connection_tried[j]) {

File diff suppressed because it is too large Load Diff

View File

@ -9,16 +9,136 @@
namespace Slic3r { namespace Slic3r {
namespace Voronoi {
using VD = Slic3r::Geometry::VoronoiDiagram;
inline const Point& contour_point(const VD::cell_type &cell, const Line &line)
{ return ((cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line.a : line.b); }
inline Point& contour_point(const VD::cell_type &cell, Line &line)
{ return ((cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line.a : line.b); }
inline const Point& contour_point(const VD::cell_type &cell, const Lines &lines)
{ return contour_point(cell, lines[cell.source_index()]); }
inline Point& contour_point(const VD::cell_type &cell, Lines &lines)
{ return contour_point(cell, lines[cell.source_index()]); }
inline Vec2d vertex_point(const VD::vertex_type &v) { return Vec2d(v.x(), v.y()); }
inline Vec2d vertex_point(const VD::vertex_type *v) { return Vec2d(v->x(), v->y()); }
// "Color" stored inside the boost::polygon Voronoi vertex.
enum class VertexCategory : unsigned char
{
// Voronoi vertex is on the input contour.
// VD::vertex_type stores coordinates in double, though the coordinates shall match exactly
// with the coordinates of the input contour when converted to int32_t.
OnContour,
// Vertex is inside the CCW input contour, holes are respected.
Inside,
// Vertex is outside the CCW input contour, holes are respected.
Outside,
// Not known yet.
Unknown,
};
// "Color" stored inside the boost::polygon Voronoi edge.
// The Voronoi edge as represented by boost::polygon Voronoi module is really a half-edge,
// the half-edges are classified based on the target vertex (VD::vertex_type::vertex1())
enum class EdgeCategory : unsigned char
{
// This half-edge points onto the contour, this VD::edge_type::vertex1().color() is OnContour.
PointsToContour,
// This half-edge points inside, this VD::edge_type::vertex1().color() is Inside.
PointsInside,
// This half-edge points outside, this VD::edge_type::vertex1().color() is Outside.
PointsOutside,
// Not known yet.
Unknown
};
// "Color" stored inside the boost::polygon Voronoi cell.
enum class CellCategory : unsigned char
{
// This Voronoi cell is split by an input segment to two halves, one is inside, the other is outside.
Boundary,
// This Voronoi cell is completely inside.
Inside,
// This Voronoi cell is completely outside.
Outside,
// Not known yet.
Unknown
};
inline VertexCategory vertex_category(const VD::vertex_type &v)
{ return static_cast<VertexCategory>(v.color()); }
inline VertexCategory vertex_category(const VD::vertex_type *v)
{ return static_cast<VertexCategory>(v->color()); }
inline void set_vertex_category(VD::vertex_type &v, VertexCategory c)
{ v.color(static_cast<VD::vertex_type::color_type>(c)); }
inline void set_vertex_category(VD::vertex_type *v, VertexCategory c)
{ v->color(static_cast<VD::vertex_type::color_type>(c)); }
inline EdgeCategory edge_category(const VD::edge_type &e)
{ return static_cast<EdgeCategory>(e.color()); }
inline EdgeCategory edge_category(const VD::edge_type *e)
{ return static_cast<EdgeCategory>(e->color()); }
inline void set_edge_category(VD::edge_type &e, EdgeCategory c)
{ e.color(static_cast<VD::edge_type::color_type>(c)); }
inline void set_edge_category(VD::edge_type *e, EdgeCategory c)
{ e->color(static_cast<VD::edge_type::color_type>(c)); }
inline CellCategory cell_category(const VD::cell_type &v)
{ return static_cast<CellCategory>(v.color()); }
inline CellCategory cell_category(const VD::cell_type *v)
{ return static_cast<CellCategory>(v->color()); }
inline void set_cell_category(const VD::cell_type &v, CellCategory c)
{ v.color(static_cast<VD::cell_type::color_type>(c)); }
inline void set_cell_category(const VD::cell_type *v, CellCategory c)
{ v->color(static_cast<VD::cell_type::color_type>(c)); }
// Mark the "Color" of VD vertices, edges and cells as Unknown.
void reset_inside_outside_annotations(VD &vd);
// Assign "Color" to VD vertices, edges and cells signifying whether the entity is inside or outside
// the input polygons defined by Lines.
void annotate_inside_outside(VD &vd, const Lines &lines);
// Returns a signed distance to Voronoi vertices from the input polygons.
// (negative distances inside, positive distances outside).
std::vector<double> signed_vertex_distances(const VD &vd, const Lines &lines);
static inline bool edge_offset_no_intersection(const Vec2d &intersection_point)
{ return std::isnan(intersection_point.x()); }
static inline bool edge_offset_has_intersection(const Vec2d &intersection_point)
{ return ! edge_offset_no_intersection(intersection_point); }
std::vector<Vec2d> edge_offset_contour_intersections(
const VD &vd, const Lines &lines, const std::vector<double> &distances,
double offset_distance);
std::vector<Vec2d> skeleton_edges_rough(
const VD &vd,
const Lines &lines,
const double threshold_alpha);
Polygons offset(
const Geometry::VoronoiDiagram &vd,
const Lines &lines,
const std::vector<double> &signed_vertex_distances,
double offset_distance,
double discretization_error);
// Offset a polygon or a set of polygons possibly with holes by traversing a Voronoi diagram. // Offset a polygon or a set of polygons possibly with holes by traversing a Voronoi diagram.
// The input polygons are stored in lines and lines are referenced by vd. // The input polygons are stored in lines and lines are referenced by vd.
// Outer curve will be extracted for a positive offset_distance, // Outer curve will be extracted for a positive offset_distance,
// inner curve will be extracted for a negative offset_distance. // inner curve will be extracted for a negative offset_distance.
// Circular arches will be discretized to achieve discretization_error. // Circular arches will be discretized to achieve discretization_error.
Polygons voronoi_offset( Polygons offset(
const Geometry::VoronoiDiagram &vd, const VD &vd,
const Lines &lines, const Lines &lines,
double offset_distance, double offset_distance,
double discretization_error); double discretization_error);
} // namespace Voronoi
} // namespace Slic3r } // namespace Slic3r

View File

@ -5,6 +5,8 @@
#include <libslic3r/Polygon.hpp> #include <libslic3r/Polygon.hpp>
#include <libslic3r/SVG.hpp> #include <libslic3r/SVG.hpp>
#include "VoronoiOffset.hpp"
namespace boost { namespace polygon { namespace boost { namespace polygon {
// The following code for the visualization of the boost Voronoi diagram is based on: // The following code for the visualization of the boost Voronoi diagram is based on:
@ -70,6 +72,7 @@ class voronoi_visual_utils {
get_point_projection((*discretization)[0], segment); get_point_projection((*discretization)[0], segment);
CT projection_end = sqr_segment_length * CT projection_end = sqr_segment_length *
get_point_projection((*discretization)[1], segment); get_point_projection((*discretization)[1], segment);
assert(projection_start != projection_end);
// Compute parabola parameters in the transformed space. // Compute parabola parameters in the transformed space.
// Parabola has next representation: // Parabola has next representation:
@ -99,13 +102,16 @@ class voronoi_visual_utils {
// furthest from the current line segment. // furthest from the current line segment.
CT mid_x = (new_y - cur_y) / (new_x - cur_x) * rot_y + rot_x; CT mid_x = (new_y - cur_y) / (new_x - cur_x) * rot_y + rot_x;
CT mid_y = parabola_y(mid_x, rot_x, rot_y); CT mid_y = parabola_y(mid_x, rot_x, rot_y);
assert(mid_x != cur_x || mid_y != cur_y);
assert(mid_x != new_x || mid_y != new_y);
// Compute maximum distance between the given parabolic arc // Compute maximum distance between the given parabolic arc
// and line segment that discretize it. // and line segment that discretize it.
CT dist = (new_y - cur_y) * (mid_x - cur_x) - CT dist = (new_y - cur_y) * (mid_x - cur_x) -
(new_x - cur_x) * (mid_y - cur_y); (new_x - cur_x) * (mid_y - cur_y);
dist = dist * dist / ((new_y - cur_y) * (new_y - cur_y) + CT div = (new_y - cur_y) * (new_y - cur_y) + (new_x - cur_x) * (new_x - cur_x);
(new_x - cur_x) * (new_x - cur_x)); assert(div != 0);
dist = dist * dist / div;
if (dist <= max_dist_transformed) { if (dist <= max_dist_transformed) {
// Distance between parabola and line segment is less than max_dist. // Distance between parabola and line segment is less than max_dist.
point_stack.pop(); point_stack.pop();
@ -236,50 +242,39 @@ namespace Voronoi { namespace Internal {
inline void clip_infinite_edge(const Points &points, const std::vector<segment_type> &segments, const edge_type& edge, coordinate_type bbox_max_size, std::vector<point_type>* clipped_edge) inline void clip_infinite_edge(const Points &points, const std::vector<segment_type> &segments, const edge_type& edge, coordinate_type bbox_max_size, std::vector<point_type>* clipped_edge)
{ {
assert(edge.is_infinite());
assert((edge.vertex0() == nullptr) != (edge.vertex1() == nullptr));
const cell_type& cell1 = *edge.cell(); const cell_type& cell1 = *edge.cell();
const cell_type& cell2 = *edge.twin()->cell(); const cell_type& cell2 = *edge.twin()->cell();
point_type origin, direction;
// Infinite edges could not be created by two segment sites. // Infinite edges could not be created by two segment sites.
assert(cell1.contains_point() || cell2.contains_point());
if (! cell1.contains_point() && ! cell2.contains_point()) { if (! cell1.contains_point() && ! cell2.contains_point()) {
printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n"); printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n");
return; return;
} }
point_type direction;
if (cell1.contains_point() && cell2.contains_point()) { if (cell1.contains_point() && cell2.contains_point()) {
assert(! edge.is_secondary());
point_type p1 = retrieve_point(points, segments, cell1); point_type p1 = retrieve_point(points, segments, cell1);
point_type p2 = retrieve_point(points, segments, cell2); point_type p2 = retrieve_point(points, segments, cell2);
origin.x((p1.x() + p2.x()) * 0.5); if (edge.vertex0() == nullptr)
origin.y((p1.y() + p2.y()) * 0.5); std::swap(p1, p2);
direction.x(p1.y() - p2.y()); direction.x(p1.y() - p2.y());
direction.y(p2.x() - p1.x()); direction.y(p2.x() - p1.x());
} else { } else {
origin = cell1.contains_segment() ? retrieve_point(points, segments, cell2) : retrieve_point(points, segments, cell1); assert(edge.is_secondary());
segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()]; segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
coordinate_type dx = high(segment).x() - low(segment).x(); direction.x(high(segment).y() - low(segment).y());
coordinate_type dy = high(segment).y() - low(segment).y(); direction.y(low(segment).x() - high(segment).x());
if ((low(segment) == origin) ^ cell1.contains_point()) {
direction.x(dy);
direction.y(-dx);
} else {
direction.x(-dy);
direction.y(dx);
}
} }
coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y())); coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
if (edge.vertex0() == NULL) { if (edge.vertex0() == nullptr) {
clipped_edge->push_back(point_type( clipped_edge->push_back(point_type(edge.vertex1()->x() + direction.x() * koef, edge.vertex1()->y() + direction.y() * koef));
origin.x() - direction.x() * koef, clipped_edge->push_back(point_type(edge.vertex1()->x(), edge.vertex1()->y()));
origin.y() - direction.y() * koef));
} else { } else {
clipped_edge->push_back( clipped_edge->push_back(point_type(edge.vertex0()->x(), edge.vertex0()->y()));
point_type(edge.vertex0()->x(), edge.vertex0()->y())); clipped_edge->push_back(point_type(edge.vertex0()->x() + direction.x() * koef, edge.vertex0()->y() + direction.y() * koef));
}
if (edge.vertex1() == NULL) {
clipped_edge->push_back(point_type(
origin.x() + direction.x() * koef,
origin.y() + direction.y() * koef));
} else {
clipped_edge->push_back(
point_type(edge.vertex1()->x(), edge.vertex1()->y()));
} }
} }
@ -307,11 +302,16 @@ static inline void dump_voronoi_to_svg(
const Lines &helper_lines = Lines(), const Lines &helper_lines = Lines(),
double scale = 0) double scale = 0)
{ {
const bool internalEdgesOnly = false;
BoundingBox bbox; BoundingBox bbox;
bbox.merge(get_extents(points)); bbox.merge(get_extents(points));
bbox.merge(get_extents(lines)); bbox.merge(get_extents(lines));
bbox.merge(get_extents(offset_curves)); bbox.merge(get_extents(offset_curves));
bbox.merge(get_extents(helper_lines)); bbox.merge(get_extents(helper_lines));
for (boost::polygon::voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it)
if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR)
bbox.merge(Point(it->x(), it->y()));
bbox.min -= (0.01 * bbox.size().cast<double>()).cast<coord_t>(); bbox.min -= (0.01 * bbox.size().cast<double>()).cast<coord_t>();
bbox.max += (0.01 * bbox.size().cast<double>()).cast<coord_t>(); bbox.max += (0.01 * bbox.size().cast<double>()).cast<coord_t>();
@ -321,15 +321,17 @@ static inline void dump_voronoi_to_svg(
0.01 0.01
* std::min(bbox.size().x(), bbox.size().y()); * std::min(bbox.size().x(), bbox.size().y());
else else
scale /= SCALING_FACTOR; scale *= SCALING_FACTOR;
const std::string inputSegmentPointColor = "lightseagreen"; const std::string inputSegmentPointColor = "lightseagreen";
const coord_t inputSegmentPointRadius = coord_t(0.09 * scale); const coord_t inputSegmentPointRadius = std::max<coord_t>(1, coord_t(0.09 * scale));
const std::string inputSegmentColor = "lightseagreen"; const std::string inputSegmentColor = "lightseagreen";
const coord_t inputSegmentLineWidth = coord_t(0.03 * scale); const coord_t inputSegmentLineWidth = coord_t(0.03 * scale);
const std::string voronoiPointColor = "black"; const std::string voronoiPointColor = "black";
const coord_t voronoiPointRadius = coord_t(0.06 * scale); const std::string voronoiPointColorOutside = "red";
const std::string voronoiPointColorInside = "blue";
const coord_t voronoiPointRadius = std::max<coord_t>(1, coord_t(0.06 * scale));
const std::string voronoiLineColorPrimary = "black"; const std::string voronoiLineColorPrimary = "black";
const std::string voronoiLineColorSecondary = "green"; const std::string voronoiLineColorSecondary = "green";
const std::string voronoiArcColor = "red"; const std::string voronoiArcColor = "red";
@ -341,7 +343,6 @@ static inline void dump_voronoi_to_svg(
const std::string helperLineColor = "orange"; const std::string helperLineColor = "orange";
const coord_t helperLineWidth = coord_t(0.04 * scale); const coord_t helperLineWidth = coord_t(0.04 * scale);
const bool internalEdgesOnly = false;
const bool primaryEdgesOnly = false; const bool primaryEdgesOnly = false;
::Slic3r::SVG svg(path, bbox); ::Slic3r::SVG svg(path, bbox);
@ -360,9 +361,11 @@ static inline void dump_voronoi_to_svg(
Voronoi::Internal::point_type(double(it->b(0)), double(it->b(1))))); Voronoi::Internal::point_type(double(it->b(0)), double(it->b(1)))));
// Color exterior edges. // Color exterior edges.
for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) if (internalEdgesOnly) {
if (!it->is_finite()) for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it)
Voronoi::Internal::color_exterior(&(*it)); if (!it->is_finite())
Voronoi::Internal::color_exterior(&(*it));
}
// Draw the end points of the input polygon. // Draw the end points of the input polygon.
for (Lines::const_iterator it = lines.begin(); it != lines.end(); ++it) { for (Lines::const_iterator it = lines.begin(); it != lines.end(); ++it) {
@ -376,8 +379,19 @@ static inline void dump_voronoi_to_svg(
#if 1 #if 1
// Draw voronoi vertices. // Draw voronoi vertices.
for (boost::polygon::voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it) for (boost::polygon::voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it)
if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR) if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR) {
svg.draw(Point(coord_t(it->x()), coord_t(it->y())), voronoiPointColor, voronoiPointRadius); const std::string *color = nullptr;
switch (Voronoi::vertex_category(*it)) {
case Voronoi::VertexCategory::OnContour: color = &voronoiPointColor; break;
case Voronoi::VertexCategory::Outside: color = &voronoiPointColorOutside; break;
case Voronoi::VertexCategory::Inside: color = &voronoiPointColorInside; break;
default: color = &voronoiPointColor; // assert(false);
}
Point pt(coord_t(it->x()), coord_t(it->y()));
if (it->x() * pt.x() >= 0. && it->y() * pt.y() >= 0.)
// Conversion to coord_t is valid.
svg.draw(Point(coord_t(it->x()), coord_t(it->y())), *color, voronoiPointRadius);
}
for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) { for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) {
if (primaryEdgesOnly && !it->is_primary()) if (primaryEdgesOnly && !it->is_primary())
@ -401,8 +415,32 @@ static inline void dump_voronoi_to_svg(
} else if (! it->is_primary()) } else if (! it->is_primary())
color = voronoiLineColorSecondary; color = voronoiLineColorSecondary;
} }
for (std::size_t i = 0; i + 1 < samples.size(); ++i) for (std::size_t i = 0; i + 1 < samples.size(); ++ i) {
svg.draw(Line(Point(coord_t(samples[i].x()), coord_t(samples[i].y())), Point(coord_t(samples[i+1].x()), coord_t(samples[i+1].y()))), color, voronoiLineWidth); Vec2d a(samples[i].x(), samples[i].y());
Vec2d b(samples[i+1].x(), samples[i+1].y());
// Convert to coord_t.
Point ia = a.cast<coord_t>();
Point ib = b.cast<coord_t>();
// Is the conversion possible? Do the resulting points fit into int32_t?
auto in_range = [](const Point &ip, const Vec2d &p) { return p.x() * ip.x() >= 0. && p.y() * ip.y() >= 0.; };
bool a_in_range = in_range(ia, a);
bool b_in_range = in_range(ib, b);
if (! a_in_range || ! b_in_range) {
if (! a_in_range && ! b_in_range)
// None fits, ignore.
continue;
// One fit, the other does not. Try to clip.
Vec2d v = b - a;
v.normalize();
v *= bbox.size().cast<double>().norm();
auto p = a_in_range ? Vec2d(a + v) : Vec2d(b - v);
Point ip = p.cast<coord_t>();
if (! in_range(ip, p))
continue;
(a_in_range ? ib : ia) = ip;
}
svg.draw(Line(ia, ib), color, voronoiLineWidth);
}
} }
#endif #endif

View File

@ -228,6 +228,16 @@ ForwardIt binary_find_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey
return first != last && equal_to_key(*first) ? first : last; return first != last && equal_to_key(*first) ? first : last;
} }
template<typename ContainerType, typename ValueType> inline bool contains(const ContainerType &c, const ValueType &v)
{ return std::find(c.begin(), c.end(), v) != c.end(); }
template<typename T> inline bool contains(const std::initializer_list<T> &il, const T &v)
{ return std::find(il.begin(), il.end(), v) != il.end(); }
template<typename ContainerType, typename ValueType> inline bool one_of(const ValueType &v, const ContainerType &c)
{ return contains(c, v); }
template<typename T> inline bool one_of(const T& v, const std::initializer_list<T>& il)
{ return contains(il, v); }
template<typename T> template<typename T>
static inline T sqr(T x) static inline T sqr(T x)
{ {

View File

@ -108,8 +108,7 @@ bool BonjourDialog::show_and_lookup()
timer->SetOwner(this); timer->SetOwner(this);
timer_state = 1; timer_state = 1;
timer->Start(1000); timer->Start(1000);
wxTimerEvent evt_dummy; on_timer_process();
on_timer(evt_dummy);
// The background thread needs to queue messages for this dialog // The background thread needs to queue messages for this dialog
// and for that it needs a valid pointer to it (mandated by the wxWidgets API). // and for that it needs a valid pointer to it (mandated by the wxWidgets API).
@ -214,18 +213,27 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e)
} }
void BonjourDialog::on_timer(wxTimerEvent &) void BonjourDialog::on_timer(wxTimerEvent &)
{
on_timer_process();
}
// This is here so the function can be bound to wxEVT_TIMER and also called
// explicitly (wxTimerEvent should not be created by user code).
void BonjourDialog::on_timer_process()
{ {
const auto search_str = _utf8(L("Searching for devices")); const auto search_str = _utf8(L("Searching for devices"));
if (timer_state > 0) { if (timer_state > 0) {
const std::string dots(timer_state, '.'); const std::string dots(timer_state, '.');
label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str())); label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str()));
timer_state = (timer_state) % 3 + 1; timer_state = (timer_state) % 3 + 1;
} else { } else {
label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str())); label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str()));
timer->Stop(); timer->Stop();
} }
} }
} }

View File

@ -43,6 +43,7 @@ private:
void on_reply(BonjourReplyEvent &); void on_reply(BonjourReplyEvent &);
void on_timer(wxTimerEvent &); void on_timer(wxTimerEvent &);
void on_timer_process();
}; };

View File

@ -734,7 +734,7 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
, text_clr_str , text_clr_str
, first_line , first_line
, second_line); , second_line);
for (int i = 0; i < printer_names.size(); ++i) for (size_t i = 0; i < printer_names.size(); ++i)
{ {
text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i])); text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i]));
if (i % 3 == 2) { if (i % 3 == 2) {
@ -830,7 +830,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
} }
} }
if (sel_printers[0] != 0) { if (sel_printers[0] != 0) {
for (size_t i = 0; i < sel_printers_count; i++) { for (int i = 0; i < sel_printers_count; i++) {
const std::string& printer_name = list_printer->get_data(sel_printers[i]); const std::string& printer_name = list_printer->get_data(sel_printers[i]);
const Preset* printer = nullptr; const Preset* printer = nullptr;
for (const Preset* it : materials->printers) { for (const Preset* it : materials->printers) {
@ -881,7 +881,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
if (sel_printers_count != 0 && sel_type != wxNOT_FOUND) { if (sel_printers_count != 0 && sel_type != wxNOT_FOUND) {
const std::string& type = list_type->get_data(sel_type); const std::string& type = list_type->get_data(sel_type);
// find printer preset // find printer preset
for (size_t i = 0; i < sel_printers_count; i++) { for (int i = 0; i < sel_printers_count; i++) {
const std::string& printer_name = list_printer->get_data(sel_printers[i]); const std::string& printer_name = list_printer->get_data(sel_printers[i]);
const Preset* printer = nullptr; const Preset* printer = nullptr;
for (const Preset* it : materials->printers) { for (const Preset* it : materials->printers) {
@ -917,7 +917,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
const std::string& vendor = list_vendor->get_data(sel_vendor); const std::string& vendor = list_vendor->get_data(sel_vendor);
// finst printer preset // finst printer preset
std::vector<ProfilePrintData> to_list; std::vector<ProfilePrintData> to_list;
for (size_t i = 0; i < sel_printers_count; i++) { for (int i = 0; i < sel_printers_count; i++) {
const std::string& printer_name = list_printer->get_data(sel_printers[i]); const std::string& printer_name = list_printer->get_data(sel_printers[i]);
const Preset* printer = nullptr; const Preset* printer = nullptr;
for (const Preset* it : materials->printers) { for (const Preset* it : materials->printers) {
@ -986,7 +986,7 @@ void PageMaterials::sort_list_data(StringList* list, bool add_All_item, bool mat
const ConfigOptionDef* def = print_config_def.get("filament_type"); const ConfigOptionDef* def = print_config_def.get("filament_type");
std::vector<std::string>enum_values = def->enum_values; std::vector<std::string>enum_values = def->enum_values;
int end_of_sorted = 0; size_t end_of_sorted = 0;
for (size_t vals = 0; vals < enum_values.size(); vals++) { for (size_t vals = 0; vals < enum_values.size(); vals++) {
for (size_t profs = end_of_sorted; profs < other_profiles.size(); profs++) for (size_t profs = end_of_sorted; profs < other_profiles.size(); profs++)
{ {
@ -1044,13 +1044,11 @@ void PageMaterials::sort_list_data(PresetList* list, const std::vector<ProfilePr
return a.name.get() < b.name.get(); return a.name.get() < b.name.get();
}); });
list->Clear(); list->Clear();
//for (const auto& item : prusa_profiles) for (size_t i = 0; i < prusa_profiles.size(); ++i) {
for (int i = 0; i < prusa_profiles.size(); ++i) {
list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get())); list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get()));
list->Check(i, prusa_profiles[i].checked); list->Check(i, prusa_profiles[i].checked);
} }
//for (const auto& item : other_profiles) for (size_t i = 0; i < other_profiles.size(); ++i) {
for (int i = 0; i < other_profiles.size(); ++i) {
list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get())); list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get()));
list->Check(i + prusa_profiles.size(), other_profiles[i].checked); list->Check(i + prusa_profiles.size(), other_profiles[i].checked);
} }

View File

@ -317,7 +317,7 @@ double Control::get_double_value(const SelectedSlider& selection)
{ {
if (m_values.empty() || m_lower_value<0) if (m_values.empty() || m_lower_value<0)
return 0.0; return 0.0;
if (m_values.size() <= m_higher_value) { if (m_values.size() <= size_t(m_higher_value)) {
correct_higher_value(); correct_higher_value();
return m_values.back(); return m_values.back();
} }
@ -621,7 +621,7 @@ static std::string short_and_splitted_time(const std::string& time)
::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds); ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
else if (hours > 10 && minutes > 10 && seconds > 10) else if (hours > 10 && minutes > 10 && seconds > 10)
::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds); ::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds);
else if (minutes < 10 && seconds > 10 || minutes > 10 && seconds < 10) else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds); ::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds);
else else
::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds); ::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds);
@ -639,15 +639,15 @@ static std::string short_and_splitted_time(const std::string& time)
wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const
{ {
const int value = tick; const size_t value = tick;
if (m_label_koef == 1.0 && m_values.empty()) if (m_label_koef == 1.0 && m_values.empty())
return wxString::Format("%d", value); return wxString::Format("%lu", static_cast<unsigned long>(value));
if (value >= m_values.size()) if (value >= m_values.size())
return "ErrVal"; return "ErrVal";
if (m_draw_mode == dmSequentialGCodeView) if (m_draw_mode == dmSequentialGCodeView)
return wxString::Format("%d", static_cast<unsigned int>(m_values[value])); return wxString::Format("%lu", static_cast<unsigned long>(m_values[value]));
else { else {
if (label_type == ltEstimatedTime) { if (label_type == ltEstimatedTime) {
return (value < m_layers_times.size()) ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : ""; return (value < m_layers_times.size()) ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : "";
@ -762,7 +762,7 @@ void Control::draw_ticks_pair(wxDC& dc, wxCoord pos, wxCoord mid, int tick_len)
dc.DrawLine(mid - (mid_space + tick_len), pos, mid - mid_space, pos); dc.DrawLine(mid - (mid_space + tick_len), pos, mid - mid_space, pos);
is_horizontal() ? dc.DrawLine(pos, mid + (mid_space + tick_len), pos, mid + mid_space) : is_horizontal() ? dc.DrawLine(pos, mid + (mid_space + tick_len), pos, mid + mid_space) :
dc.DrawLine(mid + (mid_space + tick_len), pos, mid + mid_space, pos); dc.DrawLine(mid + (mid_space + tick_len), pos, mid + mid_space, pos);
}; }
void Control::draw_ticks(wxDC& dc) void Control::draw_ticks(wxDC& dc)
{ {
@ -773,8 +773,8 @@ void Control::draw_ticks(wxDC& dc)
int height, width; int height, width;
get_size(&width, &height); get_size(&width, &height);
const wxCoord mid = is_horizontal() ? 0.5*height : 0.5*width; const wxCoord mid = is_horizontal() ? 0.5*height : 0.5*width;
for (auto tick : m_ticks.ticks) { for (const TickCode& tick : m_ticks.ticks) {
if (tick.tick >= m_values.size()) { if (size_t(tick.tick) >= m_values.size()) {
// The case when OnPaint is called before m_ticks.ticks data are updated (specific for the vase mode) // The case when OnPaint is called before m_ticks.ticks data are updated (specific for the vase mode)
break; break;
} }
@ -927,7 +927,6 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count); auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count);
while (pow < 3) { while (pow < 3) {
int tick = 0;
for (int istep : {1, 2, 5}) { for (int istep : {1, 2, 5}) {
double val = (double)istep * std::pow(10,pow); double val = (double)istep * std::pow(10,pow);
auto val_it = std::lower_bound(values.begin(), end_it, val - epsilon()); auto val_it = std::lower_bound(values.begin(), end_it, val - epsilon());
@ -970,7 +969,7 @@ void Control::draw_ruler(wxDC& dc)
dc.SetTextForeground(GREY_PEN.GetColour()); dc.SetTextForeground(GREY_PEN.GetColour());
if (m_ruler.long_step < 0) if (m_ruler.long_step < 0)
for (int tick = 1; tick < m_values.size(); tick++) { for (size_t tick = 1; tick < m_values.size(); tick++) {
wxCoord pos = get_position_from_value(tick); wxCoord pos = get_position_from_value(tick);
draw_ticks_pair(dc, pos, mid, 5); draw_ticks_pair(dc, pos, mid, 5);
draw_tick_text(dc, wxPoint(mid, pos), tick); draw_tick_text(dc, wxPoint(mid, pos), tick);
@ -986,7 +985,7 @@ void Control::draw_ruler(wxDC& dc)
} }
}; };
double short_tick; double short_tick = std::nan("");
int tick = 0; int tick = 0;
double value = 0.0; double value = 0.0;
int sequence = 0; int sequence = 0;
@ -1003,6 +1002,7 @@ void Control::draw_ruler(wxDC& dc)
if (m_values[tick] < value) if (m_values[tick] < value)
break; break;
// short ticks from the last tick to the end of current sequence // short ticks from the last tick to the end of current sequence
assert(! std::isnan(short_tick));
draw_short_ticks(dc, short_tick, tick); draw_short_ticks(dc, short_tick, tick);
sequence++; sequence++;
} }

View File

@ -1028,7 +1028,7 @@ void Choice::set_selection()
} }
if (!text_value.IsEmpty()) { if (!text_value.IsEmpty()) {
int idx = 0; size_t idx = 0;
for (auto el : m_opt.enum_values) { for (auto el : m_opt.enum_values) {
if (el == text_value) if (el == text_value)
break; break;
@ -1375,7 +1375,7 @@ void ColourPicker::msw_rescale()
size.SetHeight(m_opt.height * m_em_unit); size.SetHeight(m_opt.height * m_em_unit);
else if (parent_is_custom_ctrl && opt_height > 0) else if (parent_is_custom_ctrl && opt_height > 0)
size.SetHeight(lround(opt_height * m_em_unit)); size.SetHeight(lround(opt_height * m_em_unit));
if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
if (parent_is_custom_ctrl) if (parent_is_custom_ctrl)
field->SetSize(size); field->SetSize(size);
else else
@ -1402,7 +1402,7 @@ void PointCtrl::BUILD()
if (parent_is_custom_ctrl && m_opt.height < 0) if (parent_is_custom_ctrl && m_opt.height < 0)
opt_height = (double)x_textctrl->GetSize().GetHeight() / m_em_unit; opt_height = (double)x_textctrl->GetSize().GetHeight() / m_em_unit;
x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font()); x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font()); y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);

View File

@ -1596,8 +1596,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
Vec3f prev_up = prev_right.cross(prev_dir); Vec3f prev_up = prev_right.cross(prev_dir);
Vec3f next_dir = (next - curr).normalized(); Vec3f next_dir = (next - curr).normalized();
Vec3f next_right = Vec3f(next_dir[1], -next_dir[0], 0.0f).normalized();
Vec3f next_up = next_right.cross(next_dir);
bool is_right_turn = prev_up.dot(prev_dir.cross(next_dir)) <= 0.0f; bool is_right_turn = prev_up.dot(prev_dir.cross(next_dir)) <= 0.0f;
float cos_dir = prev_dir.dot(next_dir); float cos_dir = prev_dir.dot(next_dir);
@ -2671,13 +2669,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
}; };
auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) { auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) {
auto is_in_z_range = [](const Path& path, double min_z, double max_z) { // auto is_in_z_range = [](const Path& path, double min_z, double max_z) {
auto in_z_range = [min_z, max_z](double z) { // auto in_z_range = [min_z, max_z](double z) {
return min_z - EPSILON < z && z < max_z + EPSILON; // return min_z - EPSILON < z && z < max_z + EPSILON;
}; // };
//
return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]); // return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]);
}; // };
const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)]; const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)];
if (path_id >= buffer.paths.size()) if (path_id >= buffer.paths.size())
@ -3396,7 +3394,7 @@ void GCodeViewer::render_toolpaths() const
{ {
case TBuffer::ERenderPrimitiveType::Point: case TBuffer::ERenderPrimitiveType::Point:
{ {
EOptionsColors color; EOptionsColors color = EOptionsColors(0);
switch (buffer_type(i)) switch (buffer_type(i))
{ {
case EMoveType::Tool_change: { color = EOptionsColors::ToolChanges; break; } case EMoveType::Tool_change: { color = EOptionsColors::ToolChanges; break; }
@ -3405,6 +3403,7 @@ void GCodeViewer::render_toolpaths() const
case EMoveType::Custom_GCode: { color = EOptionsColors::CustomGCodes; break; } case EMoveType::Custom_GCode: { color = EOptionsColors::CustomGCodes; break; }
case EMoveType::Retract: { color = EOptionsColors::Retractions; break; } case EMoveType::Retract: { color = EOptionsColors::Retractions; break; }
case EMoveType::Unretract: { color = EOptionsColors::Unretractions; break; } case EMoveType::Unretract: { color = EOptionsColors::Unretractions; break; }
default: { assert(false); break; }
} }
render_as_points(buffer, static_cast<unsigned int>(j), color, *shader); render_as_points(buffer, static_cast<unsigned int>(j), color, *shader);
break; break;
@ -4101,6 +4100,7 @@ void GCodeViewer::render_legend() const
imgui.text(_u8L("Estimated printing time") + " [" + _u8L("Stealth mode") + "]:"); imgui.text(_u8L("Estimated printing time") + " [" + _u8L("Stealth mode") + "]:");
break; break;
} }
default : { assert(false); break; }
} }
ImGui::SameLine(); ImGui::SameLine();
imgui.text(short_time(get_time_dhms(time_mode.time))); imgui.text(short_time(get_time_dhms(time_mode.time)));
@ -4132,6 +4132,7 @@ void GCodeViewer::render_legend() const
show_mode_button(_L("Show normal mode"), PrintEstimatedTimeStatistics::ETimeMode::Normal); show_mode_button(_L("Show normal mode"), PrintEstimatedTimeStatistics::ETimeMode::Normal);
break; break;
} }
default : { assert(false); break; }
} }
} }

View File

@ -610,7 +610,7 @@ public:
const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; } const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; }
const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; } const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; }
const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }; const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
const SequentialView& get_sequential_view() const { return m_sequential_view; } const SequentialView& get_sequential_view() const { return m_sequential_view; }
void update_sequential_view_current(unsigned int first, unsigned int last); void update_sequential_view_current(unsigned int first, unsigned int last);

View File

@ -5822,7 +5822,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
int get_color_idx_for_tool_change(std::vector<CustomGCode::Item>::const_iterator it, const int extruder) const int get_color_idx_for_tool_change(std::vector<CustomGCode::Item>::const_iterator it, const int extruder) const
{ {
const int current_extruder = it->extruder == 0 ? extruder : it->extruder; const int current_extruder = it->extruder == 0 ? extruder : it->extruder;
if (number_tools() == extruders_cnt + 1) // there is no one "M600" if (number_tools() == size_t(extruders_cnt + 1)) // there is no one "M600"
return std::min<int>(extruders_cnt - 1, std::max<int>(current_extruder - 1, 0)); return std::min<int>(extruders_cnt - 1, std::max<int>(current_extruder - 1, 0));
auto it_n = it; auto it_n = it;

View File

@ -325,7 +325,7 @@ private:
size_t cur_len = 0; size_t cur_len = 0;
wxString longest_sub_string; wxString longest_sub_string;
auto get_longest_sub_string = [longest_sub_string, input](wxString &longest_sub_str, int cur_len, size_t i) { auto get_longest_sub_string = [input](wxString &longest_sub_str, size_t cur_len, size_t i) {
if (cur_len > longest_sub_str.Len()) if (cur_len > longest_sub_str.Len())
longest_sub_str = input.SubString(i - cur_len + 1, i); longest_sub_str = input.SubString(i - cur_len + 1, i);
}; };

View File

@ -496,13 +496,6 @@ void Preview::on_combochecklist_features(wxCommandEvent& evt)
void Preview::on_combochecklist_options(wxCommandEvent& evt) void Preview::on_combochecklist_options(wxCommandEvent& evt)
{ {
auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) {
auto is_flag_set = [](unsigned int flags, unsigned int flag) {
return (flags & (1 << flag)) != 0;
};
return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag);
};
unsigned int curr_flags = m_canvas->get_gcode_options_visibility_flags(); unsigned int curr_flags = m_canvas->get_gcode_options_visibility_flags();
unsigned int new_flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_options); unsigned int new_flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_options);
if (curr_flags == new_flags) if (curr_flags == new_flags)
@ -513,6 +506,13 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt)
#if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE #if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
m_canvas->refresh_gcode_preview_render_paths(); m_canvas->refresh_gcode_preview_render_paths();
#else #else
auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) {
auto is_flag_set = [](unsigned int flags, unsigned int flag) {
return (flags & (1 << flag)) != 0;
};
return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag);
};
bool skip_refresh = xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::Shells)) || bool skip_refresh = xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::Shells)) ||
xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::ToolMarker)); xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::ToolMarker));

View File

@ -41,7 +41,7 @@ namespace instance_check_internal
//if (argc < 2) //if (argc < 2)
// return ret; // return ret;
std::vector<std::string> arguments { argv[0] }; std::vector<std::string> arguments { argv[0] };
for (size_t i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
const std::string token = argv[i]; const std::string token = argv[i];
// Processing of boolean command line arguments shall match DynamicConfig::read_cli(). // Processing of boolean command line arguments shall match DynamicConfig::read_cli().
if (token == "--single-instance") if (token == "--single-instance")
@ -180,7 +180,7 @@ namespace instance_check_internal
if ( !checker->IsAnotherRunning() ) */ if ( !checker->IsAnotherRunning() ) */
{ {
DBusMessage* msg; DBusMessage* msg;
DBusMessageIter args; // DBusMessageIter args;
DBusConnection* conn; DBusConnection* conn;
DBusError err; DBusError err;
dbus_uint32_t serial = 0; dbus_uint32_t serial = 0;

View File

@ -392,18 +392,18 @@ void NotificationManager::PopNotification::count_spaces()
} }
void NotificationManager::PopNotification::init() void NotificationManager::PopNotification::init()
{ {
std::string text = m_text1 + " " + m_hypertext; std::string text = m_text1 + " " + m_hypertext;
int last_end = 0; size_t last_end = 0;
m_lines_count = 0; m_lines_count = 0;
count_spaces(); count_spaces();
// count lines // count lines
m_endlines.clear(); m_endlines.clear();
while (last_end < text.length() - 1) while (last_end < text.length() - 1)
{ {
int next_hard_end = text.find_first_of('\n', last_end); size_t next_hard_end = text.find_first_of('\n', last_end);
if (next_hard_end > 0 && ImGui::CalcTextSize(text.substr(last_end, next_hard_end - last_end).c_str()).x < m_window_width - m_window_width_offset) { if (next_hard_end != std::string::npos && ImGui::CalcTextSize(text.substr(last_end, next_hard_end - last_end).c_str()).x < m_window_width - m_window_width_offset) {
//next line is ended by '/n' //next line is ended by '/n'
m_endlines.push_back(next_hard_end); m_endlines.push_back(next_hard_end);
last_end = next_hard_end + 1; last_end = next_hard_end + 1;
@ -411,9 +411,9 @@ void NotificationManager::PopNotification::init()
// find next suitable endline // find next suitable endline
if (ImGui::CalcTextSize(text.substr(last_end).c_str()).x >= m_window_width - m_window_width_offset) { if (ImGui::CalcTextSize(text.substr(last_end).c_str()).x >= m_window_width - m_window_width_offset) {
// more than one line till end // more than one line till end
int next_space = text.find_first_of(' ', last_end); size_t next_space = text.find_first_of(' ', last_end);
if (next_space > 0) { if (next_space > 0) {
int next_space_candidate = text.find_first_of(' ', next_space + 1); size_t next_space_candidate = text.find_first_of(' ', next_space + 1);
while (next_space_candidate > 0 && ImGui::CalcTextSize(text.substr(last_end, next_space_candidate - last_end).c_str()).x < m_window_width - m_window_width_offset) { while (next_space_candidate > 0 && ImGui::CalcTextSize(text.substr(last_end, next_space_candidate - last_end).c_str()).x < m_window_width - m_window_width_offset) {
next_space = next_space_candidate; next_space = next_space_candidate;
next_space_candidate = text.find_first_of(' ', next_space + 1); next_space_candidate = text.find_first_of(' ', next_space + 1);
@ -456,7 +456,6 @@ void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& im
void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y) void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
{ {
ImVec2 win_size(win_size_x, win_size_y); ImVec2 win_size(win_size_x, win_size_y);
ImVec2 win_pos(win_pos_x, win_pos_y);
float x_offset = m_left_indentation; float x_offset = m_left_indentation;
std::string fulltext = m_text1 + m_hypertext; //+ m_text2; std::string fulltext = m_text1 + m_hypertext; //+ m_text2;
ImVec2 text_size = ImGui::CalcTextSize(fulltext.c_str()); ImVec2 text_size = ImGui::CalcTextSize(fulltext.c_str());
@ -594,8 +593,6 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img
{ {
ImVec2 win_size(win_size_x, win_size_y); ImVec2 win_size(win_size_x, win_size_y);
ImVec2 win_pos(win_pos_x, win_pos_y); ImVec2 win_pos(win_pos_x, win_pos_y);
ImVec4 orange_color = ImGui::GetStyleColorVec4(ImGuiCol_Button);
orange_color.w = 0.8f;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity); Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity);
@ -831,9 +828,7 @@ void NotificationManager::SlicingCompleteLargeNotification::render_text(ImGuiWra
if (!m_is_large) if (!m_is_large)
PopNotification::render_text(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y); PopNotification::render_text(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y);
else { else {
ImVec2 win_size(win_size_x, win_size_y); ImVec2 win_size(win_size_x, win_size_y);
ImVec2 win_pos(win_pos_x, win_pos_y);
ImVec2 text1_size = ImGui::CalcTextSize(m_text1.c_str()); ImVec2 text1_size = ImGui::CalcTextSize(m_text1.c_str());
float x_offset = m_left_indentation; float x_offset = m_left_indentation;
std::string fulltext = m_text1 + m_hypertext + m_text2; std::string fulltext = m_text1 + m_hypertext + m_text2;
@ -889,15 +884,12 @@ void NotificationManager::ExportFinishedNotification::count_spaces()
void NotificationManager::ExportFinishedNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y) void NotificationManager::ExportFinishedNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
{ {
ImVec2 win_size(win_size_x, win_size_y);
ImVec2 win_pos(win_pos_x, win_pos_y);
float x_offset = m_left_indentation; float x_offset = m_left_indentation;
std::string fulltext = m_text1 + m_hypertext; //+ m_text2; std::string fulltext = m_text1 + m_hypertext; //+ m_text2;
ImVec2 text_size = ImGui::CalcTextSize(fulltext.c_str());
// Lines are always at least two and m_multiline is always true for ExportFinishedNotification. // Lines are always at least two and m_multiline is always true for ExportFinishedNotification.
// First line has "Export Finished" text and than hyper text open folder. // First line has "Export Finished" text and than hyper text open folder.
// Following lines are path to gcode. // Following lines are path to gcode.
int last_end = 0; size_t last_end = 0;
float starting_y = m_line_height / 2;//10; float starting_y = m_line_height / 2;//10;
float shift_y = m_line_height;// -m_line_height / 20; float shift_y = m_line_height;// -m_line_height / 20;
for (size_t i = 0; i < m_lines_count; i++) { for (size_t i = 0; i < m_lines_count; i++) {
@ -926,8 +918,6 @@ void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiW
{ {
ImVec2 win_size(win_size_x, win_size_y); ImVec2 win_size(win_size_x, win_size_y);
ImVec2 win_pos(win_pos_x, win_pos_y); ImVec2 win_pos(win_pos_x, win_pos_y);
ImVec4 orange_color = ImGui::GetStyleColorVec4(ImGuiCol_Button);
orange_color.w = 0.8f;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity); Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity);
@ -1003,7 +993,6 @@ void NotificationManager::ProgressBarNotification::render_text(ImGuiWrapper& img
} }
void NotificationManager::ProgressBarNotification::render_bar(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y) void NotificationManager::ProgressBarNotification::render_bar(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
{ {
float bar_y = win_size_y / 2 - win_size_y / 6 + m_line_height;
ImVec4 orange_color = ImVec4(.99f, .313f, .0f, 1.0f); ImVec4 orange_color = ImVec4(.99f, .313f, .0f, 1.0f);
float invisible_length = 0;//((float)(m_data.duration - m_remaining_time) / (float)m_data.duration * win_size_x); float invisible_length = 0;//((float)(m_data.duration - m_remaining_time) / (float)m_data.duration * win_size_x);
//invisible_length -= win_size_x / ((float)m_data.duration * 60.f) * (60 - m_countdown_frame); //invisible_length -= win_size_x / ((float)m_data.duration * 60.f) * (60 - m_countdown_frame);
@ -1141,12 +1130,17 @@ void NotificationManager::push_slicing_complete_notification(int timestamp, bool
int time = 10; int time = 10;
if (has_slicing_error_notification()) if (has_slicing_error_notification())
return; return;
if (large) { if (large) {
hypertext = _u8L("Export G-Code."); hypertext = _u8L("Export G-Code.");
time = 0; time = 0;
} }
NotificationData data{ NotificationType::SlicingComplete, NotificationLevel::RegularNotification, time, _u8L("Slicing finished."), hypertext, [](wxEvtHandler* evnthndlr){ NotificationData data{ NotificationType::SlicingComplete, NotificationLevel::RegularNotification, time, _u8L("Slicing finished."), hypertext,
if (evnthndlr != nullptr) wxPostEvent(evnthndlr, ExportGcodeNotificationClickedEvent(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED)); return true; } }; [](wxEvtHandler* evnthndlr){
if (evnthndlr != nullptr)
wxPostEvent(evnthndlr, ExportGcodeNotificationClickedEvent(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED));
return true;
}
};
push_notification_data(std::make_unique<NotificationManager::SlicingCompleteLargeNotification>(data, m_id_provider, m_evt_handler, large), timestamp); push_notification_data(std::make_unique<NotificationManager::SlicingCompleteLargeNotification>(data, m_id_provider, m_evt_handler, large), timestamp);
} }
void NotificationManager::set_slicing_complete_print_time(const std::string &info) void NotificationManager::set_slicing_complete_print_time(const std::string &info)

View File

@ -339,14 +339,14 @@ private:
// Height of text // Height of text
// Used as basic scaling unit! // Used as basic scaling unit!
float m_line_height; float m_line_height;
std::vector<int> m_endlines; std::vector<size_t> m_endlines;
// Gray are f.e. eorrors when its uknown if they are still valid // Gray are f.e. eorrors when its uknown if they are still valid
bool m_is_gray { false }; bool m_is_gray { false };
//if multiline = true, notification is showing all lines(>2) //if multiline = true, notification is showing all lines(>2)
bool m_multiline { false }; bool m_multiline { false };
// True if minimized button is rendered, helps to decide where is area for invisible close button // True if minimized button is rendered, helps to decide where is area for invisible close button
bool m_minimize_b_visible { false }; bool m_minimize_b_visible { false };
int m_lines_count{ 1 }; size_t m_lines_count{ 1 };
// Target for wxWidgets events sent by clicking on the hyperlink available at some notifications. // Target for wxWidgets events sent by clicking on the hyperlink available at some notifications.
wxEvtHandler* m_evt_handler; wxEvtHandler* m_evt_handler;
}; };
@ -366,7 +366,7 @@ private:
override; override;
bool m_is_large; bool m_is_large;
bool m_has_print_info { false }; bool m_has_print_info { false };
std::string m_print_info { std::string() }; std::string m_print_info;
}; };
class SlicingWarningNotification : public PopNotification class SlicingWarningNotification : public PopNotification
@ -471,8 +471,13 @@ private:
{NotificationType::Mouse3dDisconnected, NotificationLevel::RegularNotification, 10, _u8L("3D Mouse disconnected.") }, {NotificationType::Mouse3dDisconnected, NotificationLevel::RegularNotification, 10, _u8L("3D Mouse disconnected.") },
// {NotificationType::Mouse3dConnected, NotificationLevel::RegularNotification, 5, _u8L("3D Mouse connected.") }, // {NotificationType::Mouse3dConnected, NotificationLevel::RegularNotification, 5, _u8L("3D Mouse connected.") },
// {NotificationType::NewPresetsAviable, NotificationLevel::ImportantNotification, 20, _u8L("New Presets are available."), _u8L("See here.") }, // {NotificationType::NewPresetsAviable, NotificationLevel::ImportantNotification, 20, _u8L("New Presets are available."), _u8L("See here.") },
{NotificationType::PresetUpdateAvailable, NotificationLevel::ImportantNotification, 20, _u8L("Configuration update is available."), _u8L("See more."), [](wxEvtHandler* evnthndlr){ {NotificationType::PresetUpdateAvailable, NotificationLevel::ImportantNotification, 20, _u8L("Configuration update is available."), _u8L("See more."),
if (evnthndlr != nullptr) wxPostEvent(evnthndlr, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED)); return true; }}, [](wxEvtHandler* evnthndlr) {
if (evnthndlr != nullptr)
wxPostEvent(evnthndlr, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED));
return true;
}
},
{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotification, 20, _u8L("New version is available."), _u8L("See Releases page."), [](wxEvtHandler* evnthndlr){ {NotificationType::NewAppAvailable, NotificationLevel::ImportantNotification, 20, _u8L("New version is available."), _u8L("See Releases page."), [](wxEvtHandler* evnthndlr){
wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); return true; }}, wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); return true; }},
{NotificationType::EmptyColorChangeCode, NotificationLevel::RegularNotification, 10, {NotificationType::EmptyColorChangeCode, NotificationLevel::RegularNotification, 10,

View File

@ -98,7 +98,7 @@ void OG_CustomCtrl::init_ctrl_lines()
ctrl_lines.emplace_back(CtrlLine(height, this, line, false, opt_group->staticbox)); ctrl_lines.emplace_back(CtrlLine(height, this, line, false, opt_group->staticbox));
} }
else else
int i = 0; assert(false);
} }
} }

View File

@ -250,9 +250,8 @@ void OptionsGroup::activate_line(Line& line)
if (custom_ctrl) if (custom_ctrl)
m_use_custom_ctrl_as_parent = true; m_use_custom_ctrl_as_parent = true;
// if we have an extra column, build it // if we have an extra column, build it
if (extra_column) if (extra_column) {
{
m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line)); m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3); grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
} }
@ -309,8 +308,8 @@ void OptionsGroup::activate_line(Line& line)
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
if (!custom_ctrl) if (!custom_ctrl)
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1); grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
// If we have a single option with no sidetext just add it directly to the grid sizer // If we have a single option with no sidetext just add it directly to the grid sizer
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 && if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
option_set.front().opt.label.empty() && option_set.front().opt.label.empty() &&
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
const auto& option = option_set.front(); const auto& option = option_set.front();
@ -319,16 +318,16 @@ void OptionsGroup::activate_line(Line& line)
if (!custom_ctrl) { if (!custom_ctrl) {
if (is_window_field(field)) if (is_window_field(field))
sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0,
wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2); wxBOTTOM | wxTOP | (option.opt.full_width ? int(wxEXPAND) : int(wxALIGN_CENTER_VERTICAL)), (wxOSX || !staticbox) ? 0 : 2);
if (is_sizer_field(field)) if (is_sizer_field(field))
sizer->Add(field->getSizer(), 1, option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL, 0); sizer->Add(field->getSizer(), 1, (option.opt.full_width ? int(wxEXPAND) : int(wxALIGN_CENTER_VERTICAL)), 0);
} }
return; return;
} }
for (auto opt : option_set) { for (auto opt : option_set) {
ConfigOptionDef option = opt.opt; ConfigOptionDef option = opt.opt;
wxSizer* sizer_tmp = sizer; wxSizer* sizer_tmp = sizer;
// add label if any // add label if any
if (!option.label.empty() && !custom_ctrl) { if (!option.label.empty() && !custom_ctrl) {
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1 //! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1

View File

@ -2524,7 +2524,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast<double>(), 1.0) - 2.0 * Vec3d::Ones(); const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast<double>(), 1.0) - 2.0 * Vec3d::Ones();
#ifndef AUTOPLACEMENT_ON_LOAD #ifndef AUTOPLACEMENT_ON_LOAD
bool need_arrange = false; // bool need_arrange = false;
#endif /* AUTOPLACEMENT_ON_LOAD */ #endif /* AUTOPLACEMENT_ON_LOAD */
bool scaled_down = false; bool scaled_down = false;
std::vector<size_t> obj_idxs; std::vector<size_t> obj_idxs;
@ -2544,7 +2544,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
new_instances.emplace_back(object->add_instance()); new_instances.emplace_back(object->add_instance());
#else /* AUTOPLACEMENT_ON_LOAD */ #else /* AUTOPLACEMENT_ON_LOAD */
// if object has no defined position(s) we need to rearrange everything after loading // if object has no defined position(s) we need to rearrange everything after loading
need_arrange = true; // need_arrange = true;
// add a default instance and center object around origin // add a default instance and center object around origin
object->center_around_origin(); // also aligns object to Z = 0 object->center_around_origin(); // also aligns object to Z = 0
ModelInstance* instance = object->add_instance(); ModelInstance* instance = object->add_instance();
@ -3687,9 +3687,8 @@ bool Plater::priv::warnings_dialog()
if (current_warnings.empty()) if (current_warnings.empty())
return true; return true;
std::string text = _u8L("There are active warnings concerning sliced models:") + "\n"; std::string text = _u8L("There are active warnings concerning sliced models:") + "\n";
bool empt = true;
for (auto const& it : current_warnings) { for (auto const& it : current_warnings) {
int next_n = it.first.message.find_first_of('\n', 0); size_t next_n = it.first.message.find_first_of('\n', 0);
text += "\n"; text += "\n";
if (next_n != std::string::npos) if (next_n != std::string::npos)
text += it.first.message.substr(0, next_n); text += it.first.message.substr(0, next_n);
@ -5052,6 +5051,10 @@ bool Plater::load_files(const wxArrayString& filenames)
load_files(in_paths, false, true); load_files(in_paths, false, true);
break; break;
} }
case LoadType::Unknown : {
assert(false);
break;
}
} }
return true; return true;
@ -5925,7 +5928,6 @@ void Plater::force_print_bed_update()
void Plater::on_activate() void Plater::on_activate()
{ {
#if defined(__linux__) || defined(_WIN32) #if defined(__linux__) || defined(_WIN32)
wxWindow *focus_window = wxWindow::FindFocus();
// Activating the main frame, and no window has keyboard focus. // Activating the main frame, and no window has keyboard focus.
// Set the keyboard focus to the visible Canvas3D. // Set the keyboard focus to the visible Canvas3D.
if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas()) if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas())

View File

@ -201,7 +201,7 @@ void PresetComboBox::update_selection()
if (!cell) return; if (!cell) return;
g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, NULL); g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, (char*)NULL);
// Only the list of cells must be freed, the renderer isn't ours to free // Only the list of cells must be freed, the renderer isn't ours to free
g_list_free(cells); g_list_free(cells);
@ -759,7 +759,7 @@ void PlaterPresetComboBox::update()
this->Clear(); this->Clear();
invalidate_selection(); invalidate_selection();
const Preset* selected_filament_preset; const Preset* selected_filament_preset = nullptr;
std::string extruder_color; std::string extruder_color;
if (m_type == Preset::TYPE_FILAMENT) if (m_type == Preset::TYPE_FILAMENT)
{ {

View File

@ -333,7 +333,7 @@ void PrintHostQueueDialog::on_cancel(Event &evt)
void PrintHostQueueDialog::get_active_jobs(std::vector<std::pair<std::string, std::string>>& ret) void PrintHostQueueDialog::get_active_jobs(std::vector<std::pair<std::string, std::string>>& ret)
{ {
int ic = job_list->GetItemCount(); int ic = job_list->GetItemCount();
for (size_t i = 0; i < ic; i++) for (int i = 0; i < ic; i++)
{ {
auto item = job_list->RowToItem(i); auto item = job_list->RowToItem(i);
auto data = job_list->GetItemData(item); auto data = job_list->GetItemData(item);

View File

@ -117,12 +117,6 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty
} }
} }
// Wrap a string with ColorMarkerStart and ColorMarkerEnd symbols
static wxString wrap_string(const wxString& str)
{
return wxString::Format("%c%s%c", ImGui::ColorMarkerStart, str, ImGui::ColorMarkerEnd);
}
// Mark a string using ColorMarkerStart and ColorMarkerEnd symbols // Mark a string using ColorMarkerStart and ColorMarkerEnd symbols
static std::wstring mark_string(const std::wstring &str, const std::vector<uint16_t> &matches, Preset::Type type, PrinterTechnology pt) static std::wstring mark_string(const std::wstring &str, const std::vector<uint16_t> &matches, Preset::Type type, PrinterTechnology pt)
{ {

View File

@ -2092,7 +2092,7 @@ static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d &
static void verify_instances_rotation_synchronized(const Model &model, const GLVolumePtrs &volumes) static void verify_instances_rotation_synchronized(const Model &model, const GLVolumePtrs &volumes)
{ {
for (size_t idx_object = 0; idx_object < model.objects.size(); ++idx_object) { for (int idx_object = 0; idx_object < int(model.objects.size()); ++idx_object) {
int idx_volume_first = -1; int idx_volume_first = -1;
for (int i = 0; i < (int)volumes.size(); ++i) { for (int i = 0; i < (int)volumes.size(); ++i) {
if (volumes[i]->object_idx() == idx_object) { if (volumes[i]->object_idx() == idx_object) {

View File

@ -411,11 +411,6 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
} }
} }
// Initialize the page. // Initialize the page.
#ifdef __WXOSX__
auto panel = m_tmp_panel;
#else
auto panel = this;
#endif
PageShp page(new Page(m_page_view, title, icon_idx)); PageShp page(new Page(m_page_view, title, icon_idx));
// page->SetBackgroundStyle(wxBG_STYLE_SYSTEM); // page->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -2999,8 +2994,8 @@ void Tab::update_btns_enabling()
// we can delete any preset from the physical printer // we can delete any preset from the physical printer
// and any user preset // and any user preset
const Preset& preset = m_presets->get_edited_preset(); const Preset& preset = m_presets->get_edited_preset();
m_btn_delete_preset->Show(m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection() || m_btn_delete_preset->Show((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
!preset.is_default && !preset.is_system); || (!preset.is_default && !preset.is_system));
if (m_btn_edit_ph_printer) if (m_btn_edit_ph_printer)
m_btn_edit_ph_printer->SetToolTip( m_preset_bundle->physical_printers.has_selection() ? m_btn_edit_ph_printer->SetToolTip( m_preset_bundle->physical_printers.has_selection() ?

View File

@ -989,7 +989,7 @@ wxString UnsavedChangesDialog::get_short_string(wxString full_string)
{ {
int max_len = 30; int max_len = 30;
if (full_string.IsEmpty() || full_string.StartsWith("#") || if (full_string.IsEmpty() || full_string.StartsWith("#") ||
(full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < max_len)) (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < size_t(max_len)))
return full_string; return full_string;
m_has_long_strings = true; m_has_long_strings = true;

View File

@ -62,13 +62,13 @@ namespace fts {
} }
// Public interface // Public interface
static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) { [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) {
pos_type matches[max_matches + 1]; // with the room for the stopper pos_type matches[max_matches + 1]; // with the room for the stopper
matches[0] = stopper; matches[0] = stopper;
return fuzzy_match(pattern, str, outScore, matches); return fuzzy_match(pattern, str, outScore, matches);
} }
static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) { [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) {
int recursionCount = 0; int recursionCount = 0;
static constexpr int recursionLimit = 10; static constexpr int recursionLimit = 10;
return fuzzy_internal::fuzzy_match_recursive(pattern, str, outScore, str, nullptr, matches, 0, recursionCount, recursionLimit); return fuzzy_internal::fuzzy_match_recursive(pattern, str, outScore, str, nullptr, matches, 0, recursionCount, recursionLimit);
@ -114,14 +114,15 @@ namespace fts {
while (*pattern != '\0' && *str != '\0') { while (*pattern != '\0' && *str != '\0') {
int num_matched = std::towlower(*pattern) == std::towlower(*str) ? 1 : 0; int num_matched = std::towlower(*pattern) == std::towlower(*str) ? 1 : 0;
bool folded_match = false; // bool folded_match = false;
if (! num_matched) {
if (! num_matched) {
wchar_t tmp[4]; wchar_t tmp[4];
wchar_t *end = Slic3r::fold_to_ascii(*str, tmp); wchar_t *end = Slic3r::fold_to_ascii(*str, tmp);
wchar_t *c = tmp; wchar_t *c = tmp;
for (const wchar_t* d = pattern; c != end && *d != 0 && std::towlower(*c) == std::towlower(*d); ++c, ++d); for (const wchar_t* d = pattern; c != end && *d != 0 && std::towlower(*c) == std::towlower(*d); ++c, ++d);
if (c == end) { if (c == end) {
folded_match = true; // folded_match = true;
num_matched = end - tmp; num_matched = end - tmp;
} }
} }
@ -169,7 +170,7 @@ namespace fts {
if (matched) { if (matched) {
static constexpr int sequential_bonus = 15; // bonus for adjacent matches static constexpr int sequential_bonus = 15; // bonus for adjacent matches
static constexpr int separator_bonus = 10/*30*/; // bonus if match occurs after a separator static constexpr int separator_bonus = 10/*30*/; // bonus if match occurs after a separator
static constexpr int camel_bonus = 30; // bonus if match is uppercase and prev is lower // static constexpr int camel_bonus = 30; // bonus if match is uppercase and prev is lower
static constexpr int first_letter_bonus = 15; // bonus if the first letter is matched static constexpr int first_letter_bonus = 15; // bonus if the first letter is matched
static constexpr int leading_letter_penalty = -1/*-5*/; // penalty applied for every letter in str before the first match static constexpr int leading_letter_penalty = -1/*-5*/; // penalty applied for every letter in str before the first match

View File

@ -16,6 +16,7 @@ using namespace Slic3r;
namespace Slic3r { namespace Slic3r {
ClipperLib::Path mittered_offset_path_scaled(const Points& contour, const std::vector<float>& deltas, double miter_limit); ClipperLib::Path mittered_offset_path_scaled(const Points& contour, const std::vector<float>& deltas, double miter_limit);
#if 0
static Points mittered_offset_path_scaled_points(const Points& contour, const std::vector<float>& deltas, double miter_limit) static Points mittered_offset_path_scaled_points(const Points& contour, const std::vector<float>& deltas, double miter_limit)
{ {
Points out; Points out;
@ -29,6 +30,7 @@ namespace Slic3r {
} }
return out; return out;
} }
#endif
} }
static ExPolygon spirograph_gear_1mm() static ExPolygon spirograph_gear_1mm()
@ -494,6 +496,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
ExPolygon input = spirograph_gear_1mm().simplify(SCALED_EPSILON).front(); ExPolygon input = spirograph_gear_1mm().simplify(SCALED_EPSILON).front();
ExPolygon output; ExPolygon output;
std::vector<float> deltas(input.contour.points.size(), scale_(1.)); std::vector<float> deltas(input.contour.points.size(), scale_(1.));
// mittered_offset_path_scaled_points is commented out somewhere above
output.contour.points = Slic3r::mittered_offset_path_scaled_points(input.contour.points, deltas, 2.); output.contour.points = Slic3r::mittered_offset_path_scaled_points(input.contour.points, deltas, 2.);
#ifdef TESTS_EXPORT_SVGS #ifdef TESTS_EXPORT_SVGS
{ {

View File

@ -326,7 +326,9 @@ static void recreate_object_from_rasters(const std::string &objname, float lh) {
double disp_w = 120.96; double disp_w = 120.96;
double disp_h = 68.04; double disp_h = 68.04;
#ifndef NDEBUG
size_t cntr = 0; size_t cntr = 0;
#endif
for (ExPolygons &layer : layers) { for (ExPolygons &layer : layers) {
auto rst = create_raster(res, disp_w, disp_h); auto rst = create_raster(res, disp_w, disp_h);

View File

@ -38,6 +38,26 @@ TEST_CASE("Voronoi missing edges - points 12067", "[Voronoi]")
{ -5, 0 } { -5, 0 }
}; };
#if 0
for (Point &p : pts) {
Vec2d q = p.cast<double>();
p.x() = scale_(p.x());
p.y() = scale_(p.y());
}
#endif
#if 0
// Try to rotate, maybe the issue is caused by incorrect handling of vertical or horizontal edges?
double a = 0.18764587962597876897475f;
double c = cos(a);
double s = sin(a);
for (Point &p : poly.points) {
Vec2d q = p.cast<double>();
p.x() = coord_t(q.x() * c + q.y() * s + 0.5);
p.y() = coord_t(- q.x() * s + q.y() * c + 0.5);
}
#endif
// Construction of the Voronoi Diagram. // Construction of the Voronoi Diagram.
VD vd; VD vd;
construct_voronoi(pts.begin(), pts.end(), &vd); construct_voronoi(pts.begin(), pts.end(), &vd);
@ -133,33 +153,40 @@ TEST_CASE("Voronoi missing edges - Alessandro gapfill 12707", "[Voronoi]")
{ { 41427551, 0}, { 42127548, 699996 } } { { 41427551, 0}, { 42127548, 699996 } }
}; };
Lines lines = to_lines(Polygon { Polygon poly {
{ 0, 10000000}, { 0, 10000000},
{ 700000, 1}, // it has to be 1, higher number, zero or -1 work. { 700000, 1}, // it has to be 1, higher number, zero or -1 work.
{ 700000, 9000000}, { 700000, 9000000},
{ 9100000, 9000000}, { 9100000, 9000000},
{ 9100000, 0}, { 9100000, 0},
{10000000, 10000000} {10000000, 10000000}
}); };
#if 1
// Try to rotate, maybe the issue is caused by incorrect handling of vertical or horizontal edges?
double a = 0.18764587962597876897475f;
double c = cos(a);
double s = sin(a);
for (Point &p : poly.points) {
Vec2d q = p.cast<double>();
p.x() = coord_t(q.x() * c + q.y() * s + 0.5);
p.y() = coord_t(- q.x() * s + q.y() * c + 0.5);
}
#endif
Polygon poly;
std::mt19937 gen; std::mt19937 gen;
std::uniform_int_distribution<coord_t> dist(-100, 100); std::uniform_int_distribution<coord_t> dist(-100, 100);
for (size_t i = 0; i < lines.size(); ++ i) { for (Point &p : poly.points) {
Line &l1 = lines[i];
Line &l2 = lines[(i + 1) % lines.size()];
REQUIRE(l1.b.x() == l2.a.x());
REQUIRE(l1.b.y() == l2.a.y());
#if 0 #if 0
// Wiggle the points a bit to find out whether this fixes the voronoi diagram for this particular polygon. // Wiggle the points a bit to find out whether this fixes the voronoi diagram for this particular polygon.
l1.b.x() = (l2.a.x() += dist(gen)); p.x() = (p.x() += dist(gen));
l1.b.y() = (l2.a.y() += dist(gen)); p.y() = (p.y() += dist(gen));
#endif #endif
poly.points.emplace_back(l1.a);
} }
REQUIRE(intersecting_edges({ poly }).empty()); REQUIRE(intersecting_edges({ poly }).empty());
Lines lines = to_lines(poly);
VD vd; VD vd;
construct_voronoi(lines.begin(), lines.end(), &vd); construct_voronoi(lines.begin(), lines.end(), &vd);
@ -169,6 +196,114 @@ TEST_CASE("Voronoi missing edges - Alessandro gapfill 12707", "[Voronoi]")
#endif #endif
} }
TEST_CASE("Voronoi weirdness", "[Voronoi]")
{
Polygon poly2 {
{ 0, 0 },
{ 70000000, 0 },
{ 70000000, 1300000 },
// { 70000001, 14000000 }
{ 70700000, 14000000 }
};
Polygon poly5 {
{ 35058884, -25732145 },
{ 35058884, -19586070 },
{ 32753739, -20246796 },
{ 28756244, -21010725 },
{ 24657532, -21657939 },
{ 20836260, -21960233 },
{ 16115145, -22070742 },
{ 11850152, -21839761 },
{ 7646240, -21470177 },
{ 3607605, -20786940 },
{ 1280947, -20329742 },
{ -292823, -19963790 },
{ -3844469, -18809741 },
{ -7237277, -17593723 },
{ -10225900, -16143761 },
{ -13030266, -14643721 },
{ -15404294, -12977561 },
{ -17601713, -11280712 },
{ -19241930, -9435607 },
{ -20714420, -7583739 },
{ -21726144, -5664355 },
{ -22579294, -3741947 },
{ -22966684, -1786321 },
{ -23200322, 170140 },
{ -22966684, 2126602 },
{ -22579296, 4082227 },
{ -21726148, 6004637 },
{ -20714424, 7924020 },
{ -19241932, 9775888 },
{ -17601717, 11620994 },
{ -15404423, 13317749 },
{ -13030276, 14984003 },
{ -10225910, 16484042 },
{ -7237288, 17934005 },
{ -3844482, 19150025 },
{ -292841, 20304074 },
{ 1280949, 20670031 },
{ 3607587, 21127226 },
{ 7646218, 21810465 },
{ 11850128, 22180055 },
{ 16115122, 22411036 },
{ 20836263, 22300531 },
{ 24657513, 21998239 },
{ 28756227, 21351025 },
{ 32753725, 20587092 },
{ 35058893, 19926309 },
{ 35058893, 35000000 },
{ -31657232, 35000000 },
{ -31657202, -35000000 },
{ 35058881, -35000000 }
};
Polygon poly7 {
{ 35058884, -25732145 },
{ 35058884, -19586070 },
{ -31657202, -35000000 },
{ 35058881, -35000000 }
};
// coord_t shift = 35058881;
coord_t shift_ok = 17000000;
coord_t shift = 35058881;
Polygon poly {
// <-4, 0>: bug
// -5: ok
// 1 - ok
{ 0 + shift, -35000000 },
{ 0 + shift, -25732145 },
{ 0 + shift, -19586070 },
{ -66716086 + shift, -35000000 }
};
REQUIRE(intersecting_edges({ poly }).empty());
REQUIRE(poly.area() > 0.);
#if 0
// Try to rotate, maybe the issue is caused by incorrect handling of vertical or horizontal edges?
double a = 0.18764587962597876897475f;
double c = cos(a);
double s = sin(a);
for (Point &p : poly.points) {
Vec2d q = p.cast<double>();
p.x() = coord_t(q.x() * c + q.y() * s + 0.5);
p.y() = coord_t(- q.x() * s + q.y() * c + 0.5);
}
#endif
VD vd;
Lines lines = to_lines(poly);
construct_voronoi(lines.begin(), lines.end(), &vd);
#ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-weirdness.svg").c_str(),
vd, Points(), lines);
#endif
}
// https://svn.boost.org/trac10/ticket/12903 // https://svn.boost.org/trac10/ticket/12903
// division by zero reported, but this issue is most likely a non-issue, as it produces an infinity for the interval of validity // division by zero reported, but this issue is most likely a non-issue, as it produces an infinity for the interval of validity
// of the floating point calculation, therefore forcing a recalculation with extended accuracy. // of the floating point calculation, therefore forcing a recalculation with extended accuracy.
@ -1228,7 +1363,7 @@ TEST_CASE("Voronoi offset", "[VoronoiOffset]")
for (const OffsetTest &ot : { for (const OffsetTest &ot : {
OffsetTest { scale_(0.2), 1, 1 }, OffsetTest { scale_(0.2), 1, 1 },
OffsetTest { scale_(0.4), 1, 1 }, OffsetTest { scale_(0.4), 1, 1 },
OffsetTest { scale_(0.5), 1, 1 }, OffsetTest { scale_(0.5), 1, 2 },
OffsetTest { scale_(0.505), 1, 2 }, OffsetTest { scale_(0.505), 1, 2 },
OffsetTest { scale_(0.51), 1, 2 }, OffsetTest { scale_(0.51), 1, 2 },
OffsetTest { scale_(0.52), 1, 1 }, OffsetTest { scale_(0.52), 1, 1 },
@ -1237,21 +1372,21 @@ TEST_CASE("Voronoi offset", "[VoronoiOffset]")
OffsetTest { scale_(0.55), 1, 0 } OffsetTest { scale_(0.55), 1, 0 }
}) { }) {
Polygons offsetted_polygons_out = voronoi_offset(vd, lines, ot.distance, scale_(0.005)); #if 0
REQUIRE(offsetted_polygons_out.size() == ot.num_outer); Polygons offsetted_polygons_out = Slic3r::Voronoi::offset(vd, lines, ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset-out-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset-out-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_out); vd, Points(), lines, offsetted_polygons_out);
#endif #endif
REQUIRE(offsetted_polygons_out.size() == ot.num_outer);
#endif
Polygons offsetted_polygons_in = voronoi_offset(vd, lines, - ot.distance, scale_(0.005)); Polygons offsetted_polygons_in = Slic3r::Voronoi::offset(vd, lines, - ot.distance, scale_(0.005));
REQUIRE(offsetted_polygons_in.size() == ot.num_inner);
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset-in-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset-in-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_in); vd, Points(), lines, offsetted_polygons_in);
#endif #endif
REQUIRE(offsetted_polygons_in.size() == ot.num_inner);
} }
} }
@ -1296,21 +1431,20 @@ TEST_CASE("Voronoi offset 2", "[VoronoiOffset]")
OffsetTest { scale_(0.4), 2, 2 }, OffsetTest { scale_(0.4), 2, 2 },
OffsetTest { scale_(0.45), 2, 2 }, OffsetTest { scale_(0.45), 2, 2 },
OffsetTest { scale_(0.48), 2, 2 }, OffsetTest { scale_(0.48), 2, 2 },
//FIXME Exact intersections of an Offset curve with any Voronoi vertex are not handled correctly yet. OffsetTest { scale_(0.5), 2, 4 },
// OffsetTest { scale_(0.5), 2, 2 },
OffsetTest { scale_(0.505), 2, 4 }, OffsetTest { scale_(0.505), 2, 4 },
OffsetTest { scale_(0.7), 2, 0 }, OffsetTest { scale_(0.7), 2, 0 },
OffsetTest { scale_(0.8), 1, 0 } OffsetTest { scale_(0.8), 1, 0 }
}) { }) {
Polygons offsetted_polygons_out = voronoi_offset(vd, lines, ot.distance, scale_(0.005)); Polygons offsetted_polygons_out = Slic3r::Voronoi::offset(vd, lines, ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset2-out-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset2-out-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_out); vd, Points(), lines, offsetted_polygons_out);
#endif #endif
REQUIRE(offsetted_polygons_out.size() == ot.num_outer); REQUIRE(offsetted_polygons_out.size() == ot.num_outer);
Polygons offsetted_polygons_in = voronoi_offset(vd, lines, - ot.distance, scale_(0.005)); Polygons offsetted_polygons_in = Slic3r::Voronoi::offset(vd, lines, - ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset2-in-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset2-in-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_in); vd, Points(), lines, offsetted_polygons_in);
@ -1360,14 +1494,13 @@ TEST_CASE("Voronoi offset 3", "[VoronoiOffset]")
VD vd; VD vd;
Lines lines = to_lines(poly); Lines lines = to_lines(poly);
construct_voronoi(lines.begin(), lines.end(), &vd); construct_voronoi(lines.begin(), lines.end(), &vd);
for (const OffsetTest &ot : { for (const OffsetTest &ot : {
OffsetTest { scale_(0.2), 2, 2 }, OffsetTest { scale_(0.2), 2, 2 },
OffsetTest { scale_(0.4), 2, 2 }, OffsetTest { scale_(0.4), 2, 2 },
OffsetTest { scale_(0.49), 2, 2 }, OffsetTest { scale_(0.49), 2, 2 },
//FIXME this fails OffsetTest { scale_(0.5), 2, 2 },
// OffsetTest { scale_(0.5), 2, 2 },
OffsetTest { scale_(0.51), 2, 2 }, OffsetTest { scale_(0.51), 2, 2 },
OffsetTest { scale_(0.56), 2, 2 }, OffsetTest { scale_(0.56), 2, 2 },
OffsetTest { scale_(0.6), 2, 2 }, OffsetTest { scale_(0.6), 2, 2 },
@ -1375,23 +1508,417 @@ TEST_CASE("Voronoi offset 3", "[VoronoiOffset]")
OffsetTest { scale_(0.8), 1, 6 }, OffsetTest { scale_(0.8), 1, 6 },
OffsetTest { scale_(0.9), 1, 6 }, OffsetTest { scale_(0.9), 1, 6 },
OffsetTest { scale_(0.99), 1, 6 }, OffsetTest { scale_(0.99), 1, 6 },
//FIXME this fails OffsetTest { scale_(1.0), 1, 0 },
// OffsetTest { scale_(1.0), 1, 6 },
OffsetTest { scale_(1.01), 1, 0 }, OffsetTest { scale_(1.01), 1, 0 },
}) { }) {
Polygons offsetted_polygons_out = voronoi_offset(vd, lines, ot.distance, scale_(0.005)); Polygons offsetted_polygons_out = Slic3r::Voronoi::offset(vd, lines, ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset2-out-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset3-out-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_out); vd, Points(), lines, offsetted_polygons_out);
#endif #endif
REQUIRE(offsetted_polygons_out.size() == ot.num_outer); REQUIRE(offsetted_polygons_out.size() == ot.num_outer);
Polygons offsetted_polygons_in = voronoi_offset(vd, lines, - ot.distance, scale_(0.005)); Polygons offsetted_polygons_in = Slic3r::Voronoi::offset(vd, lines, - ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT #ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset2-in-%lf.svg", ot.distance).c_str(), dump_voronoi_to_svg(debug_out_path("voronoi-offset3-in-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_in); vd, Points(), lines, offsetted_polygons_in);
#endif #endif
REQUIRE(offsetted_polygons_in.size() == ot.num_inner); REQUIRE(offsetted_polygons_in.size() == ot.num_inner);
} }
} }
TEST_CASE("Voronoi offset with edge collapse", "[VoronoiOffset4]")
{
Polygons poly
{
// Outer contour
{
{ 434890, -64754575 },
{ 541060, -64669076 },
{ 585647, -64583538 },
{ 576999, -64484233 },
{ 485666, -64191173 },
{ 1029323, -63646261 },
{ 1416925, -63666243 },
{ 1541532, -63643075 },
{ 1541535, -63643075 },
{ 1541535, -63643074 },
{ 1552612, -63641015 },
{ 1631609, -63568270 },
{ 1678393, -63443639 },
{ 1725519, -63219942 },
{ 1770552, -62903321 },
{ 1742544, -62755934 },
{ 1758152, -62588378 },
{ 1702289, -62474826 },
{ 1638627, -62242058 },
{ 1671281, -61938568 },
{ 1792676, -61478332 },
{ 1934894, -60760597 },
{ 2160333, -60064089 },
{ 2638183, -58972890 },
{ 2933095, -58478536 },
{ 3173586, -58159527 },
{ 3557779, -57556727 },
{ 3707088, -57158174 },
{ 3758053, -56907139 },
{ 3935932, -56278649 },
{ 4077331, -56033426 },
{ 4151386, -55768739 },
{ 4293796, -55561683 },
{ 4383089, -55387391 },
{ 4614128, -55201443 },
{ 5268755, -54333831 },
{ 5547634, -53797296 },
{ 5573864, -53639250 },
{ 5736812, -53304157 },
{ 6090973, -52066302 },
{ 6148630, -51666664 },
{ 6189511, -50974991 },
{ 6244112, -50774489 },
{ 6302489, -50761556 },
{ 6511179, -50579861 },
{ 6778128, -50398667 },
{ 6896879, -50350264 },
{ 7388259, -49913262 },
{ 7630584, -49602449 },
{ 7886846, -48987881 },
{ 7871333, -48318666 },
{ 7770349, -47841179 },
{ 7570223, -47234733 },
{ 7283115, -46705503 },
{ 6842948, -46056539 },
{ 6612732, -45760004 },
{ 6150430, -44991494 },
{ 5564326, -44168114 },
{ 5193032, -43807544 },
{ 4932097, -43489047 },
{ 3857385, -42548846 },
{ 3764745, -42081468 },
{ 3539887, -41422273 },
{ 3283048, -40803856 },
{ 3005925, -40367981 },
{ 3136185, -39834533 },
{ 3333757, -38499972 },
{ 3360660, -38183895 },
{ 3353375, -38036005 },
{ 3398808, -37582504 },
{ 3604229, -37221781 },
{ 3698079, -36962934 },
{ 4000449, -36007804 },
{ 4256811, -35016707 },
{ 4405951, -34581428 },
{ 4364534, -34178439 },
{ 4124603, -33432250 },
{ 3806159, -32765167 },
{ 3359088, -32109020 },
{ 2880790, -31317192 },
{ 1548334, -30402139 },
{ -7, -30131023 },
{ -1548347, -30402139 },
{ -2880803, -31317189 },
{ -3359100, -32109018 },
{ -3806173, -32765166 },
{ -4124617, -33432248 },
{ -4364548, -34178436 },
{ -4405966, -34581423 },
{ -4256825, -35016707 },
{ -4000461, -36007800 },
{ -3698093, -36962933 },
{ -3604243, -37221781 },
{ -3398823, -37582501 },
{ -3353390, -38036003 },
{ -3360675, -38183892 },
{ -3333772, -38499972 },
{ -3136200, -39834530 },
{ -3005940, -40367980 },
{ -3283062, -40803852 },
{ -3539902, -41422273 },
{ -3764761, -42081468 },
{ -3857402, -42548846 },
{ -4932112, -43489047 },
{ -5193047, -43807544 },
{ -5564341, -44168114 },
{ -6150446, -44991494 },
{ -6612748, -45760000 },
{ -6842965, -46056536 },
{ -7283130, -46705503 },
{ -7570238, -47234733 },
{ -7770365, -47841179 },
{ -7871349, -48318666 },
{ -7886860, -48987873 },
{ -7630599, -49602451 },
{ -7388277, -49913260 },
{ -6896896, -50350264 },
{ -6778145, -50398667 },
{ -6511196, -50579862 },
{ -6302504, -50761557 },
{ -6244127, -50774488 },
{ -6189527, -50974989 },
{ -6148648, -51666664 },
{ -6090990, -52066302 },
{ -5736829, -53304157 },
{ -5573882, -53639250 },
{ -5547651, -53797296 },
{ -5268772, -54333831 },
{ -4614145, -55201443 },
{ -4383106, -55387389 },
{ -4293814, -55561683 },
{ -4151404, -55768739 },
{ -4077350, -56033423 },
{ -3935952, -56278647 },
{ -3758072, -56907137 },
{ -3707107, -57158170 },
{ -3557796, -57556727 },
{ -3173605, -58159527 },
{ -2933113, -58478536 },
{ -2638201, -58972890 },
{ -2295003, -59738435 },
{ -2160353, -60064089 },
{ -1978487, -60596626 },
{ -1792695, -61478332 },
{ -1671298, -61938574 },
{ -1638646, -62242058 },
{ -1702306, -62474826 },
{ -1758168, -62588380 },
{ -1742563, -62755934 },
{ -1770570, -62903317 },
{ -1725537, -63219946 },
{ -1678412, -63443639 },
{ -1631627, -63568270 },
{ -1553479, -63640201 },
{ -1416944, -63666243 },
{ -998854, -63645714 },
{ -485685, -64191173 },
{ -577019, -64484225 },
{ -585667, -64583538 },
{ -541079, -64669076 },
{ -434910, -64754575 },
{ -294192, -64810609 },
{ 294172, -64810609 },
},
// Hole 1
{
{ -842246, -45167428 },
{ -1473641, -45154392 },
{ -2181728, -45100161 },
{ -2804308, -44985842 },
{ -3100514, -44879269 },
{ -3836807, -44802155 },
{ -4035816, -44718913 },
{ -4167175, -44583299 },
{ -4496705, -44467674 },
{ -4486674, -44382045 },
{ -4343949, -44070577 },
{ -3740991, -43494686 },
{ -2701372, -43313358 },
{ -1493599, -43312838 },
{ -8, -43352868 },
{ 1414575, -43313336 },
{ 2701358, -43313358 },
{ 3095462, -43374735 },
{ 3740975, -43494686 },
{ 4343934, -44070583 },
{ 4486657, -44382044 },
{ 4496688, -44467670 },
{ 4167159, -44583300 },
{ 4035800, -44718913 },
{ 3836792, -44802155 },
{ 3100498, -44879269 },
{ 2804292, -44985842 },
{ 2181712, -45100161 },
{ 1473625, -45154389 },
{ 842231, -45167428 },
{ -8, -45232686 },
},
// Hole 2
{
{ 1657455, -63016679 },
{ 1723196, -63056286 },
{ 1541535, -63643074 },
{ 1541532, -63643075 },
{ 1030020, -63645562 },
}
};
VD vd;
Lines lines = to_lines(poly);
construct_voronoi(lines.begin(), lines.end(), &vd);
for (const OffsetTest &ot : {
OffsetTest { scale_(0.2), 2, 2 },
OffsetTest { scale_(0.4), 2, 2 },
OffsetTest { scale_(0.49), 2, 3 },
OffsetTest { scale_(0.51), 2, 2 },
OffsetTest { scale_(0.56), 2, 2 },
OffsetTest { scale_(0.6), 2, 2 },
OffsetTest { scale_(0.7), 2, 2 },
OffsetTest { scale_(0.8), 2, 2 },
OffsetTest { scale_(0.9), 2, 2 },
OffsetTest { scale_(0.99), 1, 2 },
OffsetTest { scale_(1.0), 1, 2 },
OffsetTest { scale_(1.01), 1, 2 },
}) {
Polygons offsetted_polygons_out = Slic3r::Voronoi::offset(vd, lines, ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset3-out-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_out);
#endif
REQUIRE(offsetted_polygons_out.size() == ot.num_outer);
Polygons offsetted_polygons_in = Slic3r::Voronoi::offset(vd, lines, - ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset3-in-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_in);
#endif
REQUIRE(offsetted_polygons_in.size() == ot.num_inner);
}
}
// A sample extracted from file medallion_printable_fixed-teeth.stl from https://www.thingiverse.com/thing:1347129
// This test for offset scale_(2.9) and bigger
// triggers assert(r < std::max(d0, d1) + EPSILON) in function first_circle_segment_intersection_parameter.
TEST_CASE("Voronoi offset 5", "[VoronoiOffset5]")
{
Polygons poly = {
Polygon {
{ 0 , -16077501 },
{ 3015222 , -16142836 },
{ 3072642 , -16138163 },
{ 3094279 , -16105662 },
{ 3110660 , -15140728 },
{ 3157438 , -14105326 },
{ 3338367 , -11081394 },
{ 3443412 , -8381621 },
{ 3472489 , -6084497 },
{ 3445790 , -5962924 },
{ 3061725 , -6003484 },
{ 3030326 , -6030622 },
{ 2989343 , -6270378 },
{ 2903752 , -7368176 },
{ 2856704 , -7740619 },
{ 2795743 , -7978809 },
{ 2729231 , -8098866 },
{ 2666509 , -8131138 },
{ 2614169 , -8112308 },
{ 2561157 , -8032014 },
{ 2488290 , -7479351 },
{ 2453360 , -6911556 },
{ 2456148 , -6463146 },
{ 2546029 , -4580396 },
{ 2688181 , -2593262 },
{ 2717617 , -1700519 },
{ 2682232 , -1128411 },
{ 2631029 , -832886 },
{ 2535941 , -504483 },
{ 2399115 , -199303 },
{ 2290997 , -171213 },
{ 611824 , -132865 },
{ 6419 , -375849 },
{ -611825 , -132865 },
{ -2377355 , -185241 },
{ -2420740 , -231171 },
{ -2535942 , -504484 },
{ -2631030 , -832887 },
{ -2684831 , -1150821 },
{ -2714840 , -1586454 },
{ -2688181 , -2593262 },
{ -2546030 , -4580396 },
{ -2456149 , -6463145 },
{ -2453361 , -6911557 },
{ -2488291 , -7479352 },
{ -2561159 , -8032018 },
{ -2614171 , -8112309 },
{ -2666509 , -8131138 },
{ -2729233 , -8098868 },
{ -2795744 , -7978809 },
{ -2856706 , -7740619 },
{ -2903752 , -7368176 },
{ -2989345 , -6270378 },
{ -3030327 , -6030622 },
{ -3061726 , -6003484 },
{ -3445790 , -5962924 },
{ -3472490 , -6084498 },
{ -3468804 , -7244095 },
{ -3399287 , -9714025 },
{ -3338368 , -11081395 },
{ -3141015 , -14446051 },
{ -3094280 , -16105662 },
{ -3072643 , -16138163 },
{ -3008836 , -16143225 }
}
};
double area = std::accumulate(poly.begin(), poly.end(), 0., [](double a, auto &poly){ return a + poly.area(); });
REQUIRE(area > 0.);
VD vd;
Lines lines = to_lines(poly);
construct_voronoi(lines.begin(), lines.end(), &vd);
for (const OffsetTest &ot : {
OffsetTest { scale_(2.8), 1, 1 },
OffsetTest { scale_(2.9), 1, 1 },
OffsetTest { scale_(3.0), 1, 1 },
}) {
Polygons offsetted_polygons_out = Slic3r::Voronoi::offset(vd, lines, ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset5-out-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_out);
#endif
REQUIRE(offsetted_polygons_out.size() == ot.num_outer);
Polygons offsetted_polygons_in = Slic3r::Voronoi::offset(vd, lines, - ot.distance, scale_(0.005));
#ifdef VORONOI_DEBUG_OUT
dump_voronoi_to_svg(debug_out_path("voronoi-offset5-in-%lf.svg", ot.distance).c_str(),
vd, Points(), lines, offsetted_polygons_in);
#endif
REQUIRE(offsetted_polygons_in.size() == ot.num_inner);
}
}
TEST_CASE("Voronoi skeleton", "[VoronoiSkeleton]")
{
coord_t mm = coord_t(scale_(1.));
Polygons poly = {
Polygon {
{ 0, 0 },
{ 1, 0 },
{ 1, 1 },
{ 2, 1 },
{ 2, 0 },
{ 3, 0 },
{ 3, 2 },
{ 0, 2 }
},
Polygon {
{ 0, - 1 - 2 },
{ 3, - 1 - 2 },
{ 3, - 1 - 0 },
{ 2, - 1 - 0 },
{ 2, - 1 - 1 },
{ 1, - 1 - 1 },
{ 1, - 1 - 0 },
{ 0, - 1 - 0 }
},
};
for (Polygon &p : poly)
for (Point &pt : p.points)
pt *= mm;
double area = std::accumulate(poly.begin(), poly.end(), 0., [](double a, auto &poly){ return a + poly.area(); });
REQUIRE(area > 0.);
VD vd;
Lines lines = to_lines(poly);
construct_voronoi(lines.begin(), lines.end(), &vd);
Slic3r::Voronoi::annotate_inside_outside(vd, lines);
Slic3r::Voronoi::annotate_inside_outside(vd, lines);
static constexpr double threshold_alpha = M_PI / 12.; // 30 degrees
std::vector<Vec2d> skeleton_edges = Slic3r::Voronoi::skeleton_edges_rough(vd, lines, threshold_alpha);
REQUIRE(! skeleton_edges.empty());
}