Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsupermerill <merill@fr.fr>2019-09-26 14:14:01 +0300
committersupermerill <merill@fr.fr>2019-09-26 14:14:01 +0300
commit2f042e030c172dd634487ad8aca7c817fae362ea (patch)
tree4863104963cc94b158b929bd0ee7d3f2625f4c99 /src/libslic3r/SLA
parenta4572696e780c55612e178ffbe007a59c9b1ce78 (diff)
parent4e22761f95e4490a90353600c4569eee71fceb13 (diff)
Merge remote-tracking branch 'remotes/prusa/master'
not merged: fill.cpp, perimeter_generator, because they ahve been reworked and need to be understand fully before adding my extensive modifications. To verify: glcanvas: maybe filament color selection is deleted (or the other one i added?)
Diffstat (limited to 'src/libslic3r/SLA')
-rw-r--r--src/libslic3r/SLA/SLAAutoSupports.hpp2
-rw-r--r--src/libslic3r/SLA/SLARaster.hpp13
-rw-r--r--src/libslic3r/SLA/SLARasterWriter.cpp107
-rw-r--r--src/libslic3r/SLA/SLARasterWriter.hpp109
-rw-r--r--src/libslic3r/SLA/SLASupportTree.cpp6
5 files changed, 102 insertions, 135 deletions
diff --git a/src/libslic3r/SLA/SLAAutoSupports.hpp b/src/libslic3r/SLA/SLAAutoSupports.hpp
index 171cf854a..a2ac5f804 100644
--- a/src/libslic3r/SLA/SLAAutoSupports.hpp
+++ b/src/libslic3r/SLA/SLAAutoSupports.hpp
@@ -185,8 +185,6 @@ private:
SLAAutoSupports::Config m_config;
- float m_supports_force_total = 0.f;
-
void process(const std::vector<ExPolygons>& slices, const std::vector<float>& heights);
void uniformly_cover(const ExPolygons& islands, Structure& structure, PointGrid3D &grid3d, bool is_new_island = false, bool just_one = false);
void project_onto_mesh(std::vector<sla::SupportPoint>& points) const;
diff --git a/src/libslic3r/SLA/SLARaster.hpp b/src/libslic3r/SLA/SLARaster.hpp
index d3bd52d92..8b27fd153 100644
--- a/src/libslic3r/SLA/SLARaster.hpp
+++ b/src/libslic3r/SLA/SLARaster.hpp
@@ -68,15 +68,14 @@ public:
/// Type that represents a resolution in pixels.
struct Resolution {
- unsigned width_px;
- unsigned height_px;
+ size_t width_px;
+ size_t height_px;
- inline Resolution(unsigned w = 0, unsigned h = 0):
- width_px(w), height_px(h) {}
+ inline Resolution(size_t w = 0, size_t h = 0)
+ : width_px(w), height_px(h)
+ {}
- inline unsigned pixels() const /*noexcept*/ {
- return width_px * height_px;
- }
+ inline size_t pixels() const { return width_px * height_px; }
};
/// Types that represents the dimension of a pixel in millimeters.
diff --git a/src/libslic3r/SLA/SLARasterWriter.cpp b/src/libslic3r/SLA/SLARasterWriter.cpp
index f7c3925ac..3e6f015d4 100644
--- a/src/libslic3r/SLA/SLARasterWriter.cpp
+++ b/src/libslic3r/SLA/SLARasterWriter.cpp
@@ -1,5 +1,7 @@
#include "SLARasterWriter.hpp"
#include "libslic3r/Zipper.hpp"
+#include "libslic3r/Time.hpp"
+
#include "ExPolygon.hpp"
#include <libnest2d/backends/clipper/clipper_polygon.hpp>
@@ -10,25 +12,13 @@ namespace Slic3r { namespace sla {
std::string SLARasterWriter::createIniContent(const std::string& projectname) const
{
- auto expt_str = std::to_string(m_exp_time_s);
- auto expt_first_str = std::to_string(m_exp_time_first_s);
- auto layerh_str = std::to_string(m_layer_height);
-
- const std::string cnt_fade_layers = std::to_string(m_cnt_fade_layers);
- const std::string cnt_slow_layers = std::to_string(m_cnt_slow_layers);
- const std::string cnt_fast_layers = std::to_string(m_cnt_fast_layers);
- const std::string used_material = std::to_string(m_used_material);
-
- return std::string(
- "action = print\n"
- "jobDir = ") + projectname + "\n" +
- "expTime = " + expt_str + "\n"
- "expTimeFirst = " + expt_first_str + "\n"
- "numFade = " + cnt_fade_layers + "\n"
- "layerHeight = " + layerh_str + "\n"
- "usedMaterial = " + used_material + "\n"
- "numSlow = " + cnt_slow_layers + "\n"
- "numFast = " + cnt_fast_layers + "\n";
+ std::string out("action = print\njobDir = ");
+ out += projectname + "\n";
+
+ for (auto &param : m_config)
+ out += param.first + " = " + param.second + "\n";
+
+ return out;
}
void SLARasterWriter::flpXY(ClipperLib::Polygon &poly)
@@ -53,38 +43,14 @@ void SLARasterWriter::flpXY(ExPolygon &poly)
}
}
-SLARasterWriter::SLARasterWriter(const SLAPrinterConfig &cfg,
- const SLAMaterialConfig &mcfg,
- double layer_height)
+SLARasterWriter::SLARasterWriter(const Raster::Resolution &res,
+ const Raster::PixelDim &pixdim,
+ const std::array<bool, 2> &mirror,
+ double gamma)
+ : m_res(res), m_pxdim(pixdim), m_mirror(mirror), m_gamma(gamma)
{
- double w = cfg.display_width.getFloat();
- double h = cfg.display_height.getFloat();
- auto pw = unsigned(cfg.display_pixels_x.getInt());
- auto ph = unsigned(cfg.display_pixels_y.getInt());
-
- m_mirror[X] = cfg.display_mirror_x.getBool();
-
// PNG raster will implicitly do an Y mirror
- m_mirror[Y] = ! cfg.display_mirror_y.getBool();
-
- auto ro = cfg.display_orientation.getInt();
-
- if(ro == roPortrait) {
- std::swap(w, h);
- std::swap(pw, ph);
- m_o = roPortrait;
-
- // XY flipping implicitly does an X mirror
- m_mirror[X] = ! m_mirror[X];
- } else m_o = roLandscape;
-
- m_res = Raster::Resolution(pw, ph);
- m_pxdim = Raster::PixelDim(w/pw, h/ph);
- m_exp_time_s = mcfg.exposure_time.getFloat();
- m_exp_time_first_s = mcfg.initial_exposure_time.getFloat();
- m_layer_height = layer_height;
-
- m_gamma = cfg.gamma_correction.getFloat();
+ m_mirror[1] = !m_mirror[1];
}
void SLARasterWriter::save(const std::string &fpath, const std::string &prjname)
@@ -121,15 +87,44 @@ void SLARasterWriter::save(const std::string &fpath, const std::string &prjname)
}
}
-void SLARasterWriter::set_statistics(const std::vector<double> statistics)
+namespace {
+
+std::string get_cfg_value(const DynamicPrintConfig &cfg, const std::string &key)
{
- if (statistics.size() != psCnt)
- return;
+ std::string ret;
+
+ if (cfg.has(key)) {
+ auto opt = cfg.option(key);
+ if (opt) ret = opt->serialize();
+ }
- m_used_material = statistics[psUsedMaterial];
- m_cnt_fade_layers = int(statistics[psNumFade]);
- m_cnt_slow_layers = int(statistics[psNumSlow]);
- m_cnt_fast_layers = int(statistics[psNumFast]);
+ return ret;
+}
+
+} // namespace
+
+void SLARasterWriter::set_config(const DynamicPrintConfig &cfg)
+{
+ m_config["layerHeight"] = get_cfg_value(cfg, "layer_height");
+ m_config["expTime"] = get_cfg_value(cfg, "exposure_time");
+ m_config["expTimeFirst"] = get_cfg_value(cfg, "initial_exposure_time");
+ m_config["materialName"] = get_cfg_value(cfg, "sla_material_settings_id");
+ m_config["printerModel"] = get_cfg_value(cfg, "printer_model");
+ m_config["printerVariant"] = get_cfg_value(cfg, "printer_variant");
+ m_config["printerProfile"] = get_cfg_value(cfg, "printer_settings_id");
+ m_config["printProfile"] = get_cfg_value(cfg, "sla_print_settings_id");
+
+ m_config["fileCreationTimestamp"] = Utils::current_utc_time2str();
+ m_config["prusaSlicerVersion"] = SLIC3R_BUILD_ID;
+}
+
+void SLARasterWriter::set_statistics(const PrintStatistics &stats)
+{
+ m_config["usedMaterial"] = std::to_string(stats.used_material);
+ m_config["numFade"] = std::to_string(stats.num_fade);
+ m_config["numSlow"] = std::to_string(stats.num_slow);
+ m_config["numFast"] = std::to_string(stats.num_fast);
+ m_config["printTime"] = std::to_string(stats.estimated_print_time_s);
}
} // namespace sla
diff --git a/src/libslic3r/SLA/SLARasterWriter.hpp b/src/libslic3r/SLA/SLARasterWriter.hpp
index 7133d2dde..b9202c464 100644
--- a/src/libslic3r/SLA/SLARasterWriter.hpp
+++ b/src/libslic3r/SLA/SLARasterWriter.hpp
@@ -3,8 +3,10 @@
// For png export of the sliced model
#include <fstream>
+#include <string>
#include <sstream>
#include <vector>
+#include <map>
#include <array>
#include "libslic3r/PrintConfig.hpp"
@@ -23,20 +25,19 @@ namespace Slic3r { namespace sla {
class SLARasterWriter
{
public:
- enum RasterOrientation {
+ enum Orientation {
roLandscape,
roPortrait
};
// Used for addressing parameters of set_statistics()
- enum ePrintStatistics
- {
- psUsedMaterial = 0,
- psNumFade,
- psNumSlow,
- psNumFast,
-
- psCnt
+ struct PrintStatistics
+ {
+ double used_material = 0.;
+ double estimated_print_time_s = 0.;
+ size_t num_fade = 0;
+ size_t num_slow = 0;
+ size_t num_fast = 0;
};
private:
@@ -47,21 +48,13 @@ private:
RawBytes rawbytes;
Layer() = default;
- Layer(const Layer&) = delete; // The image is big, do not copy by accident
- Layer& operator=(const Layer&) = delete;
- // /////////////////////////////////////////////////////////////////////
- // FIXME: the following is needed for MSVC2013 compatibility
- // /////////////////////////////////////////////////////////////////////
-
- // Layer(Layer&& m) = default;
- // Layer& operator=(Layer&&) = default;
- Layer(Layer &&m):
- raster(std::move(m.raster)), rawbytes(std::move(m.rawbytes)) {}
- Layer& operator=(Layer &&m) {
- raster = std::move(m.raster); rawbytes = std::move(m.rawbytes);
- return *this;
- }
+ // The image is big, do not copy by accident
+ Layer(const Layer&) = delete;
+ Layer& operator=(const Layer&) = delete;
+
+ Layer(Layer &&m) = default;
+ Layer &operator=(Layer &&) = default;
};
// We will save the compressed PNG data into RawBytes type buffers in
@@ -69,66 +62,46 @@ private:
std::vector<Layer> m_layers_rst;
Raster::Resolution m_res;
Raster::PixelDim m_pxdim;
- double m_exp_time_s = .0, m_exp_time_first_s = .0;
- double m_layer_height = .0;
- RasterOrientation m_o = roPortrait;
std::array<bool, 2> m_mirror;
-
double m_gamma;
-
- double m_used_material = 0.0;
- int m_cnt_fade_layers = 0;
- int m_cnt_slow_layers = 0;
- int m_cnt_fast_layers = 0;
-
+
+ std::map<std::string, std::string> m_config;
+
std::string createIniContent(const std::string& projectname) const;
static void flpXY(ClipperLib::Polygon& poly);
static void flpXY(ExPolygon& poly);
public:
-
- SLARasterWriter(const SLAPrinterConfig& cfg,
- const SLAMaterialConfig& mcfg,
- double layer_height);
+ SLARasterWriter(const Raster::Resolution &res,
+ const Raster::PixelDim &pixdim,
+ const std::array<bool, 2> &mirror,
+ double gamma = 1.);
SLARasterWriter(const SLARasterWriter& ) = delete;
SLARasterWriter& operator=(const SLARasterWriter&) = delete;
-
- // /////////////////////////////////////////////////////////////////////////
- // FIXME: the following is needed for MSVC2013 compatibility
- // /////////////////////////////////////////////////////////////////////////
-
- // SLARasterWriter(SLARasterWriter&& m) = default;
- // SLARasterWriter& operator=(SLARasterWriter&&) = default;
- SLARasterWriter(SLARasterWriter&& m):
- m_layers_rst(std::move(m.m_layers_rst)),
- m_res(m.m_res),
- m_pxdim(m.m_pxdim),
- m_exp_time_s(m.m_exp_time_s),
- m_exp_time_first_s(m.m_exp_time_first_s),
- m_layer_height(m.m_layer_height),
- m_o(m.m_o),
- m_mirror(std::move(m.m_mirror)),
- m_gamma(m.m_gamma),
- m_used_material(m.m_used_material),
- m_cnt_fade_layers(m.m_cnt_fade_layers),
- m_cnt_slow_layers(m.m_cnt_slow_layers),
- m_cnt_fast_layers(m.m_cnt_fast_layers)
- {}
-
- // /////////////////////////////////////////////////////////////////////////
+ SLARasterWriter(SLARasterWriter&& m) = default;
+ SLARasterWriter& operator=(SLARasterWriter&&) = default;
inline void layers(unsigned cnt) { if(cnt > 0) m_layers_rst.resize(cnt); }
inline unsigned layers() const { return unsigned(m_layers_rst.size()); }
- template<class Poly> void draw_polygon(const Poly& p, unsigned lyr) {
+ template<class Poly> void draw_polygon(const Poly& p, unsigned lyr,
+ Orientation o = roPortrait)
+ {
assert(lyr < m_layers_rst.size());
- if(m_o == roPortrait) {
- Poly poly(p); flpXY(poly);
+
+ switch (o) {
+ case roPortrait: {
+ Poly poly(p);
+ flpXY(poly);
m_layers_rst[lyr].raster.draw(poly);
+ break;
+ }
+ case roLandscape:
+ m_layers_rst[lyr].raster.draw(p);
+ break;
}
- else m_layers_rst[lyr].raster.draw(p);
}
inline void begin_layer(unsigned lyr) {
@@ -156,9 +129,11 @@ public:
}
}
- void save(const std::string& fpath, const std::string& prjname = "");
+ void save(const std::string &fpath, const std::string &prjname = "");
- void set_statistics(const std::vector<double> statistics);
+ void set_statistics(const PrintStatistics &statistics);
+
+ void set_config(const DynamicPrintConfig &cfg);
};
} // namespace sla
diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp
index 56be5a569..a3e88243f 100644
--- a/src/libslic3r/SLA/SLASupportTree.cpp
+++ b/src/libslic3r/SLA/SLASupportTree.cpp
@@ -85,7 +85,7 @@ using Portion = std::tuple<double, double>;
// Set this to true to enable full parallelism in this module.
// Only the well tested parts will be concurrent if this is set to false.
-const constexpr bool USE_FULL_CONCURRENCY = true;
+const constexpr bool USE_FULL_CONCURRENCY = false;
template<bool> struct _ccr {};
@@ -1194,7 +1194,7 @@ class SLASupportTree::Algorithm {
// Now a and b vectors are perpendicular to v and to each other.
// Together they define the plane where we have to iterate with the
// given angles in the 'phis' vector
- ccr_seq::enumerate(phis.begin(), phis.end(),
+ ccr_par::enumerate(phis.begin(), phis.end(),
[&hits, &m, sd, r_pin, r_back, s, a, b, c]
(double phi, size_t i)
{
@@ -1297,7 +1297,7 @@ class SLASupportTree::Algorithm {
// Hit results
std::array<HitResult, SAMPLES> hits;
- ccr_seq::enumerate(phis.begin(), phis.end(),
+ ccr_par::enumerate(phis.begin(), phis.end(),
[&m, a, b, sd, dir, r, s, ins_check, &hits]
(double phi, size_t i)
{