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

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

+ Inheritance diagram for Slic3r::SL1Reader:
+ Collaboration diagram for Slic3r::SL1Reader:

Public Member Functions

ConfigSubstitutions read (std::vector< ExPolygons > &slices, DynamicPrintConfig &profile_out) override
 
ConfigSubstitutions read (DynamicPrintConfig &profile) override
 
 SL1Reader ()=default
 
 SL1Reader (const std::string &fname, SLAImportQuality quality, std::function< bool(int)> progr)
 

Static Public Member Functions

static std::unique_ptr< SLAArchiveReadercreate (const std::string &fname, const std::string &format_id, SLAImportQuality quality=SLAImportQuality::Balanced, const ProgrFn &progr=[](int) { return false;})
 

Private Attributes

SLAImportQuality m_quality = SLAImportQuality::Balanced
 
std::function< bool(int)> m_progr
 
std::string m_fname
 

Detailed Description

Constructor & Destructor Documentation

◆ SL1Reader() [1/2]

Slic3r::SL1Reader::SL1Reader ( )
default

◆ SL1Reader() [2/2]

Slic3r::SL1Reader::SL1Reader ( const std::string &  fname,
SLAImportQuality  quality,
std::function< bool(int)>  progr 
)
inline
59 : m_quality(quality), m_progr(progr), m_fname(fname)
60 {}
std::function< bool(int)> m_progr
Definition SL1.hpp:43
SLAImportQuality m_quality
Definition SL1.hpp:42
std::string m_fname
Definition SL1.hpp:44

Member Function Documentation

◆ create()

std::unique_ptr< SLAArchiveReader > Slic3r::SLAArchiveReader::create ( const std::string &  fname,
const std::string &  format_id,
SLAImportQuality  quality = SLAImportQuality::Balanced,
const ProgrFn progr = [](int) { return false; } 
)
staticinherited
23{
24 // Create an instance of SLAArchiveReader using the registered archive
25 // reader implementations.
26 // If format_id is specified and valid, that archive format will be
27 // preferred. When format_id is emtpy, the file extension is compared
28 // with the advertised extensions of registered readers and the first
29 // match will be used.
30
31 std::string ext = boost::filesystem::path(fname).extension().string();
32 boost::algorithm::to_lower(ext);
33
34 std::unique_ptr<SLAArchiveReader> ret;
35
36 auto registry = registered_sla_archives();
37
38 auto arch_from = registry.begin();
39 auto arch_to = registry.end();
40
41 auto arch_it = registry.find(ArchiveEntry{format_id.c_str()});
42 if (arch_it != registry.end()) {
43 arch_from = arch_it;
44 arch_to = arch_it;
45 }
46
47 if (!ext.empty()) {
48 if (ext.front() == '.')
49 ext.erase(ext.begin());
50
51 for (auto it = arch_from; !ret && it != arch_to; ++it) {
52 const auto &entry = *it;
53 if (entry.rdfactoryfn) {
54 auto extensions = get_extensions(entry);
55 for (const std::string& supportedext : extensions) {
56 if (ext == supportedext) {
57 ret = entry.rdfactoryfn(fname, quality, progr);
58 break;
59 }
60 }
61 }
62 }
63 }
64
65 return ret;
66}
const std::set< ArchiveEntry > & registered_sla_archives()
Definition SLAArchiveFormatRegistry.cpp:95
std::vector< std::string > get_extensions(const ArchiveEntry &entry)
Definition SLAArchiveFormatRegistry.cpp:100

References Slic3r::get_extensions(), and Slic3r::registered_sla_archives().

Referenced by Slic3r::import_sla_archive(), and Slic3r::import_sla_archive().

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

◆ read() [1/2]

ConfigSubstitutions Slic3r::SL1Reader::read ( DynamicPrintConfig profile)
overridevirtual

Implements Slic3r::SLAArchiveReader.

440{
441 ZipperArchive arch = read_zipper_archive(m_fname, {"ini"}, {"png", "thumbnail"});
442 return out.load(arch.profile, ForwardCompatibilitySubstitutionRule::Enable);
443}
@ Enable
Definition Config.hpp:221
ZipperArchive read_zipper_archive(const std::string &zipfname, const std::vector< std::string > &includes, const std::vector< std::string > &excludes)
Definition ZipperArchiveImport.cpp:47

References Slic3r::ConfigBase::load(), Slic3r::ZipperArchive::profile, and Slic3r::read_zipper_archive().

+ Here is the call graph for this function:

◆ read() [2/2]

ConfigSubstitutions Slic3r::SL1Reader::read ( std::vector< ExPolygons > &  slices,
DynamicPrintConfig profile_out 
)
overridevirtual

Implements Slic3r::SLAArchiveReader.

411{
412 Vec2i windowsize;
413
414 switch(m_quality)
415 {
416 case SLAImportQuality::Fast: windowsize = {8, 8}; break;
417 case SLAImportQuality::Balanced: windowsize = {4, 4}; break;
418 default:
420 windowsize = {2, 2}; break;
421 };
422
423 // Ensure minimum window size for marching squares
424 windowsize.x() = std::max(2, windowsize.x());
425 windowsize.y() = std::max(2, windowsize.y());
426
427 std::vector<std::string> includes = { "ini", "png"};
428 std::vector<std::string> excludes = { "thumbnail" };
429 ZipperArchive arch = read_zipper_archive(m_fname, includes, excludes);
430 auto [profile_use, config_substitutions] = extract_profile(arch, profile_out);
431
432 RasterParams rstp = get_raster_params(profile_use);
433 marchsq::Coord win = {windowsize.y(), windowsize.x()};
434 slices = extract_slices_from_sla_archive(arch, rstp, win, m_progr);
435
436 return std::move(config_substitutions);
437}
std::vector< ExPolygons > extract_slices_from_sla_archive(ZipperArchive &arch, const RasterParams &rstp, const marchsq::Coord &win, std::function< bool(int)> progr)
Definition SL1.cpp:354
std::pair< DynamicPrintConfig, ConfigSubstitutions > extract_profile(const ZipperArchive &arch, DynamicPrintConfig &profile_out)
Definition ZipperArchiveImport.cpp:110
Eigen::Matrix< int, 2, 1, Eigen::DontAlign > Vec2i
Definition Point.hpp:39
RasterParams get_raster_params(const DynamicPrintConfig &cfg)
Definition SL1.cpp:303
Definition MarchingSquares.hpp:13

References Slic3r::extract_profile(), Slic3r::get_raster_params(), and Slic3r::read_zipper_archive().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_fname

std::string Slic3r::SL1Reader::m_fname
private

◆ m_progr

std::function<bool(int)> Slic3r::SL1Reader::m_progr
private

◆ m_quality

SLAImportQuality Slic3r::SL1Reader::m_quality = SLAImportQuality::Balanced
private

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