Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{SL1.cpp} Namespace Reference

Functions

std::string to_ini (const ConfMap &m)
 
std::string get_cfg_value (const DynamicPrintConfig &cfg, const std::string &key)
 
void fill_iniconf (ConfMap &m, const SLAPrint &print)
 
void fill_slicerconf (ConfMap &m, const SLAPrint &print)
 
ExPolygons rings_to_expolygons (const std::vector< marchsq::Ring > &rings, double px_w, double px_h)
 
std::vector< ExPolygonsextract_slices_from_sla_archive (ZipperArchive &arch, const RasterParams &rstp, const marchsq::Coord &win, std::function< bool(int)> progr)
 

Function Documentation

◆ extract_slices_from_sla_archive()

std::vector< ExPolygons > Slic3r::anonymous_namespace{SL1.cpp}::extract_slices_from_sla_archive ( ZipperArchive arch,
const RasterParams rstp,
const marchsq::Coord win,
std::function< bool(int)>  progr 
)
359{
360 std::vector<ExPolygons> slices(arch.entries.size());
361
362 struct Status
363 {
364 double incr, val, prev;
365 bool stop = false;
367 } st{100. / slices.size(), 0., 0.};
368
369 execution::for_each(
370 ex_tbb, size_t(0), arch.entries.size(),
371 [&arch, &slices, &st, &rstp, &win, progr](size_t i) {
372 // Status indication guarded with the spinlock
373 {
374 std::lock_guard lck(st.mutex);
375 if (st.stop) return;
376
377 st.val += st.incr;
378 double curr = std::round(st.val);
379 if (curr > st.prev) {
380 st.prev = curr;
381 st.stop = !progr(int(curr));
382 }
383 }
384
385 png::ImageGreyscale img;
386 png::ReadBuf rb{arch.entries[i].buf.data(),
387 arch.entries[i].buf.size()};
388 if (!png::decode_png(rb, img)) return;
389
390 constexpr uint8_t isoval = 128;
391 auto rings = marchsq::execute(img, isoval, win);
392 ExPolygons expolys = rings_to_expolygons(rings, rstp.px_w,
393 rstp.px_h);
394
395 // Invert the raster transformations indicated in the profile metadata
396 invert_raster_trafo(expolys, rstp.trafo, rstp.width, rstp.height);
397
398 slices[i] = std::move(expolys);
399 },
400 execution::max_concurrency(ex_tbb));
401
402 if (st.stop) slices = {};
403
404 return slices;
405}
ExPolygons rings_to_expolygons(const std::vector< marchsq::Ring > &rings, double px_w, double px_h)
Definition SL1.cpp:335
typename AsTraits< EP >::SpinningMutex SpinningMutex
Definition Execution.hpp:33
sla::RasterBase::Trafo trafo
Definition SL1.hpp:64
double px_w
Definition SL1.hpp:66
double px_h
Definition SL1.hpp:66
std::vector< EntryBuffer > entries
Definition ZipperArchiveImport.hpp:25
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:13
void invert_raster_trafo(ExPolygons &expolys, const sla::RasterBase::Trafo &trafo, coord_t width, coord_t height)
Definition SL1.cpp:277
coord_t height
Definition SL1.hpp:65
coord_t width
Definition SL1.hpp:65
TRasterValue< T > isoval(const T &rst, const Coord &crd)
Definition MarchingSquares.hpp:65
unsigned __int8 uint8_t
Definition unistd.h:77

References Slic3r::png::decode_png(), Slic3r::ZipperArchive::entries, Slic3r::ex_tbb, extract_slices_from_sla_archive(), Slic3r::execution::for_each(), Slic3r::RasterParams::height, Slic3r::invert_raster_trafo(), Slic3r::RasterParams::px_h, Slic3r::RasterParams::px_w, rings_to_expolygons(), Slic3r::RasterParams::trafo, and Slic3r::RasterParams::width.

Referenced by extract_slices_from_sla_archive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_iniconf()

void Slic3r::anonymous_namespace{SL1.cpp}::fill_iniconf ( ConfMap m,
const SLAPrint print 
)
62{
63 CNumericLocalesSetter locales_setter; // for to_string
64 auto &cfg = print.full_print_config();
65 m["layerHeight"] = get_cfg_value(cfg, "layer_height");
66 m["expTime"] = get_cfg_value(cfg, "exposure_time");
67 m["expTimeFirst"] = get_cfg_value(cfg, "initial_exposure_time");
68 const std::string mps = get_cfg_value(cfg, "material_print_speed");
69 m["expUserProfile"] = mps == "slow" ? "1" : mps == "fast" ? "0" : "2";
70 m["materialName"] = get_cfg_value(cfg, "sla_material_settings_id");
71 m["printerModel"] = get_cfg_value(cfg, "printer_model");
72 m["printerVariant"] = get_cfg_value(cfg, "printer_variant");
73 m["printerProfile"] = get_cfg_value(cfg, "printer_settings_id");
74 m["printProfile"] = get_cfg_value(cfg, "sla_print_settings_id");
75 m["fileCreationTimestamp"] = Utils::utc_timestamp();
76 m["prusaSlicerVersion"] = SLIC3R_BUILD_ID;
77
79 // Set statistics values to the printer
80
81 double used_material = (stats.objects_used_material +
82 stats.support_used_material) / 1000;
83
84 int num_fade = print.default_object_config().faded_layers.getInt();
85 num_fade = num_fade >= 0 ? num_fade : 0;
86
87 m["usedMaterial"] = std::to_string(used_material);
88 m["numFade"] = std::to_string(num_fade);
89 m["numSlow"] = std::to_string(stats.slow_layers_count);
90 m["numFast"] = std::to_string(stats.fast_layers_count);
91 m["printTime"] = std::to_string(stats.estimated_print_time);
92
93 bool hollow_en = false;
94 auto it = print.objects().begin();
95 while (!hollow_en && it != print.objects().end())
96 hollow_en = (*it++)->config().hollowing_enable;
97
98 m["hollow"] = hollow_en ? "1" : "0";
99
100 m["action"] = "print";
101}
Definition LocalesUtils.hpp:18
const DynamicPrintConfig & full_print_config() const
Definition PrintBase.hpp:523
const PrintObjects & objects() const
Definition SLAPrint.hpp:468
const SLAPrintObjectConfig & default_object_config() const
Definition SLAPrint.hpp:485
const SLAPrintStatistics & print_statistics() const
Definition SLAPrint.hpp:495
std::string get_cfg_value(const DynamicPrintConfig &cfg, const std::string &key)
Definition SL1.cpp:49
Definition SLAPrint.hpp:401
double support_used_material
Definition SLAPrint.hpp:405
size_t slow_layers_count
Definition SLAPrint.hpp:406
double estimated_print_time
Definition SLAPrint.hpp:403
size_t fast_layers_count
Definition SLAPrint.hpp:407
double objects_used_material
Definition SLAPrint.hpp:404

References Slic3r::SLAPrint::default_object_config(), Slic3r::SLAPrintStatistics::estimated_print_time, Slic3r::SLAPrintStatistics::fast_layers_count, fill_iniconf(), Slic3r::PrintBase::full_print_config(), get_cfg_value(), Slic3r::SLAPrint::objects(), Slic3r::SLAPrintStatistics::objects_used_material, Slic3r::SLAPrint::print_statistics(), Slic3r::SLAPrintStatistics::slow_layers_count, Slic3r::SLAPrintStatistics::support_used_material, and Slic3r::Utils::utc_timestamp().

Referenced by fill_iniconf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_slicerconf()

void Slic3r::anonymous_namespace{SL1.cpp}::fill_slicerconf ( ConfMap m,
const SLAPrint print 
)
104{
105 using namespace std::literals::string_view_literals;
106
107 // Sorted list of config keys, which shall not be stored into the ini.
108 static constexpr auto banned_keys = {
109 "compatible_printers"sv,
110 "compatible_prints"sv,
111 //FIXME The print host keys should not be exported to full_print_config anymore. The following keys may likely be removed.
112 "print_host"sv,
113 "printhost_apikey"sv,
114 "printhost_cafile"sv
115 };
116
117 assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
118 auto is_banned = [](const std::string &key) {
119 return std::binary_search(banned_keys.begin(), banned_keys.end(), key);
120 };
121
122 auto &cfg = print.full_print_config();
123 for (const std::string &key : cfg.keys())
124 if (! is_banned(key) && ! cfg.option(key)->is_nil())
125 m[key] = cfg.opt_serialize(key);
126
127}
Definition getopt.h:102
if(!(yy_init))
Definition lexer.c:1190

References fill_slicerconf(), Slic3r::PrintBase::full_print_config(), and Slic3r::ConfigBase::opt_serialize().

Referenced by fill_slicerconf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_cfg_value()

std::string Slic3r::anonymous_namespace{SL1.cpp}::get_cfg_value ( const DynamicPrintConfig cfg,
const std::string &  key 
)
50{
51 std::string ret;
52
53 if (cfg.has(key)) {
54 auto opt = cfg.option(key);
55 if (opt) ret = opt->serialize();
56 }
57
58 return ret;
59}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2169
virtual std::string serialize() const =0
bool has(const t_config_option_key &opt_key) const
Definition Config.hpp:2105

References get_cfg_value(), Slic3r::ConfigOptionResolver::has(), Slic3r::ConfigBase::option(), and Slic3r::ConfigOption::serialize().

Referenced by fill_iniconf(), and get_cfg_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rings_to_expolygons()

ExPolygons Slic3r::anonymous_namespace{SL1.cpp}::rings_to_expolygons ( const std::vector< marchsq::Ring > &  rings,
double  px_w,
double  px_h 
)
337{
338 auto polys = reserve_vector<ExPolygon>(rings.size());
339
340 for (const marchsq::Ring &ring : rings) {
341 Polygon poly; Points &pts = poly.points;
342 pts.reserve(ring.size());
343
344 for (const marchsq::Coord &crd : ring)
345 pts.emplace_back(scaled(crd.c * px_w), scaled(crd.r * px_h));
346
347 polys.emplace_back(poly);
348 }
349
350 // TODO: Is a union necessary?
351 return union_ex(polys);
352}
Points points
Definition MultiPoint.hpp:18
Definition Polygon.hpp:24
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:240
Slic3r::ExPolygons union_ex(const Slic3r::Polygons &subject, ClipperLib::PolyFillType fill_type)
Definition ClipperUtils.cpp:774
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:58
std::vector< Coord > Ring
Definition MarchingSquares.hpp:26
Definition MarchingSquares.hpp:13

References Slic3r::MultiPoint::points, rings_to_expolygons(), Slic3r::scaled(), and Slic3r::union_ex().

Referenced by extract_slices_from_sla_archive(), and rings_to_expolygons().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_ini()

std::string Slic3r::anonymous_namespace{SL1.cpp}::to_ini ( const ConfMap m)
42{
43 std::string ret;
44 for (auto &param : m) ret += param.first + " = " + param.second + "\n";
45
46 return ret;
47}

References to_ini().

Referenced by to_ini().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: