| 1 | /*************************************************************************** |
| 2 | * This file is part of Robocut. * |
| 3 | * Copyright (C) 2010 Markus Schulz <[email protected]> * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 3 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #include "PathSorter.h"cxx . . $ `<file>/PathSorter.h`/ |
| 22 | #include <cmath> |
| 23 | #include <QSvgRenderer> |
| 24 | #include <iostream> |
| 25 | |
| 26 | using namespace std; |
| 27 | |
| 28 | PathSortercxx . . $ PathSorter#::PathSortercxx . . $ PathSorter#PathSorter(49f6e7a06ebc5aa8). ( ) {} |
| 29 | PathSortercxx . . $ PathSorter#::PathSortercxx . . $ PathSorter#PathSorter(dcc77b921aa1e136). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths, qrealcxx . . $ qreal# mediaheight ) |
| 30 | { |
| 31 | getQListcxx . . $ PathSorter#getQList(dc1c4aa334aff080).(inpathscxx . . $ QList#QList(3d2301cfd89f773a).); |
| 32 | mediaHeightcxx . . $ PathSorter#mediaHeight. = mediaheight; |
| 33 | } |
| 34 | PathSortercxx . . $ PathSorter#::~cxx . . $ PathSorter#`~PathSorter`(49f6e7a06ebc5aa8).PathSortercxx . . $ PathSorter# ( ) { } |
| 35 | |
| 36 | void PathSortercxx . . $ PathSorter#::getQListcxx . . $ PathSorter#getQList(dc1c4aa334aff080). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 37 | { |
| 38 | pathToSortcxx . . $ PathSorter#pathToSort. =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#>(inpaths); |
| 39 | } |
| 40 | |
| 41 | void PathSortercxx . . $ PathSorter#::setMediaHeightcxx . . $ PathSorter#setMediaHeight(ba8836b59fb42830).(qrealcxx . . $ qreal# mediaheight) |
| 42 | { |
| 43 | mediaHeightcxx . . $ PathSorter#mediaHeight. = mediaheight; |
| 44 | } |
| 45 | |
| 46 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::UnSortcxx . . $ PathSorter#UnSort(5dd9053a288285ea). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 47 | { |
| 48 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpaths = QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths); |
| 49 | return outpathscxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 50 | } |
| 51 | |
| 52 | bool PathSortercxx . . $ PathSorter#::MyLessThancxx . . $ PathSorter#MyLessThan(e28f9b805ec53022).(const QPolygonFcxx . . $ QPolygonF# &p1, const QPolygonFcxx . . $ QPolygonF# &p2) |
| 53 | { |
| 54 | qrealcxx . . $ qreal# testx1 = p1[cxx . . $ QVector#`operator[]`(e2681f9bb6b2f357).0].xcxx . . $ QPointF#x(21b6c25e127938e2).(); |
| 55 | qrealcxx . . $ qreal# testx2 = p2[cxx . . $ QVector#`operator[]`(e2681f9bb6b2f357).0].xcxx . . $ QPointF#x(21b6c25e127938e2).(); |
| 56 | qrealcxx . . $ qreal# testy1 = p1[cxx . . $ QVector#`operator[]`(e2681f9bb6b2f357).0].ycxx . . $ QPointF#y(21b6c25e127938e2).(); |
| 57 | qrealcxx . . $ qreal# testy2 = p2[cxx . . $ QVector#`operator[]`(e2681f9bb6b2f357).0].ycxx . . $ QPointF#y(21b6c25e127938e2).(); |
| 58 | if(testy1 == testy2) return testx1 > testx2; |
| 59 | else return testy1 > testy2; |
| 60 | } |
| 61 | |
| 62 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::Sortcxx . . $ PathSorter#Sort(5dd9053a288285ea). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 63 | { |
| 64 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpaths = QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths); |
| 65 | qSortcxx . . $ qSort(4d3091562df4e52e).(outpathscxx . . $ QList#iterator#iterator(fe70663a9b8f3744)..begincxx . . $ QList#begin(ca2520f641887418).(), outpathscxx . . $ QList#iterator#iterator(fe70663a9b8f3744)..endcxx . . $ QList#end(ca2520f641887418).(), MyLessThancxx . . $ PathSorter#MyLessThan(e28f9b805ec53022).); |
| 66 | return outpathscxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 67 | } |
| 68 | |
| 69 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::BestSortcxx . . $ PathSorter#BestSort(5dd9053a288285ea). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 70 | { |
| 71 | qrealcxx . . $ qreal# inpath = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(inpathscxx . . $ QList#QList(3d2301cfd89f773a).); |
| 72 | qrealcxx . . $ qreal# sortpath = inpath; |
| 73 | qrealcxx . . $ qreal# tsppath = inpath, temppath; |
| 74 | qrealcxx . . $ qreal# tsppath2 = inpath; |
| 75 | coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."in path: "<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). inpath <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 76 | |
| 77 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathSort = Sortcxx . . $ QList#QList(b1a5d2b9a710f6d1).(QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths)); |
| 78 | sortpath = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathSortcxx . . $ QList#QList(3d2301cfd89f773a).); |
| 79 | coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."Sort outpath: "<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). sortpath <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 80 | |
| 81 | int bestpath=1; |
| 82 | for (int i = 1; i < inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()/2; i++) |
| 83 | { |
| 84 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathTSP = GroupTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).(QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths),i); |
| 85 | temppath = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathTSPcxx . . $ QList#QList(3d2301cfd89f773a).); |
| 86 | //cout<<"xTSPSort outpaths: "<< temppath << " Groups " << i <<endl; |
| 87 | if (temppath < tsppath) |
| 88 | { |
| 89 | bestpath = i; |
| 90 | tsppath = temppath; |
| 91 | } |
| 92 | |
| 93 | } |
| 94 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathTSP = GroupTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).(QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths),bestpath); |
| 95 | tsppath = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathTSPcxx . . $ QList#QList(3d2301cfd89f773a).); |
| 96 | coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."TSPSort outpaths: "<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). tsppath <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Groups " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). bestpath <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 97 | |
| 98 | |
| 99 | int bestpath2=1; |
| 100 | for (int i = 1; i < outpathSort.sizecxx . . $ QList#size(455f465bc33b4cdf).()/2; i++) |
| 101 | { |
| 102 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathTSP2 = GroupTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).(QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(outpathSort),i); |
| 103 | temppath = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathTSP2cxx . . $ QList#QList(3d2301cfd89f773a).); |
| 104 | //cout<<"xxTSPSort outpaths: "<< temppath << " Groups " << i <<endl; |
| 105 | if (temppath < tsppath2) |
| 106 | { |
| 107 | bestpath2 = i; |
| 108 | tsppath2 = temppath; |
| 109 | } |
| 110 | |
| 111 | } |
| 112 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathTSP2 = GroupTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).(QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(outpathSort),bestpath2); |
| 113 | tsppath2 = getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathTSP2cxx . . $ QList#QList(3d2301cfd89f773a).); |
| 114 | coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."TSPSort outpath sort: "<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). tsppath2 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Groups " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). bestpath2 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 115 | |
| 116 | if(tsppath < tsppath2 && tsppath < tsppath2) return outpathTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 117 | if(tsppath2 < tsppath && tsppath2 < tsppath) return outpathTSP2cxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 118 | if(tsppath2 < sortpath && tsppath2 < inpath) return outpathTSP2cxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 119 | if(sortpath < inpath && sortpath < tsppath2) return outpathSortcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 120 | if(inpath < sortpath && inpath < tsppath2 ) return inpathscxx . . $ QList#QList(3d2301cfd89f773a).; |
| 121 | if(tsppath < sortpath && tsppath < inpath) return outpathTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 122 | if(sortpath < inpath && sortpath < tsppath) return outpathSortcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 123 | if(inpath < sortpath && inpath < tsppath ) return inpathscxx . . $ QList#QList(3d2301cfd89f773a).; |
| 124 | if(tsppath2 < tsppath) return outpathTSP2cxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 125 | if(tsppath < sortpath) return outpathTSPcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 126 | if(sortpath < tsppath) return outpathSortcxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 127 | return inpathscxx . . $ QList#QList(3d2301cfd89f773a).; |
| 128 | } |
| 129 | |
| 130 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::BbSortcxx . . $ PathSorter#BbSort(5dd9053a288285ea). (const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 131 | { |
| 132 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpaths = QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths); |
| 133 | for (int i = 0; i < (outpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-1); i++) |
| 134 | { |
| 135 | for (int j = (i+1); j < outpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).(); j++) |
| 136 | { |
| 137 | if (outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).().intersectscxx . . $ QRectF#intersects(ef4372ae17f897e6).(outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).())) |
| 138 | { |
| 139 | if (outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).().widthcxx . . $ QRectF#width(21b6c25e127938e2).() > outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).().widthcxx . . $ QRectF#width(21b6c25e127938e2).() || outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).().heightcxx . . $ QRectF#height(21b6c25e127938e2).() > outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j].boundingRectcxx . . $ QPolygonF#boundingRect(19f9350443f914b1).().heightcxx . . $ QRectF#height(21b6c25e127938e2).()) |
| 140 | { |
| 141 | outpaths.swapcxx . . $ QList#swap(3e454b8ccf442868).(i,j); |
| 142 | break; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | coutcxx . . $ std/cout.<<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7)."BbSort outpaths: "<<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(outpathscxx . . $ QList#QList(3d2301cfd89f773a).) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 148 | return outpathscxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 149 | } |
| 150 | |
| 151 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::GroupTSPcxx . . $ PathSorter#GroupTSP(bab62d46a170b8f6).(const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths, int groups) |
| 152 | { |
| 153 | if (groups > inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()) groups = (int)((double) inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-((double)inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()*0.2)); |
| 154 | if (groups < 1) groups = 1; |
| 155 | QListcxx . . $ QList#<QListcxx . . $ QList#< QPolygonFcxx . . $ QPolygonF#> > listlistpathcxx . . $ QList#QList(49f6e7a06ebc5aa8).; |
| 156 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> temppathscxx . . $ QList#QList(49f6e7a06ebc5aa8).; |
| 157 | int inps = inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).(); |
| 158 | int inpsparts = inps / groups; |
| 159 | |
| 160 | for (int i = 0; i < inps; i++) |
| 161 | { |
| 162 | if(i>=inpsparts) |
| 163 | { |
| 164 | listlistpath.appendcxx . . $ QList#append(77d9f17553126ecb).(temppaths); |
| 165 | inpsparts += inps / groups; |
| 166 | temppaths =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). QListcxx . . $ QList#QList(49f6e7a06ebc5aa8).<QPolygonFcxx . . $ QPolygonF#>() ; |
| 167 | } |
| 168 | temppaths.appendcxx . . $ QList#append(77d9f17553126ecb).(inpaths[cxx . . $ QList#`operator[]`(e2681f9bb6b2f357).i]); |
| 169 | } |
| 170 | listlistpath.appendcxx . . $ QList#append(77d9f17553126ecb).(temppaths); |
| 171 | |
| 172 | for (int i = 0; i < listlistpath.sizecxx . . $ QList#size(455f465bc33b4cdf).(); i++) |
| 173 | { |
| 174 | listlistpath[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i] =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). MyFakeTSPcxx . . $ PathSorter#MyFakeTSP(5dd9053a288285ea).(listlistpathcxx . . $ QList#QList(3d2301cfd89f773a).[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i]); |
| 175 | } |
| 176 | |
| 177 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpathscxx . . $ QList#QList(49f6e7a06ebc5aa8).; |
| 178 | for (int i = 0; i < listlistpath.sizecxx . . $ QList#size(455f465bc33b4cdf).(); i++) |
| 179 | { |
| 180 | for (int j = 0; j < listlistpath[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].sizecxx . . $ QList#size(455f465bc33b4cdf).(); j++) |
| 181 | { |
| 182 | outpaths.appendcxx . . $ QList#append(77d9f17553126ecb).(listlistpath[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i][cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j]); |
| 183 | } |
| 184 | } |
| 185 | //cout<<"xTSPSort outpaths: "<< getTotalDistance(outpaths) << " Groups " << groups <<endl; |
| 186 | return outpathscxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 187 | } |
| 188 | |
| 189 | qrealcxx . . $ qreal# PathSortercxx . . $ PathSorter#::getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(const QPolygonFcxx . . $ QPolygonF# &p1, const QPolygonFcxx . . $ QPolygonF# &p2) |
| 190 | { |
| 191 | qrealcxx . . $ qreal# testx1 = p1.lastcxx . . $ QVector#last(ea465e50d690edfe).().xcxx . . $ QPointF#x(21b6c25e127938e2).(); |
| 192 | qrealcxx . . $ qreal# testy1 = p1.lastcxx . . $ QVector#last(ea465e50d690edfe).().ycxx . . $ QPointF#y(21b6c25e127938e2).(); |
| 193 | qrealcxx . . $ qreal# testx2 = p2.firstcxx . . $ QVector#first(ea465e50d690edfe).().xcxx . . $ QPointF#x(21b6c25e127938e2).(); |
| 194 | qrealcxx . . $ qreal# testy2 = p2.firstcxx . . $ QVector#first(ea465e50d690edfe).().ycxx . . $ QPointF#y(21b6c25e127938e2).(); |
| 195 | qrealcxx . . $ qreal# a = 0.0; |
| 196 | qrealcxx . . $ qreal# b = 0.0; |
| 197 | double c = 0.0; |
| 198 | |
| 199 | if(testx1 >= testx2) a = testx1 - testx2; |
| 200 | else a = testx2 - testx1; |
| 201 | if(testy1 >= testy2) b = testy1 - testy2; |
| 202 | else b = testy2 - testy1; |
| 203 | c = sqrt((double)(a*a+b*b)); |
| 204 | return (qrealcxx . . $ qreal#) c; |
| 205 | } |
| 206 | |
| 207 | qrealcxx . . $ qreal# PathSortercxx . . $ PathSorter#::getTotalDistancecxx . . $ PathSorter#getTotalDistance(a9b2f4e48644aa01).(const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths, int maxdepth) |
| 208 | { |
| 209 | if (maxdepth >= inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-1) maxdepth = inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-1; |
| 210 | if (maxdepth <= 0) maxdepth = inpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-1; |
| 211 | QPolygonFcxx . . $ QPolygonF# zero = QPolygonFcxx . . $ QPolygonF#QPolygonF(cae4aa04562998ff).(QRectFcxx . . $ QRectF#QRectF(52a61fa14d44b641).(0.0,mediaHeightcxx . . $ PathSorter#mediaHeight.,0.0,0.0)); // able to change the start point |
| 212 | qrealcxx . . $ qreal# dist = getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(zero,inpaths[cxx . . $ QList#`operator[]`(e2681f9bb6b2f357).0]); |
| 213 | for (int i = 0; i < maxdepth; ++i) |
| 214 | { |
| 215 | dist = dist + getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(inpaths[cxx . . $ QList#`operator[]`(e2681f9bb6b2f357).i],inpaths[cxx . . $ QList#`operator[]`(e2681f9bb6b2f357).(i+1)]); |
| 216 | } |
| 217 | return dist; |
| 218 | } |
| 219 | |
| 220 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> PathSortercxx . . $ PathSorter#::MyFakeTSPcxx . . $ PathSorter#MyFakeTSP(5dd9053a288285ea).(const QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> inpaths) |
| 221 | { |
| 222 | QPolygonFcxx . . $ QPolygonF# zero = QPolygonFcxx . . $ QPolygonF#QPolygonF(cae4aa04562998ff).(QRectFcxx . . $ QRectF#QRectF(52a61fa14d44b641).(0.0,mediaHeightcxx . . $ PathSorter#mediaHeight.,0.0,0.0)); // able to change the start point |
| 223 | |
| 224 | QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> outpaths = QListcxx . . $ QList#QList(b1a5d2b9a710f6d1).<QPolygonFcxx . . $ QPolygonF#>(inpaths); |
| 225 | |
| 226 | // find the shortest path |
| 227 | for (int i = 0; i < (outpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).()-1); ++i) |
| 228 | { |
| 229 | if(i == 0) // find good start |
| 230 | { |
| 231 | qrealcxx . . $ qreal# dist=10000.0; |
| 232 | int bestindex=i; |
| 233 | for (int j = (i+1); j < outpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).(); ++j) |
| 234 | { |
| 235 | if (getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(zero,outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j]) < dist) |
| 236 | { |
| 237 | dist = getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(zero,outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j]); |
| 238 | bestindex = j; |
| 239 | } |
| 240 | |
| 241 | } |
| 242 | if (dist != 0) outpaths.swapcxx . . $ QList#swap(3e454b8ccf442868).(0,bestindex); |
| 243 | } |
| 244 | qrealcxx . . $ qreal# dist=10000.0; |
| 245 | int bestindex=i; |
| 246 | for (int j = (i+1); j < outpaths.sizecxx . . $ QList#size(455f465bc33b4cdf).(); ++j) |
| 247 | { |
| 248 | if (getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i],outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j]) < dist) |
| 249 | { |
| 250 | dist = getDistancecxx . . $ PathSorter#getDistance(211c8febea50d70).(outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i],outpaths[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).j]); |
| 251 | bestindex = j; |
| 252 | } |
| 253 | } |
| 254 | if (dist != 0) outpaths.swapcxx . . $ QList#swap(3e454b8ccf442868).((i+1),bestindex); |
| 255 | } |
| 256 | return outpathscxx . . $ QList#QList(b1a5d2b9a710f6d1).; |
| 257 | } |