Merge branch 'master' into fs_emboss
This commit is contained in:
commit
a78122bce7
11 changed files with 1850 additions and 1777 deletions
|
@ -83,6 +83,13 @@ public:
|
||||||
// to split around.
|
// to split around.
|
||||||
template<typename SourceNode>
|
template<typename SourceNode>
|
||||||
void build(std::vector<SourceNode> &&input)
|
void build(std::vector<SourceNode> &&input)
|
||||||
|
{
|
||||||
|
this->build_modify_input(input);
|
||||||
|
input.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename SourceNode>
|
||||||
|
void build_modify_input(std::vector<SourceNode> &input)
|
||||||
{
|
{
|
||||||
if (input.empty())
|
if (input.empty())
|
||||||
clear();
|
clear();
|
||||||
|
@ -91,7 +98,6 @@ public:
|
||||||
m_nodes.assign(next_highest_power_of_2(input.size()) * 2 - 1, Node());
|
m_nodes.assign(next_highest_power_of_2(input.size()) * 2 - 1, Node());
|
||||||
build_recursive(input, 0, 0, input.size() - 1);
|
build_recursive(input, 0, 0, input.size() - 1);
|
||||||
}
|
}
|
||||||
input.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Node>& nodes() const { return m_nodes; }
|
const std::vector<Node>& nodes() const { return m_nodes; }
|
||||||
|
|
|
@ -1769,7 +1769,7 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line, bool
|
||||||
switch (cmd[1]) {
|
switch (cmd[1]) {
|
||||||
case '1':
|
case '1':
|
||||||
switch (cmd[2]) {
|
switch (cmd[2]) {
|
||||||
case '0': { process_G10(line); break; } // Retract
|
case '0': { process_G10(line); break; } // Retract or Set tool temperature
|
||||||
case '1': { process_G11(line); break; } // Unretract
|
case '1': { process_G11(line); break; } // Unretract
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -3232,6 +3232,23 @@ void GCodeProcessor::process_G2_G3(const GCodeReader::GCodeLine& line, bool cloc
|
||||||
|
|
||||||
void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
|
if (m_flavor == gcfRepRapFirmware) {
|
||||||
|
// similar to M104/M109
|
||||||
|
float new_temp;
|
||||||
|
if (line.has_value('S', new_temp)) {
|
||||||
|
size_t id = m_extruder_id;
|
||||||
|
float val;
|
||||||
|
if (line.has_value('P', val)) {
|
||||||
|
const size_t eid = static_cast<size_t>(val);
|
||||||
|
if (eid < m_extruder_temps.size())
|
||||||
|
id = eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_extruder_temps[id] = new_temp;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// stores retract move
|
// stores retract move
|
||||||
store_move_vertex(EMoveType::Retract);
|
store_move_vertex(EMoveType::Retract);
|
||||||
}
|
}
|
||||||
|
@ -3441,18 +3458,22 @@ void GCodeProcessor::process_M108(const GCodeReader::GCodeLine& line)
|
||||||
void GCodeProcessor::process_M109(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_M109(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
float new_temp;
|
float new_temp;
|
||||||
|
size_t id = (size_t)-1;
|
||||||
if (line.has_value('R', new_temp)) {
|
if (line.has_value('R', new_temp)) {
|
||||||
float val;
|
float val;
|
||||||
if (line.has_value('T', val)) {
|
if (line.has_value('T', val)) {
|
||||||
const size_t eid = static_cast<size_t>(val);
|
const size_t eid = static_cast<size_t>(val);
|
||||||
if (eid < m_extruder_temps.size())
|
if (eid < m_extruder_temps.size())
|
||||||
m_extruder_temps[eid] = new_temp;
|
id = eid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_extruder_temps[m_extruder_id] = new_temp;
|
id = m_extruder_id;
|
||||||
}
|
}
|
||||||
else if (line.has_value('S', new_temp))
|
else if (line.has_value('S', new_temp))
|
||||||
m_extruder_temps[m_extruder_id] = new_temp;
|
id = m_extruder_id;
|
||||||
|
|
||||||
|
if (id != (size_t)-1)
|
||||||
|
m_extruder_temps[id] = new_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_M132(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_M132(const GCodeReader::GCodeLine& line)
|
||||||
|
|
|
@ -674,7 +674,7 @@ namespace Slic3r {
|
||||||
void process_G2_G3(const GCodeReader::GCodeLine& line, bool clockwise);
|
void process_G2_G3(const GCodeReader::GCodeLine& line, bool clockwise);
|
||||||
#endif // ENABLE_PROCESS_G2_G3_LINES
|
#endif // ENABLE_PROCESS_G2_G3_LINES
|
||||||
|
|
||||||
// Retract
|
// Retract or Set tool temperature
|
||||||
void process_G10(const GCodeReader::GCodeLine& line);
|
void process_G10(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Unretract
|
// Unretract
|
||||||
|
|
|
@ -1359,7 +1359,7 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||||
size_t counter = 1;
|
size_t counter = 1;
|
||||||
for (TriangleMesh &mesh : meshes) {
|
for (TriangleMesh &mesh : meshes) {
|
||||||
// FIXME: crashes if not satisfied
|
// FIXME: crashes if not satisfied
|
||||||
if (mesh.facets_count() < 3)
|
if (mesh.facets_count() < 3 || mesh.has_zero_volume())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// XXX: this seems to be the only real usage of m_model, maybe refactor this so that it's not needed?
|
// XXX: this seems to be the only real usage of m_model, maybe refactor this so that it's not needed?
|
||||||
|
@ -1833,7 +1833,7 @@ size_t ModelVolume::split(unsigned int max_extruders)
|
||||||
const Vec3d offset = this->get_offset();
|
const Vec3d offset = this->get_offset();
|
||||||
|
|
||||||
for (TriangleMesh &mesh : meshes) {
|
for (TriangleMesh &mesh : meshes) {
|
||||||
if (mesh.empty())
|
if (mesh.empty() || mesh.has_zero_volume())
|
||||||
// Repair may have removed unconnected triangles, thus emptying the mesh.
|
// Repair may have removed unconnected triangles, thus emptying the mesh.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -2198,8 +2198,7 @@ void PrintObject::combine_infill()
|
||||||
void PrintObject::_generate_support_material()
|
void PrintObject::_generate_support_material()
|
||||||
{
|
{
|
||||||
if (m_config.support_material_style == smsTree) {
|
if (m_config.support_material_style == smsTree) {
|
||||||
TreeSupport tree_support;
|
fff_tree_support_generate(*this, std::function<void()>([this](){ this->throw_if_canceled(); }));
|
||||||
tree_support.generateSupportAreas(*this);
|
|
||||||
} else {
|
} else {
|
||||||
PrintObjectSupportMaterial support_material(this, m_slicing_params);
|
PrintObjectSupportMaterial support_material(this, m_slicing_params);
|
||||||
support_material.generate(*this);
|
support_material.generate(*this);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/task_group.h>
|
#include <tbb/task_group.h>
|
||||||
|
|
||||||
namespace Slic3r
|
namespace Slic3r::FFFTreeSupport
|
||||||
{
|
{
|
||||||
|
|
||||||
// or warning
|
// or warning
|
||||||
|
@ -106,7 +106,10 @@ TreeModelVolumes::TreeModelVolumes(
|
||||||
const PrintObject &print_object,
|
const PrintObject &print_object,
|
||||||
const BuildVolume &build_volume,
|
const BuildVolume &build_volume,
|
||||||
const coord_t max_move, const coord_t max_move_slow, size_t current_mesh_idx,
|
const coord_t max_move, const coord_t max_move_slow, size_t current_mesh_idx,
|
||||||
double progress_multiplier, double progress_offset, const std::vector<Polygons>& additional_excluded_areas) :
|
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
double progress_multiplier, double progress_offset,
|
||||||
|
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
const std::vector<Polygons>& additional_excluded_areas) :
|
||||||
// -2 to avoid rounding errors
|
// -2 to avoid rounding errors
|
||||||
m_max_move{ std::max<coord_t>(max_move - 2, 0) }, m_max_move_slow{ std::max<coord_t>(max_move_slow - 2, 0) },
|
m_max_move{ std::max<coord_t>(max_move - 2, 0) }, m_max_move_slow{ std::max<coord_t>(max_move_slow - 2, 0) },
|
||||||
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
@ -161,7 +164,7 @@ TreeModelVolumes::TreeModelVolumes(
|
||||||
m_min_resolution = std::min(m_min_resolution, data_pair.first.resolution);
|
m_min_resolution = std::min(m_min_resolution, data_pair.first.resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TreeSupport::TreeSupportSettings config{ m_layer_outlines[m_current_outline_idx].first };
|
const TreeSupportSettings config{ m_layer_outlines[m_current_outline_idx].first };
|
||||||
m_current_min_xy_dist = config.xy_min_distance;
|
m_current_min_xy_dist = config.xy_min_distance;
|
||||||
m_current_min_xy_dist_delta = config.xy_distance - m_current_min_xy_dist;
|
m_current_min_xy_dist_delta = config.xy_distance - m_current_min_xy_dist;
|
||||||
assert(m_current_min_xy_dist_delta >= 0);
|
assert(m_current_min_xy_dist_delta >= 0);
|
||||||
|
@ -206,7 +209,7 @@ void TreeModelVolumes::precalculate(const coord_t max_layer)
|
||||||
// Get the config corresponding to one mesh that is in the current group. Which one has to be irrelevant.
|
// Get the config corresponding to one mesh that is in the current group. Which one has to be irrelevant.
|
||||||
// Not the prettiest way to do this, but it ensures some calculations that may be a bit more complex
|
// Not the prettiest way to do this, but it ensures some calculations that may be a bit more complex
|
||||||
// like inital layer diameter are only done in once.
|
// like inital layer diameter are only done in once.
|
||||||
TreeSupport::TreeSupportSettings config(m_layer_outlines[m_current_outline_idx].first);
|
TreeSupportSettings config(m_layer_outlines[m_current_outline_idx].first);
|
||||||
|
|
||||||
{
|
{
|
||||||
// calculate which radius each layer in the tip may have.
|
// calculate which radius each layer in the tip may have.
|
||||||
|
@ -297,7 +300,7 @@ const Polygons& TreeModelVolumes::getCollision(const coord_t orig_radius, LayerI
|
||||||
return (*result).get();
|
return (*result).get();
|
||||||
if (m_precalculated) {
|
if (m_precalculated) {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate collision at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate collision at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError("Not precalculated Collision requested.", false);
|
tree_supports_show_error("Not precalculated Collision requested.", false);
|
||||||
}
|
}
|
||||||
const_cast<TreeModelVolumes*>(this)->calculateCollision(radius, layer_idx);
|
const_cast<TreeModelVolumes*>(this)->calculateCollision(radius, layer_idx);
|
||||||
return getCollision(orig_radius, layer_idx, min_xy_dist);
|
return getCollision(orig_radius, layer_idx, min_xy_dist);
|
||||||
|
@ -312,7 +315,7 @@ const Polygons& TreeModelVolumes::getCollisionHolefree(coord_t radius, LayerInde
|
||||||
return (*result).get();
|
return (*result).get();
|
||||||
if (m_precalculated) {
|
if (m_precalculated) {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate collision holefree at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate collision holefree at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError("Not precalculated Holefree Collision requested.", false);
|
tree_supports_show_error("Not precalculated Holefree Collision requested.", false);
|
||||||
}
|
}
|
||||||
const_cast<TreeModelVolumes*>(this)->calculateCollisionHolefree({ radius, layer_idx });
|
const_cast<TreeModelVolumes*>(this)->calculateCollisionHolefree({ radius, layer_idx });
|
||||||
return getCollisionHolefree(radius, layer_idx);
|
return getCollisionHolefree(radius, layer_idx);
|
||||||
|
@ -336,10 +339,10 @@ const Polygons& TreeModelVolumes::getAvoidance(const coord_t orig_radius, LayerI
|
||||||
if (m_precalculated) {
|
if (m_precalculated) {
|
||||||
if (to_model) {
|
if (to_model) {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Avoidance to model at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Avoidance to model at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError("Not precalculated Avoidance(to model) requested.", false);
|
tree_supports_show_error("Not precalculated Avoidance(to model) requested.", false);
|
||||||
} else {
|
} else {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Avoidance at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Avoidance at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError("Not precalculated Avoidance(to buildplate) requested.", false);
|
tree_supports_show_error("Not precalculated Avoidance(to buildplate) requested.", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const_cast<TreeModelVolumes*>(this)->calculateAvoidance({ radius, layer_idx }, ! to_model, to_model);
|
const_cast<TreeModelVolumes*>(this)->calculateAvoidance({ radius, layer_idx }, ! to_model, to_model);
|
||||||
|
@ -357,7 +360,7 @@ const Polygons& TreeModelVolumes::getPlaceableAreas(const coord_t orig_radius, L
|
||||||
return (*result).get();
|
return (*result).get();
|
||||||
if (m_precalculated) {
|
if (m_precalculated) {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Placeable Areas at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Placeable Areas at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError("Not precalculated Placeable areas requested.", false);
|
tree_supports_show_error("Not precalculated Placeable areas requested.", false);
|
||||||
}
|
}
|
||||||
const_cast<TreeModelVolumes*>(this)->calculatePlaceables(radius, layer_idx);
|
const_cast<TreeModelVolumes*>(this)->calculatePlaceables(radius, layer_idx);
|
||||||
return getPlaceableAreas(orig_radius, layer_idx);
|
return getPlaceableAreas(orig_radius, layer_idx);
|
||||||
|
@ -380,7 +383,7 @@ const Polygons& TreeModelVolumes::getWallRestriction(const coord_t orig_radius,
|
||||||
return (*result).get();
|
return (*result).get();
|
||||||
if (m_precalculated) {
|
if (m_precalculated) {
|
||||||
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Wall restricions at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
BOOST_LOG_TRIVIAL(error_level_not_in_cache) << "Had to calculate Wall restricions at radius " << radius << " and layer " << layer_idx << ", but precalculate was called. Performance may suffer!";
|
||||||
TreeSupport::showError(
|
tree_supports_show_error(
|
||||||
min_xy_dist ?
|
min_xy_dist ?
|
||||||
"Not precalculated Wall restriction of minimum xy distance requested )." :
|
"Not precalculated Wall restriction of minimum xy distance requested )." :
|
||||||
"Not precalculated Wall restriction requested )."
|
"Not precalculated Wall restriction requested )."
|
||||||
|
@ -774,4 +777,4 @@ coord_t TreeModelVolumes::ceilRadius(const coord_t radius) const
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace Slic3r::FFFTreeSupport
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
namespace Slic3r
|
namespace Slic3r
|
||||||
{
|
{
|
||||||
|
|
||||||
using LayerIndex = int;
|
|
||||||
|
|
||||||
class BuildVolume;
|
class BuildVolume;
|
||||||
class PrintObject;
|
class PrintObject;
|
||||||
|
|
||||||
|
namespace FFFTreeSupport
|
||||||
|
{
|
||||||
|
|
||||||
|
using LayerIndex = int;
|
||||||
|
|
||||||
struct TreeSupportMeshGroupSettings {
|
struct TreeSupportMeshGroupSettings {
|
||||||
TreeSupportMeshGroupSettings() = default;
|
TreeSupportMeshGroupSettings() = default;
|
||||||
explicit TreeSupportMeshGroupSettings(const PrintObject &print_object);
|
explicit TreeSupportMeshGroupSettings(const PrintObject &print_object);
|
||||||
|
@ -194,15 +197,19 @@ class TreeModelVolumes
|
||||||
public:
|
public:
|
||||||
TreeModelVolumes() = default;
|
TreeModelVolumes() = default;
|
||||||
explicit TreeModelVolumes(const PrintObject &print_object, const BuildVolume &build_volume,
|
explicit TreeModelVolumes(const PrintObject &print_object, const BuildVolume &build_volume,
|
||||||
coord_t max_move, coord_t max_move_slow, size_t current_mesh_idx, double progress_multiplier,
|
coord_t max_move, coord_t max_move_slow, size_t current_mesh_idx,
|
||||||
double progress_offset, const std::vector<Polygons> &additional_excluded_areas = {});
|
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
double progress_multiplier,
|
||||||
|
double progress_offset,
|
||||||
|
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
const std::vector<Polygons> &additional_excluded_areas = {});
|
||||||
TreeModelVolumes(TreeModelVolumes&&) = default;
|
TreeModelVolumes(TreeModelVolumes&&) = default;
|
||||||
TreeModelVolumes& operator=(TreeModelVolumes&&) = default;
|
TreeModelVolumes& operator=(TreeModelVolumes&&) = default;
|
||||||
|
|
||||||
TreeModelVolumes(const TreeModelVolumes&) = delete;
|
TreeModelVolumes(const TreeModelVolumes&) = delete;
|
||||||
TreeModelVolumes& operator=(const TreeModelVolumes&) = delete;
|
TreeModelVolumes& operator=(const TreeModelVolumes&) = delete;
|
||||||
|
|
||||||
enum class AvoidanceType
|
enum class AvoidanceType : int8_t
|
||||||
{
|
{
|
||||||
Slow,
|
Slow,
|
||||||
FastSafe,
|
FastSafe,
|
||||||
|
@ -605,6 +612,7 @@ private:
|
||||||
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FFFTreeSupport
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
#endif //slic3r_TreeModelVolumes_hpp
|
#endif //slic3r_TreeModelVolumes_hpp
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,15 +12,13 @@
|
||||||
#include "TreeModelVolumes.hpp"
|
#include "TreeModelVolumes.hpp"
|
||||||
#include "Point.hpp"
|
#include "Point.hpp"
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp> // For combining hashes
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
#include "BoundingBox.hpp"
|
#include "BoundingBox.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
#define TREE_SUPPORT_SHOW_ERRORS
|
#define TREE_SUPPORT_SHOW_ERRORS
|
||||||
|
|
||||||
#define SUPPORT_TREE_CIRCLE_RESOLUTION 25 // The number of vertices in each circle.
|
|
||||||
|
|
||||||
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
#ifdef SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
// The various stages of the process can be weighted differently in the progress bar.
|
// The various stages of the process can be weighted differently in the progress bar.
|
||||||
// These weights are obtained experimentally using a small sample size. Sensible weights can differ drastically based on the assumed default settings and model.
|
// These weights are obtained experimentally using a small sample size. Sensible weights can differ drastically based on the assumed default settings and model.
|
||||||
|
@ -35,189 +33,68 @@
|
||||||
#define TREE_PROGRESS_FINALIZE_BRANCH_AREAS TREE_PROGRESS_DRAW_AREAS / 3
|
#define TREE_PROGRESS_FINALIZE_BRANCH_AREAS TREE_PROGRESS_DRAW_AREAS / 3
|
||||||
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
#endif // SLIC3R_TREESUPPORTS_PROGRESS
|
||||||
|
|
||||||
#define SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL false
|
|
||||||
#define SUPPORT_TREE_AVOID_SUPPORT_BLOCKER true
|
|
||||||
|
|
||||||
namespace Slic3r
|
namespace Slic3r
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class Print;
|
||||||
|
class PrintObject;
|
||||||
|
class SupportGeneratorLayer;
|
||||||
|
using SupportGeneratorLayerStorage = std::deque<SupportGeneratorLayer>;
|
||||||
|
using SupportGeneratorLayersPtr = std::vector<SupportGeneratorLayer*>;
|
||||||
|
|
||||||
|
namespace FFFTreeSupport
|
||||||
|
{
|
||||||
|
|
||||||
using LayerIndex = int;
|
using LayerIndex = int;
|
||||||
|
|
||||||
static constexpr const double SUPPORT_TREE_EXPONENTIAL_FACTOR = 1.5;
|
static constexpr const double SUPPORT_TREE_EXPONENTIAL_FACTOR = 1.5;
|
||||||
static constexpr const coord_t SUPPORT_TREE_EXPONENTIAL_THRESHOLD = scaled<coord_t>(1. * SUPPORT_TREE_EXPONENTIAL_FACTOR);
|
static constexpr const coord_t SUPPORT_TREE_EXPONENTIAL_THRESHOLD = scaled<coord_t>(1. * SUPPORT_TREE_EXPONENTIAL_FACTOR);
|
||||||
static constexpr const coord_t SUPPORT_TREE_COLLISION_RESOLUTION = scaled<coord_t>(0.5);
|
static constexpr const coord_t SUPPORT_TREE_COLLISION_RESOLUTION = scaled<coord_t>(0.5);
|
||||||
|
|
||||||
//FIXME
|
// The number of vertices in each circle.
|
||||||
class Print;
|
static constexpr const size_t SUPPORT_TREE_CIRCLE_RESOLUTION = 25;
|
||||||
class PrintObject;
|
static constexpr const bool SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL = false;
|
||||||
class SupportGeneratorLayer;
|
static constexpr const bool SUPPORT_TREE_AVOID_SUPPORT_BLOCKER = true;
|
||||||
using SupportGeneratorLayerStorage = std::deque<SupportGeneratorLayer>;
|
|
||||||
using SupportGeneratorLayersPtr = std::vector<SupportGeneratorLayer*>;
|
|
||||||
/*!
|
|
||||||
* \brief Generates a tree structure to support your models.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class TreeSupport
|
enum class InterfacePreference
|
||||||
{
|
{
|
||||||
public:
|
InterfaceAreaOverwritesSupport,
|
||||||
using AvoidanceType = TreeModelVolumes::AvoidanceType;
|
SupportAreaOverwritesInterface,
|
||||||
enum class InterfacePreference
|
InterfaceLinesOverwriteSupport,
|
||||||
{
|
SupportLinesOverwriteInterface,
|
||||||
INTERFACE_AREA_OVERWRITES_SUPPORT,
|
Nothing
|
||||||
SUPPORT_AREA_OVERWRITES_INTERFACE,
|
};
|
||||||
INTERFACE_LINES_OVERWRITE_SUPPORT,
|
|
||||||
SUPPORT_LINES_OVERWRITE_INTERFACE,
|
|
||||||
NOTHING
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
struct AreaIncreaseSettings
|
||||||
* \brief Creates an instance of the tree support generator.
|
{
|
||||||
*/
|
AreaIncreaseSettings(
|
||||||
TreeSupport() = default;
|
TreeModelVolumes::AvoidanceType type = TreeModelVolumes::AvoidanceType::Fast, coord_t increase_speed = 0,
|
||||||
|
bool increase_radius = false, bool no_error = false, bool use_min_distance = false, bool move = false) :
|
||||||
|
increase_speed{ increase_speed }, type{ type }, increase_radius{ increase_radius }, no_error{ no_error }, use_min_distance{ use_min_distance }, move{ move } {}
|
||||||
|
|
||||||
/*!
|
coord_t increase_speed;
|
||||||
* \brief Create the areas that need support.
|
// Packing for smaller memory footprint of SupportElementState && SupportElementMerging
|
||||||
*
|
TreeModelVolumes::AvoidanceType type;
|
||||||
* These areas are stored inside the given SliceDataStorage object.
|
bool increase_radius : 1;
|
||||||
* \param storage The data storage where the mesh data is gotten from and
|
bool no_error : 1;
|
||||||
* where the resulting support areas are stored.
|
bool use_min_distance : 1;
|
||||||
*/
|
bool move : 1;
|
||||||
void generateSupportAreas(Print &print, const BuildVolume &build_volume, const std::vector<size_t>& print_object_ids);
|
|
||||||
void generateSupportAreas(PrintObject &print_object);
|
|
||||||
|
|
||||||
//todo Remove! Only relevant for public BETA!
|
|
||||||
static bool inline showed_critical=false;
|
|
||||||
static bool inline showed_performance=false;
|
|
||||||
static void showError(std::string message,bool critical);
|
|
||||||
|
|
||||||
struct TreeSupportSettings; // forward declaration as we need some config values in the merge case
|
|
||||||
|
|
||||||
struct AreaIncreaseSettings
|
|
||||||
{
|
|
||||||
AvoidanceType type { AvoidanceType::Fast };
|
|
||||||
coord_t increase_speed { 0 };
|
|
||||||
bool increase_radius { false };
|
|
||||||
bool no_error { false };
|
|
||||||
bool use_min_distance { false };
|
|
||||||
bool move { false };
|
|
||||||
bool operator==(const AreaIncreaseSettings& other) const
|
bool operator==(const AreaIncreaseSettings& other) const
|
||||||
{
|
{
|
||||||
return increase_radius == other.increase_radius && increase_speed == other.increase_speed && type == other.type &&
|
return type == other.type &&
|
||||||
no_error == other.no_error && use_min_distance == other.use_min_distance && move == other.move;
|
increase_speed == other.increase_speed &&
|
||||||
|
increase_radius == other.increase_radius &&
|
||||||
|
no_error == other.no_error &&
|
||||||
|
use_min_distance == other.use_min_distance &&
|
||||||
|
move == other.move;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SupportElement
|
struct TreeSupportSettings;
|
||||||
{
|
|
||||||
explicit SupportElement(
|
|
||||||
coord_t distance_to_top, size_t target_height, Point target_position, bool to_buildplate, bool to_model_gracious, bool use_min_xy_dist, size_t dont_move_until,
|
|
||||||
bool supports_roof, bool can_use_safe_radius, bool force_tips_to_roof, bool skip_ovalisation) :
|
|
||||||
target_height(target_height), target_position(target_position), next_position(target_position), next_height(target_height), effective_radius_height(distance_to_top),
|
|
||||||
to_buildplate(to_buildplate), distance_to_top(distance_to_top), area(nullptr), result_on_layer(target_position), increased_to_model_radius(0), to_model_gracious(to_model_gracious),
|
|
||||||
elephant_foot_increases(0), use_min_xy_dist(use_min_xy_dist), supports_roof(supports_roof), dont_move_until(dont_move_until), can_use_safe_radius(can_use_safe_radius),
|
|
||||||
last_area_increase(AreaIncreaseSettings{ AvoidanceType::Fast, 0, false, false, false, false }), missing_roof_layers(force_tips_to_roof ? dont_move_until : 0), skip_ovalisation(skip_ovalisation)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
explicit SupportElement(const SupportElement& elem, Polygons* newArea = nullptr)
|
|
||||||
: // copy constructor with possibility to set a new area
|
|
||||||
target_height(elem.target_height),
|
|
||||||
target_position(elem.target_position),
|
|
||||||
next_position(elem.next_position),
|
|
||||||
next_height(elem.next_height),
|
|
||||||
effective_radius_height(elem.effective_radius_height),
|
|
||||||
to_buildplate(elem.to_buildplate),
|
|
||||||
distance_to_top(elem.distance_to_top),
|
|
||||||
area(newArea != nullptr ? newArea : elem.area),
|
|
||||||
result_on_layer(elem.result_on_layer),
|
|
||||||
increased_to_model_radius(elem.increased_to_model_radius),
|
|
||||||
to_model_gracious(elem.to_model_gracious),
|
|
||||||
elephant_foot_increases(elem.elephant_foot_increases),
|
|
||||||
use_min_xy_dist(elem.use_min_xy_dist),
|
|
||||||
supports_roof(elem.supports_roof),
|
|
||||||
dont_move_until(elem.dont_move_until),
|
|
||||||
can_use_safe_radius(elem.can_use_safe_radius),
|
|
||||||
last_area_increase(elem.last_area_increase),
|
|
||||||
missing_roof_layers(elem.missing_roof_layers),
|
|
||||||
skip_ovalisation(elem.skip_ovalisation)
|
|
||||||
|
|
||||||
{
|
|
||||||
parents.insert(parents.begin(), elem.parents.begin(), elem.parents.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Create a new Element for one layer below the element of the pointer supplied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
explicit SupportElement(SupportElement* element_above)
|
|
||||||
: target_height(element_above->target_height),
|
|
||||||
target_position(element_above->target_position),
|
|
||||||
next_position(element_above->next_position),
|
|
||||||
next_height(element_above->next_height),
|
|
||||||
effective_radius_height(element_above->effective_radius_height),
|
|
||||||
to_buildplate(element_above->to_buildplate),
|
|
||||||
distance_to_top(element_above->distance_to_top + 1),
|
|
||||||
area(element_above->area),
|
|
||||||
result_on_layer(Point(-1, -1)), // set to invalid as we are a new node on a new layer
|
|
||||||
increased_to_model_radius(element_above->increased_to_model_radius),
|
|
||||||
to_model_gracious(element_above->to_model_gracious),
|
|
||||||
elephant_foot_increases(element_above->elephant_foot_increases),
|
|
||||||
use_min_xy_dist(element_above->use_min_xy_dist),
|
|
||||||
supports_roof(element_above->supports_roof),
|
|
||||||
dont_move_until(element_above->dont_move_until),
|
|
||||||
can_use_safe_radius(element_above->can_use_safe_radius),
|
|
||||||
last_area_increase(element_above->last_area_increase),
|
|
||||||
missing_roof_layers(element_above->missing_roof_layers),
|
|
||||||
skip_ovalisation(false)
|
|
||||||
{
|
|
||||||
parents = { element_above };
|
|
||||||
}
|
|
||||||
|
|
||||||
// ONLY to be called in merge as it assumes a few assurances made by it.
|
|
||||||
explicit SupportElement(
|
|
||||||
const SupportElement& first, const SupportElement& second, size_t next_height, Point next_position,
|
|
||||||
coord_t increased_to_model_radius, const TreeSupportSettings& config) :
|
|
||||||
next_position(next_position), next_height(next_height), area(nullptr), increased_to_model_radius(increased_to_model_radius),
|
|
||||||
use_min_xy_dist(first.use_min_xy_dist || second.use_min_xy_dist), supports_roof(first.supports_roof || second.supports_roof),
|
|
||||||
dont_move_until(std::max(first.dont_move_until, second.dont_move_until)), can_use_safe_radius(first.can_use_safe_radius || second.can_use_safe_radius),
|
|
||||||
missing_roof_layers(std::min(first.missing_roof_layers, second.missing_roof_layers)), skip_ovalisation(false)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (first.target_height > second.target_height) {
|
|
||||||
target_height = first.target_height;
|
|
||||||
target_position = first.target_position;
|
|
||||||
} else {
|
|
||||||
target_height = second.target_height;
|
|
||||||
target_position = second.target_position;
|
|
||||||
}
|
|
||||||
effective_radius_height = std::max(first.effective_radius_height, second.effective_radius_height);
|
|
||||||
distance_to_top = std::max(first.distance_to_top, second.distance_to_top);
|
|
||||||
|
|
||||||
to_buildplate = first.to_buildplate && second.to_buildplate;
|
|
||||||
to_model_gracious = first.to_model_gracious && second.to_model_gracious; // valid as we do not merge non-gracious with gracious
|
|
||||||
|
|
||||||
AddParents(first.parents);
|
|
||||||
AddParents(second.parents);
|
|
||||||
|
|
||||||
elephant_foot_increases = 0;
|
|
||||||
if (config.diameter_scale_bp_radius > 0) {
|
|
||||||
coord_t foot_increase_radius = std::abs(std::max(config.getCollisionRadius(second), config.getCollisionRadius(first)) - config.getCollisionRadius(*this));
|
|
||||||
// elephant_foot_increases has to be recalculated, as when a smaller tree with a larger elephant_foot_increases merge with a larger branch
|
|
||||||
// the elephant_foot_increases may have to be lower as otherwise the radius suddenly increases. This results often in a non integer value.
|
|
||||||
elephant_foot_increases = foot_increase_radius / (config.branch_radius * (config.diameter_scale_bp_radius - config.diameter_angle_scale_factor));
|
|
||||||
}
|
|
||||||
|
|
||||||
// set last settings to the best out of both parents. If this is wrong, it will only cause a small performance penalty instead of weird behavior.
|
|
||||||
last_area_increase = {
|
|
||||||
std::min(first.last_area_increase.type, second.last_area_increase.type),
|
|
||||||
std::min(first.last_area_increase.increase_speed, second.last_area_increase.increase_speed),
|
|
||||||
first.last_area_increase.increase_radius || second.last_area_increase.increase_radius,
|
|
||||||
first.last_area_increase.no_error || second.last_area_increase.no_error,
|
|
||||||
first.last_area_increase.use_min_distance && second.last_area_increase.use_min_distance,
|
|
||||||
first.last_area_increase.move || second.last_area_increase.move };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
struct SupportElementID
|
||||||
|
{
|
||||||
/*!
|
/*!
|
||||||
* \brief The layer this support elements wants reach
|
* \brief The layer this support elements wants reach
|
||||||
*/
|
*/
|
||||||
|
@ -227,13 +104,15 @@ public:
|
||||||
* \brief The position this support elements wants to support on layer=target_height
|
* \brief The position this support elements wants to support on layer=target_height
|
||||||
*/
|
*/
|
||||||
Point target_position;
|
Point target_position;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SupportElementState : public SupportElementID
|
||||||
|
{
|
||||||
/*!
|
/*!
|
||||||
* \brief The next position this support elements wants to reach. NOTE: This is mainly a suggestion regarding direction inside the influence area.
|
* \brief The next position this support elements wants to reach. NOTE: This is mainly a suggestion regarding direction inside the influence area.
|
||||||
*/
|
*/
|
||||||
Point next_position;
|
Point next_position;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The next height this support elements wants to reach
|
* \brief The next height this support elements wants to reach
|
||||||
*/
|
*/
|
||||||
|
@ -242,69 +121,34 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* \brief The Effective distance to top of this element regarding radius increases and collision calculations.
|
* \brief The Effective distance to top of this element regarding radius increases and collision calculations.
|
||||||
*/
|
*/
|
||||||
|
uint32_t effective_radius_height;
|
||||||
size_t effective_radius_height;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The element trys to reach the buildplate
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool to_buildplate;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief All elements in the layer above the current one that are supported by this element
|
|
||||||
*/
|
|
||||||
std::vector<SupportElement*> parents;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The amount of layers this element is below the topmost layer of this branch.
|
* \brief The amount of layers this element is below the topmost layer of this branch.
|
||||||
*/
|
*/
|
||||||
size_t distance_to_top;
|
uint32_t distance_to_top;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The resulting influence area.
|
|
||||||
* Will only be set in the results of createLayerPathing, and will be nullptr inside!
|
|
||||||
*/
|
|
||||||
Polygons* area;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The resulting center point around which a circle will be drawn later.
|
* \brief The resulting center point around which a circle will be drawn later.
|
||||||
* Will be set by setPointsOnAreas
|
* Will be set by setPointsOnAreas
|
||||||
*/
|
*/
|
||||||
Point result_on_layer = Point(-1, -1);
|
Point result_on_layer { std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() };
|
||||||
|
bool result_on_layer_is_set() const { return this->result_on_layer != Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
|
||||||
|
void result_on_layer_reset() { this->result_on_layer = Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
|
||||||
/*!
|
/*!
|
||||||
* \brief The amount of extra radius we got from merging branches that could have reached the buildplate, but merged with ones that can not.
|
* \brief The amount of extra radius we got from merging branches that could have reached the buildplate, but merged with ones that can not.
|
||||||
*/
|
*/
|
||||||
coord_t increased_to_model_radius; // how much to model we increased only relevant for merging
|
coord_t increased_to_model_radius; // how much to model we increased only relevant for merging
|
||||||
/*!
|
|
||||||
* \brief Will the branch be able to rest completely on a flat surface, be it buildplate or model ?
|
|
||||||
*/
|
|
||||||
bool to_model_gracious;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Counter about the times the elephant foot was increased. Can be fractions for merge reasons.
|
* \brief Counter about the times the elephant foot was increased. Can be fractions for merge reasons.
|
||||||
*/
|
*/
|
||||||
double elephant_foot_increases;
|
double elephant_foot_increases;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Whether the min_xy_distance can be used to get avoidance or similar. Will only be true if support_xy_overrides_z=Z overrides X/Y.
|
|
||||||
*/
|
|
||||||
bool use_min_xy_dist;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief True if this Element or any parent provides support to a support roof.
|
|
||||||
*/
|
|
||||||
bool supports_roof;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The element trys not to move until this dtt is reached, is set to 0 if the element had to move.
|
* \brief The element trys not to move until this dtt is reached, is set to 0 if the element had to move.
|
||||||
*/
|
*/
|
||||||
size_t dont_move_until;
|
uint32_t dont_move_until;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief An influence area is considered safe when it can use the holefree avoidance <=> It will not have to encounter holes on its way downward.
|
|
||||||
*/
|
|
||||||
bool can_use_safe_radius;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Settings used to increase the influence area to its current state.
|
* \brief Settings used to increase the influence area to its current state.
|
||||||
|
@ -314,47 +158,76 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Amount of roof layers that were not yet added, because the branch needed to move.
|
* \brief Amount of roof layers that were not yet added, because the branch needed to move.
|
||||||
*/
|
*/
|
||||||
size_t missing_roof_layers;
|
uint32_t missing_roof_layers;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The element trys to reach the buildplate
|
||||||
|
*/
|
||||||
|
bool to_buildplate : 1;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Will the branch be able to rest completely on a flat surface, be it buildplate or model ?
|
||||||
|
*/
|
||||||
|
bool to_model_gracious : 1;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Whether the min_xy_distance can be used to get avoidance or similar. Will only be true if support_xy_overrides_z=Z overrides X/Y.
|
||||||
|
*/
|
||||||
|
bool use_min_xy_dist : 1;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief True if this Element or any parent provides support to a support roof.
|
||||||
|
*/
|
||||||
|
bool supports_roof : 1;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief An influence area is considered safe when it can use the holefree avoidance <=> It will not have to encounter holes on its way downward.
|
||||||
|
*/
|
||||||
|
bool can_use_safe_radius : 1;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Skip the ovalisation to parent and children when generating the final circles.
|
* \brief Skip the ovalisation to parent and children when generating the final circles.
|
||||||
*/
|
*/
|
||||||
bool skip_ovalisation;
|
bool skip_ovalisation : 1;
|
||||||
|
|
||||||
bool operator==(const SupportElement& other) const
|
// called by increase_single_area() and increaseAreas()
|
||||||
|
[[nodiscard]] static SupportElementState propagate_down(const SupportElementState &src)
|
||||||
{
|
{
|
||||||
return target_position == other.target_position && target_height == other.target_height;
|
SupportElementState dst{ src };
|
||||||
|
++ dst.distance_to_top;
|
||||||
|
// set to invalid as we are a new node on a new layer
|
||||||
|
dst.result_on_layer_reset();
|
||||||
|
dst.skip_ovalisation = false;
|
||||||
|
return dst;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool operator<(const SupportElement& other) const // true if me < other
|
struct SupportElement
|
||||||
{
|
{
|
||||||
return !(*this == other) && !(*this > other);
|
// SupportElement(const SupportElementState &state) : SupportElementState(state) {}
|
||||||
}
|
SupportElement(const SupportElementState &state, Polygons &&influence_area) : state(state), influence_area(std::move(influence_area)) {}
|
||||||
bool operator>(const SupportElement& other) const
|
SupportElement(const SupportElementState &state, boost::container::small_vector<SupportElement*, 4> &&parents, Polygons &&influence_area) :
|
||||||
{
|
state(state), parents(std::move(parents)), influence_area(std::move(influence_area)) {}
|
||||||
// Doesn't really have to make sense, only required for ordering in maps to ensure deterministic behavior.
|
|
||||||
if (*this == other)
|
|
||||||
return false;
|
|
||||||
if (other.target_height != target_height)
|
|
||||||
return other.target_height < target_height;
|
|
||||||
return other.target_position.x() == target_position.x() ? other.target_position.y() < target_position.y() : other.target_position.x() < target_position.x();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddParents(const std::vector<SupportElement*>& adding)
|
SupportElementState state;
|
||||||
{
|
/*!
|
||||||
for (SupportElement* ptr : adding)
|
* \brief All elements in the layer above the current one that are supported by this element
|
||||||
{
|
*/
|
||||||
parents.emplace_back(ptr);
|
boost::container::small_vector<SupportElement*, 4> parents;
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
* \brief The resulting influence area.
|
||||||
|
* Will only be set in the results of createLayerPathing, and will be nullptr inside!
|
||||||
|
*/
|
||||||
|
Polygons influence_area;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
* \brief This struct contains settings used in the tree support. Thanks to this most functions do not need to know of meshes etc. Also makes the code shorter.
|
* \brief This struct contains settings used in the tree support. Thanks to this most functions do not need to know of meshes etc. Also makes the code shorter.
|
||||||
*/
|
*/
|
||||||
struct TreeSupportSettings
|
struct TreeSupportSettings
|
||||||
{
|
{
|
||||||
TreeSupportSettings() = default; // required for the definition of the config variable in the TreeSupport class.
|
TreeSupportSettings() = default; // required for the definition of the config variable in the TreeSupportGenerator class.
|
||||||
|
|
||||||
explicit TreeSupportSettings(const TreeSupportMeshGroupSettings& mesh_group_settings)
|
explicit TreeSupportSettings(const TreeSupportMeshGroupSettings& mesh_group_settings)
|
||||||
: angle(mesh_group_settings.support_tree_angle),
|
: angle(mesh_group_settings.support_tree_angle),
|
||||||
|
@ -397,7 +270,7 @@ public:
|
||||||
{
|
{
|
||||||
layer_start_bp_radius = (bp_radius - branch_radius) / (branch_radius * diameter_scale_bp_radius);
|
layer_start_bp_radius = (bp_radius - branch_radius) / (branch_radius * diameter_scale_bp_radius);
|
||||||
|
|
||||||
if (TreeSupport::TreeSupportSettings::soluble) {
|
if (TreeSupportSettings::soluble) {
|
||||||
// safeOffsetInc can only work in steps of the size xy_min_distance in the worst case => xy_min_distance has to be a bit larger than 0 in this worst case and should be large enough for performance to not suffer extremely
|
// safeOffsetInc can only work in steps of the size xy_min_distance in the worst case => xy_min_distance has to be a bit larger than 0 in this worst case and should be large enough for performance to not suffer extremely
|
||||||
// When for all meshes the z bottom and top distance is more than one layer though the worst case is xy_min_distance + min_feature_size
|
// When for all meshes the z bottom and top distance is more than one layer though the worst case is xy_min_distance + min_feature_size
|
||||||
// This is not the best solution, but the only one to ensure areas can not lag though walls at high maximum_move_distance.
|
// This is not the best solution, but the only one to ensure areas can not lag though walls at high maximum_move_distance.
|
||||||
|
@ -406,19 +279,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// const std::unordered_map<std::string, InterfacePreference> interface_map = { { "support_area_overwrite_interface_area", InterfacePreference::SUPPORT_AREA_OVERWRITES_INTERFACE }, { "interface_area_overwrite_support_area", InterfacePreference::INTERFACE_AREA_OVERWRITES_SUPPORT }, { "support_lines_overwrite_interface_area", InterfacePreference::SUPPORT_LINES_OVERWRITE_INTERFACE }, { "interface_lines_overwrite_support_area", InterfacePreference::INTERFACE_LINES_OVERWRITE_SUPPORT }, { "nothing", InterfacePreference::NOTHING } };
|
// const std::unordered_map<std::string, InterfacePreference> interface_map = { { "support_area_overwrite_interface_area", InterfacePreference::SupportAreaOverwritesInterface }, { "interface_area_overwrite_support_area", InterfacePreference::InterfaceAreaOverwritesSupport }, { "support_lines_overwrite_interface_area", InterfacePreference::SupportLinesOverwriteInterface }, { "interface_lines_overwrite_support_area", InterfacePreference::InterfaceLinesOverwriteSupport }, { "nothing", InterfacePreference::Nothing } };
|
||||||
// interface_preference = interface_map.at(mesh_group_settings.get<std::string>("support_interface_priority"));
|
// interface_preference = interface_map.at(mesh_group_settings.get<std::string>("support_interface_priority"));
|
||||||
//FIXME this was the default
|
//FIXME this was the default
|
||||||
// interface_preference = InterfacePreference::SUPPORT_LINES_OVERWRITE_INTERFACE;
|
// interface_preference = InterfacePreference::SupportLinesOverwriteInterface;
|
||||||
interface_preference = InterfacePreference::SUPPORT_AREA_OVERWRITES_INTERFACE;
|
interface_preference = InterfacePreference::SupportAreaOverwritesInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double angle;
|
double angle;
|
||||||
double angle_slow;
|
double angle_slow;
|
||||||
std::vector<coord_t> known_z;
|
std::vector<coord_t> known_z;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// some static variables dependent on other meshes that are not currently processed.
|
// some static variables dependent on other meshes that are not currently processed.
|
||||||
// Has to be static because TreeSupportConfig will be used in TreeModelVolumes as this reduces redundancy.
|
// Has to be static because TreeSupportConfig will be used in TreeModelVolumes as this reduces redundancy.
|
||||||
inline static bool soluble = false;
|
inline static bool soluble = false;
|
||||||
|
@ -580,7 +453,7 @@ public:
|
||||||
&& min_feature_size == other.min_feature_size // interface_preference should be identical to ensure the tree will correctly interact with the roof.
|
&& min_feature_size == other.min_feature_size // interface_preference should be identical to ensure the tree will correctly interact with the roof.
|
||||||
// The infill class now wants the settings object and reads a lot of settings, and as the infill class is used to calculate support roof lines for interface-preference. Not all of these may be required to be identical, but as I am not sure, better safe than sorry
|
// The infill class now wants the settings object and reads a lot of settings, and as the infill class is used to calculate support roof lines for interface-preference. Not all of these may be required to be identical, but as I am not sure, better safe than sorry
|
||||||
#if 0
|
#if 0
|
||||||
&& (interface_preference == InterfacePreference::INTERFACE_AREA_OVERWRITES_SUPPORT || interface_preference == InterfacePreference::SUPPORT_AREA_OVERWRITES_INTERFACE
|
&& (interface_preference == InterfacePreference::InterfaceAreaOverwritesSupport || interface_preference == InterfacePreference::SupportAreaOverwritesInterface
|
||||||
// Perimeter generator parameters
|
// Perimeter generator parameters
|
||||||
||
|
||
|
||||||
(settings.get<bool>("fill_outline_gaps") == other.settings.get<bool>("fill_outline_gaps") &&
|
(settings.get<bool>("fill_outline_gaps") == other.settings.get<bool>("fill_outline_gaps") &&
|
||||||
|
@ -599,13 +472,12 @@ public:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get the Distance to top regarding the real radius this part will have. This is different from distance_to_top, which is can be used to calculate the top most layer of the branch.
|
* \brief Get the Distance to top regarding the real radius this part will have. This is different from distance_to_top, which is can be used to calculate the top most layer of the branch.
|
||||||
* \param elem[in] The SupportElement one wants to know the effectiveDTT
|
* \param elem[in] The SupportElement one wants to know the effectiveDTT
|
||||||
* \return The Effective DTT.
|
* \return The Effective DTT.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] inline size_t getEffectiveDTT(const TreeSupport::SupportElement& elem) const
|
[[nodiscard]] inline size_t getEffectiveDTT(const SupportElementState &elem) const
|
||||||
{
|
{
|
||||||
return elem.effective_radius_height < increase_radius_until_layer ? (elem.distance_to_top < increase_radius_until_layer ? elem.distance_to_top : increase_radius_until_layer) : elem.effective_radius_height;
|
return elem.effective_radius_height < increase_radius_until_layer ? (elem.distance_to_top < increase_radius_until_layer ? elem.distance_to_top : increase_radius_until_layer) : elem.effective_radius_height;
|
||||||
}
|
}
|
||||||
|
@ -630,17 +502,17 @@ public:
|
||||||
* \param elem[in] The Element.
|
* \param elem[in] The Element.
|
||||||
* \return The radius the element has.
|
* \return The radius the element has.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] inline coord_t getRadius(const TreeSupport::SupportElement& elem) const
|
[[nodiscard]] inline coord_t getRadius(const SupportElementState &elem) const
|
||||||
{
|
{ return getRadius(getEffectiveDTT(elem), elem.elephant_foot_increases); }
|
||||||
return getRadius(getEffectiveDTT(elem), elem.elephant_foot_increases);
|
[[nodiscard]] inline coord_t getRadius(const SupportElement &elem) const
|
||||||
}
|
{ return this->getRadius(elem.state); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get the collision Radius of this Element. This can be smaller then the actual radius, as the drawAreas will cut off areas that may collide with the model.
|
* \brief Get the collision Radius of this Element. This can be smaller then the actual radius, as the drawAreas will cut off areas that may collide with the model.
|
||||||
* \param elem[in] The Element.
|
* \param elem[in] The Element.
|
||||||
* \return The collision radius the element has.
|
* \return The collision radius the element has.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] inline coord_t getCollisionRadius(const TreeSupport::SupportElement& elem) const
|
[[nodiscard]] inline coord_t getCollisionRadius(const SupportElementState &elem) const
|
||||||
{
|
{
|
||||||
return getRadius(elem.effective_radius_height, elem.elephant_foot_increases);
|
return getRadius(elem.effective_radius_height, elem.elephant_foot_increases);
|
||||||
}
|
}
|
||||||
|
@ -675,202 +547,15 @@ public:
|
||||||
{
|
{
|
||||||
known_z = z;
|
known_z = z;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
/*!
|
|
||||||
* \brief Creates the initial influence areas (that can later be propagated down) by placing them below the overhang.
|
|
||||||
*
|
|
||||||
* Generates Points where the Model should be supported and creates the areas where these points have to be placed.
|
|
||||||
*
|
|
||||||
* \param mesh[in] The mesh that is currently processed.
|
|
||||||
* \param move_bounds[out] Storage for the influence areas.
|
|
||||||
* \param storage[in] Background storage, required for adding roofs.
|
|
||||||
*/
|
|
||||||
void generateInitialAreas(const PrintObject &print_object,
|
|
||||||
const std::vector<Polygons> &overhangs,
|
|
||||||
std::vector<std::set<SupportElement*>> &move_bounds,
|
|
||||||
SupportGeneratorLayersPtr &top_contacts,
|
|
||||||
SupportGeneratorLayersPtr &top_interface_layers,
|
|
||||||
SupportGeneratorLayerStorage &layer_storage);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Checks if an influence area contains a valid subsection and returns the corresponding metadata and the new Influence area.
|
|
||||||
*
|
|
||||||
* Calculates an influence areas of the layer below, based on the influence area of one element on the current layer.
|
|
||||||
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in we would change our gracious or to_buildplate status the influence areas are instead increased by maximum_move_distance_slow.
|
|
||||||
* Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this were the case, the radius is not increased instead.
|
|
||||||
*
|
|
||||||
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was done to avoid not needed heap allocations.
|
|
||||||
*
|
|
||||||
* \param settings[in] Which settings have to be used to check validity.
|
|
||||||
* \param layer_idx[in] Number of the current layer.
|
|
||||||
* \param parent[in] The metadata of the parents influence area.
|
|
||||||
* \param relevant_offset[in] The maximal possible influence area. No guarantee regarding validity with current layer collision required, as it is ensured in-function!
|
|
||||||
* \param to_bp_data[out] The part of the Influence area that can reach the buildplate.
|
|
||||||
* \param to_model_data[out] The part of the Influence area that do not have to reach the buildplate. This has overlap with new_layer_data.
|
|
||||||
* \param increased[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the user-supplied settings.
|
|
||||||
* \param overspeed[in] How much should the already offset area be offset again. Usually this is 0.
|
|
||||||
* \param mergelayer[in] Will the merge method be called on this layer. This information is required as some calculation can be avoided if they are not required for merging.
|
|
||||||
* \return A valid support element for the next layer regarding the calculated influence areas. Empty if no influence are can be created using the supplied influence area and settings.
|
|
||||||
*/
|
|
||||||
std::optional<TreeSupport::SupportElement> increaseSingleArea(AreaIncreaseSettings settings, LayerIndex layer_idx, SupportElement* parent, const Polygons& relevant_offset, Polygons& to_bp_data, Polygons& to_model_data, Polygons& increased, const coord_t overspeed, const bool mergelayer);
|
|
||||||
/*!
|
|
||||||
* \brief Increases influence areas as far as required.
|
|
||||||
*
|
|
||||||
* Calculates influence areas of the layer below, based on the influence areas of the current layer.
|
|
||||||
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in it would change the gracious or to_buildplate status, the influence areas are instead increased by maximum_move_distance.
|
|
||||||
* Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this were the case, the radius is not increased instead.
|
|
||||||
*
|
|
||||||
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was done to avoid not needed heap allocations.
|
|
||||||
*
|
|
||||||
* \param to_bp_areas[out] Influence areas that can reach the buildplate
|
|
||||||
* \param to_model_areas[out] Influence areas that do not have to reach the buildplate. This has overlap with new_layer_data, as areas that can reach the buildplate are also considered valid areas to the model.
|
|
||||||
* This redundancy is required if a to_buildplate influence area is allowed to merge with a to model influence area.
|
|
||||||
* \param influence_areas[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the user-supplied settings.
|
|
||||||
* \param bypass_merge_areas[out] Influence areas ready to be added to the layer below that do not need merging.
|
|
||||||
* \param last_layer[in] Influence areas of the current layer.
|
|
||||||
* \param layer_idx[in] Number of the current layer.
|
|
||||||
* \param mergelayer[in] Will the merge method be called on this layer. This information is required as some calculation can be avoided if they are not required for merging.
|
|
||||||
*/
|
|
||||||
void increaseAreas(std::unordered_map<SupportElement, Polygons>& to_bp_areas, std::unordered_map<SupportElement, Polygons>& to_model_areas, std::map<SupportElement, Polygons>& influence_areas, std::vector<SupportElement*>& bypass_merge_areas, const std::vector<SupportElement*>& last_layer, const LayerIndex layer_idx, const bool mergelayer);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Propagates influence downwards, and merges overlapping ones.
|
|
||||||
*
|
|
||||||
* \param move_bounds[in,out] All currently existing influence areas
|
|
||||||
*/
|
|
||||||
void createLayerPathing(std::vector<std::set<SupportElement*>>& move_bounds);
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Sets the result_on_layer for all parents based on the SupportElement supplied.
|
|
||||||
*
|
|
||||||
* \param elem[in] The SupportElements, which parent's position should be determined.
|
|
||||||
*/
|
|
||||||
void setPointsOnAreas(const SupportElement* elem);
|
|
||||||
/*!
|
|
||||||
* \brief Get the best point to connect to the model and set the result_on_layer of the relevant SupportElement accordingly.
|
|
||||||
*
|
|
||||||
* \param move_bounds[in,out] All currently existing influence areas
|
|
||||||
* \param first_elem[in,out] SupportElement that did not have its result_on_layer set meaning that it does not have a child element.
|
|
||||||
* \param layer_idx[in] The current layer.
|
|
||||||
* \return Should elem be deleted.
|
|
||||||
*/
|
|
||||||
bool setToModelContact(std::vector<std::set<SupportElement*>>& move_bounds, SupportElement* first_elem, const LayerIndex layer_idx);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Set the result_on_layer point for all influence areas
|
|
||||||
*
|
|
||||||
* \param move_bounds[in,out] All currently existing influence areas
|
|
||||||
*/
|
|
||||||
void createNodesFromArea(std::vector<std::set<SupportElement*>>& move_bounds);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Draws circles around result_on_layer points of the influence areas
|
|
||||||
*
|
|
||||||
* \param linear_data[in] All currently existing influence areas with the layer they are on
|
|
||||||
* \param layer_tree_polygons[out] Resulting branch areas with the layerindex they appear on. layer_tree_polygons.size() has to be at least linear_data.size() as each Influence area in linear_data will save have at least one (that's why it's a vector<vector>) corresponding branch area in layer_tree_polygons.
|
|
||||||
* \param inverse_tree_order[in] A mapping that returns the child of every influence area.
|
|
||||||
*/
|
|
||||||
void generateBranchAreas(std::vector<std::pair<LayerIndex, SupportElement*>>& linear_data, std::vector<std::unordered_map<SupportElement*, Polygons>>& layer_tree_polygons, const std::map<SupportElement*, SupportElement*>& inverse_tree_order);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Applies some smoothing to the outer wall, intended to smooth out sudden jumps as they can happen when a branch moves though a hole.
|
|
||||||
*
|
|
||||||
* \param layer_tree_polygons[in,out] Resulting branch areas with the layerindex they appear on.
|
|
||||||
*/
|
|
||||||
void smoothBranchAreas(std::vector<std::unordered_map<SupportElement*, Polygons>>& layer_tree_polygons);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Drop down areas that do rest non-gracefully on the model to ensure the branch actually rests on something.
|
|
||||||
*
|
|
||||||
* \param layer_tree_polygons[in] Resulting branch areas with the layerindex they appear on.
|
|
||||||
* \param linear_data[in] All currently existing influence areas with the layer they are on
|
|
||||||
* \param dropped_down_areas[out] Areas that have to be added to support all non-graceful areas.
|
|
||||||
* \param inverse_tree_order[in] A mapping that returns the child of every influence area.
|
|
||||||
*/
|
|
||||||
void dropNonGraciousAreas(std::vector<std::unordered_map<SupportElement*, Polygons>>& layer_tree_polygons, const std::vector<std::pair<LayerIndex, SupportElement*>>& linear_data, std::vector<std::vector<std::pair<LayerIndex, Polygons>>>& dropped_down_areas, const std::map<SupportElement*, SupportElement*>& inverse_tree_order);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Generates Support Floor, ensures Support Roof can not cut of branches, and saves the branches as support to storage
|
|
||||||
*
|
|
||||||
* \param support_layer_storage[in] Areas where support should be generated.
|
|
||||||
* \param support_roof_storage[in] Areas where support was replaced with roof.
|
|
||||||
* \param storage[in,out] The storage where the support should be stored.
|
|
||||||
*/
|
|
||||||
void finalizeInterfaceAndSupportAreas(
|
|
||||||
const PrintObject &print_object,
|
|
||||||
const std::vector<Polygons> &overhangs,
|
|
||||||
std::vector<Polygons> &support_layer_storage,
|
|
||||||
std::vector<Polygons> &support_roof_storage,
|
|
||||||
|
|
||||||
SupportGeneratorLayersPtr &bottom_contacts,
|
|
||||||
SupportGeneratorLayersPtr &top_contacts,
|
|
||||||
SupportGeneratorLayersPtr &intermediate_layers,
|
|
||||||
SupportGeneratorLayerStorage &layer_storage);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Draws circles around result_on_layer points of the influence areas and applies some post processing.
|
|
||||||
*
|
|
||||||
* \param move_bounds[in] All currently existing influence areas
|
|
||||||
* \param storage[in,out] The storage where the support should be stored.
|
|
||||||
*/
|
|
||||||
void drawAreas(
|
|
||||||
PrintObject &print_object,
|
|
||||||
const std::vector<Polygons> &overhangs,
|
|
||||||
std::vector<std::set<SupportElement*>> &move_bounds,
|
|
||||||
|
|
||||||
SupportGeneratorLayersPtr &bottom_contacts,
|
|
||||||
SupportGeneratorLayersPtr &top_contacts,
|
|
||||||
SupportGeneratorLayersPtr &intermediate_layers,
|
|
||||||
SupportGeneratorLayerStorage &layer_storage);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Settings with the indexes of meshes that use these settings.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
std::vector<std::pair<TreeSupportSettings, std::vector<size_t>>> m_grouped_meshes;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Generator for model collision, avoidance and internal guide volumes.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
TreeModelVolumes m_volumes;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Contains config settings to avoid loading them in every function. This was done to improve readability of the code.
|
|
||||||
*/
|
|
||||||
TreeSupportSettings m_config;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The progress multiplier of all values added progress bar.
|
|
||||||
* Required for the progress bar the behave as expected when areas have to be calculated multiple times
|
|
||||||
*/
|
|
||||||
double m_progress_multiplier = 1;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The progress offset added to all values communicated to the progress bar.
|
|
||||||
* Required for the progress bar the behave as expected when areas have to be calculated multiple times
|
|
||||||
*/
|
|
||||||
double m_progress_offset = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// todo Remove! ONLY FOR PUBLIC BETA!!
|
||||||
|
void tree_supports_show_error(std::string message, bool critical);
|
||||||
|
|
||||||
|
} // namespace FFFTreeSupport
|
||||||
|
|
||||||
|
void fff_tree_support_generate(PrintObject &print_object, std::function<void()> throw_on_cancel = []{});
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
template <>
|
|
||||||
struct hash<Slic3r::TreeSupport::SupportElement>
|
|
||||||
{
|
|
||||||
size_t operator()(const Slic3r::TreeSupport::SupportElement& node) const
|
|
||||||
{
|
|
||||||
size_t hash_node = Slic3r::PointHash{}(node.target_position);
|
|
||||||
boost::hash_combine(hash_node, size_t(node.target_height));
|
|
||||||
return hash_node;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif /* slic3r_TreeSupport_hpp */
|
#endif /* slic3r_TreeSupport_hpp */
|
||||||
|
|
|
@ -378,6 +378,14 @@ bool TriangleMesh::is_splittable() const
|
||||||
return its_is_splittable(this->its);
|
return its_is_splittable(this->its);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TriangleMesh::has_zero_volume() const
|
||||||
|
{
|
||||||
|
const Vec3d sz = size();
|
||||||
|
const double volume_val = sz.x() * sz.y() * sz.z();
|
||||||
|
|
||||||
|
return is_approx(volume_val, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<TriangleMesh> TriangleMesh::split() const
|
std::vector<TriangleMesh> TriangleMesh::split() const
|
||||||
{
|
{
|
||||||
std::vector<indexed_triangle_set> itss = its_split(this->its);
|
std::vector<indexed_triangle_set> itss = its_split(this->its);
|
||||||
|
|
|
@ -139,6 +139,7 @@ public:
|
||||||
bool empty() const { return this->facets_count() == 0; }
|
bool empty() const { return this->facets_count() == 0; }
|
||||||
bool repaired() const;
|
bool repaired() const;
|
||||||
bool is_splittable() const;
|
bool is_splittable() const;
|
||||||
|
bool has_zero_volume() const;
|
||||||
// Estimate of the memory occupied by this structure, important for keeping an eye on the Undo / Redo stack allocation.
|
// Estimate of the memory occupied by this structure, important for keeping an eye on the Undo / Redo stack allocation.
|
||||||
size_t memsize() const;
|
size_t memsize() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue