From 63ebebf4a0a6d013a79de5ea0c71b2328749de40 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 5 Sep 2024 09:45:59 +0800 Subject: [PATCH] Improve debugging output --- src/libslic3r/LayerRegion.cpp | 4 ++-- src/libslic3r/PrintObject.cpp | 26 +++++++++++++------------- src/libslic3r/utils.cpp | 3 +++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 2900c2fae9..df6d20258b 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -424,10 +424,10 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly expand_merge_surfaces(this->fill_surfaces.surfaces, stBottomBridge, shells, expansion_params_into_solid_infill, sparse, expansion_params_into_sparse_infill, closing_radius, Geometry::deg2rad(custom_angle)) : expand_bridges_detect_orientations(this->fill_surfaces.surfaces, shells, expansion_params_into_solid_infill, sparse, expansion_params_into_sparse_infill, closing_radius); BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done"; -#if 0 +#ifdef SLIC3R_DEBUG_SLICE_PROCESSING { static int iRun = 0; - bridges.export_to_svg(debug_out_path("bridges-after-grouping-%d.svg", iRun++), true); + bridges.export_to_svg(debug_out_path("bridges-after-grouping-%d.svg", iRun++).c_str(), true); } #endif } diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 7b16f8a697..16c986bfac 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -447,17 +447,6 @@ void PrintObject::prepare_infill() #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ - // Debugging output. -#ifdef SLIC3R_DEBUG_SLICE_PROCESSING - for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) { - for (const Layer *layer : m_layers) { - LayerRegion *layerm = layer->m_regions[region_id]; - layerm->export_region_slices_to_svg_debug("3_process_external_surfaces-final"); - layerm->export_region_fill_surfaces_to_svg_debug("3_process_external_surfaces-final"); - } // for each layer - } // for each region -#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ - // Detect, which fill surfaces are near external layers. // They will be split in internal and internal-solid surfaces. // The purpose is to add a configurable number of solid layers to support the TOP surfaces @@ -469,6 +458,16 @@ void PrintObject::prepare_infill() this->discover_horizontal_shells(); m_print->throw_if_canceled(); +#ifdef SLIC3R_DEBUG_SLICE_PROCESSING + for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) { + for (const Layer *layer : m_layers) { + LayerRegion *layerm = layer->m_regions[region_id]; + layerm->export_region_slices_to_svg_debug("5_discover_horizontal_shells-final"); + layerm->export_region_fill_surfaces_to_svg_debug("5_discover_horizontal_shells-final"); + } // for each layer + } // for each region +#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ + // this will detect bridges and reverse bridges // and rearrange top/bottom/internal surfaces // It produces enlarged overlapping bridging areas. @@ -481,12 +480,13 @@ void PrintObject::prepare_infill() this->process_external_surfaces(); m_print->throw_if_canceled(); + // Debugging output. #ifdef SLIC3R_DEBUG_SLICE_PROCESSING for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) { for (const Layer *layer : m_layers) { LayerRegion *layerm = layer->m_regions[region_id]; - layerm->export_region_slices_to_svg_debug("7_discover_horizontal_shells-final"); - layerm->export_region_fill_surfaces_to_svg_debug("7_discover_horizontal_shells-final"); + layerm->export_region_slices_to_svg_debug("7_process_external_surfaces-final"); + layerm->export_region_fill_surfaces_to_svg_debug("7_process_external_surfaces-final"); } // for each layer } // for each region #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 733ac626f4..b6900553ee 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -301,6 +301,9 @@ std::string debug_out_path(const char *name, ...) static constexpr const char *SLIC3R_DEBUG_OUT_PATH_PREFIX = "out/"; if (! debug_out_path_called.exchange(true)) { std::string path = boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX).string(); + if (!boost::filesystem::exists(path)) { + boost::filesystem::create_directory(path); + } printf("Debugging output files will be written to %s\n", path.c_str()); } char buffer[2048];