Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::SL1Archive Class Reference

#include <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 (const std::string fname, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname="") 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={})
 

Static Public Member Functions

static std::unique_ptr< SLAArchiveWritercreate (const std::string &archtype, const SLAPrinterConfig &)
 

Protected Member Functions

std::unique_ptr< sla::RasterBasecreate_raster () const override
 
sla::RasterEncoder get_encoder () const override
 
SLAPrinterConfigcfg ()
 
const SLAPrinterConfigcfg () const
 
void export_print (Zipper &, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname)
 

Protected Attributes

std::vector< sla::EncodedRasterm_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
32: m_cfg(cfg) {}
SLAPrinterConfig m_cfg
Definition SL1.hpp:15
SLAPrinterConfig & cfg()
Definition SL1.hpp:21

◆ SL1Archive() [3/3]

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

Member Function Documentation

◆ cfg() [1/2]

SLAPrinterConfig & Slic3r::SL1Archive::cfg ( )
inlineprotected
21{ return m_cfg; }

References m_cfg.

Referenced by Slic3r::SL1_SVGArchive::create_raster().

+ Here is the caller graph for this function:

◆ cfg() [2/2]

const SLAPrinterConfig & Slic3r::SL1Archive::cfg ( ) const
inlineprotected
22{ return m_cfg; }

References m_cfg.

◆ create()

std::unique_ptr< SLAArchiveWriter > Slic3r::SLAArchiveWriter::create ( const std::string &  archtype,
const SLAPrinterConfig cfg 
)
staticinherited
8{
9 std::unique_ptr<SLAArchiveWriter> ret;
10 auto factory = get_writer_factory(archtype.c_str());
11
12 if (factory)
13 ret = factory(cfg);
14
15 return ret;
16}
ArchiveWriterFactory get_writer_factory(const char *formatid)
Definition SLAArchiveFormatRegistry.cpp:111

References Slic3r::get_writer_factory().

Referenced by Slic3r::SLAPrint::apply().

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

◆ create_raster()

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

Implements Slic3r::SLAArchiveWriter.

132{
133 sla::Resolution res;
134 sla::PixelDim pxdim;
135 std::array<bool, 2> mirror;
136
137 double w = m_cfg.display_width.getFloat();
138 double h = m_cfg.display_height.getFloat();
139 auto pw = size_t(m_cfg.display_pixels_x.getInt());
140 auto ph = size_t(m_cfg.display_pixels_y.getInt());
141
142 mirror[X] = m_cfg.display_mirror_x.getBool();
143 mirror[Y] = m_cfg.display_mirror_y.getBool();
144
145 auto ro = m_cfg.display_orientation.getInt();
146 sla::RasterBase::Orientation orientation =
149
150 if (orientation == sla::RasterBase::roPortrait) {
151 std::swap(w, h);
152 std::swap(pw, ph);
153 }
154
155 res = sla::Resolution{pw, ph};
156 pxdim = sla::PixelDim{w / pw, h / ph};
157 sla::RasterBase::Trafo tr{orientation, mirror};
158
159 double gamma = m_cfg.gamma_correction.getFloat();
160
161 return sla::create_raster_grayscale_aa(res, pxdim, gamma, tr);
162}
Orientation
Definition RasterBase.hpp:60
@ roPortrait
Definition RasterBase.hpp:60
@ roLandscape
Definition RasterBase.hpp:60
std::unique_ptr< RasterBase > create_raster_grayscale_aa(const Resolution &res, const PixelDim &pxdim, double gamma, const RasterBase::Trafo &tr)
Definition RasterBase.cpp:65
@ Y
Definition libslic3r.h:99
@ X
Definition libslic3r.h:98

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

+ Here is the call graph for this function:

◆ draw_layers()

