Customized object function for arrange algorithm to arrange into a circle.

Now we optimize for smallest diameter of the circle around the arranged pile of items. This implies that we can forget about pack efficiency but the result will be better for the heat characteristics of the print bed.
This commit is contained in:
tamasmeszaros 2018-07-04 14:11:21 +02:00
parent 4b9a504c04
commit 0b914c5ea3
4 changed files with 508 additions and 374 deletions

View file

@ -687,6 +687,17 @@ public:
selector_.configure(std::forward<SelectionConfig>(sconfig)); selector_.configure(std::forward<SelectionConfig>(sconfig));
} }
void configure(const PlacementConfig& pconf) { pconfig_ = pconf; }
void configure(const SelectionConfig& sconf) { selector_.configure(sconf); }
void configure(const PlacementConfig& pconf, const SelectionConfig& sconf) {
pconfig_ = pconf;
selector_.configure(sconf);
}
void configure(const SelectionConfig& sconf, const PlacementConfig& pconf) {
pconfig_ = pconf;
selector_.configure(sconf);
}
/** /**
* \brief Arrange an input sequence and return a PackGroup object with * \brief Arrange an input sequence and return a PackGroup object with
* the packed groups corresponding to the bins. * the packed groups corresponding to the bins.

View file

@ -28,6 +28,9 @@ struct NfpPConfig {
/// Where to align the resulting packed pile /// Where to align the resulting packed pile
Alignment alignment; Alignment alignment;
std::function<double(const Nfp::Shapes<RawShape>&, double, double, double)>
object_function;
NfpPConfig(): rotations({0.0, Pi/2.0, Pi, 3*Pi/2}), NfpPConfig(): rotations({0.0, Pi/2.0, Pi, 3*Pi/2}),
alignment(Alignment::CENTER) {} alignment(Alignment::CENTER) {}
}; };
@ -213,7 +216,16 @@ class _NofitPolyPlacer: public PlacerBoilerplate<_NofitPolyPlacer<RawShape>,
const double norm_; const double norm_;
const double penality_; const double penality_;
bool static wouldFit(const RawShape& chull, const RawShape& bin) { public:
using Pile = const Nfp::Shapes<RawShape>&;
inline explicit _NofitPolyPlacer(const BinType& bin):
Base(bin),
norm_(std::sqrt(ShapeLike::area<RawShape>(bin))),
penality_(1e6*norm_) {}
bool static inline wouldFit(const RawShape& chull, const RawShape& bin) {
auto bbch = ShapeLike::boundingBox<RawShape>(chull); auto bbch = ShapeLike::boundingBox<RawShape>(chull);
auto bbin = ShapeLike::boundingBox<RawShape>(bin); auto bbin = ShapeLike::boundingBox<RawShape>(bin);
auto d = bbin.minCorner() - bbch.minCorner(); auto d = bbin.minCorner() - bbch.minCorner();
@ -222,18 +234,16 @@ class _NofitPolyPlacer: public PlacerBoilerplate<_NofitPolyPlacer<RawShape>,
return ShapeLike::isInside<RawShape>(chullcpy, bbin); return ShapeLike::isInside<RawShape>(chullcpy, bbin);
} }
bool static wouldFit(const RawShape& chull, const Box& bin) bool static inline wouldFit(const RawShape& chull, const Box& bin)
{ {
auto bbch = ShapeLike::boundingBox<RawShape>(chull); auto bbch = ShapeLike::boundingBox<RawShape>(chull);
return bbch.width() <= bin.width() && bbch.height() <= bin.height(); return wouldFit(bbch, bin);
} }
public: bool static inline wouldFit(const Box& bb, const Box& bin)
{
inline explicit _NofitPolyPlacer(const BinType& bin): return bb.width() <= bin.width() && bb.height() <= bin.height();
Base(bin), }
norm_(std::sqrt(ShapeLike::area<RawShape>(bin))),
penality_(1e6*norm_) {}
PackResult trypack(Item& item) { PackResult trypack(Item& item) {
@ -291,21 +301,13 @@ public:
pile_area += mitem.area(); pile_area += mitem.area();
} }
// Our object function for placement auto _objfunc = config_.object_function?
auto objfunc = [&] (double relpos) config_.object_function :
[this](const Nfp::Shapes<RawShape>& pile, double occupied_area,
double /*norm*/, double penality)
{ {
Vertex v = getNfpPoint(relpos);
auto d = v - iv;
d += startpos;
item.translation(d);
pile.emplace_back(item.transformedShape());
double occupied_area = pile_area + item.area();
auto ch = ShapeLike::convexHull(pile); auto ch = ShapeLike::convexHull(pile);
pile.pop_back();
// The pack ratio -- how much is the convex hull occupied // The pack ratio -- how much is the convex hull occupied
double pack_rate = occupied_area/ShapeLike::area(ch); double pack_rate = occupied_area/ShapeLike::area(ch);
@ -317,7 +319,27 @@ public:
// (larger) values. // (larger) values.
auto score = std::sqrt(waste); auto score = std::sqrt(waste);
if(!wouldFit(ch, bin_)) score = 2*penality_ - score; if(!wouldFit(ch, bin_)) score = 2*penality - score;
return score;
};
// Our object function for placement
auto objfunc = [&] (double relpos)
{
Vertex v = getNfpPoint(relpos);
auto d = v - iv;
d += startpos;
item.translation(d);
pile.emplace_back(item.transformedShape());
double occupied_area = pile_area + item.area();
double score = _objfunc(pile, occupied_area,
norm_, penality_);
pile.pop_back();
return score; return score;
}; };

