mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 07:11:10 +00:00
* Add Missing Includes Across src/libslic3r Every libslic3r source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, with libslic3r headers spelled libslic3r/... so they resolve outside the library's private include paths. MultiMaterialSegmentation.hpp, Support/SupportParameters.hpp and Format/STEP.hpp are made self-contained by hand. * Make the libslic3r Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Left out: I18N.hpp, which errors on purpose when included from GUI code, and VoxelizeCSGMesh.hpp and SLA/bicubic.h, which nothing includes and which no longer compile at all. * Add the Includes Missing From the Hand-Fixed libslic3r Headers clang-tidy would not edit these headers while they failed to compile on their own, so the first pass skipped them. With the headers now self-contained, a second pass adds the rest. * Keep Windows Setup Ahead of the Added libslic3r Includes Print.cpp and Thread.cpp open with a _WIN32 block that has to come first; without the precompiled header, Print.cpp otherwise reaches windows.h through OCCT with NONLS defined and boost/regex fails. OpenVDBUtils.cpp and SLA/SupportTreeBuilder.cpp had includes inside #ifndef NOMINMAX, which libslic3r defines on Windows, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory. * Re-Add libslic3r Includes After the Clipper2 2.0.1 Migration Rebasing onto main took main's version of the files the Clipper2 migration rewrote, so their added includes are restored here, along with includes for main's new code. Clipper2's individual headers are now ignored by clang-tidy: they only build the Z variant through clipper2_z.hpp, which defines USINGZ first, so including clipper.core.h and the like directly broke ClipperZUtils.cpp.
152 lines
6.3 KiB
C++
152 lines
6.3 KiB
C++
#ifndef slic3r_Flow_hpp_
|
|
#define slic3r_Flow_hpp_
|
|
|
|
#include "libslic3r.h"
|
|
#include "Config.hpp"
|
|
#include "Exception.hpp"
|
|
#include "ExtrusionEntity.hpp"
|
|
#include <string>
|
|
#include <cassert>
|
|
|
|
namespace Slic3r {
|
|
|
|
class PrintObject;
|
|
|
|
// Extra spacing of bridge threads, in mm.
|
|
#define BRIDGE_EXTRA_SPACING 0.05
|
|
|
|
enum FlowRole {
|
|
frExternalPerimeter,
|
|
frPerimeter,
|
|
frInfill,
|
|
frSolidInfill,
|
|
frTopSolidInfill,
|
|
frSupportMaterial,
|
|
frSupportMaterialInterface,
|
|
frSupportTransition, // BBS
|
|
};
|
|
|
|
class FlowError : public Slic3r::InvalidArgument
|
|
{
|
|
public:
|
|
FlowError(const std::string& what_arg) : Slic3r::InvalidArgument(what_arg) {}
|
|
FlowError(const char* what_arg) : Slic3r::InvalidArgument(what_arg) {}
|
|
};
|
|
|
|
class FlowErrorNegativeSpacing : public FlowError
|
|
{
|
|
public:
|
|
FlowErrorNegativeSpacing();
|
|
};
|
|
|
|
class FlowErrorNegativeFlow : public FlowError
|
|
{
|
|
public:
|
|
FlowErrorNegativeFlow();
|
|
};
|
|
|
|
class FlowErrorMissingVariable : public FlowError
|
|
{
|
|
public:
|
|
FlowErrorMissingVariable(const std::string& what_arg) : FlowError(what_arg) {}
|
|
};
|
|
|
|
class Flow
|
|
{
|
|
public:
|
|
Flow() = default;
|
|
Flow(float width, float height, float nozzle_diameter) :
|
|
Flow(width, height, rounded_rectangle_extrusion_spacing(width, height), nozzle_diameter, false) {}
|
|
|
|
// Non bridging flow: Maximum width of an extrusion with semicircles at the ends.
|
|
// Bridging flow: Bridge thread diameter.
|
|
float width() const { return m_width; }
|
|
coord_t scaled_width() const { return coord_t(scale_(m_width)); }
|
|
// Non bridging flow: Layer height.
|
|
// Bridging flow: Bridge thread diameter = layer height.
|
|
float height() const { return m_height; }
|
|
// Spacing between the extrusion centerlines.
|
|
float spacing() const { return m_spacing; }
|
|
void set_spacing(float spacing) { m_spacing = spacing; }
|
|
coord_t scaled_spacing() const { return coord_t(scale_(m_spacing)); }
|
|
// Nozzle diameter.
|
|
float nozzle_diameter() const { return m_nozzle_diameter; }
|
|
// Is it a bridge?
|
|
bool bridge() const { return m_bridge; }
|
|
// Cross section area of the extrusion.
|
|
double mm3_per_mm() const;
|
|
|
|
// Elephant foot compensation spacing to be used to detect narrow parts, where the elephant foot compensation cannot be applied.
|
|
// To be used on frExternalPerimeter only.
|
|
// Enable some perimeter squish (see INSET_OVERLAP_TOLERANCE).
|
|
// Here an overlap of 0.2x external perimeter spacing is allowed for by the elephant foot compensation.
|
|
coord_t scaled_elephant_foot_spacing() const { return coord_t(0.5f * float(this->scaled_width() + 0.6f * this->scaled_spacing())); }
|
|
|
|
bool operator==(const Flow &rhs) const { return m_width == rhs.m_width && m_height == rhs.m_height && m_nozzle_diameter == rhs.m_nozzle_diameter && m_bridge == rhs.m_bridge; }
|
|
|
|
bool operator!=(const Flow &rhs) const{
|
|
return m_width != rhs.m_width || m_height != rhs.m_height || m_nozzle_diameter != rhs.m_nozzle_diameter || m_bridge != rhs.m_bridge;
|
|
}
|
|
|
|
bool operator <(const Flow &rhs) const {
|
|
return this->mm3_per_mm() < rhs.mm3_per_mm();
|
|
}
|
|
Flow with_width (float width) const {
|
|
assert(! m_bridge);
|
|
return Flow(width, m_height, rounded_rectangle_extrusion_spacing(width, m_height), m_nozzle_diameter, m_bridge);
|
|
}
|
|
Flow with_height(float height) const {
|
|
assert(! m_bridge);
|
|
return Flow(m_width, height, rounded_rectangle_extrusion_spacing(m_width, height), m_nozzle_diameter, m_bridge);
|
|
}
|
|
// Adjust extrusion flow for new extrusion line spacing, maintaining the old spacing between extrusions.
|
|
Flow with_spacing(float spacing) const;
|
|
// Adjust the width / height of a rounded extrusion model to reach the prescribed cross section area while maintaining extrusion spacing.
|
|
Flow with_cross_section(float area) const;
|
|
Flow with_flow_ratio(double ratio) const { return this->with_cross_section(this->mm3_per_mm() * ratio); }
|
|
|
|
static Flow bridging_flow(float dmr, float nozzle_diameter) { return Flow { dmr, dmr, bridge_extrusion_spacing(dmr), nozzle_diameter, true }; }
|
|
|
|
static Flow new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height);
|
|
|
|
// Spacing of extrusions with rounded extrusion model.
|
|
static float rounded_rectangle_extrusion_spacing(float width, float height);
|
|
// Width of extrusions with rounded extrusion model.
|
|
static float rounded_rectangle_extrusion_width_from_spacing(float spacing, float height);
|
|
// Spacing of round thread extrusions.
|
|
static float bridge_extrusion_spacing(float dmr);
|
|
|
|
// Sane extrusion width defautl based on nozzle diameter.
|
|
// The defaults were derived from manual Prusa MK3 profiles.
|
|
static float auto_extrusion_width(FlowRole role, float nozzle_diameter);
|
|
|
|
// Extrusion width from full config, taking into account the defaults (when set to zero) and ratios (percentages).
|
|
// Precise value depends on layer index (1st layer vs. other layers vs. variable layer height),
|
|
// on active extruder etc. Therefore the value calculated by this function shall be used as a hint only.
|
|
static double extrusion_width(const std::string &opt_key, const ConfigOptionFloatOrPercent *opt, const ConfigOptionResolver &config, const unsigned int first_printing_extruder = 0);
|
|
static double extrusion_width(const std::string &opt_key, const ConfigOptionResolver &config, const unsigned int first_printing_extruder = 0);
|
|
|
|
private:
|
|
Flow(float width, float height, float spacing, float nozzle_diameter, bool bridge) :
|
|
m_width(width), m_height(height), m_spacing(spacing), m_nozzle_diameter(nozzle_diameter), m_bridge(bridge)
|
|
{
|
|
// Gap fill violates this condition.
|
|
//assert(width >= height);
|
|
}
|
|
|
|
float m_width { 0 };
|
|
float m_height { 0 };
|
|
float m_spacing { 0 };
|
|
float m_nozzle_diameter { 0 };
|
|
bool m_bridge { false };
|
|
};
|
|
|
|
extern Flow support_material_flow(const PrintObject* object, float layer_height = 0.f);
|
|
extern Flow support_transition_flow(const PrintObject *object); //BBS
|
|
extern Flow support_material_1st_layer_flow(const PrintObject *object, float layer_height = 0.f);
|
|
extern Flow support_material_interface_flow(const PrintObject *object, float layer_height = 0.f);
|
|
|
|
}
|
|
|
|
#endif
|