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
|
} // 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()) {
|
if (_objsPtrToId.find(objPtr) == _objsPtrToId.end()) {
|
||||||
_objsPtrToId.insert({objPtr, _objsPtrToId.size()});
|
_objsPtrToId.insert({objPtr, _objsPtrToId.size()});
|
||||||
_idToObjsPtr.insert({_objsPtrToId.size() - 1, objPtr});
|
_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()
|
void LinesBucketQueue::build_queue()
|
||||||
{
|
{
|
||||||
assert(_pq.empty);
|
assert(_pq.empty());
|
||||||
for (LinesBucket &bucket : _buckets)
|
for (LinesBucket &bucket : _buckets)
|
||||||
_pq.push(&bucket);
|
_pq.push(&bucket);
|
||||||
}
|
}
|
||||||
@ -210,12 +210,17 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP
|
|||||||
LinesBucketQueue conflictQueue;
|
LinesBucketQueue conflictQueue;
|
||||||
if (wtdptr.has_value()) { // wipe tower at 0 by default
|
if (wtdptr.has_value()) { // wipe tower at 0 by default
|
||||||
auto wtpaths = (*wtdptr)->getFakeExtrusionPathsFromWipeTower();
|
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) {
|
for (PrintObject *obj : objs) {
|
||||||
auto layers = getAllLayersExtrusionPathsFromObject(obj);
|
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();
|
conflictQueue.build_queue();
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@ private:
|
|||||||
|
|
||||||
std::vector<ExtrusionPaths> _piles;
|
std::vector<ExtrusionPaths> _piles;
|
||||||
int _id;
|
int _id;
|
||||||
Point _offset;
|
Points _offsets;
|
||||||
|
|
||||||
public:
|
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;
|
LinesBucket(LinesBucket &&) = default;
|
||||||
|
|
||||||
bool valid() const { return _curPileIdx < _piles.size(); }
|
bool valid() const { return _curPileIdx < _piles.size(); }
|
||||||
@ -50,10 +50,13 @@ public:
|
|||||||
{
|
{
|
||||||
LineWithIDs lines;
|
LineWithIDs lines;
|
||||||
for (const ExtrusionPath &path : _piles[_curPileIdx]) {
|
for (const ExtrusionPath &path : _piles[_curPileIdx]) {
|
||||||
Polyline check_polyline = path.polyline;
|
Polyline check_polyline;
|
||||||
check_polyline.translate(_offset);
|
for (const Point& offset : _offsets) {
|
||||||
Lines tmpLines = check_polyline.lines();
|
check_polyline = path.polyline;
|
||||||
for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); }
|
check_polyline.translate(offset);
|
||||||
|
Lines tmpLines = check_polyline.lines();
|
||||||
|
for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
@ -77,7 +80,7 @@ private:
|
|||||||
std::map<const void *, int> _objsPtrToId;
|
std::map<const void *, int> _objsPtrToId;
|
||||||
|
|
||||||
public:
|
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();
|
void build_queue();
|
||||||
bool valid() const { return _pq.empty() == false; }
|
bool valid() const { return _pq.empty() == false; }
|
||||||
const void *idToObjsPtr(int id)
|
const void *idToObjsPtr(int id)
|
||||||
|
Loading…
Reference in New Issue
Block a user