Conflict checker: first steps to extend it so it takes instances into account
This commit is contained in:
parent
720ddf73da
commit
b0bef4eeb4
@ -89,18 +89,18 @@ inline Grids line_rasterization(const Line &line, int64_t xdist = RasteXDistance
|
||||
}
|
||||
} // namespace RasterizationImpl
|
||||
|
||||
void LinesBucketQueue::emplace_back_bucket(std::vector<ExtrusionPaths> &&paths, const void *objPtr, Point offset)
|
||||
void LinesBucketQueue::emplace_back_bucket(std::vector<ExtrusionPaths> &&paths, const void *objPtr, Points offsets)
|
||||
{
|
||||
if (_objsPtrToId.find(objPtr) == _objsPtrToId.end()) {
|
||||
_objsPtrToId.insert({objPtr, _objsPtrToId.size()});
|
||||
_idToObjsPtr.insert({_objsPtrToId.size() - 1, objPtr});
|
||||
}
|
||||
_buckets.emplace_back(std::move(paths), _objsPtrToId[objPtr], offset);
|
||||
_buckets.emplace_back(std::move(paths), _objsPtrToId[objPtr], offsets);
|
||||
}
|
||||
|
||||
void LinesBucketQueue::build_queue()
|
||||
{
|
||||
assert(_pq.empty);
|
||||
assert(_pq.empty());
|
||||
for (LinesBucket &bucket : _buckets)
|
||||
_pq.push(&bucket);
|
||||
}
|
||||
@ -210,12 +210,17 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP
|
||||
LinesBucketQueue conflictQueue;
|
||||
if (wtdptr.has_value()) { // wipe tower at 0 by default
|
||||
auto wtpaths = (*wtdptr)->getFakeExtrusionPathsFromWipeTower();
|
||||
conflictQueue.emplace_back_bucket(std::move(wtpaths), *wtdptr, { (*wtdptr)->plate_origin.x(), (*wtdptr)->plate_origin.y() });
|
||||
conflictQueue.emplace_back_bucket(std::move(wtpaths), *wtdptr, Points{Point((*wtdptr)->plate_origin)});
|
||||
}
|
||||
for (PrintObject *obj : objs) {
|
||||
auto layers = getAllLayersExtrusionPathsFromObject(obj);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.first), obj, obj->instances().front().shift);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.second), obj, obj->instances().front().shift);
|
||||
|
||||
Points instances_shifts;
|
||||
for (const PrintInstance& inst : obj->instances())
|
||||
instances_shifts.emplace_back(inst.shift);
|
||||
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.first), obj, instances_shifts);
|
||||
conflictQueue.emplace_back_bucket(std::move(layers.second), obj, instances_shifts);
|
||||
}
|
||||
conflictQueue.build_queue();
|
||||
|
||||
|
@ -31,10 +31,10 @@ private:
|
||||
|
||||
std::vector<ExtrusionPaths> _piles;
|
||||
int _id;
|
||||
Point _offset;
|
||||
Points _offsets;
|
||||
|
||||
public:
|
||||
LinesBucket(std::vector<ExtrusionPaths> &&paths, int id, Point offset) : _piles(paths), _id(id), _offset(offset) {}
|
||||
LinesBucket(std::vector<ExtrusionPaths> &&paths, int id, Points offsets) : _piles(paths), _id(id), _offsets(offsets) {}
|
||||
LinesBucket(LinesBucket &&) = default;
|
||||
|
||||
bool valid() const { return _curPileIdx < _piles.size(); }
|
||||
@ -50,10 +50,13 @@ public:
|
||||
{
|
||||
LineWithIDs lines;
|
||||
for (const ExtrusionPath &path : _piles[_curPileIdx]) {
|
||||
Polyline check_polyline = path.polyline;
|
||||
check_polyline.translate(_offset);
|
||||
Lines tmpLines = check_polyline.lines();
|
||||
for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); }
|
||||
Polyline check_polyline;
|
||||
for (const Point& offset : _offsets) {
|
||||
check_polyline = path.polyline;
|
||||
check_polyline.translate(offset);
|
||||
Lines tmpLines = check_polyline.lines();
|
||||
for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); }
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@ -77,7 +80,7 @@ private:
|
||||
std::map<const void *, int> _objsPtrToId;
|
||||
|
||||
public:
|
||||
void emplace_back_bucket(std::vector<ExtrusionPaths> &&paths, const void *objPtr, Point offset);
|
||||
void emplace_back_bucket(std::vector<ExtrusionPaths> &&paths, const void *objPtr, Points offset);
|
||||
void build_queue();
|
||||
bool valid() const { return _pq.empty() == false; }
|
||||
const void *idToObjsPtr(int id)
|
||||
|
Loading…
Reference in New Issue
Block a user