template<class Fn , class CancelFn , class EP = ExecutionTBB>
void Slic3r::SLAArchiveWriter::draw_layers ( size_t  layer_num,
Fn &&  drawfn,
CancelFn  cancelfn = []() { return false; },
const EP &  ep = {} 
)
inlineinherited
30 { return false; },
31 const EP & ep = {})
32 {
33 m_layers.resize(layer_num);
35 ep, size_t(0), m_layers.size(),
36 [this, &drawfn, &cancelfn](size_t idx) {
37 if (cancelfn()) return;
38
39 sla::EncodedRaster &enc = m_layers[idx];
40 auto rst = create_raster();
41 drawfn(*rst, idx);
42 enc = rst->encode(get_encoder());
43 },
45 }
std::vector< sla::EncodedRaster > m_layers
Definition SLAArchiveWriter.hpp:17
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 ThumbnailsList thumbnails,
const std::string &  projectname = "" 
)
overridevirtual

Implements Slic3r::SLAArchiveWriter.

235{
236 Zipper zipper{fname, Zipper::FAST_COMPRESSION};
237
238 export_print(zipper, print, thumbnails, prjname);
239}
void export_print(Zipper &, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname)
Definition SL1.cpp:187
@ FAST_COMPRESSION
Definition Zipper.hpp:16

References export_print(), and Slic3r::Zipper::FAST_COMPRESSION.

+ Here is the call graph for this function:

◆ export_print() [2/2]

void Slic3r::SL1Archive::export_print ( Zipper zipper,
const SLAPrint print,
const ThumbnailsList thumbnails,
const std::string &  projectname 
)
protected
191{
192 std::string project =
193 prjname.empty() ?
194 boost::filesystem::path(zipper.get_filename()).stem().string() :
195 prjname;
196
197 ConfMap iniconf, slicerconf;
198 fill_iniconf(iniconf, print);
199
200 iniconf["jobDir"] = project;
201
202 fill_slicerconf(slicerconf, print);
203
204 try {
205 zipper.add_entry("config.ini");
206 zipper << to_ini(iniconf);
207 zipper.add_entry("prusaslicer.ini");
208 zipper << to_ini(slicerconf);
209
210 size_t i = 0;
211 for (const sla::EncodedRaster &rst : m_layers) {
212
213 std::string imgname = project + string_printf("%.5d", i++) + "." +
214 rst.extension();
215
216 zipper.add_entry(imgname.c_str(), rst.data(), rst.size());
217 }
218
219 for (const ThumbnailData& data : thumbnails)
220 if (data.is_valid())
221 write_thumbnail(zipper, data);
222
223 zipper.finalize();
224 } catch(std::exception& e) {
225 BOOST_LOG_TRIVIAL(error) << e.what();
226 // Rethrow the exception
227 throw;
228 }
229}
if(!(yy_init))
Definition lexer.c:1190
std::string to_ini(const ConfMap &m)
Definition SL1.cpp:41
void fill_slicerconf(ConfMap &m, const SLAPrint &print)
Definition SL1.cpp:103
void fill_iniconf(ConfMap &m, const SLAPrint &print)
Definition SL1.cpp:61
std::map< std::string, std::string > ConfMap
Definition AnycubicSLA.cpp:87
static void write_thumbnail(Zipper &zipper, const ThumbnailData &data)
Definition SL1.cpp:169
std::string string_printf(const char *format,...)
Definition utils.cpp:890
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195
IGL_INLINE int project(const double objX, const double objY, const double objZ, double *winX, double *winY, double *winZ)
Definition project.cpp:14
bool is_valid(const FontFile &font, unsigned int index)
Definition Emboss.cpp:233
static char error[256]
Definition tga.cpp:50

References Slic3r::Zipper::add_entry(), error, Slic3r::Zipper::finalize(), Slic3r::Zipper::get_filename(), Slic3r::SLAArchiveWriter::m_layers, Slic3r::string_printf(), and Slic3r::write_thumbnail().

Referenced by export_print(), and Slic3r::SL1_SVGArchive::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::SLAArchiveWriter.

165{
166 return sla::PNGRasterEncoder{};
167}

Member Data Documentation

◆ m_cfg

SLAPrinterConfig Slic3r::SL1Archive::m_cfg
private

Referenced by cfg(), cfg(), and create_raster().

◆ m_layers

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

The documentation for this class was generated from the following files: