2014-01-06 17:29:10 +00:00
|
|
|
#ifndef slic3r_Layer_hpp_
|
|
|
|
#define slic3r_Layer_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2014-08-03 17:17:23 +00:00
|
|
|
#include "Flow.hpp"
|
2014-05-06 08:07:18 +00:00
|
|
|
#include "SurfaceCollection.hpp"
|
|
|
|
#include "ExtrusionEntityCollection.hpp"
|
|
|
|
#include "ExPolygonCollection.hpp"
|
|
|
|
#include "PolylineCollection.hpp"
|
|
|
|
|
2014-01-06 17:29:10 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
class Layer;
|
|
|
|
class PrintRegion;
|
|
|
|
class PrintObject;
|
|
|
|
|
|
|
|
class LayerRegion
|
|
|
|
{
|
2017-03-22 14:35:09 +00:00
|
|
|
public:
|
2018-09-11 12:04:47 +00:00
|
|
|
Layer* layer() { return m_layer; }
|
|
|
|
const Layer* layer() const { return m_layer; }
|
|
|
|
PrintRegion* region() { return m_region; }
|
|
|
|
const PrintRegion* region() const { return m_region; }
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of surfaces generated by slicing the original geometry
|
|
|
|
// divided by type top/bottom/internal
|
2018-09-11 12:04:47 +00:00
|
|
|
SurfaceCollection slices;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of extrusion paths/loops filling gaps
|
2017-05-25 20:27:53 +00:00
|
|
|
// These fills are generated by the perimeter generator.
|
|
|
|
// They are not printed on their own, but they are copied to this->fills during infill generation.
|
2018-09-11 12:04:47 +00:00
|
|
|
ExtrusionEntityCollection thin_fills;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
2016-11-17 22:22:59 +00:00
|
|
|
// Unspecified fill polygons, used for overhang detection ("ensure vertical wall thickness feature")
|
|
|
|
// and for re-starting of infills.
|
2018-09-11 12:04:47 +00:00
|
|
|
ExPolygons fill_expolygons;
|
2014-05-06 08:07:18 +00:00
|
|
|
// collection of surfaces for infill generation
|
2018-09-11 12:04:47 +00:00
|
|
|
SurfaceCollection fill_surfaces;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
2016-09-26 11:44:23 +00:00
|
|
|
// Collection of perimeter surfaces. This is a cached result of diff(slices, fill_surfaces).
|
|
|
|
// While not necessary, the memory consumption is meager and it speeds up calculation.
|
|
|
|
// The perimeter_surfaces keep the IDs of the slices (top/bottom/)
|
2018-09-11 12:04:47 +00:00
|
|
|
SurfaceCollection perimeter_surfaces;
|
2016-09-26 11:44:23 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
// collection of expolygons representing the bridged areas (thus not
|
|
|
|
// needing support material)
|
2018-09-11 12:04:47 +00:00
|
|
|
Polygons bridged;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of polylines representing the unsupported bridge edges
|
2018-09-11 12:04:47 +00:00
|
|
|
PolylineCollection unsupported_bridge_edges;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// ordered collection of extrusion paths/loops to build all perimeters
|
2015-04-12 18:16:27 +00:00
|
|
|
// (this collection contains only ExtrusionEntityCollection objects)
|
2018-09-11 12:04:47 +00:00
|
|
|
ExtrusionEntityCollection perimeters;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// ordered collection of extrusion paths to fill surfaces
|
2014-12-16 23:34:00 +00:00
|
|
|
// (this collection contains only ExtrusionEntityCollection objects)
|
2018-09-11 12:04:47 +00:00
|
|
|
ExtrusionEntityCollection fills;
|
2014-08-03 17:17:23 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
|
|
|
void slices_to_fill_surfaces_clipped();
|
|
|
|
void prepare_fill_surfaces();
|
|
|
|
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
|
|
|
|
void process_external_surfaces(const Layer* lower_layer);
|
2015-10-26 22:23:03 +00:00
|
|
|
double infill_area_threshold() const;
|
2016-09-26 11:44:23 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
void export_region_slices_to_svg(const char *path) const;
|
|
|
|
void export_region_fill_surfaces_to_svg(const char *path) const;
|
2016-09-26 11:44:23 +00:00
|
|
|
// Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export.
|
2018-09-11 12:04:47 +00:00
|
|
|
void export_region_slices_to_svg_debug(const char *name) const;
|
|
|
|
void export_region_fill_surfaces_to_svg_debug(const char *name) const;
|
2016-09-26 11:44:23 +00:00
|
|
|
|
2017-07-27 08:39:43 +00:00
|
|
|
// Is there any valid extrusion assigned to this LayerRegion?
|
2018-09-11 12:04:47 +00:00
|
|
|
bool has_extrusions() const { return ! this->perimeters.entities.empty() || ! this->fills.entities.empty(); }
|
2017-07-27 08:39:43 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
protected:
|
|
|
|
friend class Layer;
|
2014-05-19 20:38:10 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
LayerRegion(Layer *layer, PrintRegion *region) : m_layer(layer), m_region(region) {}
|
2017-03-07 16:43:43 +00:00
|
|
|
~LayerRegion() {}
|
2018-09-11 12:04:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Layer *m_layer;
|
|
|
|
PrintRegion *m_region;
|
2014-05-06 08:07:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<LayerRegion*> LayerRegionPtrs;
|
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
class Layer
|
|
|
|
{
|
2016-09-26 11:44:23 +00:00
|
|
|
public:
|
2018-09-11 12:04:47 +00:00
|
|
|
size_t id() const { return m_id; }
|
|
|
|
void set_id(size_t id) { m_id = id; }
|
|
|
|
PrintObject* object() { return m_object; }
|
|
|
|
const PrintObject* object() const { return m_object; }
|
|
|
|
|
|
|
|
Layer *upper_layer;
|
|
|
|
Layer *lower_layer;
|
|
|
|
bool slicing_errors;
|
|
|
|
coordf_t slice_z; // Z used for slicing in unscaled coordinates
|
|
|
|
coordf_t print_z; // Z used for printing in unscaled coordinates
|
|
|
|
coordf_t height; // layer height in unscaled coordinates
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of expolygons generated by slicing the original geometry;
|
|
|
|
// also known as 'islands' (all regions and surface types are merged here)
|
2016-11-17 22:22:59 +00:00
|
|
|
// The slices are chained by the shortest traverse distance and this traversal
|
|
|
|
// order will be recovered by the G-code generator.
|
2014-05-06 08:07:18 +00:00
|
|
|
ExPolygonCollection slices;
|
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
size_t region_count() const { return m_regions.size(); }
|
|
|
|
const LayerRegion* get_region(int idx) const { return m_regions.at(idx); }
|
|
|
|
LayerRegion* get_region(int idx) { return m_regions[idx]; }
|
|
|
|
LayerRegion* add_region(PrintRegion* print_region);
|
|
|
|
const LayerRegionPtrs& regions() const { return m_regions; }
|
2018-12-14 16:17:51 +00:00
|
|
|
// Test whether whether there are any slices assigned to this layer.
|
|
|
|
bool empty() const;
|
2018-09-11 12:04:47 +00:00
|
|
|
void make_slices();
|
|
|
|
void merge_slices();
|
2017-07-10 11:15:36 +00:00
|
|
|
template <class T> bool any_internal_region_slice_contains(const T &item) const {
|
2018-09-11 12:04:47 +00:00
|
|
|
for (const LayerRegion *layerm : m_regions) if (layerm->slices.any_internal_contains(item)) return true;
|
2017-07-10 11:15:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
template <class T> bool any_bottom_region_slice_contains(const T &item) const {
|
2018-09-11 12:04:47 +00:00
|
|
|
for (const LayerRegion *layerm : m_regions) if (layerm->slices.any_bottom_contains(item)) return true;
|
2017-07-10 11:15:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-09-11 12:04:47 +00:00
|
|
|
void make_perimeters();
|
|
|
|
void make_fills();
|
2016-09-26 11:44:23 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
void export_region_slices_to_svg(const char *path) const;
|
|
|
|
void export_region_fill_surfaces_to_svg(const char *path) const;
|
2016-09-26 11:44:23 +00:00
|
|
|
// Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export.
|
2018-09-11 12:04:47 +00:00
|
|
|
void export_region_slices_to_svg_debug(const char *name) const;
|
|
|
|
void export_region_fill_surfaces_to_svg_debug(const char *name) const;
|
2017-07-27 08:39:43 +00:00
|
|
|
|
|
|
|
// Is there any valid extrusion assigned to this LayerRegion?
|
2018-09-11 12:04:47 +00:00
|
|
|
virtual bool has_extrusions() const { for (auto layerm : m_regions) if (layerm->has_extrusions()) return true; return false; }
|
2017-07-27 08:39:43 +00:00
|
|
|
|
2016-09-26 11:44:23 +00:00
|
|
|
protected:
|
2018-09-11 12:04:47 +00:00
|
|
|
friend class PrintObject;
|
2014-05-19 20:38:10 +00:00
|
|
|
|
2017-05-30 16:33:17 +00:00
|
|
|
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
|
|
|
|
upper_layer(nullptr), lower_layer(nullptr), slicing_errors(false),
|
|
|
|
slice_z(slice_z), print_z(print_z), height(height),
|
2018-09-11 12:04:47 +00:00
|
|
|
m_id(id), m_object(object) {}
|
2014-05-06 08:07:18 +00:00
|
|
|
virtual ~Layer();
|
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
private:
|
|
|
|
// sequential number of layer, 0-based
|
|
|
|
size_t m_id;
|
|
|
|
PrintObject *m_object;
|
|
|
|
LayerRegionPtrs m_regions;
|
|
|
|
};
|
2014-05-06 08:07:18 +00:00
|
|
|
|
2018-09-11 12:04:47 +00:00
|
|
|
class SupportLayer : public Layer
|
|
|
|
{
|
2016-10-06 19:41:52 +00:00
|
|
|
public:
|
|
|
|
// Polygons covered by the supports: base, interface and contact areas.
|
2018-09-11 12:04:47 +00:00
|
|
|
ExPolygonCollection support_islands;
|
2017-04-07 15:37:30 +00:00
|
|
|
// Extrusion paths for the support base and for the support interface and contacts.
|
2018-09-11 12:04:47 +00:00
|
|
|
ExtrusionEntityCollection support_fills;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
2017-07-27 08:39:43 +00:00
|
|
|
// Is there any valid extrusion assigned to this LayerRegion?
|
2018-09-11 12:04:47 +00:00
|
|
|
virtual bool has_extrusions() const { return ! support_fills.empty(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class PrintObject;
|
2017-07-27 08:39:43 +00:00
|
|
|
|
2017-12-11 16:19:55 +00:00
|
|
|
// 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.
|
2017-05-30 16:33:17 +00:00
|
|
|
SupportLayer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
|
|
|
|
Layer(id, object, height, print_z, slice_z) {}
|
2017-01-11 12:43:33 +00:00
|
|
|
virtual ~SupportLayer() {}
|
2014-05-06 08:07:18 +00:00
|
|
|
};
|
|
|
|
|
2014-01-06 17:29:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|