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 {
|
|
|
|
|
|
|
|
typedef std::pair<coordf_t,coordf_t> t_layer_height_range;
|
|
|
|
typedef std::map<t_layer_height_range,coordf_t> t_layer_height_ranges;
|
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
class Layer;
|
|
|
|
class PrintRegion;
|
|
|
|
class PrintObject;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: make stuff private
|
|
|
|
class LayerRegion
|
|
|
|
{
|
|
|
|
friend class Layer;
|
|
|
|
|
|
|
|
public:
|
2014-05-19 20:38:10 +00:00
|
|
|
Layer* layer();
|
2016-10-16 14:30:56 +00:00
|
|
|
PrintRegion* region() { return this->_region; }
|
|
|
|
const PrintRegion* region() const { return this->_region; }
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of surfaces generated by slicing the original geometry
|
|
|
|
// divided by type top/bottom/internal
|
|
|
|
SurfaceCollection slices;
|
|
|
|
|
|
|
|
// collection of extrusion paths/loops filling gaps
|
|
|
|
ExtrusionEntityCollection thin_fills;
|
|
|
|
|
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.
|
|
|
|
ExPolygons fill_expolygons;
|
2014-05-06 08:07:18 +00:00
|
|
|
// collection of surfaces for infill generation
|
2016-11-17 22:22:59 +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/)
|
|
|
|
SurfaceCollection perimeter_surfaces;
|
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
// collection of expolygons representing the bridged areas (thus not
|
|
|
|
// needing support material)
|
2015-10-26 22:23:03 +00:00
|
|
|
Polygons bridged;
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
// collection of polylines representing the unsupported bridge edges
|
|
|
|
PolylineCollection unsupported_bridge_edges;
|
|
|
|
|
|
|
|
// ordered collection of extrusion paths/loops to build all perimeters
|
2015-04-12 18:16:27 +00:00
|
|
|
// (this collection contains only ExtrusionEntityCollection objects)
|
2014-05-06 08:07:18 +00:00
|
|
|
ExtrusionEntityCollection perimeters;
|
|
|
|
|
|
|
|
// ordered collection of extrusion paths to fill surfaces
|
2014-12-16 23:34:00 +00:00
|
|
|
// (this collection contains only ExtrusionEntityCollection objects)
|
2014-05-06 08:07:18 +00:00
|
|
|
ExtrusionEntityCollection fills;
|
2014-08-03 17:17:23 +00:00
|
|
|
|
|
|
|
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
2014-11-09 15:23:50 +00:00
|
|
|
void merge_slices();
|
2016-11-10 18:23:01 +00:00
|
|
|
void slices_to_fill_surfaces_clipped();
|
2015-02-01 11:43:58 +00:00
|
|
|
void prepare_fill_surfaces();
|
2016-11-17 22:22:59 +00:00
|
|
|
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
|
2015-10-26 22:23:03 +00:00
|
|
|
void process_external_surfaces(const Layer* lower_layer);
|
|
|
|
double infill_area_threshold() const;
|
2016-09-26 11:44:23 +00:00
|
|
|
|
|
|
|
void export_region_slices_to_svg(const char *path);
|
|
|
|
void export_region_fill_surfaces_to_svg(const char *path);
|
|
|
|
// Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export.
|
|
|
|
void export_region_slices_to_svg_debug(const char *name);
|
|
|
|
void export_region_fill_surfaces_to_svg_debug(const char *name);
|
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
private:
|
2014-05-19 20:38:10 +00:00
|
|
|
Layer *_layer;
|
|
|
|
PrintRegion *_region;
|
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
LayerRegion(Layer *layer, PrintRegion *region);
|
|
|
|
~LayerRegion();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<LayerRegion*> LayerRegionPtrs;
|
|
|
|
|
|
|
|
class Layer {
|
|
|
|
friend class PrintObject;
|
|
|
|
|
2016-09-26 11:44:23 +00:00
|
|
|
public:
|
2015-01-18 11:35:05 +00:00
|
|
|
size_t id() const;
|
|
|
|
void set_id(size_t id);
|
2014-05-19 20:38:10 +00:00
|
|
|
PrintObject* object();
|
2015-07-02 18:24:16 +00:00
|
|
|
const PrintObject* object() const;
|
2014-05-19 20:38:10 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
Layer *upper_layer;
|
|
|
|
Layer *lower_layer;
|
|
|
|
LayerRegionPtrs regions;
|
|
|
|
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
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2015-07-27 23:26:01 +00:00
|
|
|
size_t region_count() const;
|
2016-11-10 18:23:01 +00:00
|
|
|
const LayerRegion* get_region(int idx) const { return this->regions.at(idx); }
|
|
|
|
LayerRegion* get_region(int idx) { return this->regions.at(idx); }
|
2014-05-06 08:07:18 +00:00
|
|
|
LayerRegion* add_region(PrintRegion* print_region);
|
2014-08-03 16:41:09 +00:00
|
|
|
|
|
|
|
void make_slices();
|
2015-04-16 18:44:55 +00:00
|
|
|
void merge_slices();
|
2014-12-25 10:37:54 +00:00
|
|
|
template <class T> bool any_internal_region_slice_contains(const T &item) const;
|
2015-01-06 10:29:34 +00:00
|
|
|
template <class T> bool any_bottom_region_slice_contains(const T &item) const;
|
2015-12-02 18:32:57 +00:00
|
|
|
void make_perimeters();
|
2016-11-02 09:47:00 +00:00
|
|
|
void make_fills();
|
2016-09-26 11:44:23 +00:00
|
|
|
|
|
|
|
void export_region_slices_to_svg(const char *path);
|
|
|
|
void export_region_fill_surfaces_to_svg(const char *path);
|
|
|
|
// Export to "out/LayerRegion-name-%d.svg" with an increasing index with every export.
|
|
|
|
void export_region_slices_to_svg_debug(const char *name);
|
|
|
|
void export_region_fill_surfaces_to_svg_debug(const char *name);
|
2015-01-06 13:47:53 +00:00
|
|
|
|
2016-09-26 11:44:23 +00:00
|
|
|
protected:
|
2015-01-18 11:35:05 +00:00
|
|
|
size_t _id; // sequential number of layer, 0-based
|
2014-05-19 20:38:10 +00:00
|
|
|
PrintObject *_object;
|
|
|
|
|
2014-05-24 21:10:20 +00:00
|
|
|
|
2015-01-18 11:35:05 +00:00
|
|
|
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
2014-05-06 08:07:18 +00:00
|
|
|
coordf_t slice_z);
|
|
|
|
virtual ~Layer();
|
2014-05-24 21:10:20 +00:00
|
|
|
|
|
|
|
void clear_regions();
|
|
|
|
void delete_region(int idx);
|
2014-05-06 08:07:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SupportLayer : public Layer {
|
|
|
|
friend class PrintObject;
|
|
|
|
|
2016-10-06 19:41:52 +00:00
|
|
|
public:
|
|
|
|
// Polygons covered by the supports: base, interface and contact areas.
|
2014-05-06 08:07:18 +00:00
|
|
|
ExPolygonCollection support_islands;
|
2016-10-06 19:41:52 +00:00
|
|
|
// Extrusion paths for the support base.
|
2014-05-06 08:07:18 +00:00
|
|
|
ExtrusionEntityCollection support_fills;
|
2016-10-06 19:41:52 +00:00
|
|
|
// Extrusion paths for the support interface and contacts.
|
2014-05-06 08:07:18 +00:00
|
|
|
ExtrusionEntityCollection support_interface_fills;
|
|
|
|
|
2016-10-06 19:41:52 +00:00
|
|
|
protected:
|
2015-01-18 11:35:05 +00:00
|
|
|
SupportLayer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
2014-05-06 08:07:18 +00:00
|
|
|
coordf_t slice_z);
|
|
|
|
virtual ~SupportLayer();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-06 17:29:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|