OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SL1Archive Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Format/SL1.hpp>

Inheritance diagram for Slic3r::SL1Archive:
Collaboration diagram for Slic3r::SL1Archive:

Public Member Functions

 SL1Archive ()=default
 SL1Archive (const SLAPrinterConfig &cfg)
 SL1Archive (SLAPrinterConfig &&cfg)
void export_print (Zipper &zipper, const SLAPrint &print, const std::string &projectname="")
void export_print (const std::string &fname, const SLAPrint &print, const std::string &projectname="")
void apply (const SLAPrinterConfig &cfg) override
template<class Fn, class CancelFn, class EP = ExecutionTBB>
void draw_layers (size_t layer_num, Fn &&drawfn, CancelFn cancelfn=[]() { return false;}, const EP &ep={})

Protected Member Functions

std::unique_ptr< sla::RasterBase > create_raster () const override
sla::RasterEncoder get_encoder () const override

Protected Attributes

std::vector< sla::EncodedRaster > m_layers

Private Attributes

SLAPrinterConfig m_cfg

Detailed Description

Constructor & Destructor Documentation

◆ SL1Archive() [1/3]

Slic3r::SL1Archive::SL1Archive ( )
default

◆ SL1Archive() [2/3]

Slic3r::SL1Archive::SL1Archive ( const SLAPrinterConfig & cfg)
inlineexplicit
30: m_cfg(cfg) {}
SLAPrinterConfig m_cfg
Definition SL1.hpp:21

References m_cfg.

◆ SL1Archive() [3/3]

Slic3r::SL1Archive::SL1Archive ( SLAPrinterConfig && cfg)
inlineexplicit
31: m_cfg(std::move(cfg)) {}

References m_cfg.

Member Function Documentation

◆ apply()

void Slic3r::SL1Archive::apply ( const SLAPrinterConfig & cfg)
inlineoverridevirtual

Implements Slic3r::SLAArchive.

41 {
42 auto diff = m_cfg.diff(cfg);
43 if (!diff.empty()) {
44 m_cfg.apply_only(cfg, diff);
45 m_layers = {};
46 }
47 }
std::vector< sla::EncodedRaster > m_layers
Definition SLAPrint.hpp:413
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:731

References Slic3r::diff(), m_cfg, and Slic3r::SLAArchive::m_layers.

Here is the call graph for this function:

◆ create_raster()

std::unique_ptr< sla::RasterBase > Slic3r::SL1Archive::create_raster ( ) const
overrideprotectedvirtual

Implements Slic3r::SLAArchive.

469{
470 sla::Resolution res;
471 sla::PixelDim pxdim;
472 std::array<bool, 2> mirror;
473
474 double w = m_cfg.display_width.getFloat();
475 double h = m_cfg.display_height.getFloat();
476 auto pw = size_t(m_cfg.display_pixels_x.getInt());
477 auto ph = size_t(m_cfg.display_pixels_y.getInt());
478
479 mirror[X] = m_cfg.display_mirror_x.getBool();
480 mirror[Y] = m_cfg.display_mirror_y.getBool();
481
482 auto ro = m_cfg.display_orientation.getInt();
483 sla::RasterBase::Orientation orientation =
486
487 if (orientation == sla::RasterBase::roPortrait) {
488 std::swap(w, h);
489 std::swap(pw, ph);
490 }
491
492 res = sla::Resolution{pw, ph};
493 pxdim = sla::PixelDim{w / pw, h / ph};
494 sla::RasterBase::Trafo tr{orientation, mirror};
495
496 double gamma = m_cfg.gamma_correction.getFloat();
497
498 return sla::create_raster_grayscale_aa(res, pxdim, gamma, tr);
499}
Orientation
Definition RasterBase.hpp:65
@ roPortrait
Definition RasterBase.hpp:65
@ roLandscape
Definition RasterBase.hpp:65
std::unique_ptr< RasterBase > create_raster_grayscale_aa(const Resolution &res, const PixelDim &pxdim, double gamma, const RasterBase::Trafo &tr)
Definition RasterBase.cpp:77
@ Y
Definition libslic3r.h:142
@ X
Definition libslic3r.h:141

