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

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

+ Inheritance diagram for Slic3r::AnycubicSLAArchive:
+ Collaboration diagram for Slic3r::AnycubicSLAArchive:

Public Member Functions

 AnycubicSLAArchive ()=default
 
 AnycubicSLAArchive (const SLAPrinterConfig &cfg)
 
 AnycubicSLAArchive (SLAPrinterConfig &&cfg)
 
 AnycubicSLAArchive (const SLAPrinterConfig &cfg, uint16_t version)
 
 AnycubicSLAArchive (SLAPrinterConfig &&cfg, uint16_t version)
 
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
 

Protected Attributes

std::vector< sla::EncodedRasterm_layers
 

Private Attributes

SLAPrinterConfig m_cfg
 
uint16_t m_version
 

Detailed Description

Constructor & Destructor Documentation

◆ AnycubicSLAArchive() [1/5]

Slic3r::AnycubicSLAArchive::AnycubicSLAArchive ( )
default

◆ AnycubicSLAArchive() [2/5]

Slic3r::AnycubicSLAArchive::AnycubicSLAArchive ( const SLAPrinterConfig cfg)
inlineexplicit
32 :
constexpr uint16_t ANYCUBIC_SLA_FORMAT_VERSION_1
Definition AnycubicSLA.hpp:11
SLAPrinterConfig m_cfg
Definition AnycubicSLA.hpp:19
uint16_t m_version
Definition AnycubicSLA.hpp:20
SLAPrinterConfig & cfg()
Definition AnycubicSLA.hpp:26

◆ AnycubicSLAArchive() [3/5]

Slic3r::AnycubicSLAArchive::AnycubicSLAArchive ( SLAPrinterConfig &&  cfg)
inlineexplicit

◆ AnycubicSLAArchive() [4/5]

Slic3r::AnycubicSLAArchive::AnycubicSLAArchive ( const SLAPrinterConfig cfg,
uint16_t  version 
)
inlineexplicit
37 :
char * version
Definition main.c:59

◆ AnycubicSLAArchive() [5/5]

Slic3r::AnycubicSLAArchive::AnycubicSLAArchive ( SLAPrinterConfig &&  cfg,
uint16_t  version 
)
inlineexplicit
39 :
40 m_cfg(std::move(cfg)), m_version(version) {}

Member Function Documentation

◆ cfg() [1/2]

SLAPrinterConfig & Slic3r::AnycubicSLAArchive::cfg ( )
inlineprotected
26{ return m_cfg; }

References m_cfg.

◆ cfg() [2/2]

const SLAPrinterConfig & Slic3r::AnycubicSLAArchive::cfg ( ) const
inlineprotected
27{ 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::AnycubicSLAArchive::create_raster ( ) const
overrideprotectedvirtual

Implements Slic3r::SLAArchiveWriter.

369{
370 sla::Resolution res;
371 sla::PixelDim pxdim;
372 std::array<bool, 2> mirror;
373
374 double w = m_cfg.display_width.getFloat();
375 double h = m_cfg.display_height.getFloat();
376 auto pw = size_t(m_cfg.display_pixels_x.getInt());
377 auto ph = size_t(m_cfg.display_pixels_y.getInt());
378
379 mirror[X] = m_cfg.display_mirror_x.getBool();
380 mirror[Y] = m_cfg.display_mirror_y.getBool();
381
382 auto ro = m_cfg.display_orientation.getInt();
383 sla::RasterBase::Orientation orientation =
386
387 if (orientation == sla::RasterBase::roPortrait) {
388 std::swap(w, h);
389 std::swap(pw, ph);
390 }
391
392 res = sla::Resolution{pw, ph};
393 pxdim = sla::PixelDim{w / pw, h / ph};
394 sla::RasterBase::Trafo tr{orientation, mirror};
395
396 double gamma = m_cfg.gamma_correction.getFloat();
397
398 return sla::create_raster_grayscale_aa(res, pxdim, gamma, tr);
399}
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()

void Slic3r::AnycubicSLAArchive::export_print ( const std::string  fname,
const SLAPrint print,
const ThumbnailsList thumbnails,
const std::string &  projectname = "" 
)
overridevirtual

Implements Slic3r::SLAArchiveWriter.

498{
499 std::uint32_t layer_count = m_layers.size();
500
501 anycubicsla_format_intro intro = {};
502 anycubicsla_format_header header = {};
503 anycubicsla_format_preview preview = {};
504 anycubicsla_format_layers_header layers_header = {};
505 anycubicsla_format_misc misc = {};
506 std::vector<uint8_t> layer_images;
507 std::uint32_t image_offset;
508
510
511 intro.version = m_version;
512 intro.area_num = 4;
513 intro.header_data_offset = sizeof(intro);
514 intro.preview_data_offset = sizeof(intro) + sizeof(header);
515 intro.layer_data_offset = intro.preview_data_offset + sizeof(preview);
516 intro.image_data_offset = intro.layer_data_offset +
517 sizeof(layers_header) +
518 (sizeof(anycubicsla_format_layer) * layer_count);
519
520 fill_header(header, misc, print, layer_count);
521 fill_preview(preview, misc, thumbnails);
522
523 try {
524 // open the file and write the contents
525 std::ofstream out;
526 out.open(fname, std::ios::binary | std::ios::out | std::ios::trunc);
527 anycubicsla_write_intro(out, intro);
528 anycubicsla_write_header(out, header);
529 anycubicsla_write_preview(out, preview);
530
531 layers_header.payload_size = intro.image_data_offset - intro.layer_data_offset -
532 sizeof(layers_header.tag) - sizeof(layers_header.payload_size);
533 layers_header.layer_count = layer_count;
534 anycubicsla_write_layers_header(out, layers_header);
535
536 //layers
537 layer_images.reserve(layer_count * LAYER_SIZE_ESTIMATE);
538 image_offset = intro.image_data_offset;
539 size_t i = 0;
540 for (const sla::EncodedRaster &rst : m_layers) {
542 std::memset(&l, 0, sizeof(l));
543 l.image_offset = image_offset;
544 l.image_size = rst.size();
545 if (i < header.bottom_layer_count) {
546 l.exposure_time_s = header.bottom_exposure_time_s;
547 l.layer_height_mm = misc.bottom_layer_height_mm;
548 l.lift_distance_mm = misc.bottom_lift_distance_mm;
549 l.lift_speed_mms = misc.bottom_lift_speed_mms;
550 } else {
551 l.exposure_time_s = header.exposure_time_s;
552 l.layer_height_mm = header.layer_height_mm;
553 l.lift_distance_mm = header.lift_distance_mm;
554 l.lift_speed_mms = header.lift_speed_mms;
555 }
556 image_offset += l.image_size;
558 // add the rle encoded layer image into the buffer
559 const char* img_start = reinterpret_cast<const char*>(rst.data());
560 const char* img_end = img_start + rst.size();
561 std::copy(img_start, img_end, std::back_inserter(layer_images));
562 i++;
563 }
564 const char* img_buffer = reinterpret_cast<const char*>(layer_images.data());
565 out.write(img_buffer, layer_images.size());
566 out.close();
567 } catch(std::exception& e) {
568 BOOST_LOG_TRIVIAL(error) << e.what();
569 // Rethrow the exception
570 throw;
571 }
572
573}
#define LAYER_SIZE_ESTIMATE
Definition AnycubicSLA.cpp:32
void fill_preview(anycubicsla_format_preview &p, anycubicsla_format_misc &, const ThumbnailsList &thumbnails)
Definition AnycubicSLA.cpp:228
void fill_header(anycubicsla_format_header &h, anycubicsla_format_misc &m, const SLAPrint &print, std::uint32_t layer_count)
Definition AnycubicSLA.cpp:272
struct Slic3r::anycubicsla_format_layer anycubicsla_format_layer
struct Slic3r::anycubicsla_format_misc anycubicsla_format_misc
static void anycubicsla_write_intro(std::ofstream &out, anycubicsla_format_intro &i)
Definition AnycubicSLA.cpp:425
struct Slic3r::anycubicsla_format_preview anycubicsla_format_preview
static void anycubicsla_write_layer(std::ofstream &out, anycubicsla_format_layer &l)
Definition AnycubicSLA.cpp:482
static void anycubicsla_write_header(std::ofstream &out, anycubicsla_format_header &h)
Definition AnycubicSLA.cpp:439
static void anycubicsla_write_preview(std::ofstream &out, anycubicsla_format_preview &p)
Definition AnycubicSLA.cpp:465
struct Slic3r::anycubicsla_format_intro anycubicsla_format_intro
struct Slic3r::anycubicsla_format_layers_header anycubicsla_format_layers_header
static void anycubicsla_write_layers_header(std::ofstream &out, anycubicsla_format_layers_header &h)
Definition AnycubicSLA.cpp:475
struct Slic3r::anycubicsla_format_header anycubicsla_format_header
static char error[256]
Definition tga.cpp:50

References ANYCUBIC_SLA_FORMAT_VERSION_1, Slic3r::anycubicsla_write_header(), Slic3r::anycubicsla_write_intro(), Slic3r::anycubicsla_write_layer(), Slic3r::anycubicsla_write_layers_header(), Slic3r::anycubicsla_write_preview(), Slic3r::anycubicsla_format_intro::area_num, Slic3r::anycubicsla_format_header::bottom_exposure_time_s, Slic3r::anycubicsla_format_header::bottom_layer_count, Slic3r::anycubicsla_format_misc::bottom_layer_height_mm, Slic3r::anycubicsla_format_misc::bottom_lift_distance_mm, Slic3r::anycubicsla_format_misc::bottom_lift_speed_mms, error, Slic3r::anycubicsla_format_header::exposure_time_s, Slic3r::anycubicsla_format_layer::exposure_time_s, Slic3r::anycubicsla_format_intro::header_data_offset, Slic3r::anycubicsla_format_intro::image_data_offset, Slic3r::anycubicsla_format_layer::image_offset, Slic3r::anycubicsla_format_layer::image_size, Slic3r::anycubicsla_format_layers_header::layer_count, Slic3r::anycubicsla_format_intro::layer_data_offset, Slic3r::anycubicsla_format_header::layer_height_mm, Slic3r::anycubicsla_format_layer::layer_height_mm, LAYER_SIZE_ESTIMATE, Slic3r::anycubicsla_format_header::lift_distance_mm, Slic3r::anycubicsla_format_layer::lift_distance_mm, Slic3r::anycubicsla_format_header::lift_speed_mms, Slic3r::anycubicsla_format_layer::lift_speed_mms, Slic3r::SLAArchiveWriter::m_layers, m_version, Slic3r::anycubicsla_format_layers_header::payload_size, Slic3r::anycubicsla_format_intro::preview_data_offset, Slic3r::anycubicsla_format_layers_header::tag, and Slic3r::anycubicsla_format_intro::version.

+ Here is the call graph for this function:

◆ get_encoder()

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

Implements Slic3r::SLAArchiveWriter.

402{
403 return AnycubicSLARasterEncoder{};
404}

Member Data Documentation

◆ m_cfg

SLAPrinterConfig Slic3r::AnycubicSLAArchive::m_cfg
private

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

◆ m_layers

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

◆ m_version

uint16_t Slic3r::AnycubicSLAArchive::m_version
private

Referenced by export_print().


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