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

#include <src/libslic3r/Format/SL1_SVG.hpp>

+ Inheritance diagram for Slic3r::SL1_SVGArchive:
+ Collaboration diagram for Slic3r::SL1_SVGArchive:

Public Member Functions

void export_print (const std::string fname, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname="") override
 
 SL1Archive ()=default
 
 SL1Archive (const SLAPrinterConfig &cfg)
 
 SL1Archive (SLAPrinterConfig &&cfg)
 
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

Member Function Documentation

◆ cfg() [1/2]

SLAPrinterConfig & Slic3r::SL1Archive::cfg ( )
inlineprotectedinherited
21{ return m_cfg; }
SLAPrinterConfig m_cfg
Definition SL1.hpp:15

References Slic3r::SL1Archive::m_cfg.

Referenced by create_raster().

+ Here is the caller graph for this function:

◆ cfg() [2/2]

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

References Slic3r::SL1Archive::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::SL1_SVGArchive::create_raster ( ) const
overrideprotectedvirtual

Implements Slic3r::SLAArchiveWriter.

195{
196 auto w = cfg().display_width.getFloat();
197 auto h = cfg().display_height.getFloat();
198
199 float precision_nm = scaled<float>(cfg().sla_output_precision.getFloat());
200 auto res_x = size_t(std::round(scaled(w) / precision_nm));
201 auto res_y = size_t(std::round(scaled(h) / precision_nm));
202
203 std::array<bool, 2> mirror;
204
205 mirror[X] = cfg().display_mirror_x.getBool();
206 mirror[Y] = cfg().display_mirror_y.getBool();
207
208 auto ro = cfg().display_orientation.getInt();
209 sla::RasterBase::Orientation orientation =
212
213 if (orientation == sla::RasterBase::roPortrait) {
214 std::swap(w, h);
215 std::swap(res_x, res_y);
216 }
217
218 BoundingBox svgarea{{0, 0}, {scaled(w), scaled(h)}};
219
220 sla::RasterBase::Trafo tr{orientation, mirror};
221
222 // Gamma does not really make sense in an svg, right?
223 // double gamma = cfg().gamma_correction.getFloat();
224 return std::make_unique<SVGRaster>(svgarea, sla::Resolution{res_x, res_y}, tr);
225}
SLAPrinterConfig & cfg()
Definition SL1.hpp:21
Orientation
Definition RasterBase.hpp:60
@ roPortrait
Definition RasterBase.hpp:60
@ roLandscape
Definition RasterBase.hpp:60
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:240
@ Y
Definition libslic3r.h:99
@ X
Definition libslic3r.h:98

References Slic3r::SL1Archive::cfg(), Slic3r::sla::RasterBase::roLandscape, Slic3r::sla::RasterBase::roPortrait, Slic3r::scaled(), 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::SL1_SVGArchive::export_print ( const std::string  fname,
const SLAPrint print,
const ThumbnailsList thumbnails,
const std::string &  projectname = "" 
)
overridevirtual

Implements Slic3r::SLAArchiveWriter.

237{
238 // Export code is completely identical to SL1, only the compression level
239 // is elevated, as the SL1 has already compressed PNGs with deflate,
240 // but the svg is just text.
241 Zipper zipper{fname, Zipper::TIGHT_COMPRESSION};
242
243 SL1Archive::export_print(zipper, print, thumbnails, projectname);
244}
void export_print(Zipper &, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname)
Definition SL1.cpp:187
@ TIGHT_COMPRESSION
Definition Zipper.hpp:17

References Slic3r::SL1Archive::export_print(), and Slic3r::Zipper::TIGHT_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 
)
protectedinherited
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 Slic3r::SL1Archive::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::SL1_SVGArchive::get_encoder ( ) const
overrideprotectedvirtual

Implements Slic3r::SLAArchiveWriter.

229{
230 return nullptr;
231}

◆ SL1Archive() [1/3]

Slic3r::SL1Archive::SL1Archive ( )
default

◆ SL1Archive() [2/3]

Slic3r::SL1Archive::SL1Archive ( const SLAPrinterConfig cfg)
inlineexplicit
32: m_cfg(cfg) {}

◆ SL1Archive() [3/3]

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

Member Data Documentation

◆ m_cfg

SLAPrinterConfig Slic3r::SL1Archive::m_cfg
privateinherited

◆ m_layers

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

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