Horizon
pns_line_placer.h
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2017 CERN
5 * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_LINE_PLACER_H
23#define __PNS_LINE_PLACER_H
24
25#include <math/vector2d.h>
26
27#include <geometry/shape.h>
28#include <geometry/shape_line_chain.h>
29
30#include "pns_sizes_settings.h"
31#include "pns_node.h"
32#include "pns_via.h"
33#include "pns_line.h"
34#include "pns_placement_algo.h"
35
36namespace PNS {
37
38class ROUTER;
39class SHOVE;
40class OPTIMIZER;
41class VIA;
42class SIZES_SETTINGS;
43
44
53{
54public:
55 LINE_PLACER( ROUTER* aRouter );
57
64 bool Start( const VECTOR2I& aP, ITEM* aStartItem ) override;
65
73 bool Move( const VECTOR2I& aP, ITEM* aEndItem ) override;
74
84 bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) override;
85
91 bool ToggleVia( bool aEnabled ) override;
92
98 bool SetLayer( int aLayer ) override;
99
106 const LINE& Head() const { return m_head; }
107
114 const LINE& Tail() const { return m_tail; }
115
121 const LINE Trace() const;
122
128 const ITEM_SET Traces() override;
129
136 const VECTOR2I& CurrentEnd() const override
137 {
138 return m_currentEnd;
139 }
140
146 const std::vector<int> CurrentNets() const override
147 {
148 return std::vector<int>( 1, m_currentNet );
149 }
150
156 int CurrentLayer() const override
157 {
158 return m_currentLayer;
159 }
160
166 NODE* CurrentNode( bool aLoopsRemoved = false ) const override;
167
173 void FlipPosture() override;
174
182 void UpdateSizes( const SIZES_SETTINGS& aSizes ) override;
183
184 void SetOrthoMode( bool aOrthoMode ) override;
185
186 bool IsPlacingVia() const override { return m_placingVia; }
187
188 void GetModifiedNets( std::vector<int>& aNets ) const override;
189
190 LOGGER* Logger() override;
191
198 bool SplitAdjacentSegments( NODE* aNode, ITEM* aSeg, const VECTOR2I& aP );
199
200
201private:
212 bool route( const VECTOR2I& aP );
213
221 void updateLeadingRatLine();
222
228 void setWorld( NODE* aWorld );
229
235 void initPlacement();
236
243 void setInitialDirection( const DIRECTION_45& aDirection );
244
251 void removeLoops( NODE* aNode, LINE& aLatest );
252
260 void simplifyNewLine( NODE* aNode, SEGMENT* aLatest );
261
269 bool checkObtusity( const SEG& aA, const SEG& aB ) const;
270
279 bool handleSelfIntersections();
280
288 bool handlePullback();
289
297 bool mergeHead();
298
308 bool reduceTail( const VECTOR2I& aEnd );
309
317 bool optimizeTailHeadTransition();
318
327 bool routeHead( const VECTOR2I& aP, LINE& aNewHead);
328
336 void routeStep( const VECTOR2I& aP );
337
338 const LINE reduceToNearestObstacle( const LINE& aOriginalLine );
339
340 bool rhStopAtNearestObstacle( const VECTOR2I& aP, LINE& aNewHead );
341
342
344 bool rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead);
345
347 bool rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead);
348
350 bool rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead );
351
352 const VIA makeVia( const VECTOR2I& aP );
353
354 bool buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aInvertPosture = false );
355
357 DIRECTION_45 m_direction;
358
360 DIRECTION_45 m_initial_direction;
361
364 LINE m_head;
365
367 LINE m_tail;
368
370 NODE* m_world;
371
373 VECTOR2I m_p_start;
374
376 std::unique_ptr< SHOVE > m_shove;
377
379 NODE* m_currentNode;
380
382 NODE* m_lastNode;
383
384 SIZES_SETTINGS m_sizes;
385
387 bool m_placingVia;
388
389 int m_currentNet;
390 int m_currentLayer;
391
392 VECTOR2I m_currentEnd, m_currentStart;
393 LINE m_currentTrace;
394
395 PNS_MODE m_currentMode;
396 ITEM* m_startItem;
397
398 bool m_idle;
399 bool m_chainedPlacement;
400 bool m_orthoMode;
401};
402
403}
404
405#endif // __PNS_LINE_PLACER_H
Class DIRECTION_45.
Definition: direction45.h:37
Definition: pns_itemset.h:40
Class ITEM.
Definition: pns_item.h:55
Class LINE_PLACER.
Definition: pns_line_placer.h:53
bool SetLayer(int aLayer) override
Function SetLayer()
Definition: pns_line_placer.cpp:876
const LINE Trace() const
Function Trace()
Definition: pns_line_placer.cpp:811
const std::vector< int > CurrentNets() const override
Function CurrentNet()
Definition: pns_line_placer.h:146
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Function UpdateSizes()
Definition: pns_line_placer.cpp:1177
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
Definition: pns_line_placer.cpp:1199
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Function Start()
Definition: pns_line_placer.cpp:899
const LINE & Tail() const
Function Tail()
Definition: pns_line_placer.h:114
LOGGER * Logger() override
‍Returns the logger object, allowing to dump geometry to a file.
Definition: pns_line_placer.cpp:1273
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Function CurrentNode()
Definition: pns_line_placer.cpp:836
bool SplitAdjacentSegments(NODE *aNode, ITEM *aSeg, const VECTOR2I &aP)
Function SplitAdjacentSegments()
Definition: pns_line_placer.cpp:845
int CurrentLayer() const override
Function CurrentLayer()
Definition: pns_line_placer.h:156
void FlipPosture() override
Function FlipPosture()
Definition: pns_line_placer.cpp:829
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
Definition: pns_line_placer.cpp:1268
bool IsPlacingVia() const override
Function IsPlacingVia()
Definition: pns_line_placer.h:186
const LINE & Head() const
Function Head()
Definition: pns_line_placer.h:106
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
Definition: pns_line_placer.cpp:958
const VECTOR2I & CurrentEnd() const override
Function CurrentEnd()
Definition: pns_line_placer.h:136
const ITEM_SET Traces() override
Function Traces()
Definition: pns_line_placer.cpp:822
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish) override
Function FixRoute()
Definition: pns_line_placer.cpp:998
bool ToggleVia(bool aEnabled) override
Function ToggleVia()
Definition: pns_line_placer.cpp:77
Definition: pns_line.h:61
Definition: pns_logger.h:40
Class NODE.
Definition: pns_node.h:138
Class PLACEMENT_ALGO.
Definition: pns_placement_algo.h:46
Definition: pns_router.h:113
Definition: pns_segment.h:39
Definition: pns_sizes_settings.h:37
Definition: pns_via.h:38
Definition: seg.h:37