Parallel placer now works with the custom Slic3r object function. Works an order of magnitude faster.

This commit is contained in:
tamasmeszaros
2018-08-22 13:52:41 +02:00
parent 8617b0a409
commit e522ad1a00
18 changed files with 739 additions and 296 deletions

View File

@@ -102,17 +102,17 @@ TEST(BasicFunctionality, creationAndDestruction)
TEST(GeometryAlgorithms, boundingCircle) {
using namespace libnest2d;
using strategies::boundingCircle;
using placers::boundingCircle;
PolygonImpl p = {{{0, 10}, {10, 0}, {0, -10}, {0, 10}}, {}};
_Circle<PointImpl> c = boundingCircle<PolygonImpl>(p);
Circle c = boundingCircle(p);
ASSERT_EQ(c.center().X, 0);
ASSERT_EQ(c.center().Y, 0);
ASSERT_DOUBLE_EQ(c.radius(), 10);
shapelike::translate(p, PointImpl{10, 10});
c = boundingCircle<PolygonImpl>(p);
c = boundingCircle(p);
ASSERT_EQ(c.center().X, 10);
ASSERT_EQ(c.center().Y, 10);
@@ -712,7 +712,7 @@ void testNfp(const std::vector<ItemPair>& testdata) {
auto& exportfun = exportSVG<SCALE, Box>;
auto onetest = [&](Item& orbiter, Item& stationary){
auto onetest = [&](Item& orbiter, Item& stationary, unsigned testidx){
testcase++;
orbiter.translate({210*SCALE, 0});
@@ -720,15 +720,19 @@ void testNfp(const std::vector<ItemPair>& testdata) {
auto&& nfp = nfp::noFitPolygon<lvl>(stationary.rawShape(),
orbiter.transformedShape());
strategies::correctNfpPosition(nfp, stationary, orbiter);
placers::correctNfpPosition(nfp, stationary, orbiter);
auto v = shapelike::isValid(nfp.first);
auto valid = shapelike::isValid(nfp.first);
if(!v.first) {
std::cout << v.second << std::endl;
}
/*Item infp(nfp.first);
if(!valid.first) {
std::cout << "test instance: " << testidx << " "
<< valid.second << std::endl;
std::vector<std::reference_wrapper<Item>> inp = {std::ref(infp)};
exportfun(inp, bin, testidx);
}*/
ASSERT_TRUE(v.first);
ASSERT_TRUE(valid.first);
Item infp(nfp.first);
@@ -748,7 +752,7 @@ void testNfp(const std::vector<ItemPair>& testdata) {
bool touching = Item::touches(tmp, stationary);
if(!touching) {
if(!touching || !valid.first) {
std::vector<std::reference_wrapper<Item>> inp = {
std::ref(stationary), std::ref(tmp), std::ref(infp)
};
@@ -760,16 +764,18 @@ void testNfp(const std::vector<ItemPair>& testdata) {
}
};
unsigned tidx = 0;
for(auto& td : testdata) {
auto orbiter = td.orbiter;
auto stationary = td.stationary;
onetest(orbiter, stationary);
onetest(orbiter, stationary, tidx++);
}
tidx = 0;
for(auto& td : testdata) {
auto orbiter = td.stationary;
auto stationary = td.orbiter;
onetest(orbiter, stationary);
onetest(orbiter, stationary, tidx++);
}
}
}
@@ -796,7 +802,7 @@ TEST(GeometryAlgorithms, pointOnPolygonContour) {
Rectangle input(10, 10);
strategies::EdgeCache<PolygonImpl> ecache(input);
placers::EdgeCache<PolygonImpl> ecache(input);
auto first = *input.begin();
ASSERT_TRUE(getX(first) == getX(ecache.coords(0)));