mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Port PrintRegion::flow() and LayerRegion.flow() to XS
This commit is contained in:
parent
380dd8adfc
commit
7ff13c063f
11 changed files with 80 additions and 85 deletions
|
@ -28,6 +28,19 @@ LayerRegion::region()
|
|||
return this->_region;
|
||||
}
|
||||
|
||||
Flow
|
||||
LayerRegion::flow(FlowRole role, bool bridge, double width) const
|
||||
{
|
||||
return this->_region->flow(
|
||||
role,
|
||||
this->_layer->height,
|
||||
bridge,
|
||||
this->_layer->id() == 0,
|
||||
width,
|
||||
*this->_layer->object()
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
REGISTER_CLASS(LayerRegion, "Layer::Region");
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define slic3r_Layer_hpp_
|
||||
|
||||
#include <myinit.h>
|
||||
#include "Flow.hpp"
|
||||
#include "SurfaceCollection.hpp"
|
||||
#include "ExtrusionEntityCollection.hpp"
|
||||
#include "ExPolygonCollection.hpp"
|
||||
|
@ -49,7 +50,9 @@ class LayerRegion
|
|||
|
||||
// ordered collection of extrusion paths to fill surfaces
|
||||
ExtrusionEntityCollection fills;
|
||||
|
||||
|
||||
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
||||
|
||||
private:
|
||||
Layer *_layer;
|
||||
PrintRegion *_region;
|
||||
|
|
|
@ -60,6 +60,52 @@ PrintRegion::print()
|
|||
return this->_print;
|
||||
}
|
||||
|
||||
Flow
|
||||
PrintRegion::flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, const PrintObject &object) const
|
||||
{
|
||||
ConfigOptionFloatOrPercent config_width;
|
||||
if (width != -1) {
|
||||
// use the supplied custom width, if any
|
||||
config_width.value = width;
|
||||
config_width.percent = false;
|
||||
} else {
|
||||
// otherwise, get extrusion width from configuration
|
||||
// (might be an absolute value, or a percent value, or zero for auto)
|
||||
if (first_layer && this->_print->config.first_layer_extrusion_width.value > 0) {
|
||||
config_width = this->_print->config.first_layer_extrusion_width;
|
||||
} else if (role == frExternalPerimeter) {
|
||||
config_width = this->config.external_perimeter_extrusion_width;
|
||||
} else if (role == frPerimeter) {
|
||||
config_width = this->config.perimeter_extrusion_width;
|
||||
} else if (role == frInfill) {
|
||||
config_width = this->config.infill_extrusion_width;
|
||||
} else if (role == frSolidInfill) {
|
||||
config_width = this->config.solid_infill_extrusion_width;
|
||||
} else if (role == frTopSolidInfill) {
|
||||
config_width = this->config.top_infill_extrusion_width;
|
||||
} else {
|
||||
CONFESS("Unknown role");
|
||||
}
|
||||
}
|
||||
if (config_width.value == 0) {
|
||||
config_width = object.config.extrusion_width;
|
||||
}
|
||||
|
||||
// get the configured nozzle_diameter for the extruder associated
|
||||
// to the flow role requested
|
||||
size_t extruder; // 1-based
|
||||
if (role == frPerimeter || role == frExternalPerimeter) {
|
||||
extruder = this->config.perimeter_extruder;
|
||||
} else if (role == frInfill || role == frSolidInfill || role == frTopSolidInfill) {
|
||||
extruder = this->config.infill_extruder;
|
||||
} else {
|
||||
CONFESS("Unknown role $role");
|
||||
}
|
||||
double nozzle_diameter = this->_print->config.nozzle_diameter.get_at(extruder-1);
|
||||
|
||||
return Flow::new_from_config_width(role, config_width, nozzle_diameter, layer_height, bridge ? this->config.bridge_flow_ratio : 0);
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
REGISTER_CLASS(PrintRegion, "Print::Region");
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <myinit.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include "Flow.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "Layer.hpp"
|
||||
|
@ -13,6 +14,7 @@
|
|||
namespace Slic3r {
|
||||
|
||||
class Print;
|
||||
class PrintObject;
|
||||
class ModelObject;
|
||||
|
||||
|
||||
|
@ -47,6 +49,7 @@ class PrintRegion
|
|||
PrintRegionConfig config;
|
||||
|
||||
Print* print();
|
||||
Flow flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, const PrintObject &object) const;
|
||||
|
||||
private:
|
||||
Print* _print;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue