diff options
author | bubnikv <bubnikv@gmail.com> | 2017-03-03 14:53:05 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-03-03 14:53:05 +0300 |
commit | 4d00aa180036c74d494b7762ac7512c67849c4b2 (patch) | |
tree | 93dcac5aa2efc45ec0d2f994ccb352209217e488 /xs | |
parent | 062a6628e54f67dba08491b6ec717163a63523b8 (diff) |
More tracing of the slicing process.
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/libslic3r/Layer.cpp | 8 | ||||
-rw-r--r-- | xs/src/libslic3r/PrintObject.cpp | 12 | ||||
-rw-r--r-- | xs/src/libslic3r/TriangleMesh.cpp | 8 | ||||
-rw-r--r-- | xs/src/libslic3r/Utils.hpp | 1 | ||||
-rw-r--r-- | xs/src/libslic3r/utils.cpp | 28 | ||||
-rw-r--r-- | xs/xsp/XS.xsp | 7 |
6 files changed, 56 insertions, 8 deletions
diff --git a/xs/src/libslic3r/Layer.cpp b/xs/src/libslic3r/Layer.cpp index c40c036e7..f685906e9 100644 --- a/xs/src/libslic3r/Layer.cpp +++ b/xs/src/libslic3r/Layer.cpp @@ -5,6 +5,8 @@ #include "Fill/Fill.hpp" #include "SVG.hpp" +#include <boost/log/trivial.hpp> + namespace Slic3r { Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, @@ -170,9 +172,7 @@ template bool Layer::any_bottom_region_slice_contains<Polyline>(const Polyline & void Layer::make_perimeters() { - #ifdef SLIC3R_DEBUG - printf("Making perimeters for layer " PRINTF_ZU "\n", this->id()); - #endif + BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for layer " << this->id(); // keep track of regions whose perimeters we have already generated std::set<size_t> done; @@ -180,6 +180,7 @@ Layer::make_perimeters() FOREACH_LAYERREGION(this, layerm) { size_t region_id = layerm - this->regions.begin(); if (done.find(region_id) != done.end()) continue; + BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for layer " << this->id() << ", region " << region_id; done.insert(region_id); const PrintRegionConfig &config = (*layerm)->region()->config; @@ -237,6 +238,7 @@ Layer::make_perimeters() } } } + BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for layer " << this->id() << " - Done"; } void Layer::make_fills() diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index bb62217fa..5a97d66fe 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -363,7 +363,7 @@ void PrintObject::detect_surfaces_type() BOOST_LOG_TRIVIAL(info) << "Detecting solid surfaces..."; for (int idx_region = 0; idx_region < this->_print->regions.size(); ++ idx_region) { - BOOST_LOG_TRIVIAL(trace) << "Detecting solid surfaces for region " << idx_region; + BOOST_LOG_TRIVIAL(debug) << "Detecting solid surfaces for region " << idx_region; #ifdef SLIC3R_DEBUG_SLICE_PROCESSING for (int idx_layer = 0; idx_layer < int(this->layer_count()); ++ idx_layer) { LayerRegion *layerm = this->layers[idx_layer]->get_region(idx_region); @@ -825,8 +825,8 @@ PrintObject::discover_vertical_shells() } // for each region // Write the profiler measurements to file - PROFILE_UPDATE(); - PROFILE_OUTPUT(debug_out_path("discover_vertical_shells-profile.txt").c_str()); +// PROFILE_UPDATE(); +// PROFILE_OUTPUT(debug_out_path("discover_vertical_shells-profile.txt").c_str()); } /* This method applies bridge flow to the first internal solid layer above @@ -1143,7 +1143,7 @@ end: std::vector<ExPolygons> PrintObject::_slice_region(size_t region_id, const std::vector<float> &z, bool modifier) { - BOOST_LOG_TRIVIAL(trace) << "Slicing region " << region_id; + BOOST_LOG_TRIVIAL(debug) << "Slicing region " << region_id; std::vector<ExPolygons> layers; assert(region_id < this->region_volumes.size()); @@ -1197,7 +1197,6 @@ PrintObject::_make_perimeters() // hollow objects FOREACH_REGION(this->_print, region_it) { size_t region_id = region_it - this->_print->regions.begin(); - BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for region " << region_id; const PrintRegion ®ion = **region_it; @@ -1206,6 +1205,7 @@ PrintObject::_make_perimeters() || region.config.fill_density == 0 || this->layer_count() < 2) continue; + BOOST_LOG_TRIVIAL(debug) << "Generating extra perimeters for region " << region_id; for (size_t i = 0; i < this->layer_count() - 1; ++ i) { LayerRegion &layerm = *this->get_layer(i)->get_region(region_id); const LayerRegion &upper_layerm = *this->get_layer(i+1)->get_region(region_id); @@ -1267,6 +1267,7 @@ PrintObject::_make_perimeters() } } + BOOST_LOG_TRIVIAL(debug) << "Generating perimeters in parallel"; parallelize<Layer*>( std::queue<Layer*>(std::deque<Layer*>(this->layers.begin(), this->layers.end())), // cast LayerPtrs to std::queue<Layer*> boost::bind(&Slic3r::Layer::make_perimeters, _1), @@ -1289,6 +1290,7 @@ PrintObject::_infill() if (this->state.is_done(posInfill)) return; this->state.set_started(posInfill); + BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel"; parallelize<Layer*>( std::queue<Layer*>(std::deque<Layer*>(this->layers.begin(), this->layers.end())), // cast LayerPtrs to std::queue<Layer*> boost::bind(&Slic3r::Layer::make_fills, _1), diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index d4dcacb13..195092773 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -12,6 +12,8 @@ #include <algorithm> #include <math.h> +#include <boost/log/trivial.hpp> + #if 0 #define DEBUG #define _DEBUG @@ -543,6 +545,7 @@ TriangleMesh::require_shared_vertices() TriangleMeshSlicer::TriangleMeshSlicer(TriangleMesh* _mesh) : mesh(_mesh) { + BOOST_LOG_TRIVIAL(trace) << "TriangleMeshSlicer::constructor"; _mesh->require_shared_vertices(); facets_edges.assign(_mesh->stl.stats.number_of_facets * 3, -1); v_scaled_shared.assign(_mesh->stl.v_shared, _mesh->stl.v_shared + _mesh->stl.stats.shared_vertices); @@ -593,6 +596,8 @@ TriangleMeshSlicer::TriangleMeshSlicer(TriangleMesh* _mesh) : void TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* layers) const { + BOOST_LOG_TRIVIAL(trace) << "TriangleMeshSlicer::slice"; + /* This method gets called with a list of unscaled Z coordinates and outputs a vector pointer having the same number of items as the original list. @@ -620,6 +625,7 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la type is float. */ + BOOST_LOG_TRIVIAL(trace) << "TriangleMeshSlicer::_slice_do"; std::vector<IntersectionLines> lines(z.size()); { boost::mutex lines_mutex; @@ -633,12 +639,14 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la // v_scaled_shared could be freed here // build loops + BOOST_LOG_TRIVIAL(trace) << "TriangleMeshSlicer::_make_loops_do"; layers->resize(z.size()); parallelize<size_t>( 0, lines.size()-1, boost::bind(&TriangleMeshSlicer::_make_loops_do, this, _1, &lines, layers) ); + BOOST_LOG_TRIVIAL(trace) << "TriangleMeshSlicer::slice finished"; } void TriangleMeshSlicer::_slice_do(size_t facet_idx, std::vector<IntersectionLines>* lines, boost::mutex* lines_mutex, diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp index ca2125b06..5e55ccd2b 100644 --- a/xs/src/libslic3r/Utils.hpp +++ b/xs/src/libslic3r/Utils.hpp @@ -4,6 +4,7 @@ namespace Slic3r { extern void set_logging_level(unsigned int level); +extern void trace(unsigned int level, const char *message); } // namespace Slic3r diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index b66d58489..828ece50f 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -9,11 +9,17 @@ static boost::log::trivial::severity_level logSeverity = boost::log::trivial::fa void set_logging_level(unsigned int level) { switch (level) { + // Report fatal errors only. case 0: logSeverity = boost::log::trivial::fatal; break; + // Report fatal errors and errors. case 1: logSeverity = boost::log::trivial::error; break; + // Report fatal errors, errors and warnings. case 2: logSeverity = boost::log::trivial::warning; break; + // Report all errors, warnings and infos. case 3: logSeverity = boost::log::trivial::info; break; + // Report all errors, warnings, infos and debugging. case 4: logSeverity = boost::log::trivial::debug; break; + // Report everyting including fine level tracing information. default: logSeverity = boost::log::trivial::trace; break; } @@ -23,6 +29,28 @@ void set_logging_level(unsigned int level) ); } +void trace(unsigned int level, const char *message) +{ + boost::log::trivial::severity_level severity = boost::log::trivial::trace; + switch (level) { + // Report fatal errors only. + case 0: severity = boost::log::trivial::fatal; break; + // Report fatal errors and errors. + case 1: severity = boost::log::trivial::error; break; + // Report fatal errors, errors and warnings. + case 2: severity = boost::log::trivial::warning; break; + // Report all errors, warnings and infos. + case 3: severity = boost::log::trivial::info; break; + // Report all errors, warnings, infos and debugging. + case 4: severity = boost::log::trivial::debug; break; + // Report everyting including fine level tracing information. + default: severity = boost::log::trivial::trace; break; + } + + BOOST_LOG_STREAM_WITH_PARAMS(::boost::log::trivial::logger::get(),\ + (::boost::log::keywords::severity = severity)) << message; +} + } // namespace Slic3r #ifdef SLIC3R_HAS_BROKEN_CROAK diff --git a/xs/xsp/XS.xsp b/xs/xsp/XS.xsp index bf4a3733e..8389e2d99 100644 --- a/xs/xsp/XS.xsp +++ b/xs/xsp/XS.xsp @@ -42,6 +42,13 @@ set_logging_level(level) Slic3r::set_logging_level(level); void +trace(level, message) + unsigned int level; + char *message; + CODE: + Slic3r::trace(level, message); + +void xspp_test_croak_hangs_on_strawberry() CODE: try { |