mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 10:47:50 -06:00
Moved AvoidCrossingPerimeters to separate file
This commit is contained in:
parent
20916e2362
commit
8adf02a289
5 changed files with 658 additions and 613 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "Point.hpp"
|
||||
#include "PlaceholderParser.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
#include "GCode/AvoidCrossingPerimeters.hpp"
|
||||
#include "GCode/CoolingBuffer.hpp"
|
||||
#include "GCode/SpiralVase.hpp"
|
||||
#include "GCode/ToolOrdering.hpp"
|
||||
|
@ -34,83 +35,6 @@ namespace { struct Item; }
|
|||
struct PrintInstance;
|
||||
using PrintObjectPtrs = std::vector<PrintObject*>;
|
||||
|
||||
class AvoidCrossingPerimeters {
|
||||
public:
|
||||
|
||||
// this flag triggers the use of the external configuration space
|
||||
bool use_external_mp;
|
||||
bool use_external_mp_once; // just for the next travel move
|
||||
|
||||
// this flag disables avoid_crossing_perimeters just for the next travel move
|
||||
// we enable it by default for the first travel move in print
|
||||
bool disable_once;
|
||||
|
||||
AvoidCrossingPerimeters() : use_external_mp(false), use_external_mp_once(false), disable_once(true) {}
|
||||
virtual ~AvoidCrossingPerimeters() = default;
|
||||
|
||||
void reset() { m_external_mp.reset(); m_layer_mp.reset(); }
|
||||
void init_external_mp(const Print &print);
|
||||
void init_layer_mp(const ExPolygons &islands) { m_layer_mp = Slic3r::make_unique<MotionPlanner>(islands); }
|
||||
|
||||
virtual Polyline travel_to(const GCode &gcodegen, const Point &point);
|
||||
|
||||
protected:
|
||||
// For initializing the regions to avoid.
|
||||
static Polygons collect_contours_all_layers(const PrintObjectPtrs& objects);
|
||||
|
||||
std::unique_ptr<MotionPlanner> m_external_mp;
|
||||
std::unique_ptr<MotionPlanner> m_layer_mp;
|
||||
};
|
||||
|
||||
class AvoidCrossingPerimeters2 : public AvoidCrossingPerimeters
|
||||
{
|
||||
protected:
|
||||
struct Intersection
|
||||
{
|
||||
size_t border_idx;
|
||||
size_t line_idx;
|
||||
Point point_transformed;
|
||||
Point point;
|
||||
|
||||
Intersection(size_t border_idx, size_t line_idx, const Point &point_transformed, const Point &point)
|
||||
: border_idx(border_idx), line_idx(line_idx), point_transformed(point_transformed), point(point){};
|
||||
|
||||
inline bool operator<(const Intersection &other) const { return this->point_transformed.x() < other.point_transformed.x(); }
|
||||
};
|
||||
|
||||
enum class Direction { Forward, Backward };
|
||||
|
||||
private:
|
||||
static Direction get_shortest_direction(const Lines &lines,
|
||||
const size_t start_idx,
|
||||
const size_t end_idx,
|
||||
const Point &intersection_first,
|
||||
const Point &intersection_last);
|
||||
static ExPolygons get_boundary(const Layer &layer);
|
||||
|
||||
static ExPolygons get_boundary_external(const Layer &layer);
|
||||
|
||||
static Polyline simplify_travel(const EdgeGrid::Grid &edge_grid, const Polyline &travel);
|
||||
|
||||
static Polyline avoid_perimeters(const Polygons &boundaries, const EdgeGrid::Grid &grid, const Point &start, const Point &end);
|
||||
|
||||
Polygons m_boundaries;
|
||||
Polygons m_boundaries_external;
|
||||
BoundingBox m_bbox;
|
||||
BoundingBox m_bbox_external;
|
||||
EdgeGrid::Grid m_grid;
|
||||
EdgeGrid::Grid m_grid_external;
|
||||
|
||||
public:
|
||||
AvoidCrossingPerimeters2() : AvoidCrossingPerimeters() {}
|
||||
|
||||
virtual ~AvoidCrossingPerimeters2() = default;
|
||||
|
||||
virtual Polyline travel_to(const GCode &gcodegen, const Point &point) override;
|
||||
|
||||
void init_layer(const Layer &layer);
|
||||
};
|
||||
|
||||
class OozePrevention {
|
||||
public:
|
||||
bool enable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue