mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 16:27:54 -06:00

* Travel very close to the inner holes, could cross external perimeter when the avoid crossing perimeters was enabled. (cherry picked from commit prusa3d/PrusaSlicer@6c51e5148c) * Modified variable offset in the avoid crossing perimeters to not cause scars on thin objects (#7699). Previously, the minimum contour width was chosen too conservative and, on some thin objects, only allowed minimal (or non) offset. This could result in travels being planned along the outer perimeter. Now, the minimum contour width is chosen much smaller at the start and tested if the variable offset wasn't failed (the outer contour broke up into more parts, more or fewer holes, etc.). If any problem is detected, the variable offset is recalculated with a larger minimum contour width. (cherry picked from commit prusa3d/PrusaSlicer@dc00f0bf98) --------- Co-authored-by: Lukáš Hejl <hejl.lukas@gmail.com>
78 lines
2.8 KiB
C++
78 lines
2.8 KiB
C++
///|/ Copyright (c) Prusa Research 2020 - 2022 Lukáš Hejl @hejllukas, Vojtěch Bubník @bubnikv
|
|
///|/
|
|
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
|
///|/
|
|
#ifndef slic3r_AvoidCrossingPerimeters_hpp_
|
|
#define slic3r_AvoidCrossingPerimeters_hpp_
|
|
|
|
#include "../libslic3r.h"
|
|
#include "../ExPolygon.hpp"
|
|
#include "../EdgeGrid.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
// Forward declarations.
|
|
class GCode;
|
|
class Layer;
|
|
class Point;
|
|
|
|
class AvoidCrossingPerimeters
|
|
{
|
|
public:
|
|
// Routing around the objects vs. inside a single object.
|
|
void use_external_mp(bool use = true) { m_use_external_mp = use; };
|
|
void use_external_mp_once() { m_use_external_mp_once = true; }
|
|
bool used_external_mp_once() { return m_use_external_mp_once; }
|
|
void disable_once() { m_disabled_once = true; }
|
|
bool disabled_once() const { return m_disabled_once; }
|
|
void reset_once_modifiers() { m_use_external_mp_once = false; m_disabled_once = false; }
|
|
|
|
void init_layer(const Layer &layer);
|
|
|
|
Polyline travel_to(const GCode& gcodegen, const Point& point)
|
|
{
|
|
bool could_be_wipe_disabled;
|
|
return this->travel_to(gcodegen, point, &could_be_wipe_disabled);
|
|
}
|
|
|
|
Polyline travel_to(const GCode& gcodegen, const Point& point, bool* could_be_wipe_disabled);
|
|
|
|
struct Boundary {
|
|
// Collection of boundaries used for detection of crossing perimeters for travels
|
|
Polygons boundaries;
|
|
// Bounding box of boundaries
|
|
BoundingBoxf bbox;
|
|
// Precomputed distances of all points in boundaries
|
|
std::vector<std::vector<float>> boundaries_params;
|
|
// Used for detection of intersection between line and any polygon from boundaries
|
|
EdgeGrid::Grid grid;
|
|
|
|
void clear()
|
|
{
|
|
boundaries.clear();
|
|
boundaries_params.clear();
|
|
}
|
|
};
|
|
|
|
private:
|
|
bool m_use_external_mp { false };
|
|
// just for the next travel move
|
|
bool m_use_external_mp_once { false };
|
|
// this flag disables reduce_crossing_wall just for the next travel move
|
|
// we enable it by default for the first travel move in print
|
|
bool m_disabled_once { true };
|
|
|
|
// Lslices offseted by half an external perimeter width. Used for detection if line or polyline is inside of any polygon.
|
|
ExPolygons m_lslices_offset;
|
|
std::vector<BoundingBox> m_lslices_offset_bboxes;
|
|
// Used for detection of line or polyline is inside of any polygon.
|
|
EdgeGrid::Grid m_grid_lslices_offset;
|
|
// Store all needed data for travels inside object
|
|
Boundary m_internal;
|
|
// Store all needed data for travels outside object
|
|
Boundary m_external;
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif // slic3r_AvoidCrossingPerimeters_hpp_
|