Improve debugging output

This commit is contained in:
Noisyfox 2024-09-05 09:45:59 +08:00
parent c179a57725
commit 63ebebf4a0
3 changed files with 18 additions and 15 deletions

View file

@ -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_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); 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"; BOOST_LOG_TRIVIAL(trace) << "Processing external surface, detecting bridges - done";
#if 0 #ifdef SLIC3R_DEBUG_SLICE_PROCESSING
{ {
static int iRun = 0; 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 #endif
} }

View file

@ -447,17 +447,6 @@ void PrintObject::prepare_infill()
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ #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. // Detect, which fill surfaces are near external layers.
// They will be split in internal and internal-solid surfaces. // 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 // 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(); this->discover_horizontal_shells();
m_print->throw_if_canceled(); 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 // this will detect bridges and reverse bridges
// and rearrange top/bottom/internal surfaces // and rearrange top/bottom/internal surfaces
// It produces enlarged overlapping bridging areas. // It produces enlarged overlapping bridging areas.
@ -481,12 +480,13 @@ void PrintObject::prepare_infill()
this->process_external_surfaces(); this->process_external_surfaces();
m_print->throw_if_canceled(); m_print->throw_if_canceled();
// Debugging output.
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING #ifdef SLIC3R_DEBUG_SLICE_PROCESSING
for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) { for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) {
for (const Layer *layer : m_layers) { for (const Layer *layer : m_layers) {
LayerRegion *layerm = layer->m_regions[region_id]; LayerRegion *layerm = layer->m_regions[region_id];
layerm->export_region_slices_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_discover_horizontal_shells-final"); layerm->export_region_fill_surfaces_to_svg_debug("7_process_external_surfaces-final");
} // for each layer } // for each layer
} // for each region } // for each region
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */

View file

@ -301,6 +301,9 @@ std::string debug_out_path(const char *name, ...)
static constexpr const char *SLIC3R_DEBUG_OUT_PATH_PREFIX = "out/"; static constexpr const char *SLIC3R_DEBUG_OUT_PATH_PREFIX = "out/";
if (! debug_out_path_called.exchange(true)) { if (! debug_out_path_called.exchange(true)) {
std::string path = boost::filesystem::system_complete(SLIC3R_DEBUG_OUT_PATH_PREFIX).string(); 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()); printf("Debugging output files will be written to %s\n", path.c_str());
} }
char buffer[2048]; char buffer[2048];