This commit is contained in:
Vojtech Bubnik 2021-11-16 15:48:17 +01:00
commit 135b3fcea8
29 changed files with 105 additions and 374 deletions

View file

@ -1764,6 +1764,8 @@ public:
// By setting min=0, only nonnegative input is allowed.
int min = INT_MIN;
int max = INT_MAX;
// To check if it's not a typo and a % is missing
double max_literal = 1;
ConfigOptionMode mode = comSimple;
// Legacy names for this configuration option.
// Used when parsing legacy configuration file.

View file

@ -719,9 +719,7 @@ void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
void GCodeProcessorResult::reset() {
moves = std::vector<GCodeProcessorResult::MoveVertex>();
bed_shape = Pointfs();
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
max_print_height = 0.0f;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
settings_ids.reset();
extruders_count = 0;
extruder_colors = std::vector<std::string>();
@ -736,9 +734,7 @@ void GCodeProcessorResult::reset() {
moves.clear();
lines_ends.clear();
bed_shape = Pointfs();
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
max_print_height = 0.0f;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
settings_ids.reset();
extruders_count = 0;
extruder_colors = std::vector<std::string>();
@ -889,9 +885,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
if (first_layer_height != nullptr)
m_first_layer_height = std::abs(first_layer_height->value);
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
m_result.max_print_height = config.max_print_height;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
}
void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
@ -1122,11 +1116,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
if (first_layer_height != nullptr)
m_first_layer_height = std::abs(first_layer_height->value);
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
const ConfigOptionFloat* max_print_height = config.option<ConfigOptionFloat>("max_print_height");
if (max_print_height != nullptr)
m_result.max_print_height = max_print_height->value;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
}
void GCodeProcessor::enable_stealth_time_estimator(bool enabled)

View file

@ -117,9 +117,7 @@ namespace Slic3r {
// Positions of ends of lines of the final G-code this->filename after TimeProcessor::post_process() finalizes the G-code.
std::vector<size_t> lines_ends;
Pointfs bed_shape;
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
float max_print_height;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
SettingsIds settings_ids;
size_t extruders_count;
std::vector<std::string> extruder_colors;

View file

@ -33,14 +33,12 @@ bool directions_parallel(double angle1, double angle2, double max_diff)
return diff < max_diff || fabs(diff - PI) < max_diff;
}
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
bool directions_perpendicular(double angle1, double angle2, double max_diff)
{
double diff = fabs(angle1 - angle2);
max_diff += EPSILON;
return fabs(diff - 0.5 * PI) < max_diff || fabs(diff - 1.5 * PI) < max_diff;
}
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
template<class T>
bool contains(const std::vector<T> &vector, const Point &point)

View file

@ -288,9 +288,7 @@ bool liang_barsky_line_clipping(
}
bool directions_parallel(double angle1, double angle2, double max_diff = 0);
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
bool directions_perpendicular(double angle1, double angle2, double max_diff = 0);
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
template<class T> bool contains(const std::vector<T> &vector, const Point &point);
template<typename T> T rad2deg(T angle) { return T(180.0) * angle / T(PI); }
double rad2deg_dir(double angle);

View file

