Solved issue with virtual bed management.

libnest2d: Fix for unclosed polygons after merge.
This commit is contained in:
tamasmeszaros 2019-07-17 13:32:31 +02:00
parent 44801f4429
commit 2728f41123
5 changed files with 64 additions and 67 deletions

View file

@ -516,7 +516,7 @@ public:
const Vec3d& get_offset() const { return m_transformation.get_offset(); }
double get_offset(Axis axis) const { return m_transformation.get_offset(axis); }
void set_offset(const Vec3d& offset) { m_transformation.set_offset(offset); }
void set_offset(Axis axis, double offset) { m_transformation.set_offset(axis, offset); }
@ -558,15 +558,12 @@ public:
arrangement::ArrangePolygon get_arrange_polygon() const;
// Apply the arrange result on the ModelInstance
void apply_arrange_result(const arrangement::ArrangePolygon& ap,
const Vec2crd& bed_origin = {0, 0})
void apply_arrange_result(const Vec2crd& offs, double rotation)
{
// write the transformation data into the model instance
set_rotation(Z, ap.rotation);
set_offset(X, unscale<double>(ap.translation(X) + bed_origin.x()));
set_offset(Y, unscale<double>(ap.translation(Y) + bed_origin.y()));
m_arrange_cache.bed_origin = bed_origin;
m_arrange_cache.bed_idx = ap.bed_idx;
set_rotation(Z, rotation);
set_offset(X, unscale<double>(offs(X)));
set_offset(Y, unscale<double>(offs(Y)));
}
protected:
@ -601,9 +598,7 @@ private:
// Warning! This object is not guarded against concurrency.
mutable struct ArrangeCache {
bool valid = false;
Vec2crd bed_origin {0, 0};
ExPolygon poly;
int bed_idx = arrangement::UNARRANGED;
} m_arrange_cache;
};