mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 06:41:10 +00:00
* Add Missing Includes Across src/libslic3r Every libslic3r source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, with libslic3r headers spelled libslic3r/... so they resolve outside the library's private include paths. MultiMaterialSegmentation.hpp, Support/SupportParameters.hpp and Format/STEP.hpp are made self-contained by hand. * Make the libslic3r Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Left out: I18N.hpp, which errors on purpose when included from GUI code, and VoxelizeCSGMesh.hpp and SLA/bicubic.h, which nothing includes and which no longer compile at all. * Add the Includes Missing From the Hand-Fixed libslic3r Headers clang-tidy would not edit these headers while they failed to compile on their own, so the first pass skipped them. With the headers now self-contained, a second pass adds the rest. * Keep Windows Setup Ahead of the Added libslic3r Includes Print.cpp and Thread.cpp open with a _WIN32 block that has to come first; without the precompiled header, Print.cpp otherwise reaches windows.h through OCCT with NONLS defined and boost/regex fails. OpenVDBUtils.cpp and SLA/SupportTreeBuilder.cpp had includes inside #ifndef NOMINMAX, which libslic3r defines on Windows, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory. * Re-Add libslic3r Includes After the Clipper2 2.0.1 Migration Rebasing onto main took main's version of the files the Clipper2 migration rewrote, so their added includes are restored here, along with includes for main's new code. Clipper2's individual headers are now ignored by clang-tidy: they only build the Z variant through clipper2_z.hpp, which defines USINGZ first, so including clipper.core.h and the like directly broke ClipperZUtils.cpp.
164 lines
5.1 KiB
C++
164 lines
5.1 KiB
C++
#ifndef slic3r_ConflictChecker_hpp_
|
|
#define slic3r_ConflictChecker_hpp_
|
|
|
|
#include "../Utils.hpp"
|
|
#include "../Model.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/ExtrusionEntityCollection.hpp"
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
|
|
#include <queue>
|
|
#include <utility>
|
|
#include <algorithm>
|
|
#include <iterator>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
|
|
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
|