diff --git a/backend/app/services/price_engine.py b/backend/app/services/price_engine.py index b8239f1..6828a52 100644 --- a/backend/app/services/price_engine.py +++ b/backend/app/services/price_engine.py @@ -98,14 +98,24 @@ def _estimate_weight(file_info: FileInfo, density_g_cm3: float, logger.debug("Walls: perimeter=%.1f mm/layer, thickness=%.1f mm, volume=%.1f mm3", perimeter_per_layer_mm, wall_thickness_total, wall_volume_mm3) - # Top + bottom solid layers volume + # Top + bottom solid layers volume (use interior footprint, excluding walls) solid_layers = TOP_SOLID_LAYERS + BOTTOM_SOLID_LAYERS solid_volume_mm3 = footprint_mm2 * layer_height_mm * solid_layers logger.debug("Solid top/bottom: footprint=%.1f mm2, layers=%d, volume=%.1f mm3", footprint_mm2, solid_layers, solid_volume_mm3) - # Interior volume for infill (total volume minus walls minus top/bottom) - interior_volume_mm3 = max(volume_mm3 - wall_volume_mm3 - solid_volume_mm3, 0) + # Shell = walls + top/bottom. Cap at 75% of volume so infill always matters. + shell_volume_mm3 = wall_volume_mm3 + solid_volume_mm3 + max_shell = volume_mm3 * 0.75 + if shell_volume_mm3 > max_shell: + scale = max_shell / shell_volume_mm3 + wall_volume_mm3 *= scale + solid_volume_mm3 *= scale + shell_volume_mm3 = max_shell + logger.debug("Shell capped: scale=%.2f, shell=%.1f mm3", scale, shell_volume_mm3) + + # Interior volume for infill (total volume minus shell) + interior_volume_mm3 = volume_mm3 - shell_volume_mm3 infill_volume_mm3 = interior_volume_mm3 * (infill_percent / 100.0) logger.debug("Infill: interior=%.1f mm3, infill%%=%d, infill_volume=%.1f mm3", interior_volume_mm3, infill_percent, infill_volume_mm3) @@ -152,11 +162,18 @@ def _estimate_print_time(file_info: FileInfo, layer_height_mm: float, outer_wall_time_s, inner_wall_time_s, wall_time_s) # Infill time: total infill length / speed - # infill_length = infill_volume / (line_width * layer_height) + # Use weight-based total volume, then subtract shell (capped same as weight calc) total_filament_mm3 = weight_grams / density_g_cm3 * 1000.0 wall_volume_mm3 = perimeter_per_layer_mm * WALL_COUNT * LINE_WIDTH_MM * layer_height_mm * num_layers solid_volume_mm3 = footprint_mm2 * layer_height_mm * (TOP_SOLID_LAYERS + BOTTOM_SOLID_LAYERS) - infill_volume_mm3 = max(total_filament_mm3 - wall_volume_mm3 - solid_volume_mm3, 0) + shell_volume_mm3 = wall_volume_mm3 + solid_volume_mm3 + max_shell = volume_mm3 * 0.75 + if shell_volume_mm3 > max_shell: + scale = max_shell / shell_volume_mm3 + wall_volume_mm3 *= scale + solid_volume_mm3 *= scale + shell_volume_mm3 = max_shell + infill_volume_mm3 = max(total_filament_mm3 - shell_volume_mm3, 0) infill_length_mm = infill_volume_mm3 / (LINE_WIDTH_MM * layer_height_mm) infill_time_s = infill_length_mm / SPEED_INFILL logger.debug("Infill time: length=%.0f mm, time=%.0fs", infill_length_mm, infill_time_s) diff --git a/frontend/src/views/MaterialsView.vue b/frontend/src/views/MaterialsView.vue index 25eaf71..054e335 100644 --- a/frontend/src/views/MaterialsView.vue +++ b/frontend/src/views/MaterialsView.vue @@ -39,8 +39,9 @@
- - {{ c }} + + + {{ c.name }}