2014-12-12 18:14:52 +00:00
|
|
|
#ifndef slic3r_SupportMaterial_hpp_
|
|
|
|
#define slic3r_SupportMaterial_hpp_
|
|
|
|
|
2016-10-16 20:11:19 +00:00
|
|
|
#include "Flow.hpp"
|
2016-10-20 15:44:46 +00:00
|
|
|
#include "PrintConfig.hpp"
|
2016-12-20 11:19:13 +00:00
|
|
|
#include "Slicing.hpp"
|
2016-10-16 20:11:19 +00:00
|
|
|
|
2014-12-12 18:14:52 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
2016-10-16 14:30:56 +00:00
|
|
|
class PrintObject;
|
2016-10-16 20:11:19 +00:00
|
|
|
class PrintConfig;
|
|
|
|
class PrintObjectConfig;
|
2016-10-16 14:30:56 +00:00
|
|
|
|
2014-12-12 18:14:52 +00:00
|
|
|
// how much we extend support around the actual contact area
|
2016-10-13 14:00:22 +00:00
|
|
|
#define SUPPORT_MATERIAL_MARGIN 1.5
|
2014-12-12 18:14:52 +00:00
|
|
|
|
2016-10-20 11:04:23 +00:00
|
|
|
// This class manages raft and supports for a single PrintObject.
|
2016-10-13 14:00:22 +00:00
|
|
|
// Instantiated by Slic3r::Print::Object->_support_material()
|
2016-10-20 11:04:23 +00:00
|
|
|
// This class is instantiated before the slicing starts as Object.pm will query
|
|
|
|
// the parameters of the raft to determine the 1st layer height and thickness.
|
|
|
|
class PrintObjectSupportMaterial
|
2016-10-13 14:00:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-01-05 08:14:59 +00:00
|
|
|
// Support layer type to be used by MyLayer. This type carries a much more detailed information
|
|
|
|
// about the support layer type than the final support layers stored in a PrintObject.
|
2016-10-13 14:00:22 +00:00
|
|
|
enum SupporLayerType {
|
|
|
|
sltUnknown = 0,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Ratft base layer, to be printed with the support material.
|
2016-12-20 11:19:13 +00:00
|
|
|
sltRaftBase,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Raft interface layer, to be printed with the support interface material.
|
2016-12-20 11:19:13 +00:00
|
|
|
sltRaftInterface,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Bottom contact layer placed over a top surface of an object. To be printed with a support interface material.
|
2016-10-13 14:00:22 +00:00
|
|
|
sltBottomContact,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Dense interface layer, to be printed with the support interface material.
|
|
|
|
// This layer is separated from an object by an sltBottomContact layer.
|
2016-10-13 14:00:22 +00:00
|
|
|
sltBottomInterface,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Sparse base support layer, to be printed with a support material.
|
2016-10-13 14:00:22 +00:00
|
|
|
sltBase,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Dense interface layer, to be printed with the support interface material.
|
|
|
|
// This layer is separated from an object with sltTopContact layer.
|
2016-10-13 14:00:22 +00:00
|
|
|
sltTopInterface,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Top contact layer directly supporting an overhang. To be printed with a support interface material.
|
2016-10-13 14:00:22 +00:00
|
|
|
sltTopContact,
|
2017-01-05 08:14:59 +00:00
|
|
|
// Some undecided type yet. It will turn into sltBase first, then it may turn into sltBottomInterface or sltTopInterface.
|
2016-10-13 14:00:22 +00:00
|
|
|
stlIntermediate,
|
|
|
|
};
|
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// A support layer type used internally by the SupportMaterial class. This class carries a much more detailed
|
|
|
|
// information about the support layer than the layers stored in the PrintObject, mainly
|
|
|
|
// the MyLayer is aware of the bridging flow and the interface gaps between the object and the support.
|
2016-10-13 14:00:22 +00:00
|
|
|
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)),
|
2016-11-02 09:47:00 +00:00
|
|
|
bridging(false),
|
|
|
|
aux_polygons(NULL)
|
2016-10-13 14:00:22 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
~MyLayer()
|
|
|
|
{
|
|
|
|
delete aux_polygons;
|
|
|
|
aux_polygons = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const MyLayer &layer2) const {
|
2016-10-16 14:30:56 +00:00
|
|
|
return print_z == layer2.print_z && height == layer2.height && bridging == layer2.bridging;
|
2016-10-13 14:00:22 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Order the layers by lexicographically by an increasing print_z and a decreasing layer height.
|
2016-10-13 14:00:22 +00:00
|
|
|
bool operator<(const MyLayer &layer2) const {
|
|
|
|
if (print_z < layer2.print_z) {
|
|
|
|
return true;
|
|
|
|
} else if (print_z == layer2.print_z) {
|
|
|
|
if (height > layer2.height)
|
|
|
|
return true;
|
|
|
|
else if (height == layer2.height) {
|
|
|
|
return bridging < layer2.bridging;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SupporLayerType layer_type;
|
2017-01-05 08:14:59 +00:00
|
|
|
// Z used for printing, in unscaled coordinates.
|
2016-10-13 14:00:22 +00:00
|
|
|
coordf_t print_z;
|
2017-01-05 08:14:59 +00:00
|
|
|
// Bottom Z of this layer. For soluble layers, bottom_z + height = print_z,
|
2016-10-13 14:00:22 +00:00
|
|
|
// otherwise bottom_z + gap + height = print_z.
|
|
|
|
coordf_t bottom_z;
|
2017-01-05 08:14:59 +00:00
|
|
|
// Layer height in unscaled coordinates.
|
2016-10-13 14:00:22 +00:00
|
|
|
coordf_t height;
|
|
|
|
// 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;
|
|
|
|
// 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;
|
|
|
|
// Use a bridging flow when printing this support layer.
|
|
|
|
bool bridging;
|
|
|
|
|
|
|
|
// Polygons to be filled by the support pattern.
|
|
|
|
Polygons polygons;
|
|
|
|
// Currently for the contact layers only: Overhangs are stored here.
|
2017-01-05 08:14:59 +00:00
|
|
|
// MyLayer owns the aux_polygons, they are freed by the destructor.
|
2016-10-13 14:00:22 +00:00
|
|
|
Polygons *aux_polygons;
|
|
|
|
};
|
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Layers are allocated and owned by a deque. Once a layer is allocated, it is maintained
|
|
|
|
// up to the end of a generate() method. The layer storage may be replaced by an allocator class in the future,
|
|
|
|
// which would allocate layers by multiple chunks.
|
2016-10-16 14:30:56 +00:00
|
|
|
typedef std::deque<MyLayer> MyLayerStorage;
|
2017-01-05 08:14:59 +00:00
|
|
|
typedef std::vector<MyLayer*> MyLayersPtr;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
|
|
|
public:
|
2016-12-20 11:19:13 +00:00
|
|
|
PrintObjectSupportMaterial(const PrintObject *object, const SlicingParameters &slicing_params);
|
2016-10-20 11:04:23 +00:00
|
|
|
|
|
|
|
// Height of the 1st layer is user configured as it is important for the print
|
|
|
|
// to stick to he print bed.
|
2016-10-20 15:44:46 +00:00
|
|
|
coordf_t first_layer_height() const { return m_object_config->first_layer_height.value; }
|
2016-10-20 11:04:23 +00:00
|
|
|
|
|
|
|
// Is raft enabled?
|
2016-12-20 11:19:13 +00:00
|
|
|
bool has_raft() const { return m_slicing_params.has_raft(); }
|
2016-10-20 11:04:23 +00:00
|
|
|
// Has any support?
|
|
|
|
bool has_support() const { return m_object_config->support_material.value; }
|
2017-01-05 08:14:59 +00:00
|
|
|
bool build_plate_only() const { return this->has_support() && m_object_config->support_material_buildplate_only.value; }
|
|
|
|
|
|
|
|
bool synchronize_layers() const { return m_object_config->support_material_synchronize_layers.value; }
|
|
|
|
bool has_contact_loops() const { return m_object_config->support_material_interface_contact_loops.value; }
|
2016-10-20 11:04:23 +00:00
|
|
|
|
2016-10-16 14:30:56 +00:00
|
|
|
// Generate support material for the object.
|
|
|
|
// New support layers will be added to the object,
|
|
|
|
// with extrusion paths and islands filled in for each support layer.
|
2016-10-20 11:04:23 +00:00
|
|
|
void generate(PrintObject &object);
|
2016-10-13 14:00:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// 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.
|
2016-11-29 18:30:59 +00:00
|
|
|
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;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
2016-10-16 14:30:56 +00:00
|
|
|
// 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;
|
|
|
|
|
2016-10-13 14:00:22 +00:00
|
|
|
// Generate raft layers and the intermediate support layers between the bottom contact and top contact surfaces.
|
|
|
|
MyLayersPtr raft_and_intermediate_support_layers(
|
|
|
|
const PrintObject &object,
|
|
|
|
const MyLayersPtr &bottom_contacts,
|
|
|
|
const MyLayersPtr &top_contacts,
|
|
|
|
MyLayerStorage &layer_storage,
|
2016-10-16 14:30:56 +00:00
|
|
|
const coordf_t max_object_layer_height) const;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Fill in the base layers with polygons.
|
2016-10-13 14:00:22 +00:00
|
|
|
void generate_base_layers(
|
|
|
|
const PrintObject &object,
|
|
|
|
const MyLayersPtr &bottom_contacts,
|
|
|
|
const MyLayersPtr &top_contacts,
|
2016-11-29 18:30:59 +00:00
|
|
|
MyLayersPtr &intermediate_layers,
|
|
|
|
std::vector<Polygons> &layer_support_areas) const;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Generate raft layers, also expand the 1st support layer
|
|
|
|
// in case there is no raft layer to improve support adhesion.
|
2016-12-20 11:19:13 +00:00
|
|
|
MyLayersPtr generate_raft_base(
|
2016-10-20 11:04:23 +00:00
|
|
|
const PrintObject &object,
|
2016-12-20 11:19:13 +00:00
|
|
|
const MyLayersPtr &top_contacts,
|
|
|
|
MyLayersPtr &intermediate_layers,
|
|
|
|
MyLayerStorage &layer_storage) const;
|
2016-10-20 11:04:23 +00:00
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Turn some of the base layers into interface layers.
|
2016-10-13 14:00:22 +00:00
|
|
|
MyLayersPtr generate_interface_layers(
|
|
|
|
const PrintObject &object,
|
|
|
|
const MyLayersPtr &bottom_contacts,
|
|
|
|
const MyLayersPtr &top_contacts,
|
|
|
|
MyLayersPtr &intermediate_layers,
|
2016-10-16 14:30:56 +00:00
|
|
|
MyLayerStorage &layer_storage) const;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Trim support layers by an object to leave a defined gap between
|
|
|
|
// the support volume and the object.
|
|
|
|
void trim_support_layers_by_object(
|
|
|
|
const PrintObject &object,
|
|
|
|
MyLayersPtr &support_layers,
|
|
|
|
const coordf_t gap_extra_above,
|
|
|
|
const coordf_t gap_extra_below,
|
|
|
|
const coordf_t gap_xy) const;
|
|
|
|
|
2016-10-13 14:00:22 +00:00
|
|
|
/*
|
|
|
|
void generate_pillars_shape();
|
|
|
|
void clip_with_shape();
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Produce the actual G-code.
|
|
|
|
void generate_toolpaths(
|
|
|
|
const PrintObject &object,
|
2016-12-20 11:19:13 +00:00
|
|
|
const MyLayersPtr &raft_layers,
|
2016-10-13 14:00:22 +00:00
|
|
|
const MyLayersPtr &bottom_contacts,
|
|
|
|
const MyLayersPtr &top_contacts,
|
|
|
|
const MyLayersPtr &intermediate_layers,
|
2016-10-16 14:30:56 +00:00
|
|
|
const MyLayersPtr &interface_layers) const;
|
2016-10-13 14:00:22 +00:00
|
|
|
|
2017-01-05 08:14:59 +00:00
|
|
|
// Following objects are not owned by SupportMaterial class.
|
2016-10-20 11:04:23 +00:00
|
|
|
const PrintObject *m_object;
|
2016-10-16 14:30:56 +00:00
|
|
|
const PrintConfig *m_print_config;
|
|
|
|
const PrintObjectConfig *m_object_config;
|
2017-01-05 08:14:59 +00:00
|
|
|
// 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.
|
2016-12-20 11:19:13 +00:00
|
|
|
SlicingParameters m_slicing_params;
|
2016-10-20 11:04:23 +00:00
|
|
|
|
2016-10-13 14:00:22 +00:00
|
|
|
Flow m_first_layer_flow;
|
2016-10-20 11:04:23 +00:00
|
|
|
Flow m_support_material_flow;
|
|
|
|
Flow m_support_material_interface_flow;
|
2016-12-20 11:19:13 +00:00
|
|
|
|
2016-10-20 11:04:23 +00:00
|
|
|
coordf_t m_support_layer_height_min;
|
2016-10-13 14:00:22 +00:00
|
|
|
coordf_t m_support_layer_height_max;
|
2017-01-05 08:14:59 +00:00
|
|
|
|
|
|
|
coordf_t m_gap_xy;
|
2016-10-13 14:00:22 +00:00
|
|
|
};
|
2014-12-12 18:14:52 +00:00
|
|
|
|
2016-10-16 14:30:56 +00:00
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif /* slic3r_SupportMaterial_hpp_ */
|