mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 15:51:10 -06:00
AppController integration
This commit is contained in:
parent
5446b9f1e5
commit
ad4d95f60c
17 changed files with 1435 additions and 12 deletions
|
@ -142,6 +142,9 @@ inline void ShapeLike::offset(PolygonImpl& sh, TCoord<PointImpl> distance) {
|
|||
using ClipperLib::etClosedPolygon;
|
||||
using ClipperLib::Paths;
|
||||
|
||||
// If the input is not at least a triangle, we can not do this algorithm
|
||||
if(sh.Contour.size() <= 3) throw GeometryException(GeoErr::OFFSET);
|
||||
|
||||
ClipperOffset offs;
|
||||
Paths result;
|
||||
offs.AddPath(sh.Contour, jtMiter, etClosedPolygon);
|
||||
|
@ -151,7 +154,8 @@ inline void ShapeLike::offset(PolygonImpl& sh, TCoord<PointImpl> distance) {
|
|||
// it removes the last vertex as well so boost will not have a closed
|
||||
// polygon
|
||||
|
||||
assert(result.size() == 1);
|
||||
if(result.size() != 1) throw GeometryException(GeoErr::OFFSET);
|
||||
|
||||
sh.Contour = result.front();
|
||||
|
||||
// recreate closed polygon
|
||||
|
|
|
@ -205,5 +205,36 @@ inline Radians::Radians(const Degrees °s): Double( degs * Pi/180) {}
|
|||
|
||||
inline double Radians::toDegrees() { return operator Degrees(); }
|
||||
|
||||
enum class GeoErr : std::size_t {
|
||||
OFFSET,
|
||||
MERGE,
|
||||
NFP
|
||||
};
|
||||
|
||||
static const std::string ERROR_STR[] = {
|
||||
"Offsetting could not be done! An invalid geometry may have been added."
|
||||
"Error while merging geometries!"
|
||||
"No fit polygon cannaot be calculated."
|
||||
};
|
||||
|
||||
class GeometryException: public std::exception {
|
||||
|
||||
virtual const char * errorstr(GeoErr errcode) const {
|
||||
return ERROR_STR[static_cast<std::size_t>(errcode)].c_str();
|
||||
}
|
||||
|
||||
GeoErr errcode_;
|
||||
public:
|
||||
|
||||
GeometryException(GeoErr code): errcode_(code) {}
|
||||
|
||||
GeoErr errcode() const { return errcode_; }
|
||||
|
||||
virtual const char * what() const override {
|
||||
return errorstr(errcode_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // LIBNEST2D_CONFIG_HPP
|
||||
|
|
|
@ -648,6 +648,8 @@ public:
|
|||
|
||||
using IndexedPackGroup = _IndexedPackGroup<typename Item::ShapeType>;
|
||||
using PackGroup = _PackGroup<typename Item::ShapeType>;
|
||||
using ResultType = PackGroup;
|
||||
using ResultTypeIndexed = IndexedPackGroup;
|
||||
|
||||
private:
|
||||
BinType bin_;
|
||||
|
|
|
@ -74,10 +74,370 @@ void arrangeRectangles() {
|
|||
// {{0, 0}, {0, 20*SCALE}, {10*SCALE, 0}, {0, 0}}
|
||||
// };
|
||||
|
||||
std::vector<Item> crasher = {
|
||||
{
|
||||
{-10836093, -2542602},
|
||||
{-10834392, -1849197},
|
||||
{-10826793, 1172203},
|
||||
{-10824993, 1884506},
|
||||
{-10823291, 2547500},
|
||||
{-10822994, 2642700},
|
||||
{-10807392, 2768295},
|
||||
{-10414295, 3030403},
|
||||
{-9677799, 3516204},
|
||||
{-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},
|
||||
{-3487197, 9352449},
|
||||
{-3486797, 9462949},
|
||||
{-3482795, 9573547},
|
||||
{-3467201, 9695350},
|
||||
{-3386997, 9816949},
|
||||
{-2977699, 10429548},
|
||||
{-2713897, 10821249},
|
||||
{-2587997, 10836149},
|
||||
{-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},
|
||||
{-3487697, 9234249},
|
||||
{-3486999, 9462949},
|
||||
{-3482997, 9573547},
|
||||
{-3467296, 9695350},
|
||||
{-3387199, 9816949},
|
||||
{-2977798, 10429548},
|
||||
{-2714096, 10821249},
|
||||
{-2588199, 10836149},
|
||||
{-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},
|
||||
{-49407352, 4421947},
|
||||
{-49355751, 4534446},
|
||||
{-29789449, 36223850},
|
||||
{-29737350, 36307445},
|
||||
{-29512149, 36401447},
|
||||
{-29089149, 36511646},
|
||||
{-28894351, 36550342},
|
||||
{-18984951, 37803447},
|
||||
{-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},
|
||||
{-47009803, 27392650},
|
||||
{-46855804, 28327953},
|
||||
{-46829402, 28427051},
|
||||
{-46764102, 28657550},
|
||||
{-46200401, 30466648},
|
||||
{-46066703, 30832347},
|
||||
{-45887104, 31247554},
|
||||
{-45663700, 31670848},
|
||||
{-45414802, 32080554},
|
||||
{-45273700, 32308956},
|
||||
{-45179702, 32431850},
|
||||
{-45057804, 32549350},
|
||||
{-34670803, 40990154},
|
||||
{-34539802, 41094348},
|
||||
{-34393600, 41184452},
|
||||
{-34284805, 41229953},
|
||||
{-34080402, 41267154},
|
||||
{17335296, 48077648},
|
||||
{18460296, 48153553},
|
||||
{18976600, 48182147},
|
||||
{20403999, 48148555},
|
||||
{20562301, 48131153},
|
||||
{20706001, 48102855},
|
||||
{20938796, 48053150},
|
||||
{21134101, 48010051},
|
||||
{21483192, 47920154},
|
||||
{21904701, 47806346},
|
||||
{22180099, 47670154},
|
||||
{22357795, 47581645},
|
||||
{22615295, 47423046},
|
||||
{22782295, 47294651},
|
||||
{24281791, 45908344},
|
||||
{24405296, 45784854},
|
||||
{41569297, 21952449},
|
||||
{41784301, 21638050},
|
||||
{41938491, 21393650},
|
||||
{42030899, 21245052},
|
||||
{42172996, 21015850},
|
||||
{42415298, 20607151},
|
||||
{42468299, 20504650},
|
||||
{42553100, 20320850},
|
||||
{42584594, 20250644},
|
||||
{42684997, 20004344},
|
||||
{42807098, 19672351},
|
||||
{42939002, 19255153},
|
||||
{43052299, 18693950},
|
||||
{45094100, 7846851},
|
||||
{45118400, 7684154},
|
||||
{47079101, -16562252},
|
||||
{47082000, -16705646},
|
||||
{46916297, -22172447},
|
||||
{46911598, -22294349},
|
||||
{46874893, -22358146},
|
||||
{44866996, -25470146},
|
||||
{30996795, -46852050},
|
||||
{30904998, -46933750},
|
||||
{30864791, -46945850},
|
||||
{9315696, -48169147},
|
||||
{9086494, -48182147},
|
||||
{8895500, -48160049},
|
||||
{8513496, -48099548},
|
||||
{8273696, -48057350},
|
||||
{8180198, -48039051},
|
||||
{7319801, -47854949},
|
||||
{6288299, -47569950},
|
||||
{6238498, -47554248},
|
||||
{5936199, -47453250},
|
||||
{-11930000, -41351551},
|
||||
{-28986402, -33654148},
|
||||
{-29111103, -33597148},
|
||||
{-29201803, -33544147},
|
||||
{-29324401, -33467845},
|
||||
{-29467000, -33352848},
|
||||
{-29606603, -33229351},
|
||||
{-31140401, -31849147},
|
||||
{-31264303, -31736450},
|
||||
{-31385803, -31625452},
|
||||
{-31829103, -31216148},
|
||||
{-32127403, -30935951},
|
||||
{-32253803, -30809648},
|
||||
{-32364803, -30672147},
|
||||
{-34225402, -28078847},
|
||||
{-35819404, -25762451},
|
||||
{-36304801, -25035346},
|
||||
{-36506103, -24696445},
|
||||
{-36574104, -24560146},
|
||||
{-36926700, -23768646},
|
||||
{-39767402, -17341148},
|
||||
{-39904102, -16960147},
|
||||
{-41008602, -11799850},
|
||||
{-43227401, -704147},
|
||||
{-43247303, -577148},
|
||||
{-47057403, 24847454},
|
||||
{-47077602, 25021648},
|
||||
{-47080101, 25128650},
|
||||
{-47082000, 25562953},
|
||||
{-47073699, 26300853},
|
||||
},
|
||||
};
|
||||
|
||||
std::vector<Item> input;
|
||||
input.insert(input.end(), prusaParts().begin(), prusaParts().end());
|
||||
// input.insert(input.end(), prusaParts().begin(), prusaParts().end());
|
||||
// input.insert(input.end(), stegoParts().begin(), stegoParts().end());
|
||||
// input.insert(input.end(), rects.begin(), rects.end());
|
||||
input.insert(input.end(), crasher.begin(), crasher.end());
|
||||
|
||||
Box bin(250*SCALE, 210*SCALE);
|
||||
|
||||
|
@ -90,7 +450,7 @@ void arrangeRectangles() {
|
|||
// pconf.rotations = {0.0, Pi/2.0, Pi, 3*Pi/2};
|
||||
Packer::SelectionConfig sconf;
|
||||
sconf.allow_parallel = true;
|
||||
sconf.force_parallel = false;
|
||||
sconf.force_parallel = true;
|
||||
sconf.try_reverse_order = false;
|
||||
Packer arrange(bin, min_obj_distance, pconf, sconf);
|
||||
|
||||
|
@ -107,8 +467,17 @@ void arrangeRectangles() {
|
|||
Benchmark bench;
|
||||
|
||||
bench.start();
|
||||
auto result = arrange.arrange(input.begin(),
|
||||
input.end());
|
||||
Packer::ResultType result;
|
||||
|
||||
try {
|
||||
result = arrange.arrange(input.begin(), input.end());
|
||||
} catch(GeometryException& ge) {
|
||||
std::cerr << "Geometry error: " << ge.what() << std::endl;
|
||||
return ;
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
bench.stop();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue