FIX: skip gcode path conflict check for adaptive layer height

adaptive layer height won't work with conflict checker because m_fake_wipe_tower's path is generated using fixed layer height.

Jira: STUDIO-4442
Change-Id: I964a69af2fa0be8224ffc11e4c86f8ccf6dbf152
(cherry picked from commit e8c915f9e0b8c8f6cb549259b20d6d850a06d7d3)
This commit is contained in:
Arthur 2023-09-13 18:26:46 +08:00 committed by Lane.Wei
parent c00f944308
commit c5db5551bf
4 changed files with 30 additions and 24 deletions

View File

@ -91,34 +91,34 @@ inline Grids line_rasterization(const Line &line, int64_t xdist = RasteXDistance
void LinesBucketQueue::emplace_back_bucket(ExtrusionLayers &&els, const void *objPtr, Point offset)
{
auto oldSize = _buckets.capacity();
_buckets.emplace_back(std::move(els), objPtr, offset);
_pq.push(&_buckets.back());
auto newSize = _buckets.capacity();
auto oldSize = line_buckets.capacity();
line_buckets.emplace_back(std::move(els), objPtr, offset);
line_bucket_ptr_queue.push(&line_buckets.back());
auto newSize = line_buckets.capacity();
if (oldSize != newSize) { // pointers change
decltype(_pq) newQueue;
for (LinesBucket &bucket : _buckets) { newQueue.push(&bucket); }
std::swap(_pq, newQueue);
decltype(line_bucket_ptr_queue) newQueue;
for (LinesBucket &bucket : line_buckets) { newQueue.push(&bucket); }
std::swap(line_bucket_ptr_queue, newQueue);
}
}
// remove lowest and get the current bottom z
float LinesBucketQueue::getCurrBottomZ()
{
auto lowest = _pq.top();
_pq.pop();
auto lowest = line_bucket_ptr_queue.top();
line_bucket_ptr_queue.pop();
float layerBottomZ = lowest->curBottomZ();
std::vector<LinesBucket *> lowests;
lowests.push_back(lowest);
while (_pq.empty() == false && std::abs(_pq.top()->curBottomZ() - lowest->curBottomZ()) < EPSILON) {
lowests.push_back(_pq.top());
_pq.pop();
while (line_bucket_ptr_queue.empty() == false && std::abs(line_bucket_ptr_queue.top()->curBottomZ() - lowest->curBottomZ()) < EPSILON) {
lowests.push_back(line_bucket_ptr_queue.top());
line_bucket_ptr_queue.pop();
}
for (LinesBucket *bp : lowests) {
bp->raise();
if (bp->valid()) { _pq.push(bp); }
if (bp->valid()) { line_bucket_ptr_queue.push(bp); }
}
return layerBottomZ;
}
@ -126,7 +126,7 @@ float LinesBucketQueue::getCurrBottomZ()
LineWithIDs LinesBucketQueue::getCurLines() const
{
LineWithIDs lines;
for (const LinesBucket &bucket : _buckets) {
for (const LinesBucket &bucket : line_buckets) {
if (bucket.valid()) {
LineWithIDs tmpLines = bucket.curLines();
lines.insert(lines.end(), tmpLines.begin(), tmpLines.end());

View File

@ -109,12 +109,12 @@ struct LinesBucketPtrComp
class LinesBucketQueue
{
public:
std::vector<LinesBucket> _buckets;
std::priority_queue<LinesBucket *, std::vector<LinesBucket *>, LinesBucketPtrComp> _pq;
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 _pq.empty() == false; }
bool valid() const { return line_bucket_ptr_queue.empty() == false; }
float getCurrBottomZ();
LineWithIDs getCurLines() const;
};

View File

@ -1797,7 +1797,15 @@ void Print::process(bool use_cache)
}
// BBS
if(!m_no_check)
bool has_adaptive_layer_height = false;
for (PrintObject* obj : m_objects) {
if (obj->model_object()->layer_height_profile.empty() == false) {
has_adaptive_layer_height = true;
break;
}
}
// TODO adaptive layer height won't work with conflict checker because m_fake_wipe_tower's path is generated using fixed layer height
if(!m_no_check && !has_adaptive_layer_height)
{
using Clock = std::chrono::high_resolution_clock;
auto startTime = Clock::now();

View File

@ -565,8 +565,6 @@ struct FakeWipeTower
std::vector<ExtrusionPaths> getFakeExtrusionPathsFromWipeTower() const
{
float h = height;
float lh = layer_height;
int d = scale_(depth);
int w = scale_(width);
int bd = scale_(brim_width);
@ -574,13 +572,13 @@ struct FakeWipeTower
Point maxCorner = {minCorner.x() + w, minCorner.y() + d};
std::vector<ExtrusionPaths> paths;
for (float hh = 0.f; hh < h; hh += lh) {
ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, lh);
for (float h = 0.f; h < height; h += layer_height) {
ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, layer_height);
path.polyline = {minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner};
paths.push_back({path});
if (hh == 0.f) { // add brim
ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, lh);
if (h == 0.f) { // add brim
ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, layer_height);
Point wtbminCorner = {minCorner - Point{bd, bd}};
Point wtbmaxCorner = {maxCorner + Point{bd, bd}};
fakeBrim.polyline = {wtbminCorner, {wtbmaxCorner.x(), wtbminCorner.y()}, wtbmaxCorner, {wtbminCorner.x(), wtbmaxCorner.y()}, wtbminCorner};