mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 23:01:17 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
163 lines
5.1 KiB
C++
163 lines
5.1 KiB
C++
#ifndef slic3r_ConflictChecker_hpp_
|
|
#define slic3r_ConflictChecker_hpp_
|
|
|
|
#include "../Print.hpp"
|
|
#include "../Layer.hpp"
|
|
#include "libslic3r/Line.hpp"
|
|
#include "libslic3r/ExtrusionEntity.hpp"
|
|
#include "libslic3r/Point.hpp"
|
|
#include "libslic3r/Polyline.hpp"
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
|
|
#include <queue>
|
|
#include <utility>
|
|
#include <algorithm>
|
|
#include <iterator>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
|
|
namespace Slic3r { class ExtrusionEntityCollection; }
|
|
|
|
namespace Slic3r {
|
|
|
|
struct LineWithID
|
|
{
|
|
Line _line;
|
|
const void * _id;
|
|
ExtrusionRole _role;
|
|
|
|
LineWithID(const Line &line, const void* id, ExtrusionRole role) : _line(line), _id(id), _role(role) {}
|
|
};
|
|
|
|
using LineWithIDs = std::vector<LineWithID>;
|
|
|
|
struct ExtrusionLayer
|
|
{
|
|
ExtrusionPaths paths;
|
|
const Layer * layer;
|
|
float bottom_z;
|
|
float height;
|
|
};
|
|
|
|
enum class ExtrusionLayersType { INFILL, PERIMETERS, SUPPORT, WIPE_TOWER };
|
|
|
|
class ExtrusionLayers : public std::vector<ExtrusionLayer>
|
|
{
|
|
public:
|
|
ExtrusionLayersType type;
|
|
};
|
|
|
|
struct ObjectExtrusions
|
|
{
|
|
ExtrusionLayers perimeters;
|
|
ExtrusionLayers support;
|
|
|
|
ObjectExtrusions()
|
|
{
|
|
perimeters.type = ExtrusionLayersType::PERIMETERS;
|
|
support.type = ExtrusionLayersType::SUPPORT;
|
|
}
|
|
};
|
|
|
|
class LinesBucket
|
|
{
|
|
public:
|
|
float _curBottomZ = 0.0;
|
|
unsigned _curPileIdx = 0;
|
|
|
|
ExtrusionLayers _piles;
|
|
const void* _id;
|
|
Point _offset;
|
|
|
|
public:
|
|
LinesBucket(ExtrusionLayers &&paths, const void* id, Point offset) : _piles(paths), _id(id), _offset(offset) {}
|
|
LinesBucket(LinesBucket &&) = default;
|
|
|
|
std::pair<int, int> curRange() const
|
|
{
|
|
auto begin = std::lower_bound(_piles.begin(), _piles.end(), _piles[_curPileIdx], [](const ExtrusionLayer &l, const ExtrusionLayer &r) { return l.bottom_z < r.bottom_z; });
|
|
auto end = std::upper_bound(_piles.begin(), _piles.end(), _piles[_curPileIdx], [](const ExtrusionLayer &l, const ExtrusionLayer &r) { return l.bottom_z < r.bottom_z; });
|
|
return std::make_pair<int, int>(std::distance(_piles.begin(), begin), std::distance(_piles.begin(), end));
|
|
}
|
|
bool valid() const { return _curPileIdx < _piles.size(); }
|
|
void raise()
|
|
{
|
|
if (!valid()) { return; }
|
|
auto [b, e] = curRange();
|
|
_curPileIdx += (e - b);
|
|
_curBottomZ = _curPileIdx == _piles.size() ? _piles.back().bottom_z : _piles[_curPileIdx].bottom_z;
|
|
}
|
|
float curBottomZ() const { return _curBottomZ; }
|
|
LineWithIDs curLines() const
|
|
{
|
|
auto [b, e] = curRange();
|
|
LineWithIDs lines;
|
|
for (int i = b; i < e; ++i) {
|
|
for (const ExtrusionPath &path : _piles[i].paths) {
|
|
if (path.is_force_no_extrusion() == false) {
|
|
Polyline check_polyline = path.polyline.to_polyline();
|
|
check_polyline.translate(_offset);
|
|
Lines tmpLines = check_polyline.lines();
|
|
for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); }
|
|
}
|
|
}
|
|
}
|
|
return lines;
|
|
}
|
|
|
|
friend bool operator>(const LinesBucket &left, const LinesBucket &right) { return left._curBottomZ > right._curBottomZ; }
|
|
friend bool operator<(const LinesBucket &left, const LinesBucket &right) { return left._curBottomZ < right._curBottomZ; }
|
|
friend bool operator==(const LinesBucket &left, const LinesBucket &right) { return left._curBottomZ == right._curBottomZ; }
|
|
};
|
|
|
|
struct LinesBucketPtrComp
|
|
{
|
|
bool operator()(const LinesBucket *left, const LinesBucket *right) { return *left > *right; }
|
|
};
|
|
|
|
class LinesBucketQueue
|
|
{
|
|
public:
|
|
std::vector<LinesBucket> line_buckets;
|
|
std::priority_queue<LinesBucket *, std::vector<LinesBucket *>, LinesBucketPtrComp> line_bucket_ptr_queue;
|
|
|
|
public:
|
|
void emplace_back_bucket(ExtrusionLayers &&els, const void *objPtr, Point offset);
|
|
bool valid() const { return line_bucket_ptr_queue.empty() == false; }
|
|
float getCurrBottomZ();
|
|
LineWithIDs getCurLines() const;
|
|
};
|
|
|
|
void getExtrusionPathsFromEntity(const ExtrusionEntityCollection *entity, ExtrusionPaths &paths);
|
|
|
|
ExtrusionLayers getExtrusionPathsFromLayer(const LayerRegionPtrs layerRegionPtrs);
|
|
|
|
ExtrusionLayer getExtrusionPathsFromSupportLayer(SupportLayer *supportLayer);
|
|
|
|
ObjectExtrusions getAllLayersExtrusionPathsFromObject(PrintObject *obj);
|
|
|
|
struct ConflictComputeResult
|
|
{
|
|
const void* _obj1;
|
|
const void* _obj2;
|
|
|
|
ConflictComputeResult(const void* o1, const void* o2) : _obj1(o1), _obj2(o2) {}
|
|
ConflictComputeResult() = default;
|
|
};
|
|
|
|
using ConflictComputeOpt = std::optional<ConflictComputeResult>;
|
|
|
|
using ConflictObjName = std::optional<std::pair<std::string, std::string>>;
|
|
|
|
struct ConflictChecker
|
|
{
|
|
static ConflictResultOpt find_inter_of_lines_in_diff_objs(PrintObjectPtrs objs, std::optional<const FakeWipeTower *> wtdptr);
|
|
static ConflictComputeOpt find_inter_of_lines(const LineWithIDs &lines);
|
|
static ConflictComputeOpt line_intersect(const LineWithID &l1, const LineWithID &l2);
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif
|