|
12 | 12 | #include "Support/SupportSpotsGenerator.hpp" |
13 | 13 | #ifdef HAS_RUST_TREE_SUPPORTS |
14 | 14 | #include "Support/TreeSupportRust/include/orca_tree_supports.h" |
| 15 | +#include "Support/SupportCommon.hpp" |
| 16 | +#include "Support/SupportParameters.hpp" |
15 | 17 | #endif |
16 | 18 | #include "Surface.hpp" |
17 | 19 | #include "Slicing.hpp" |
@@ -4018,15 +4020,44 @@ void PrintObject::_generate_support_material() |
4018 | 4020 | TreeSupportHandle *handle = orca_tree_support_create(&cfg, &mesh_data); |
4019 | 4021 | if (handle) { |
4020 | 4022 | SupportOutput *output = orca_tree_support_generate(handle); |
4021 | | - if (output && output->success) { |
4022 | | - // Convert Rust output to SupportLayer objects |
4023 | | - // Note: layer.z is already in millimeters (not scaled) |
| 4023 | + if (output && output->success && output->layer_count > 0) { |
| 4024 | + // Set up support parameters and flow for extrusion generation |
| 4025 | + SupportParameters support_params(*this); |
| 4026 | + Flow support_flow = Slic3r::support_material_flow(this, float(m_slicing_params.layer_height)); |
| 4027 | + |
| 4028 | + // Convert Rust output to SupportLayer objects with polygon data |
4024 | 4029 | for (uint32_t i = 0; i < output->layer_count; i++) { |
4025 | 4030 | const auto &layer = output->layers[i]; |
4026 | 4031 | coordf_t print_z = layer.z; |
4027 | 4032 | coordf_t height = (i > 0) ? print_z - output->layers[i - 1].z : print_z; |
4028 | | - add_tree_support_layer(static_cast<int>(i), height, print_z, print_z - 0.5 * height); |
| 4033 | + SupportLayer *support_layer = add_tree_support_layer(static_cast<int>(i), height, print_z, print_z - 0.5 * height); |
| 4034 | + |
| 4035 | + // Convert Rust polygon data to Slic3r Polygons |
| 4036 | + Polygons polygons; |
| 4037 | + if (layer.polygon_count > 0 && layer.polygon_points != nullptr && layer.polygon_sizes != nullptr) { |
| 4038 | + uint32_t point_offset = 0; |
| 4039 | + for (uint32_t p = 0; p < layer.polygon_count; p++) { |
| 4040 | + uint32_t poly_size = layer.polygon_sizes[p]; |
| 4041 | + Polygon polygon; |
| 4042 | + polygon.points.reserve(poly_size); |
| 4043 | + for (uint32_t j = 0; j < poly_size; j++) { |
| 4044 | + const auto &pt = layer.polygon_points[point_offset + j]; |
| 4045 | + polygon.points.emplace_back(static_cast<coord_t>(pt.x), static_cast<coord_t>(pt.y)); |
| 4046 | + } |
| 4047 | + point_offset += poly_size; |
| 4048 | + if (!polygon.points.empty()) |
| 4049 | + polygons.push_back(std::move(polygon)); |
| 4050 | + } |
| 4051 | + } |
| 4052 | + |
| 4053 | + if (!polygons.empty()) { |
| 4054 | + // Store as base_areas for retraction suppression |
| 4055 | + support_layer->base_areas = union_ex(polygons); |
| 4056 | + // Generate extrusion fills for G-code output |
| 4057 | + tree_supports_generate_paths(support_layer->support_fills.entities, polygons, support_flow, support_params); |
| 4058 | + } |
4029 | 4059 | } |
| 4060 | + BOOST_LOG_TRIVIAL(info) << "Rust tree support generated " << output->layer_count << " layers, " << output->branch_count << " branches"; |
4030 | 4061 | } else if (output && !output->success) { |
4031 | 4062 | BOOST_LOG_TRIVIAL(error) << "Rust tree support generation failed"; |
4032 | 4063 | } else { |
|
0 commit comments