ENH: merge tree support layers to support layers

Will greately reduce repeated codes.

Change-Id: I506a97a907b5b393fe41e13ae53e2f7c9247c4c5
This commit is contained in:
Arthur 2022-12-09 14:08:30 +08:00 committed by Lane.Wei
parent b6ef31f7b9
commit 646b259972
11 changed files with 123 additions and 624 deletions

View file

@ -211,6 +211,11 @@ private:
LayerRegionPtrs m_regions;
};
enum SupportInnerType {
stInnerNormal,
stInnerTree
};
class SupportLayer : public Layer
{
public:
@ -219,6 +224,10 @@ public:
ExPolygonCollection support_islands;
// Extrusion paths for the support base and for the support interface and contacts.
ExtrusionEntityCollection support_fills;
SupportInnerType support_type = stInnerNormal;
// for tree supports
ExPolygons base_areas;
// Is there any valid extrusion assigned to this LayerRegion?
@ -231,33 +240,23 @@ public:
protected:
friend class PrintObject;
friend class TreeSupport;
// The constructor has been made public to be able to insert additional support layers for the skirt or a wipe tower
// between the raft and the object first layer.
SupportLayer(size_t id, size_t interface_id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
Layer(id, object, height, print_z, slice_z), m_interface_id(interface_id) {}
Layer(id, object, height, print_z, slice_z), m_interface_id(interface_id), support_type(stInnerNormal) {}
virtual ~SupportLayer() = default;
size_t m_interface_id;
};
class TreeSupportLayer : public Layer
{
public:
ExtrusionEntityCollection support_fills;
ExPolygons overhang_areas;
ExPolygons roof_areas;
ExPolygons roof_1st_layer; // the layer just below roof. When working with PolySupport, this layer should be printed with regular material
ExPolygons floor_areas;
ExPolygons base_areas;
ExPolygons roof_gap_areas; // the areas in the gap between support roof and overhang
enum AreaType {
BaseType=0,
RoofType=1,
FloorType=2,
Roof1stLayer=3
};
// for tree support
ExPolygons overhang_areas;
ExPolygons roof_areas;
ExPolygons roof_1st_layer; // the layer just below roof. When working with PolySupport, this layer should be printed with regular material
ExPolygons floor_areas;
ExPolygons roof_gap_areas; // the areas in the gap between support roof and overhang
enum AreaType { BaseType = 0, RoofType = 1, FloorType = 2, Roof1stLayer = 3 };
struct AreaGroup
{
ExPolygon *area;
@ -265,23 +264,9 @@ public:
coordf_t dist_to_top; // mm dist to top
AreaGroup(ExPolygon *a, int t, coordf_t d) : area(a), type(t), dist_to_top(d) {}
};
std::vector<AreaGroup> area_groups;
enum OverhangType {
Detected=0,
Enforced
};
enum OverhangType { Detected = 0, Enforced };
std::vector<AreaGroup> area_groups;
std::map<const ExPolygon *, OverhangType> overhang_types;
virtual bool has_extrusions() const { return !support_fills.empty(); }
void simplify_support_extrusion_path() { this->simplify_support_entity_collection(&support_fills);}
protected:
friend class PrintObject;
TreeSupportLayer(size_t id, PrintObject* object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
Layer(id, object, height, print_z, slice_z) {}
virtual ~TreeSupportLayer() = default;
};
template<typename LayerContainer>