References create_raster(), Slic3r::sla::create_raster_grayscale_aa(), m_cfg, Slic3r::sla::RasterBase::roLandscape, Slic3r::sla::RasterBase::roPortrait, Slic3r::X, and Slic3r::Y.

Referenced by create_raster().

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

◆ draw_layers()

template<class Fn, class CancelFn, class EP = ExecutionTBB>
void Slic3r::SLAArchive::draw_layers ( size_t layer_num,
Fn && drawfn,
CancelFn cancelfn = []() { return false; },
const EP & ep = {} )
inlineinherited
428 { return false; },
429 const EP & ep = {})
430 {
431 m_layers.resize(layer_num);
433 ep, size_t(0), m_layers.size(),
434 [this, &drawfn, &cancelfn](size_t idx) {
435 if (cancelfn()) return;
436
437 sla::EncodedRaster &enc = m_layers[idx];
438 auto rst = create_raster();
439 drawfn(*rst, idx);
440 enc = rst->encode(get_encoder());
441 },
443 }
void for_each(const EP &ep, It from, It to, Fn &&fn, size_t granularity=1)
Definition Execution.hpp:46
size_t max_concurrency(const EP &ep)
Definition Execution.hpp:38

◆ export_print() [1/2]

void Slic3r::SL1Archive::export_print ( const std::string & fname,
const SLAPrint & print,
const std::string & projectname = "" )
inline
35 {
36 Zipper zipper(fname);
37 export_print(zipper, print, projectname);
38 }
void export_print(Zipper &zipper, const SLAPrint &print, const std::string &projectname="")
Definition SL1.cpp:506

References export_print().

Here is the call graph for this function:

◆ export_print() [2/2]

void Slic3r::SL1Archive::export_print ( Zipper & zipper,
const SLAPrint & print,
const std::string & projectname = "" )
509{
510 std::string project =
511 prjname.empty() ?
512 boost::filesystem::path(zipper.get_filename()).stem().string() :
513 prjname;
514
515 ConfMap iniconf, slicerconf;
516 fill_iniconf(iniconf, print);
517
518 iniconf["jobDir"] = project;
519
520 fill_slicerconf(slicerconf, print);
521
522 try {
523 zipper.add_entry("config.ini");
524 zipper << to_ini(iniconf);
525 zipper.add_entry("prusaslicer.ini");
526 zipper << to_ini(slicerconf);
527
528 size_t i = 0;
529 for (const sla::EncodedRaster &rst : m_layers) {
530
531 std::string imgname = project + string_printf("%.5d", i++) + "." +
532 rst.extension();
533
534 zipper.add_entry(imgname.c_str(), rst.data(), rst.size());
535 }
536 } catch(std::exception& e) {
537 BOOST_LOG_TRIVIAL(error) << e.what();
538 // Rethrow the exception
539 throw;
540 }
541}
std::string to_ini(const ConfMap &m)
Definition SL1.cpp:383
void fill_slicerconf(ConfMap &m, const SLAPrint &print)
Definition SL1.cpp:444
void fill_iniconf(ConfMap &m, const SLAPrint &print)
Definition SL1.cpp:403
std::map< std::string, std::string > ConfMap
Definition SL1.cpp:379
std::string string_printf(const char *format,...)
Definition utils.cpp:1448

References Slic3r::Zipper::add_entry(), export_print(), Slic3r::Zipper::get_filename(), Slic3r::SLAArchive::m_layers, and Slic3r::string_printf().

Referenced by export_print(), and export_print().

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

◆ get_encoder()

sla::RasterEncoder Slic3r::SL1Archive::get_encoder ( ) const
overrideprotectedvirtual

Implements Slic3r::SLAArchive.

502{
503 return sla::PNGRasterEncoder{};
504}

References get_encoder().

Referenced by get_encoder().

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

Member Data Documentation

◆ m_cfg

SLAPrinterConfig Slic3r::SL1Archive::m_cfg
private

◆ m_layers

std::vector<sla::EncodedRaster> Slic3r::SLAArchive::m_layers
protectedinherited

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Format/SL1.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Format/SL1.cpp