Refactoring of FDM support generator:
1) If "support on build plate only" is enabled, the support columns are newly trimmed to not land on top of an object. However this may make the column too small to be stable. 2) Support enforcers newly take precedence over "supports on build plate only" and over "don't support bridges". 3) Some refactoring of the support generator code for clarity: Reduced some of the worst spagetti offenders. Fixes Support generated even if support on build only activated #915 Fixes Bug: supports on build plate only #1340 Fixes Bottom interface layer is not generated , support on build plate only. (long open defect) #4199 Fixes option "supports on build plate only" does not work #3980 Fixes No support interface layers generated #1997 Fixes Feature Request: Option to combine results of 'support from build plate only' and 'support enforcers only' #2801 Fixes Support interface isn't generated: build plate only + blocked by model + support enforcer #3831 Fixes Support Enforcer don't create interface layers #5748 Fixes Support Enforcers Don't Have Top Loops/Raft #1870 Fixes Don't cancel support enforcers with "don't support bridges" #5105
This commit is contained in:
parent
4602f40813
commit
9f09f03228
5 changed files with 1024 additions and 803 deletions
|
@ -373,7 +373,7 @@ private:
|
|||
void print_machine_envelope(FILE *file, Print &print);
|
||||
void _print_first_layer_bed_temperature(FILE *file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
void _print_first_layer_extruder_temperatures(FILE *file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
// this flag triggers first layer speeds
|
||||
// On the first printing layer. This flag triggers first layer speeds.
|
||||
bool on_first_layer() const { return m_layer != nullptr && m_layer->id() == 0; }
|
||||
|
||||
friend ObjectByExtruder& object_by_extruder(
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef std::vector<LayerRegion*> LayerRegionPtrs;
|
|||
class Layer
|
||||
{
|
||||
public:
|
||||
// Sequential index of this layer in PrintObject::m_layers, offsetted by the number of raft layers.
|
||||
size_t id() const { return m_id; }
|
||||
void set_id(size_t id) { m_id = id; }
|
||||
PrintObject* object() { return m_object; }
|
||||
|
@ -115,7 +116,7 @@ public:
|
|||
|
||||
// Collection of expolygons generated by slicing the possibly multiple meshes of the source geometry
|
||||
// (with possibly differing extruder ID and slicing parameters) and merged.
|
||||
// For the first layer, if the ELephant foot compensation is applied, this lslice is uncompensated, therefore
|
||||
// For the first layer, if the Elephant foot compensation is applied, this lslice is uncompensated, therefore
|
||||
// it includes the Elephant foot effect, thus it corresponds to the shape of the printed 1st layer.
|
||||
// These lslices aka islands are chained by the shortest traverse distance and this traversal
|
||||
// order will be applied by the G-code generator to the extrusions fitting into these lslices.
|
||||
|
@ -170,7 +171,7 @@ protected:
|
|||
virtual ~Layer();
|
||||
|
||||
private:
|
||||
// sequential number of layer, 0-based
|
||||
// Sequential index of layer, 0-based, offsetted by number of raft layers.
|
||||
size_t m_id;
|
||||
PrintObject *m_object;
|
||||
LayerRegionPtrs m_regions;
|
||||
|
|
|
@ -74,6 +74,7 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollec
|
|||
const PrintRegionConfig ®ion_config = this->region()->config();
|
||||
// This needs to be in sync with PrintObject::_slice() slicing_mode_normal_below_layer!
|
||||
bool spiral_vase = print_config.spiral_vase &&
|
||||
//FIXME account for raft layers.
|
||||
(this->layer()->id() >= size_t(region_config.bottom_solid_layers.value) &&
|
||||
this->layer()->print_z >= region_config.bottom_solid_min_thickness - EPSILON);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,39 +48,8 @@ public:
|
|||
class MyLayer
|
||||
{
|
||||
public:
|
||||
MyLayer() :
|
||||
layer_type(sltUnknown),
|
||||
print_z(0.),
|
||||
bottom_z(0.),
|
||||
height(0.),
|
||||
idx_object_layer_above(size_t(-1)),
|
||||
idx_object_layer_below(size_t(-1)),
|
||||
bridging(false),
|
||||
contact_polygons(nullptr),
|
||||
overhang_polygons(nullptr)
|
||||
{}
|
||||
|
||||
~MyLayer()
|
||||
{
|
||||
delete contact_polygons;
|
||||
contact_polygons = nullptr;
|
||||
delete overhang_polygons;
|
||||
overhang_polygons = nullptr;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
layer_type = sltUnknown;
|
||||
print_z = 0.;
|
||||
bottom_z = 0.;
|
||||
height = 0.;
|
||||
idx_object_layer_above = size_t(-1);
|
||||
idx_object_layer_below = size_t(-1);
|
||||
bridging = false;
|
||||
polygons.clear();
|
||||
delete contact_polygons;
|
||||
contact_polygons = nullptr;
|
||||
delete overhang_polygons;
|
||||
overhang_polygons = nullptr;
|
||||
*this = MyLayer();
|
||||
}
|
||||
|
||||
bool operator==(const MyLayer &layer2) const {
|
||||
|
@ -103,6 +72,21 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void merge(MyLayer &&rhs) {
|
||||
// The union_() does not support move semantic yet, but maybe one day it will.
|
||||
this->polygons = union_(this->polygons, std::move(rhs.polygons));
|
||||
auto merge = [](std::unique_ptr<Polygons> &dst, std::unique_ptr<Polygons> &src) {
|
||||
if (! dst || dst->empty())
|
||||
dst = std::move(src);
|
||||
else if (src && ! src->empty())
|
||||
*dst = union_(*dst, std::move(*src));
|
||||
};
|
||||
merge(this->contact_polygons, rhs.contact_polygons);
|
||||
merge(this->overhang_polygons, rhs.overhang_polygons);
|
||||
merge(this->enforcer_polygons, rhs.enforcer_polygons);
|
||||
rhs.reset();
|
||||
}
|
||||
|
||||
// For the bridging flow, bottom_print_z will be above bottom_z to account for the vertical separation.
|
||||
// For the non-bridging flow, bottom_print_z will be equal to bottom_z.
|
||||
coordf_t bottom_print_z() const { return print_z - height; }
|
||||
|
@ -110,29 +94,44 @@ public:
|
|||
// To sort the extremes of top / bottom interface layers.
|
||||
coordf_t extreme_z() const { return (this->layer_type == sltTopContact) ? this->bottom_z : this->print_z; }
|
||||
|
||||
SupporLayerType layer_type;
|
||||
SupporLayerType layer_type { sltUnknown };
|
||||
// Z used for printing, in unscaled coordinates.
|
||||
coordf_t print_z;
|
||||
coordf_t print_z { 0 };
|
||||
// Bottom Z of this layer. For soluble layers, bottom_z + height = print_z,
|
||||
// otherwise bottom_z + gap + height = print_z.
|
||||
coordf_t bottom_z;
|
||||
coordf_t bottom_z { 0 };
|
||||
// Layer height in unscaled coordinates.
|
||||
coordf_t height;
|
||||
coordf_t height { 0 };
|
||||
// Index of a PrintObject layer_id supported by this layer. This will be set for top contact layers.
|
||||
// If this is not a contact layer, it will be set to size_t(-1).
|
||||
size_t idx_object_layer_above;
|
||||
size_t idx_object_layer_above { size_t(-1) };
|
||||
// Index of a PrintObject layer_id, which supports this layer. This will be set for bottom contact layers.
|
||||
// If this is not a contact layer, it will be set to size_t(-1).
|
||||
size_t idx_object_layer_below;
|
||||
size_t idx_object_layer_below { size_t(-1) };
|
||||
// Use a bridging flow when printing this support layer.
|
||||
bool bridging;
|
||||
bool bridging { false };
|
||||
|
||||
// Polygons to be filled by the support pattern.
|
||||
Polygons polygons;
|
||||
// Currently for the contact layers only.
|
||||
// MyLayer owns the contact_polygons and overhang_polygons, they are freed by the destructor.
|
||||
Polygons *contact_polygons;
|
||||
Polygons *overhang_polygons;
|
||||
std::unique_ptr<Polygons> contact_polygons;
|
||||
std::unique_ptr<Polygons> overhang_polygons;
|
||||
// Enforcers need to be propagated independently in case the "support on build plate only" option is enabled.
|
||||
std::unique_ptr<Polygons> enforcer_polygons;
|
||||
};
|
||||
|
||||
struct SupportParams {
|
||||
Flow first_layer_flow;
|
||||
Flow support_material_flow;
|
||||
Flow support_material_interface_flow;
|
||||
Flow support_material_bottom_interface_flow;
|
||||
// Is merging of regions allowed? Could the interface & base support regions be printed with the same extruder?
|
||||
bool can_merge_support_regions;
|
||||
|
||||
coordf_t support_layer_height_min;
|
||||
// coordf_t support_layer_height_max;
|
||||
|
||||
coordf_t gap_xy;
|
||||
};
|
||||
|
||||
// Layers are allocated and owned by a deque. Once a layer is allocated, it is maintained
|
||||
|
@ -159,17 +158,19 @@ public:
|
|||
void generate(PrintObject &object);
|
||||
|
||||
private:
|
||||
std::vector<Polygons> buildplate_covered(const PrintObject &object) const;
|
||||
|
||||
// Generate top contact layers supporting overhangs.
|
||||
// For a soluble interface material synchronize the layer heights with the object, otherwise leave the layer height undefined.
|
||||
// If supports over bed surface only are requested, don't generate contact layers over an object.
|
||||
MyLayersPtr top_contact_layers(const PrintObject &object, MyLayerStorage &layer_storage) const;
|
||||
MyLayersPtr top_contact_layers(const PrintObject &object, const std::vector<Polygons> &buildplate_covered, MyLayerStorage &layer_storage) const;
|
||||
|
||||
// Generate bottom contact layers supporting the top contact layers.
|
||||
// For a soluble interface material synchronize the layer heights with the object,
|
||||
// otherwise set the layer height to a bridging flow of a support interface nozzle.
|
||||
MyLayersPtr bottom_contact_layers_and_layer_support_areas(
|
||||
const PrintObject &object, const MyLayersPtr &top_contacts, MyLayerStorage &layer_storage,
|
||||
std::vector<Polygons> &layer_support_areas) const;
|
||||
const PrintObject &object, const MyLayersPtr &top_contacts, std::vector<Polygons> &buildplate_covered,
|
||||
MyLayerStorage &layer_storage, std::vector<Polygons> &layer_support_areas) const;
|
||||
|
||||
// Trim the top_contacts layers with the bottom_contacts layers if they overlap, so there would not be enough vertical space for both of them.
|
||||
void trim_top_contacts_by_bottom_contacts(const PrintObject &object, const MyLayersPtr &bottom_contacts, MyLayersPtr &top_contacts) const;
|
||||
|
@ -240,18 +241,8 @@ private:
|
|||
// Pre-calculated parameters shared between the object slicer and the support generator,
|
||||
// carrying information on a raft, 1st layer height, 1st object layer height, gap between the raft and object etc.
|
||||
SlicingParameters m_slicing_params;
|
||||
|
||||
Flow m_first_layer_flow;
|
||||
Flow m_support_material_flow;
|
||||
Flow m_support_material_interface_flow;
|
||||
Flow m_support_material_bottom_interface_flow;
|
||||
// Is merging of regions allowed? Could the interface & base support regions be printed with the same extruder?
|
||||
bool m_can_merge_support_regions;
|
||||
|
||||
coordf_t m_support_layer_height_min;
|
||||
// coordf_t m_support_layer_height_max;
|
||||
|
||||
coordf_t m_gap_xy;
|
||||
// Various precomputed support parameters to be shared with external functions.
|
||||
SupportParams m_support_params;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Reference in a new issue