| 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 | #pragma once |
| 22 | |
| 23 | #include <QGraphicsItem> |
| 24 | |
| 25 | class PathSorter |
| 26 | { |
| 27 | public: |
| 28 | PathSorter( ); |
| 29 | PathSorter(const QList<QPolygonF> inpaths, qreal mediaheight); |
| 30 | virtual ~PathSorter( ); |
| 31 | |
| 32 | void getQList (const QList<QPolygonF> inpaths); |
| 33 | QList<QPolygonF> Sort (const QList<QPolygonF> inpaths); |
| 34 | QList<QPolygonF> Sort () {return Sort(pathToSort);} |
| 35 | QList<QPolygonF> UnSort (const QList<QPolygonF> inpaths); |
| 36 | QList<QPolygonF> UnSort () {return UnSort(pathToSort);} |
| 37 | QList<QPolygonF> BestSort (const QList<QPolygonF> inpaths); |
| 38 | QList<QPolygonF> BestSort () {return BestSort(pathToSort);} |
| 39 | QList<QPolygonF> GroupTSP(const QList<QPolygonF> inpaths1, int groups = 3); |
| 40 | QList<QPolygonF> GroupTSP(int groups = 3) {return GroupTSP(pathToSort, groups);} |
| 41 | QList<QPolygonF> BbSort (const QList<QPolygonF> inpaths); |
| 42 | QList<QPolygonF> BbSort () {return BbSort(pathToSort);} |
| 43 | void setMediaHeight(qreal mediaheight); |
| 44 | private: |
| 45 | QList<QPolygonF> pathToSort; |
| 46 | qreal mediaHeight; |
| 47 | |
| 48 | protected: |
| 49 | |
| 50 | private: |
| 51 | QList<QPolygonF> MyFakeTSP(const QList<QPolygonF> inpaths); |
| 52 | qreal getDistance(const QPolygonF &p1, const QPolygonF &p2); |
| 53 | qreal getTotalDistance(const QList<QPolygonF> inpaths, int maxdepth = 0); |
| 54 | static bool MyLessThan(const QPolygonF &p1, const QPolygonF &p2); |
| 55 | }; |
| 56 |