debugging function debug_output_path() moved to utils.cpp/hpp

and it now prints to console the default path when called for the first time.
Fixed compilation of debugging output in SupportMaterial.
This commit is contained in:
Vojtech Bubnik 2021-08-27 11:25:50 +02:00
parent f90b10b63e
commit ae8e0311d7
4 changed files with 75 additions and 64 deletions

View File

@ -37,6 +37,7 @@
#define DEBUG #define DEBUG
#define _DEBUG #define _DEBUG
#undef NDEBUG #undef NDEBUG
#include "utils.hpp"
#include "SVG.hpp" #include "SVG.hpp"
#endif #endif
@ -429,7 +430,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
for (const MyLayer *layer : top_contacts) for (const MyLayer *layer : top_contacts)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-top-contacts-%d-%lf.svg", iRun, layer->print_z), debug_out_path("support-top-contacts-%d-%lf.svg", iRun, layer->print_z),
union_ex(layer->polygons, false)); union_ex(layer->polygons));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating bottom contacts"; BOOST_LOG_TRIVIAL(info) << "Support generator - Creating bottom contacts";
@ -447,7 +448,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
for (size_t layer_id = 0; layer_id < object.layers().size(); ++ layer_id) for (size_t layer_id = 0; layer_id < object.layers().size(); ++ layer_id)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-areas-%d-%lf.svg", iRun, object.layers()[layer_id]->print_z), debug_out_path("support-areas-%d-%lf.svg", iRun, object.layers()[layer_id]->print_z),
union_ex(layer_support_areas[layer_id], false)); union_ex(layer_support_areas[layer_id]));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating intermediate layers - indices"; BOOST_LOG_TRIVIAL(info) << "Support generator - Creating intermediate layers - indices";
@ -466,7 +467,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
for (const MyLayer *layer : top_contacts) for (const MyLayer *layer : top_contacts)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-top-contacts-trimmed-by-object-%d-%lf.svg", iRun, layer->print_z), debug_out_path("support-top-contacts-trimmed-by-object-%d-%lf.svg", iRun, layer->print_z),
union_ex(layer->polygons, false)); union_ex(layer->polygons));
#endif #endif
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating base layers"; BOOST_LOG_TRIVIAL(info) << "Support generator - Creating base layers";
@ -478,7 +479,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
for (MyLayersPtr::const_iterator it = intermediate_layers.begin(); it != intermediate_layers.end(); ++ it) for (MyLayersPtr::const_iterator it = intermediate_layers.begin(); it != intermediate_layers.end(); ++ it)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-base-layers-%d-%lf.svg", iRun, (*it)->print_z), debug_out_path("support-base-layers-%d-%lf.svg", iRun, (*it)->print_z),
union_ex((*it)->polygons, false)); union_ex((*it)->polygons));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
BOOST_LOG_TRIVIAL(info) << "Support generator - Trimming top contacts by bottom contacts"; BOOST_LOG_TRIVIAL(info) << "Support generator - Trimming top contacts by bottom contacts";
@ -507,11 +508,11 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
for (const MyLayer *l : interface_layers) for (const MyLayer *l : interface_layers)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-interface-layers-%d-%lf.svg", iRun, l->print_z), debug_out_path("support-interface-layers-%d-%lf.svg", iRun, l->print_z),
union_ex(l->polygons, false)); union_ex(l->polygons));
for (const MyLayer *l : base_interface_layers) for (const MyLayer *l : base_interface_layers)
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-base-interface-layers-%d-%lf.svg", iRun, l->print_z), debug_out_path("support-base-interface-layers-%d-%lf.svg", iRun, l->print_z),
union_ex(l->polygons, false)); union_ex(l->polygons));
#endif // SLIC3R_DEBUG #endif // SLIC3R_DEBUG
/* /*
@ -1308,9 +1309,9 @@ namespace SupportMaterialInternal {
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
static int iRun = 0; static int iRun = 0;
SVG::export_expolygons(debug_out_path("support-top-contacts-remove-bridges-run%d.svg", iRun ++), SVG::export_expolygons(debug_out_path("support-top-contacts-remove-bridges-run%d.svg", iRun ++),
{ { { union_ex(offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS), false) }, { "unsupported_bridge_edges", "orange", 0.5f } }, { { { union_ex(offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS)) }, { "unsupported_bridge_edges", "orange", 0.5f } },
{ { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, { { union_ex(contact_polygons) }, { "contact_polygons", "blue", 0.5f } },
{ { union_ex(bridges, false) }, { "bridges", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_ex(bridges) }, { "bridges", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
} }
} }
@ -1494,7 +1495,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
iRun, layer_id, iRun, layer_id,
std::find_if(layer.regions().begin(), layer.regions().end(), [layerm](const LayerRegion* other){return other == layerm;}) - layer.regions().begin()), std::find_if(layer.regions().begin(), layer.regions().end(), [layerm](const LayerRegion* other){return other == layerm;}) - layer.regions().begin()),
get_extents(diff_polygons)); get_extents(diff_polygons));
Slic3r::ExPolygons expolys = union_ex(diff_polygons, false); Slic3r::ExPolygons expolys = union_ex(diff_polygons);
svg.draw(expolys); svg.draw(expolys);
} }
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
@ -1512,7 +1513,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
iRun, layer_id, iRun, layer_id,
std::find_if(layer.regions().begin(), layer.regions().end(), [layerm](const LayerRegion* other){return other == layerm;}) - layer.regions().begin(), std::find_if(layer.regions().begin(), layer.regions().end(), [layerm](const LayerRegion* other){return other == layerm;}) - layer.regions().begin(),
layer.print_z), layer.print_z),
union_ex(diff_polygons, false)); union_ex(diff_polygons));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
//FIXME the overhang_polygons are used to construct the support towers as well. //FIXME the overhang_polygons are used to construct the support towers as well.
@ -1572,10 +1573,10 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
offset(lower_layer_polygons, 0.05f * fw, SUPPORT_SURFACES_OFFSET_PARAMETERS)); offset(lower_layer_polygons, 0.05f * fw, SUPPORT_SURFACES_OFFSET_PARAMETERS));
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-top-contacts-enforcers-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), SVG::export_expolygons(debug_out_path("support-top-contacts-enforcers-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
{ { layer.lslices, { "layer.lslices", "gray", 0.2f } }, { { layer.lslices, { "layer.lslices", "gray", 0.2f } },
{ { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "green", 0.5f } }, { { union_ex(lower_layer_polygons) }, { "lower_layer_polygons", "green", 0.5f } },
{ enforcers_united, { "enforcers", "blue", 0.5f } }, { enforcers_united, { "enforcers", "blue", 0.5f } },
{ { union_ex(enforcer_polygons, true) }, { "new_contacts", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(enforcer_polygons) }, { "new_contacts", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
polygons_append(overhang_polygons, enforcer_polygons); polygons_append(overhang_polygons, enforcer_polygons);
polygons_append(contact_polygons, diff(enforcer_polygons, slices_margin.all_polygons.empty() ? slices_margin.polygons : slices_margin.all_polygons)); polygons_append(contact_polygons, diff(enforcer_polygons, slices_margin.all_polygons.empty() ? slices_margin.polygons : slices_margin.all_polygons));
@ -1739,18 +1740,18 @@ static inline void fill_contact_layer(
); );
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
{ { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, { { { union_ex(lower_layer_polygons) }, { "lower_layer_polygons", "gray", 0.2f } },
{ { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, { { union_ex(*new_layer.contact_polygons) }, { "new_layer.contact_polygons", "yellow", 0.5f } },
{ { union_ex(slices_margin.polygons, false) }, { "slices_margin_cached", "blue", 0.5f } }, { { union_ex(slices_margin.polygons) }, { "slices_margin_cached", "blue", 0.5f } },
{ { union_ex(dense_interface_polygons, false) }, { "dense_interface_polygons", "green", 0.5f } }, { { union_ex(dense_interface_polygons) }, { "dense_interface_polygons", "green", 0.5f } },
{ { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(new_layer.polygons) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
//support_grid_pattern.serialize(debug_out_path("support-top-contacts-final-run%d-layer%d-z%f.bin", iRun, layer_id, layer.print_z)); //support_grid_pattern.serialize(debug_out_path("support-top-contacts-final-run%d-layer%d-z%f.bin", iRun, layer_id, layer.print_z));
SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
{ { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, { { { union_ex(lower_layer_polygons) }, { "lower_layer_polygons", "gray", 0.2f } },
{ { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, { { union_ex(*new_layer.contact_polygons) }, { "new_layer.contact_polygons", "yellow", 0.5f } },
{ { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, { { union_ex(contact_polygons) }, { "contact_polygons", "blue", 0.5f } },
{ { union_ex(dense_interface_polygons, false) }, { "dense_interface_polygons", "green", 0.5f } }, { { union_ex(dense_interface_polygons) }, { "dense_interface_polygons", "green", 0.5f } },
{ { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(new_layer.polygons) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
} }
} }
@ -1796,11 +1797,11 @@ static inline void fill_contact_layer(
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
{ { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, { { { union_ex(lower_layer_polygons) }, { "lower_layer_polygons", "gray", 0.2f } },
{ { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, { { union_ex(*new_layer.contact_polygons) }, { "new_layer.contact_polygons", "yellow", 0.5f } },
{ { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, { { union_ex(contact_polygons) }, { "contact_polygons", "blue", 0.5f } },
{ { union_ex(overhang_polygons, false) }, { "overhang_polygons", "green", 0.5f } }, { { union_ex(overhang_polygons) }, { "overhang_polygons", "green", 0.5f } },
{ { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(new_layer.polygons) }, { "new_layer.polygons", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
// Even after the contact layer was expanded into a grid, some of the contact islands may be too tiny to be extruded. // Even after the contact layer was expanded into a grid, some of the contact islands may be too tiny to be extruded.
@ -1964,10 +1965,10 @@ static inline PrintObjectSupportMaterial::MyLayer* detect_bottom_contacts(
Polygons top = collect_region_slices_by_type(layer, stTop); Polygons top = collect_region_slices_by_type(layer, stTop);
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-bottom-layers-raw-%d-%lf.svg", iRun, layer.print_z), SVG::export_expolygons(debug_out_path("support-bottom-layers-raw-%d-%lf.svg", iRun, layer.print_z),
{ { { union_ex(top, false) }, { "top", "blue", 0.5f } }, { { { union_ex(top) }, { "top", "blue", 0.5f } },
{ { union_ex(supports_projected, true) }, { "overhangs", "magenta", 0.5f } }, { { union_safety_offset_ex(supports_projected) }, { "overhangs", "magenta", 0.5f } },
{ layer.lslices, { "layer.lslices", "green", 0.5f } }, { layer.lslices, { "layer.lslices", "green", 0.5f } },
{ { union_ex(polygons_new, true) }, { "polygons_new", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(polygons_new) }, { "polygons_new", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
// Now find whether any projection of the contact surfaces above layer.print_z not yet supported by any // Now find whether any projection of the contact surfaces above layer.print_z not yet supported by any
@ -2037,7 +2038,7 @@ static inline PrintObjectSupportMaterial::MyLayer* detect_bottom_contacts(
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-bottom-contacts-%d-%lf.svg", iRun, layer_new.print_z), debug_out_path("support-bottom-contacts-%d-%lf.svg", iRun, layer_new.print_z),
union_ex(layer_new.polygons, false)); union_ex(layer_new.polygons));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
// Trim the already created base layers above the current layer intersecting with the new bottom contacts layer. // Trim the already created base layers above the current layer intersecting with the new bottom contacts layer.
@ -2050,14 +2051,14 @@ static inline PrintObjectSupportMaterial::MyLayer* detect_bottom_contacts(
if (! layer_support_areas[layer_id_above].empty()) { if (! layer_support_areas[layer_id_above].empty()) {
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-support-areas-raw-before-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z), SVG::export_expolygons(debug_out_path("support-support-areas-raw-before-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z),
{ { { union_ex(touching, false) }, { "touching", "blue", 0.5f } }, { { { union_ex(touching) }, { "touching", "blue", 0.5f } },
{ { union_ex(layer_support_areas[layer_id_above], true) }, { "above", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(layer_support_areas[layer_id_above]) }, { "above", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
layer_support_areas[layer_id_above] = diff(layer_support_areas[layer_id_above], touching); layer_support_areas[layer_id_above] = diff(layer_support_areas[layer_id_above], touching);
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-support-areas-raw-after-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z), debug_out_path("support-support-areas-raw-after-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z),
union_ex(layer_support_areas[layer_id_above], false)); union_ex(layer_support_areas[layer_id_above]));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
} }
} }
@ -2080,8 +2081,8 @@ static inline std::pair<Polygons, Polygons> project_support_to_grid(const Layer
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-support-areas-%s-raw-%d-%lf.svg", debug_name, iRun, layer.print_z), SVG::export_expolygons(debug_out_path("support-support-areas-%s-raw-%d-%lf.svg", debug_name, iRun, layer.print_z),
{ { { union_ex(trimming, false) }, { "trimming", "blue", 0.5f } }, { { { union_ex(trimming) }, { "trimming", "blue", 0.5f } },
{ { union_ex(overhangs_projection, true) }, { "overhangs_projection", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(overhangs_projection) }, { "overhangs_projection", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
remove_sticks(overhangs_projection); remove_sticks(overhangs_projection);
@ -2089,8 +2090,8 @@ static inline std::pair<Polygons, Polygons> project_support_to_grid(const Layer
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-support-areas-%s-raw-cleaned-%d-%lf.svg", debug_name, iRun, layer.print_z), SVG::export_expolygons(debug_out_path("support-support-areas-%s-raw-cleaned-%d-%lf.svg", debug_name, iRun, layer.print_z),
{ { { union_ex(trimming, false) }, { "trimming", "blue", 0.5f } }, { { { union_ex(trimming) }, { "trimming", "blue", 0.5f } },
{ { union_ex(overhangs_projection, false) }, { "overhangs_projection", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_ex(overhangs_projection) }, { "overhangs_projection", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
SupportGridPattern support_grid_pattern(&overhangs_projection, &trimming, grid_params); SupportGridPattern support_grid_pattern(&overhangs_projection, &trimming, grid_params);
@ -2113,7 +2114,7 @@ static inline std::pair<Polygons, Polygons> project_support_to_grid(const Layer
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-layer_support_area-gridded-%s-%d-%lf.svg", debug_name, iRun, layer.print_z), debug_out_path("support-layer_support_area-gridded-%s-%d-%lf.svg", debug_name, iRun, layer.print_z),
union_ex(out.first, false)); union_ex(out.first));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
}); });
@ -2131,13 +2132,13 @@ static inline std::pair<Polygons, Polygons> project_support_to_grid(const Layer
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons( Slic3r::SVG::export_expolygons(
debug_out_path("support-projection_new-gridded-%d-%lf.svg", iRun, layer.print_z), debug_out_path("support-projection_new-gridded-%d-%lf.svg", iRun, layer.print_z),
union_ex(out.second, false)); union_ex(out.second));
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
#ifdef SLIC3R_DEBUG #ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-projection_new-gridded-%d-%lf.svg", iRun, layer.print_z), SVG::export_expolygons(debug_out_path("support-projection_new-gridded-%d-%lf.svg", iRun, layer.print_z),
{ { { union_ex(trimming, false) }, { "trimming", "gray", 0.5f } }, { { { union_ex(trimming) }, { "trimming", "gray", 0.5f } },
{ { union_ex(overhangs_projection, true) }, { "overhangs_projection", "blue", 0.5f } }, { { union_safety_offset_ex(overhangs_projection) }, { "overhangs_projection", "blue", 0.5f } },
{ { union_ex(out.second, true) }, { "projection_new", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } }); { { union_safety_offset_ex(out.second) }, { "projection_new", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
}); });
@ -2667,10 +2668,10 @@ void PrintObjectSupportMaterial::generate_base_layers(
BoundingBox bbox = get_extents(polygons_new); BoundingBox bbox = get_extents(polygons_new);
bbox.merge(get_extents(polygons_trimming)); bbox.merge(get_extents(polygons_trimming));
::Slic3r::SVG svg(debug_out_path("support-intermediate-layers-raw-%d-%lf.svg", iRun, layer_intermediate.print_z), bbox); ::Slic3r::SVG svg(debug_out_path("support-intermediate-layers-raw-%d-%lf.svg", iRun, layer_intermediate.print_z), bbox);
svg.draw(union_ex(polygons_new, false), "blue", 0.5f); svg.draw(union_ex(polygons_new), "blue", 0.5f);
svg.draw(to_polylines(polygons_new), "blue"); svg.draw(to_polylines(polygons_new), "blue");
svg.draw(union_ex(polygons_trimming, true), "red", 0.5f); svg.draw(union_safety_offset_ex(polygons_trimming), "red", 0.5f);
svg.draw(to_polylines(polygons_trimming), "red"); svg.draw(to_polylines(polygons_trimming), "red");
} }
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */
@ -2706,7 +2707,7 @@ void PrintObjectSupportMaterial::generate_base_layers(
for (MyLayersPtr::const_iterator it = intermediate_layers.begin(); it != intermediate_layers.end(); ++it) for (MyLayersPtr::const_iterator it = intermediate_layers.begin(); it != intermediate_layers.end(); ++it)
::Slic3r::SVG::export_expolygons( ::Slic3r::SVG::export_expolygons(
debug_out_path("support-intermediate-layers-untrimmed-%d-%lf.svg", iRun, (*it)->print_z), debug_out_path("support-intermediate-layers-untrimmed-%d-%lf.svg", iRun, (*it)->print_z),
union_ex((*it)->polygons, false)); union_ex((*it)->polygons));
++ iRun; ++ iRun;
#endif /* SLIC3R_DEBUG */ #endif /* SLIC3R_DEBUG */

View File

@ -58,6 +58,11 @@ void set_data_dir(const std::string &path);
// Return a full path to the GUI resource files. // Return a full path to the GUI resource files.
const std::string& data_dir(); const std::string& data_dir();
// Format an output path for debugging purposes.
// Writes out the output path prefix to the console for the first time the function is called,
// so the user knows where to search for the debugging output.
std::string debug_out_path(const char *name, ...);
// A special type for strings encoded in the local Windows 8-bit code page. // A special type for strings encoded in the local Windows 8-bit code page.
// This type is only needed for Perl bindings to relay to Perl that the string is raw, not UTF-8 encoded. // This type is only needed for Perl bindings to relay to Perl that the string is raw, not UTF-8 encoded.
typedef std::string local_encoded_string; typedef std::string local_encoded_string;

View File

@ -65,18 +65,6 @@ static constexpr double EXTERNAL_INFILL_MARGIN = 3.;
#define SCALED_EPSILON scale_(EPSILON) #define SCALED_EPSILON scale_(EPSILON)
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
inline std::string debug_out_path(const char *name, ...)
{
char buffer[2048];
va_list args;
va_start(args, name);
std::vsprintf(buffer, name, args);
va_end(args);
return std::string(SLIC3R_DEBUG_OUT_PATH_PREFIX) + std::string(buffer);
}
#ifndef UNUSED #ifndef UNUSED
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
#endif /* UNUSED */ #endif /* UNUSED */

View File

@ -207,6 +207,23 @@ std::string custom_shapes_dir()
return (boost::filesystem::path(g_data_dir) / "shapes").string(); return (boost::filesystem::path(g_data_dir) / "shapes").string();
} }
static std::atomic<bool> debug_out_path_called(false);
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();
printf("Debugging output files will be written to %s\n", path.c_str());
}
char buffer[2048];
va_list args;
va_start(args, name);
std::vsprintf(buffer, name, args);
va_end(args);
return std::string(SLIC3R_DEBUG_OUT_PATH_PREFIX) + std::string(buffer);
}
#ifdef _WIN32 #ifdef _WIN32
// The following helpers are borrowed from the LLVM project https://github.com/llvm // The following helpers are borrowed from the LLVM project https://github.com/llvm
namespace WindowsSupport namespace WindowsSupport