mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Fix libnest2d tests
This commit is contained in:
parent
bc315f4c2c
commit
b5215dae1b
3 changed files with 20 additions and 10 deletions
|
@ -68,11 +68,11 @@ public:
|
||||||
return toWallPoly(item, Dir::DOWN);
|
return toWallPoly(item, Dir::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Unit availableSpaceLeft(const Item& item) {
|
inline Coord availableSpaceLeft(const Item& item) {
|
||||||
return availableSpace(item, Dir::LEFT);
|
return availableSpace(item, Dir::LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Unit availableSpaceDown(const Item& item) {
|
inline Coord availableSpaceDown(const Item& item) {
|
||||||
return availableSpace(item, Dir::DOWN);
|
return availableSpace(item, Dir::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ protected:
|
||||||
// Get initial position for item in the top right corner
|
// Get initial position for item in the top right corner
|
||||||
setInitialPosition(item);
|
setInitialPosition(item);
|
||||||
|
|
||||||
Unit d = availableSpaceDown(item);
|
Coord d = availableSpaceDown(item);
|
||||||
auto eps = config_.epsilon;
|
auto eps = config_.epsilon;
|
||||||
bool can_move = d > eps;
|
bool can_move = d > eps;
|
||||||
bool can_be_packed = can_move;
|
bool can_be_packed = can_move;
|
||||||
|
@ -179,7 +179,7 @@ protected:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit availableSpace(const Item& _item, const Dir dir) {
|
Coord availableSpace(const Item& _item, const Dir dir) {
|
||||||
|
|
||||||
Item item (_item.transformedShape());
|
Item item (_item.transformedShape());
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ protected:
|
||||||
cmp);
|
cmp);
|
||||||
|
|
||||||
// Get the initial distance in floating point
|
// Get the initial distance in floating point
|
||||||
Unit m = getCoord(*minvertex_it);
|
Coord m = getCoord(*minvertex_it);
|
||||||
|
|
||||||
// Check available distance for every vertex of item to the objects
|
// Check available distance for every vertex of item to the objects
|
||||||
// in the way for the nearest intersection
|
// in the way for the nearest intersection
|
||||||
|
|
|
@ -18,7 +18,6 @@ public:
|
||||||
using Segment = _Segment<Vertex>;
|
using Segment = _Segment<Vertex>;
|
||||||
using BinType = TBin;
|
using BinType = TBin;
|
||||||
using Coord = TCoord<Vertex>;
|
using Coord = TCoord<Vertex>;
|
||||||
using Unit = Coord;
|
|
||||||
using Config = Cfg;
|
using Config = Cfg;
|
||||||
using ItemGroup = _ItemGroup<RawShape>;
|
using ItemGroup = _ItemGroup<RawShape>;
|
||||||
using DefaultIter = typename ItemGroup::const_iterator;
|
using DefaultIter = typename ItemGroup::const_iterator;
|
||||||
|
@ -131,7 +130,6 @@ using typename Base::Vertex; \
|
||||||
using typename Base::Segment; \
|
using typename Base::Segment; \
|
||||||
using typename Base::PackResult; \
|
using typename Base::PackResult; \
|
||||||
using typename Base::Coord; \
|
using typename Base::Coord; \
|
||||||
using typename Base::Unit; \
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,8 +363,14 @@ TEST(GeometryAlgorithms, ArrangeRectanglesTight)
|
||||||
{5, 5},
|
{5, 5},
|
||||||
{20, 20} };
|
{20, 20} };
|
||||||
|
|
||||||
|
Box bin(210, 250, {105, 125});
|
||||||
|
|
||||||
Nester<BottomLeftPlacer, DJDHeuristic> arrange(Box(210, 250));
|
ASSERT_EQ(bin.width(), 210);
|
||||||
|
ASSERT_EQ(bin.height(), 250);
|
||||||
|
ASSERT_EQ(getX(bin.center()), 105);
|
||||||
|
ASSERT_EQ(getY(bin.center()), 125);
|
||||||
|
|
||||||
|
Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin);
|
||||||
|
|
||||||
auto groups = arrange.execute(rects.begin(), rects.end());
|
auto groups = arrange.execute(rects.begin(), rects.end());
|
||||||
|
|
||||||
|
@ -416,10 +422,16 @@ TEST(GeometryAlgorithms, ArrangeRectanglesLoose)
|
||||||
{5, 5},
|
{5, 5},
|
||||||
{20, 20} };
|
{20, 20} };
|
||||||
|
|
||||||
|
Box bin(210, 250, {105, 125});
|
||||||
|
|
||||||
|
ASSERT_EQ(bin.width(), 210);
|
||||||
|
ASSERT_EQ(bin.height(), 250);
|
||||||
|
ASSERT_EQ(getX(bin.center()), 105);
|
||||||
|
ASSERT_EQ(getY(bin.center()), 125);
|
||||||
|
|
||||||
Coord min_obj_distance = 5;
|
Coord min_obj_distance = 5;
|
||||||
|
|
||||||
Nester<BottomLeftPlacer, DJDHeuristic> arrange(Box(210, 250),
|
Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin, min_obj_distance);
|
||||||
min_obj_distance);
|
|
||||||
|
|
||||||
auto groups = arrange.execute(rects.begin(), rects.end());
|
auto groups = arrange.execute(rects.begin(), rects.end());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue