Fixed the orientation of ExtrusionLoops when Arachne is used.

This commit is contained in:
Lukáš Hejl 2022-06-15 23:24:43 +02:00
parent 2d7d8ba2f6
commit f34c1f14da
4 changed files with 51 additions and 7 deletions

View file

@ -354,6 +354,8 @@ static ClipperLib_Z::Paths clip_extrusion(const ClipperLib_Z::Path &subject, con
struct PerimeterGeneratorArachneExtrusion
{
Arachne::ExtrusionLine *extrusion = nullptr;
// Indicates if closed ExtrusionLine is a contour or a hole. Used it only when ExtrusionLine is a closed loop.
bool is_contour = false;
// Should this extrusion be fuzzyfied on path generation?
bool fuzzify = false;
};
@ -414,11 +416,18 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator &p
// Append paths to collection.
if (!paths.empty()) {
if (extrusion->is_closed)
extrusion_coll.entities.emplace_back(new ExtrusionLoop(std::move(paths)));
else
if (extrusion->is_closed) {
ExtrusionLoop extrusion_loop(std::move(paths));
// Restore the orientation of the extrusion loop.
if (pg_extrusion.is_contour)
extrusion_loop.make_counter_clockwise();
else
extrusion_loop.make_clockwise();
extrusion_coll.append(std::move(extrusion_loop));
} else
for (ExtrusionPath &path : paths)
extrusion_coll.entities.emplace_back(new ExtrusionPath(std::move(path)));
extrusion_coll.append(ExtrusionPath(std::move(path)));
}
}
@ -541,7 +550,7 @@ void PerimeterGenerator::process_arachne()
}
auto &best_path = all_extrusions[best_candidate];
ordered_extrusions.push_back({best_path, false});
ordered_extrusions.push_back({best_path, best_path->is_contour(), false});
processed[best_candidate] = true;
for (size_t unlocked_idx : blocking[best_candidate])
blocked[unlocked_idx]--;