2013-09-18 17:55:16 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 CERN
|
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.or/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PNS_SHOVE_H
|
|
|
|
#define __PNS_SHOVE_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
#include "pns_optimizer.h"
|
|
|
|
|
|
|
|
class PNS_LINE;
|
|
|
|
class PNS_NODE;
|
|
|
|
class PNS_ROUTER;
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
class PNS_SHOVE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PNS_SHOVE( PNS_NODE* aWorld );
|
|
|
|
~PNS_SHOVE();
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
enum ShoveStatus
|
|
|
|
{
|
|
|
|
SH_OK = 0,
|
|
|
|
SH_NULL,
|
|
|
|
SH_INCOMPLETE
|
|
|
|
};
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
ShoveStatus ShoveLines( PNS_LINE* aCurrentHead );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
PNS_NODE* GetCurrentNode()
|
|
|
|
{
|
|
|
|
return m_nodeStack.empty() ? m_root : m_nodeStack.back().node;
|
|
|
|
}
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
const PNS_COST_ESTIMATOR TotalCost() const;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
void Reset();
|
|
|
|
void KillChildNodes();
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
private:
|
|
|
|
static const int ShoveTimeLimit = 3000;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-10-14 11:43:57 +00:00
|
|
|
bool tryShove( PNS_NODE* aWorld, PNS_LINE* aTrack, PNS_LINE* aObstacle,
|
2013-09-26 21:53:54 +00:00
|
|
|
PNS_SEGMENT& aObstacleSeg, PNS_LINE* aResult, bool aInvertWinding );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
ShoveStatus shoveSingleLine( PNS_NODE* aNode, PNS_LINE* aCurrent, PNS_LINE* aObstacle,
|
|
|
|
PNS_SEGMENT& aObstacleSeg, PNS_LINE* aResult );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
bool reduceSpringback( PNS_LINE* aHead );
|
|
|
|
bool pushSpringback( PNS_NODE* aNode, PNS_LINE* aHead, const PNS_COST_ESTIMATOR& aCost );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
struct SpringbackTag
|
|
|
|
{
|
|
|
|
int64_t length;
|
|
|
|
int segments;
|
|
|
|
VECTOR2I p;
|
|
|
|
PNS_NODE* node;
|
|
|
|
PNS_COST_ESTIMATOR cost;
|
|
|
|
};
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
std::vector<SpringbackTag> m_nodeStack;
|
|
|
|
PNS_NODE* m_root;
|
|
|
|
PNS_NODE* m_currentNode;
|
|
|
|
int m_iterLimit;
|
2013-09-18 17:55:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|