@ -70,7 +70,6 @@ bool Line::parallel_to(const Line& line) const
return sqr(cross2(v1, v2)) < sqr(EPSILON) * v1.squaredNorm() * v2.squaredNorm();
}
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
bool Line::perpendicular_to(double angle) const
{
return Slic3r::Geometry::directions_perpendicular(this->direction(), angle);
@ -82,7 +81,6 @@ bool Line::perpendicular_to(const Line& line) const
const Vec2d v2 = (line.b - line.a).cast<double>();
return sqr(v1.dot(v2)) < sqr(EPSILON) * v1.squaredNorm() * v2.squaredNorm();
}
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
bool Line::intersection(const Line &l2, Point *intersection) const
{

View file

@ -105,10 +105,8 @@ public:
double perp_distance_to(const Point &point) const;
bool parallel_to(double angle) const;
bool parallel_to(const Line& line) const;
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
bool perpendicular_to(double angle) const;
bool perpendicular_to(const Line& line) const;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
double atan2_() const { return atan2(this->b(1) - this->a(1), this->b(0) - this->a(0)); }
double orientation() const;
double direction() const;

View file

@ -374,6 +374,7 @@ void PrintConfigDef::init_fff_params()
"Detour length could be specified either as an absolute value or as percentage (for example 50%) of a direct travel path.");
def->sidetext = L("mm or % (zero to disable)");
def->min = 0;
def->max_literal = 1000;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloatOrPercent(0., false));
@ -720,6 +721,7 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (for example 200%), it will be computed over layer height.");
def->sidetext = L("mm or %");
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -831,6 +833,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm or %");
def->min = 0;
def->max = 1000;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -1181,6 +1184,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm or %");
def->ratio_over = "first_layer_height";
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(200, true));
@ -1200,6 +1204,7 @@ void PrintConfigDef::init_fff_params()
"(for example: 40%) it will scale the default speeds.");
def->sidetext = L("mm/s or %");
def->min = 0;
def->max_literal = 20;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(30, false));
@ -1374,6 +1379,7 @@ void PrintConfigDef::init_fff_params()
"Set this parameter to zero to disable anchoring perimeters connected to a single infill line.");
def->sidetext = L("mm or %");
def->ratio_over = "infill_extrusion_width";
def->max_literal = 1000;
def->gui_type = ConfigOptionDef::GUIType::f_enum_open;
def->enum_values.push_back("0");
def->enum_values.push_back("1");
@ -1401,6 +1407,7 @@ void PrintConfigDef::init_fff_params()
"Set this parameter to zero to disable anchoring.");
def->sidetext = def_infill_anchor_min->sidetext;
def->ratio_over = def_infill_anchor_min->ratio_over;
def->max_literal = def_infill_anchor_min->max_literal;
def->gui_type = def_infill_anchor_min->gui_type;
def->enum_values = def_infill_anchor_min->enum_values;
def->enum_labels.push_back(L("0 (not anchored)"));
@ -1429,6 +1436,7 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (for example 90%) it will be computed over layer height.");
def->sidetext = L("mm or %");
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -1928,6 +1936,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm or %");
def->aliases = { "perimeters_extrusion_width" };
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -2300,6 +2309,7 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (for example 90%) it will be computed over layer height.");
def->sidetext = L("mm or %");
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -2474,6 +2484,7 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("mm or %");
def->ratio_over = "external_perimeter_extrusion_width";
def->min = 0;
def->max_literal = 10;
def->mode = comAdvanced;
// Default is half the external perimeter width.
def->set_default_value(new ConfigOptionFloatOrPercent(50, true));
@ -2560,6 +2571,7 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (for example 90%) it will be computed over layer height.");
def->sidetext = L("mm or %");
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
@ -2793,6 +2805,7 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (for example 90%) it will be computed over layer height.");
def->sidetext = L("mm or %");
def->min = 0;
def->max_literal = 50;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));

View file

@ -80,9 +80,6 @@
// Enable rendering modifiers and similar objects always as transparent
#define ENABLE_MODIFIERS_ALWAYS_TRANSPARENT (1 && ENABLE_2_4_0_BETA1)
// Enable the fix for the detection of the out of bed state for sinking objects
// and detection of out of bed using the bed perimeter
#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_2_4_0_BETA1)
//====================

View file

@ -436,7 +436,6 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d &trafo) c
return bbox;
}
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafod, double world_min_z) const
{
// 1) Allocate transformed vertices with their position with respect to print bed surface.
@ -487,7 +486,6 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafod,
};
return out;
}
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
TriangleMesh TriangleMesh::convex_hull_3d() const
{

View file

@ -125,10 +125,8 @@ public:
BoundingBoxf3 bounding_box() const;
// Returns the bbox of this TriangleMesh transformed by the given transformation
BoundingBoxf3 transformed_bounding_box(const Transform3d &trafo) const;
#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
// Variant returning the bbox of the part of this TriangleMesh above the given world_min_z
BoundingBoxf3 transformed_bounding_box(const Transform3d& trafo, double world_min_z) const;
#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS
// Return the size of the mesh in coordinates.
Vec3d size() const { return m_stats.size.cast<double>(); }
/// Return the center of the related bounding box.