2015-07-03 20:58:29 +00:00
|
|
|
#ifndef slic3r_PerimeterGenerator_hpp_
|
|
|
|
#define slic3r_PerimeterGenerator_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2015-07-23 13:53:02 +00:00
|
|
|
#include <vector>
|
|
|
|
#include "ExPolygonCollection.hpp"
|
|
|
|
#include "Flow.hpp"
|
|
|
|
#include "Polygon.hpp"
|
|
|
|
#include "PrintConfig.hpp"
|
|
|
|
#include "SurfaceCollection.hpp"
|
2015-07-03 20:58:29 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2016-09-13 11:30:00 +00:00
|
|
|
// Hierarchy of perimeters.
|
2015-07-03 20:58:29 +00:00
|
|
|
class PerimeterGeneratorLoop {
|
2016-09-13 11:30:00 +00:00
|
|
|
public:
|
|
|
|
// Polygon of this contour.
|
2015-07-03 20:58:29 +00:00
|
|
|
Polygon polygon;
|
2016-09-13 11:30:00 +00:00
|
|
|
// Is it a contour or a hole?
|
|
|
|
// Contours are CCW oriented, holes are CW oriented.
|
2015-07-03 20:58:29 +00:00
|
|
|
bool is_contour;
|
2016-09-13 11:30:00 +00:00
|
|
|
// Depth in the hierarchy. External perimeter has depth = 0. An external perimeter could be both a contour and a hole.
|
2015-07-03 20:58:29 +00:00
|
|
|
unsigned short depth;
|
2016-09-13 11:30:00 +00:00
|
|
|
// Children contour, may be both CCW and CW oriented (outer contours or holes).
|
2015-07-03 20:58:29 +00:00
|
|
|
std::vector<PerimeterGeneratorLoop> children;
|
|
|
|
|
|
|
|
PerimeterGeneratorLoop(Polygon polygon, unsigned short depth)
|
2015-07-28 21:29:25 +00:00
|
|
|
: polygon(polygon), is_contour(false), depth(depth)
|
2015-07-03 20:58:29 +00:00
|
|
|
{};
|
2016-09-13 11:30:00 +00:00
|
|
|
// External perimeter. It may be CCW or CW oriented (outer contour or hole contour).
|
|
|
|
bool is_external() const { return this->depth == 0; }
|
|
|
|
// An island, which may have holes, but it does not have another internal island.
|
2015-07-03 20:58:29 +00:00
|
|
|
bool is_internal_contour() const;
|
|
|
|
};
|
|
|
|
|
2016-09-13 11:30:00 +00:00
|
|
|
typedef std::vector<PerimeterGeneratorLoop> PerimeterGeneratorLoops;
|
|
|
|
|
2015-07-03 20:58:29 +00:00
|
|
|
class PerimeterGenerator {
|
2016-09-13 11:30:00 +00:00
|
|
|
public:
|
|
|
|
// Inputs:
|
2015-07-23 14:27:21 +00:00
|
|
|
const SurfaceCollection* slices;
|
|
|
|
const ExPolygonCollection* lower_slices;
|
2015-07-03 20:58:29 +00:00
|
|
|
double layer_height;
|
|
|
|
int layer_id;
|
|
|
|
Flow perimeter_flow;
|
|
|
|
Flow ext_perimeter_flow;
|
|
|
|
Flow overhang_flow;
|
|
|
|
Flow solid_infill_flow;
|
|
|
|
PrintRegionConfig* config;
|
|
|
|
PrintObjectConfig* object_config;
|
|
|
|
PrintConfig* print_config;
|
2016-09-13 11:30:00 +00:00
|
|
|
// Outputs:
|
2015-07-03 20:58:29 +00:00
|
|
|
ExtrusionEntityCollection* loops;
|
|
|
|
ExtrusionEntityCollection* gap_fill;
|
|
|
|
SurfaceCollection* fill_surfaces;
|
|
|
|
|
2016-09-13 11:30:00 +00:00
|
|
|
PerimeterGenerator(
|
|
|
|
// Input:
|
|
|
|
const SurfaceCollection* slices,
|
|
|
|
double layer_height,
|
|
|
|
Flow flow,
|
|
|
|
PrintRegionConfig* config,
|
|
|
|
PrintObjectConfig* object_config,
|
|
|
|
PrintConfig* print_config,
|
|
|
|
// Output:
|
|
|
|
// Loops with the external thin walls
|
|
|
|
ExtrusionEntityCollection* loops,
|
|
|
|
// Gaps without the thin walls
|
|
|
|
ExtrusionEntityCollection* gap_fill,
|
|
|
|
// Infills without the gap fills
|
|
|
|
SurfaceCollection* fill_surfaces)
|
2015-07-23 13:53:02 +00:00
|
|
|
: slices(slices), lower_slices(NULL), layer_height(layer_height),
|
2015-07-28 21:29:25 +00:00
|
|
|
layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
|
|
|
|
overhang_flow(flow), solid_infill_flow(flow),
|
2015-07-06 23:17:31 +00:00
|
|
|
config(config), object_config(object_config), print_config(print_config),
|
2015-07-23 13:53:02 +00:00
|
|
|
loops(loops), gap_fill(gap_fill), fill_surfaces(fill_surfaces),
|
2015-07-06 23:17:31 +00:00
|
|
|
_ext_mm3_per_mm(-1), _mm3_per_mm(-1), _mm3_per_mm_overhang(-1)
|
2015-07-03 20:58:29 +00:00
|
|
|
{};
|
|
|
|
void process();
|
|
|
|
|
|
|
|
private:
|
2015-07-06 23:17:31 +00:00
|
|
|
double _ext_mm3_per_mm;
|
|
|
|
double _mm3_per_mm;
|
|
|
|
double _mm3_per_mm_overhang;
|
2015-07-03 20:58:29 +00:00
|
|
|
Polygons _lower_slices_p;
|
|
|
|
|
2015-07-06 23:17:31 +00:00
|
|
|
ExtrusionEntityCollection _traverse_loops(const PerimeterGeneratorLoops &loops,
|
2016-03-19 18:40:11 +00:00
|
|
|
ThickPolylines &thin_walls) const;
|
2016-03-19 14:33:58 +00:00
|
|
|
ExtrusionEntityCollection _variable_width
|
|
|
|
(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) const;
|
2015-07-06 23:17:31 +00:00
|
|
|
};
|
|
|
|
|
2015-07-03 20:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|