View file

@ -76,360 +76,433 @@ void arrangeRectangles() {
std::vector<Item> crasher = { std::vector<Item> crasher = {
{ {
{-10836093, -2542602}, {-5000000, 8954050},
{-10834392, -1849197}, {5000000, 8954050},
{-10826793, 1172203}, {5000000, -45949},
{-10824993, 1884506}, {4972609, -568549},
{-10823291, 2547500}, {3500000, -8954050},
{-10822994, 2642700}, {-3500000, -8954050},
{-10807392, 2768295}, {-4972609, -568549},
{-10414295, 3030403}, {-5000000, -45949},
{-9677799, 3516204}, {-5000000, 8954050},
{-9555896, 3531204},
{-9445194, 3534698},
{9353008, 3487297},
{9463504, 3486999},
{9574008, 3482902},
{9695903, 3467399},
{10684803, 2805702},
{10814098, 2717803},
{10832805, 2599502},
{10836200, 2416801},
{10819705, -2650299},
{10800403, -2772300},
{10670505, -2859596},
{9800403, -3436599},
{9678203, -3516197},
{9556308, -3531196},
{9445903, -3534698},
{9084011, -3533798},
{-9234294, -3487701},
{-9462894, -3486999},
{-9573497, -3483001},
{-9695392, -3467300},
{-9816898, -3387199},
{-10429492, -2977798},
{-10821193, -2714096},
{-10836200, -2588195},
{-10836093, -2542602},
}, },
{ {
{-3533699, -9084051}, {-5000000, 8954050},
{-3487197, 9352449}, {5000000, 8954050},
{-3486797, 9462949}, {5000000, -45949},
{-3482795, 9573547}, {4972609, -568549},
{-3467201, 9695350}, {3500000, -8954050},
{-3386997, 9816949}, {-3500000, -8954050},
{-2977699, 10429548}, {-4972609, -568549},
{-2713897, 10821249}, {-5000000, -45949},
{-2587997, 10836149}, {-5000000, 8954050},
{-2542396, 10836149},
{-2054698, 10834949},
{2223503, 10824150},
{2459800, 10823547},
{2555002, 10823247},
{2642601, 10822948},
{2768301, 10807350},
{3030302, 10414247},
{3516099, 9677850},
{3531002, 9555850},
{3534502, 9445247},
{3534301, 9334949},
{3487300, -9353052},
{3486904, -9463548},
{3482801, -9574148},
{3467302, -9695848},
{2805601, -10684751},
{2717802, -10814149},
{2599403, -10832952},
{2416801, -10836149},
{-2650199, -10819749},
{-2772197, -10800451},
{-2859397, -10670450},
{-3436401, -9800451},
{-3515998, -9678350},
{-3530998, -9556451},
{-3534500, -9445848},
{-3533699, -9084051},
}, },
{ {
{-3533798, -9084051}, {-5000000, 8954050},
{-3487697, 9234249}, {5000000, 8954050},
{-3486999, 9462949}, {5000000, -45949},
{-3482997, 9573547}, {4972609, -568549},
{-3467296, 9695350}, {3500000, -8954050},
{-3387199, 9816949}, {-3500000, -8954050},
{-2977798, 10429548}, {-4972609, -568549},
{-2714096, 10821249}, {-5000000, -45949},
{-2588199, 10836149}, {-5000000, 8954050},
{-2542594, 10836149},
{-2054798, 10834949},
{2223701, 10824150},
{2459903, 10823547},
{2555202, 10823247},
{2642704, 10822948},
{2768302, 10807350},
{3030403, 10414247},
{3516204, 9677850},
{3531204, 9555850},
{3534702, 9445247},
{3487300, -9353052},
{3486999, -9463548},
{3482902, -9574148},
{3467403, -9695848},
{2805702, -10684751},
{2717803, -10814149},
{2599502, -10832952},
{2416801, -10836149},
{-2650299, -10819749},
{-2772296, -10800451},
{-2859596, -10670450},
{-3436595, -9800451},
{-3516197, -9678350},
{-3531196, -9556451},
{-3534698, -9445848},
{-3533798, -9084051},
}, },
{ {
{-49433151, 4289947}, {-5000000, 8954050},
{-49407352, 4421947}, {5000000, 8954050},
{-49355751, 4534446}, {5000000, -45949},
{-29789449, 36223850}, {4972609, -568549},
{-29737350, 36307445}, {3500000, -8954050},
{-29512149, 36401447}, {-3500000, -8954050},
{-29089149, 36511646}, {-4972609, -568549},
{-28894351, 36550342}, {-5000000, -45949},
{-18984951, 37803447}, {-5000000, 8954050},
{-18857151, 37815151},
{-18271148, 37768947},
{-18146148, 37755146},
{-17365447, 37643947},
{-17116649, 37601146},
{11243545, 29732448},
{29276451, 24568149},
{29497543, 24486148},
{29654548, 24410953},
{31574546, 23132640},
{33732849, 21695148},
{33881950, 21584445},
{34019454, 21471950},
{34623153, 20939151},
{34751945, 20816951},
{35249244, 20314647},
{36681549, 18775447},
{36766548, 18680446},
{36794250, 18647144},
{36893951, 18521953},
{37365951, 17881946},
{37440948, 17779247},
{37529243, 17642444},
{42233245, 10012245},
{42307250, 9884048},
{42452949, 9626548},
{44258949, 4766647},
{48122245, -5990951},
{48160751, -6117950},
{49381546, -17083953},
{49412246, -17420953},
{49429450, -18011253},
{49436141, -18702651},
{49438949, -20087953},
{49262947, -24000852},
{49172546, -24522455},
{48847549, -25859151},
{48623847, -26705650},
{48120246, -28514953},
{48067146, -28699455},
{48017845, -28862453},
{47941543, -29096954},
{47892547, -29246852},
{47813545, -29466651},
{47758453, -29612955},
{47307548, -30803253},
{46926544, -31807151},
{46891448, -31899551},
{46672546, -32475852},
{46502449, -32914852},
{46414451, -33140853},
{46294250, -33447650},
{46080146, -33980255},
{46039245, -34071853},
{45970542, -34186653},
{45904243, -34295955},
{45786247, -34475650},
{43063247, -37740955},
{42989547, -37815151},
{12128349, -36354953},
{12101844, -36343955},
{11806152, -36217453},
{7052848, -34171649},
{-3234352, -29743150},
{-15684650, -24381851},
{-16573852, -23998851},
{-20328948, -22381254},
{-20383052, -22357254},
{-20511447, -22280651},
{-42221252, -8719951},
{-42317150, -8653255},
{-42457851, -8528949},
{-42600151, -8399852},
{-47935852, -2722949},
{-48230651, -2316852},
{-48500850, -1713150},
{-48516853, -1676551},
{-48974651, -519649},
{-49003852, -412551},
{-49077850, -129650},
{-49239753, 735946},
{-49312652, 1188549},
{-49349349, 1467647},
{-49351650, 1513347},
{-49438949, 4165744},
{-49433151, 4289947},
},
// {
// {6000, 5851},
// {-6000, -5851},
// {6000, 5851},
// },
{
{-10836097, -2542396},
{-10834396, -1848999},
{-10826797, 1172000},
{-10825000, 1884403},
{-10823299, 2547401},
{-10822998, 2642604},
{-10807395, 2768299},
{-10414299, 3030300},
{-9677799, 3516101},
{-9555896, 3531002},
{-9445198, 3534500},
{-9334899, 3534297},
{9353000, 3487300},
{9463499, 3486904},
{9573999, 3482799},
{9695901, 3467300},
{10684803, 2805603},
{10814102, 2717800},
{10832803, 2599399},
{10836200, 2416797},
{10819700, -2650199},
{10800401, -2772201},
{10670499, -2859397},
{9800401, -3436397},
{9678201, -3515998},
{9556303, -3530998},
{9445901, -3534500},
{9083999, -3533699},
{-9352500, -3487201},
{-9462898, -3486797},
{-9573501, -3482799},
{-9695396, -3467201},
{-9816898, -3386997},
{-10429500, -2977699},
{-10821197, -2713897},
{-10836196, -2588001},
{-10836097, -2542396},
}, },
{ {
{-47073699, 26300853}, {-5000000, 8954050},
{-47009803, 27392650}, {5000000, 8954050},
{-46855804, 28327953}, {5000000, -45949},
{-46829402, 28427051}, {4972609, -568549},
{-46764102, 28657550}, {3500000, -8954050},
{-46200401, 30466648}, {-3500000, -8954050},
{-46066703, 30832347}, {-4972609, -568549},
{-45887104, 31247554}, {-5000000, -45949},
{-45663700, 31670848}, {-5000000, 8954050},
{-45414802, 32080554}, },
{-45273700, 32308956}, {
{-45179702, 32431850}, {-5000000, 8954050},
{-45057804, 32549350}, {5000000, 8954050},
{-34670803, 40990154}, {5000000, -45949},
{-34539802, 41094348}, {4972609, -568549},
{-34393600, 41184452}, {3500000, -8954050},
{-34284805, 41229953}, {-3500000, -8954050},
{-34080402, 41267154}, {-4972609, -568549},
{17335296, 48077648}, {-5000000, -45949},
{18460296, 48153553}, {-5000000, 8954050},
{18976600, 48182147}, },
{20403999, 48148555}, {
{20562301, 48131153}, {-9945219, -3065619},
{20706001, 48102855}, {-9781479, -2031780},
{20938796, 48053150}, {-9510560, -1020730},
{21134101, 48010051}, {-9135450, -43529},
{21483192, 47920154}, {-2099999, 14110899},
{21904701, 47806346}, {2099999, 14110899},
{22180099, 47670154}, {9135450, -43529},
{22357795, 47581645}, {9510560, -1020730},
{22615295, 47423046}, {9781479, -2031780},
{22782295, 47294651}, {9945219, -3065619},
{24281791, 45908344}, {10000000, -4110899},
{24405296, 45784854}, {9945219, -5156179},
{41569297, 21952449}, {9781479, -6190020},
{41784301, 21638050}, {9510560, -7201069},
{41938491, 21393650}, {9135450, -8178270},
{42030899, 21245052}, {8660249, -9110899},
{42172996, 21015850}, {8090169, -9988750},
{42415298, 20607151}, {7431449, -10802200},
{42468299, 20504650}, {6691309, -11542300},
{42553100, 20320850}, {5877850, -12201100},
{42584594, 20250644}, {5000000, -12771100},
{42684997, 20004344}, {4067369, -13246399},
{42807098, 19672351}, {3090169, -13621500},
{42939002, 19255153}, {2079119, -13892399},
{43052299, 18693950}, {1045279, -14056099},
{45094100, 7846851}, {0, -14110899},
{45118400, 7684154}, {-1045279, -14056099},
{47079101, -16562252}, {-2079119, -13892399},
{47082000, -16705646}, {-3090169, -13621500},
{46916297, -22172447}, {-4067369, -13246399},
{46911598, -22294349}, {-5000000, -12771100},
{46874893, -22358146}, {-5877850, -12201100},
{44866996, -25470146}, {-6691309, -11542300},
{30996795, -46852050}, {-7431449, -10802200},
{30904998, -46933750}, {-8090169, -9988750},
{30864791, -46945850}, {-8660249, -9110899},
{9315696, -48169147}, {-9135450, -8178270},
{9086494, -48182147}, {-9510560, -7201069},
{8895500, -48160049}, {-9781479, -6190020},
{8513496, -48099548}, {-9945219, -5156179},
{8273696, -48057350}, {-10000000, -4110899},
{8180198, -48039051}, {-9945219, -3065619},
{7319801, -47854949}, },
{6288299, -47569950}, {
{6238498, -47554248}, {-9945219, -3065619},
{5936199, -47453250}, {-9781479, -2031780},
{-11930000, -41351551}, {-9510560, -1020730},
{-28986402, -33654148}, {-9135450, -43529},
{-29111103, -33597148}, {-2099999, 14110899},
{-29201803, -33544147}, {2099999, 14110899},
{-29324401, -33467845}, {9135450, -43529},
{-29467000, -33352848}, {9510560, -1020730},
{-29606603, -33229351}, {9781479, -2031780},
{-31140401, -31849147}, {9945219, -3065619},
{-31264303, -31736450}, {10000000, -4110899},
{-31385803, -31625452}, {9945219, -5156179},
{-31829103, -31216148}, {9781479, -6190020},
{-32127403, -30935951}, {9510560, -7201069},
{-32253803, -30809648}, {9135450, -8178270},
{-32364803, -30672147}, {8660249, -9110899},
{-34225402, -28078847}, {8090169, -9988750},
{-35819404, -25762451}, {7431449, -10802200},
{-36304801, -25035346}, {6691309, -11542300},
{-36506103, -24696445}, {5877850, -12201100},
{-36574104, -24560146}, {5000000, -12771100},
{-36926700, -23768646}, {4067369, -13246399},
{-39767402, -17341148}, {3090169, -13621500},
{-39904102, -16960147}, {2079119, -13892399},
{-41008602, -11799850}, {1045279, -14056099},
{-43227401, -704147}, {0, -14110899},
{-43247303, -577148}, {-1045279, -14056099},
{-47057403, 24847454}, {-2079119, -13892399},
{-47077602, 25021648}, {-3090169, -13621500},
{-47080101, 25128650}, {-4067369, -13246399},
{-47082000, 25562953}, {-5000000, -12771100},
{-47073699, 26300853}, {-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-9945219, -3065619},
{-9781479, -2031780},
{-9510560, -1020730},
{-9135450, -43529},
{-2099999, 14110899},
{2099999, 14110899},
{9135450, -43529},
{9510560, -1020730},
{9781479, -2031780},
{9945219, -3065619},
{10000000, -4110899},
{9945219, -5156179},
{9781479, -6190020},
{9510560, -7201069},
{9135450, -8178270},
{8660249, -9110899},
{8090169, -9988750},
{7431449, -10802200},
{6691309, -11542300},
{5877850, -12201100},
{5000000, -12771100},
{4067369, -13246399},
{3090169, -13621500},
{2079119, -13892399},
{1045279, -14056099},
{0, -14110899},
{-1045279, -14056099},
{-2079119, -13892399},
{-3090169, -13621500},
{-4067369, -13246399},
{-5000000, -12771100},
{-5877850, -12201100},
{-6691309, -11542300},
{-7431449, -10802200},
{-8090169, -9988750},
{-8660249, -9110899},
{-9135450, -8178270},
{-9510560, -7201069},
{-9781479, -6190020},
{-9945219, -5156179},
{-10000000, -4110899},
{-9945219, -3065619},
},
{
{-18000000, -1000000},
{-15000000, 22000000},
{-11000000, 26000000},
{11000000, 26000000},
{15000000, 22000000},
{18000000, -1000000},
{18000000, -26000000},
{-18000000, -26000000},
{-18000000, -1000000},
}, },
}; };
@ -445,14 +518,28 @@ void arrangeRectangles() {
using Packer = Arranger<NfpPlacer, DJDHeuristic>; using Packer = Arranger<NfpPlacer, DJDHeuristic>;
Packer arrange(bin, min_obj_distance);
Packer::PlacementConfig pconf; Packer::PlacementConfig pconf;
pconf.alignment = NfpPlacer::Config::Alignment::CENTER; pconf.alignment = NfpPlacer::Config::Alignment::CENTER;
// pconf.rotations = {0.0, Pi/2.0, Pi, 3*Pi/2}; pconf.rotations = {0.0/*, Pi/2.0, Pi, 3*Pi/2*/};
pconf.object_function = [&bin](NfpPlacer::Pile pile, double area,
double norm, double penality) {
auto bb = ShapeLike::boundingBox(pile);
double score = (2*bb.width() + 2*bb.height()) / norm;
if(!NfpPlacer::wouldFit(bb, bin)) score = 2*penality - score;
return score;
};
Packer::SelectionConfig sconf; Packer::SelectionConfig sconf;
sconf.allow_parallel = true; sconf.allow_parallel = true;
sconf.force_parallel = true; sconf.force_parallel = true;
sconf.try_reverse_order = false; sconf.try_reverse_order = true;
Packer arrange(bin, min_obj_distance, pconf, sconf);
arrange.configure(pconf, sconf);
arrange.progressIndicator([&](unsigned r){ arrange.progressIndicator([&](unsigned r){
// svg::SVGWriter::Config conf; // svg::SVGWriter::Config conf;
@ -462,7 +549,7 @@ void arrangeRectangles() {
// svgw.writePackGroup(arrange.lastResult()); // svgw.writePackGroup(arrange.lastResult());
// svgw.save("debout"); // svgw.save("debout");
std::cout << "Remaining items: " << r << std::endl; std::cout << "Remaining items: " << r << std::endl;
}).useMinimumBoundigBoxRotation(); })/*.useMinimumBoundigBoxRotation()*/;
Benchmark bench; Benchmark bench;

View file

@ -480,8 +480,8 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb,
SConf scfg; SConf scfg;
scfg.try_reverse_order = true; scfg.try_reverse_order = true;
scfg.allow_parallel = true; scfg.allow_parallel = false;
scfg.force_parallel = true; scfg.force_parallel = false;
pcfg.alignment = PConf::Alignment::CENTER; pcfg.alignment = PConf::Alignment::CENTER;
@ -489,6 +489,20 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb,
// handle different rotations // handle different rotations
// arranger.useMinimumBoundigBoxRotation(); // arranger.useMinimumBoundigBoxRotation();
pcfg.rotations = { 0.0 }; pcfg.rotations = { 0.0 };
pcfg.object_function = [&bin](
NfpPlacer::Pile pile, double /*area*/, double norm, double penality)
{
auto bb = ShapeLike::boundingBox(pile);
// We will optimize to the diameter of the circle around the bounding box
double score = PointLike::distance(bb.minCorner(), bb.maxCorner()) / norm;
if(!NfpPlacer::wouldFit(bb, bin)) score = 2*penality - score;
return score;
};
Arranger arranger(bin, min_obj_distance, pcfg, scfg); Arranger arranger(bin, min_obj_distance, pcfg, scfg);
arranger.progressIndicator(progressind); arranger.progressIndicator(progressind);