mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
Another step to make the new C++ supports working.
Added support_material_xy_spacing configuration.
This commit is contained in:
parent
1ba03af2da
commit
d9ea3df85f
2 changed files with 426 additions and 531 deletions
File diff suppressed because it is too large
Load diff
|
@ -21,20 +21,33 @@ class PrintObjectConfig;
|
||||||
class PrintObjectSupportMaterial
|
class PrintObjectSupportMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// 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.
|
||||||
enum SupporLayerType {
|
enum SupporLayerType {
|
||||||
sltUnknown = 0,
|
sltUnknown = 0,
|
||||||
|
// Ratft base layer, to be printed with the support material.
|
||||||
sltRaftBase,
|
sltRaftBase,
|
||||||
|
// Raft interface layer, to be printed with the support interface material.
|
||||||
sltRaftInterface,
|
sltRaftInterface,
|
||||||
stlFirstLayer,
|
// Bottom contact layer placed over a top surface of an object. To be printed with a support interface material.
|
||||||
sltBottomContact,
|
sltBottomContact,
|
||||||
|
// Dense interface layer, to be printed with the support interface material.
|
||||||
|
// This layer is separated from an object by an sltBottomContact layer.
|
||||||
sltBottomInterface,
|
sltBottomInterface,
|
||||||
|
// Sparse base support layer, to be printed with a support material.
|
||||||
sltBase,
|
sltBase,
|
||||||
|
// Dense interface layer, to be printed with the support interface material.
|
||||||
|
// This layer is separated from an object with sltTopContact layer.
|
||||||
sltTopInterface,
|
sltTopInterface,
|
||||||
|
// Top contact layer directly supporting an overhang. To be printed with a support interface material.
|
||||||
sltTopContact,
|
sltTopContact,
|
||||||
// Some undecided type yet. It will turn into stlBase first, then it may turn into stlBottomInterface or stlTopInterface.
|
// Some undecided type yet. It will turn into sltBase first, then it may turn into sltBottomInterface or sltTopInterface.
|
||||||
stlIntermediate,
|
stlIntermediate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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.
|
||||||
class MyLayer
|
class MyLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -59,6 +72,7 @@ public:
|
||||||
return print_z == layer2.print_z && height == layer2.height && bridging == layer2.bridging;
|
return print_z == layer2.print_z && height == layer2.height && bridging == layer2.bridging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Order the layers by lexicographically by an increasing print_z and a decreasing layer height.
|
||||||
bool operator<(const MyLayer &layer2) const {
|
bool operator<(const MyLayer &layer2) const {
|
||||||
if (print_z < layer2.print_z) {
|
if (print_z < layer2.print_z) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,12 +88,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
SupporLayerType layer_type;
|
SupporLayerType layer_type;
|
||||||
// Z used for printing in unscaled coordinates
|
// Z used for printing, in unscaled coordinates.
|
||||||
coordf_t print_z;
|
coordf_t print_z;
|
||||||
// Bottom height of this layer. For soluble layers, bottom_z + height = print_z,
|
// Bottom Z of this layer. For soluble layers, bottom_z + height = print_z,
|
||||||
// otherwise bottom_z + gap + height = print_z.
|
// otherwise bottom_z + gap + height = print_z.
|
||||||
coordf_t bottom_z;
|
coordf_t bottom_z;
|
||||||
// layer height in unscaled coordinates
|
// Layer height in unscaled coordinates.
|
||||||
coordf_t height;
|
coordf_t height;
|
||||||
// Index of a PrintObject layer_id supported by this layer. This will be set for top contact layers.
|
// 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).
|
// If this is not a contact layer, it will be set to size_t(-1).
|
||||||
|
@ -93,31 +107,15 @@ public:
|
||||||
// Polygons to be filled by the support pattern.
|
// Polygons to be filled by the support pattern.
|
||||||
Polygons polygons;
|
Polygons polygons;
|
||||||
// Currently for the contact layers only: Overhangs are stored here.
|
// Currently for the contact layers only: Overhangs are stored here.
|
||||||
|
// MyLayer owns the aux_polygons, they are freed by the destructor.
|
||||||
Polygons *aux_polygons;
|
Polygons *aux_polygons;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LayerExtreme
|
// 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,
|
||||||
LayerExtreme(MyLayer *alayer, bool ais_top) : layer(alayer), is_top(ais_top) {}
|
// which would allocate layers by multiple chunks.
|
||||||
MyLayer *layer;
|
|
||||||
// top or bottom extreme
|
|
||||||
bool is_top;
|
|
||||||
|
|
||||||
coordf_t z() const { return is_top ? layer->print_z : layer->print_z - layer->height; }
|
|
||||||
|
|
||||||
bool operator<(const LayerExtreme &other) const { return z() < other.z(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
struct LayerPrintZ_Hash {
|
|
||||||
size_t operator()(const MyLayer &layer) const {
|
|
||||||
return std::hash<double>()(layer.print_z)^std::hash<double>()(layer.height)^size_t(layer.bridging);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef std::vector<MyLayer*> MyLayersPtr;
|
|
||||||
typedef std::deque<MyLayer> MyLayerStorage;
|
typedef std::deque<MyLayer> MyLayerStorage;
|
||||||
|
typedef std::vector<MyLayer*> MyLayersPtr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrintObjectSupportMaterial(const PrintObject *object, const SlicingParameters &slicing_params);
|
PrintObjectSupportMaterial(const PrintObject *object, const SlicingParameters &slicing_params);
|
||||||
|
@ -130,6 +128,10 @@ public:
|
||||||
bool has_raft() const { return m_slicing_params.has_raft(); }
|
bool has_raft() const { return m_slicing_params.has_raft(); }
|
||||||
// Has any support?
|
// Has any support?
|
||||||
bool has_support() const { return m_object_config->support_material.value; }
|
bool has_support() const { return m_object_config->support_material.value; }
|
||||||
|
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; }
|
||||||
|
|
||||||
// Generate support material for the object.
|
// Generate support material for the object.
|
||||||
// New support layers will be added to the object,
|
// New support layers will be added to the object,
|
||||||
|
@ -160,6 +162,7 @@ private:
|
||||||
MyLayerStorage &layer_storage,
|
MyLayerStorage &layer_storage,
|
||||||
const coordf_t max_object_layer_height) const;
|
const coordf_t max_object_layer_height) const;
|
||||||
|
|
||||||
|
// Fill in the base layers with polygons.
|
||||||
void generate_base_layers(
|
void generate_base_layers(
|
||||||
const PrintObject &object,
|
const PrintObject &object,
|
||||||
const MyLayersPtr &bottom_contacts,
|
const MyLayersPtr &bottom_contacts,
|
||||||
|
@ -167,12 +170,15 @@ private:
|
||||||
MyLayersPtr &intermediate_layers,
|
MyLayersPtr &intermediate_layers,
|
||||||
std::vector<Polygons> &layer_support_areas) const;
|
std::vector<Polygons> &layer_support_areas) const;
|
||||||
|
|
||||||
|
// Generate raft layers, also expand the 1st support layer
|
||||||
|
// in case there is no raft layer to improve support adhesion.
|
||||||
MyLayersPtr generate_raft_base(
|
MyLayersPtr generate_raft_base(
|
||||||
const PrintObject &object,
|
const PrintObject &object,
|
||||||
const MyLayersPtr &top_contacts,
|
const MyLayersPtr &top_contacts,
|
||||||
MyLayersPtr &intermediate_layers,
|
MyLayersPtr &intermediate_layers,
|
||||||
MyLayerStorage &layer_storage) const;
|
MyLayerStorage &layer_storage) const;
|
||||||
|
|
||||||
|
// Turn some of the base layers into interface layers.
|
||||||
MyLayersPtr generate_interface_layers(
|
MyLayersPtr generate_interface_layers(
|
||||||
const PrintObject &object,
|
const PrintObject &object,
|
||||||
const MyLayersPtr &bottom_contacts,
|
const MyLayersPtr &bottom_contacts,
|
||||||
|
@ -180,6 +186,15 @@ private:
|
||||||
MyLayersPtr &intermediate_layers,
|
MyLayersPtr &intermediate_layers,
|
||||||
MyLayerStorage &layer_storage) const;
|
MyLayerStorage &layer_storage) const;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void generate_pillars_shape();
|
void generate_pillars_shape();
|
||||||
void clip_with_shape();
|
void clip_with_shape();
|
||||||
|
@ -194,31 +209,22 @@ private:
|
||||||
const MyLayersPtr &intermediate_layers,
|
const MyLayersPtr &intermediate_layers,
|
||||||
const MyLayersPtr &interface_layers) const;
|
const MyLayersPtr &interface_layers) const;
|
||||||
|
|
||||||
|
// Following objects are not owned by SupportMaterial class.
|
||||||
const PrintObject *m_object;
|
const PrintObject *m_object;
|
||||||
const PrintConfig *m_print_config;
|
const PrintConfig *m_print_config;
|
||||||
const PrintObjectConfig *m_object_config;
|
const PrintObjectConfig *m_object_config;
|
||||||
|
// 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;
|
SlicingParameters m_slicing_params;
|
||||||
|
|
||||||
Flow m_first_layer_flow;
|
Flow m_first_layer_flow;
|
||||||
Flow m_support_material_flow;
|
Flow m_support_material_flow;
|
||||||
coordf_t m_support_material_spacing;
|
|
||||||
Flow m_support_material_interface_flow;
|
Flow m_support_material_interface_flow;
|
||||||
coordf_t m_support_material_interface_spacing;
|
|
||||||
|
|
||||||
coordf_t m_support_layer_height_min;
|
coordf_t m_support_layer_height_min;
|
||||||
coordf_t m_support_layer_height_max;
|
coordf_t m_support_layer_height_max;
|
||||||
coordf_t m_support_interface_layer_height_max;
|
|
||||||
|
|
||||||
coordf_t m_gap_extra_above;
|
coordf_t m_gap_xy;
|
||||||
coordf_t m_gap_extra_below;
|
|
||||||
coordf_t m_gap_xy;
|
|
||||||
|
|
||||||
// If enabled, the support layers will be synchronized with object layers.
|
|
||||||
// This does not prevent the support layers to be combined.
|
|
||||||
bool m_synchronize_support_layers_with_object;
|
|
||||||
// If disabled and m_synchronize_support_layers_with_object,
|
|
||||||
// the support layers will be synchronized with the object layers exactly, no layer will be combined.
|
|
||||||
bool m_combine_support_layers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue