KiCad PCB EDA Suite
pns_line_placer.h
Go to the documentation of this file.
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>
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 
36 namespace PNS {
37 
38 class ROUTER;
39 class SHOVE;
40 class OPTIMIZER;
41 class VIA;
42 class SIZES_SETTINGS;
43 
44 
53 {
54 public:
55  LINE_PLACER( ROUTER* aRouter );
56  ~LINE_PLACER();
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 ) 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 
201 private:
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 
280 
288  bool handlePullback();
289 
297  bool mergeHead();
298 
308  bool reduceTail( const VECTOR2I& aEnd );
309 
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 
358 
361 
365 
368 
371 
374 
376  std::unique_ptr< SHOVE > m_shove;
377 
380 
383 
385 
388 
391 
394 
397 
398  bool m_idle;
401 };
402 
403 }
404 
405 #endif // __PNS_LINE_PLACER_H
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem) override
Function FixRoute()
Class ITEM.
Definition: pns_item.h:53
const ITEM_SET Traces() override
Function Traces()
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
Class NODE.
Definition: pns_node.h:137
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
PNS_MODE
Routing modes
void routeStep(const VECTOR2I &aP)
Function routeStep()
NODE * m_world
pointer to world to search colliding items
void removeLoops(NODE *aNode, LINE &aLatest)
Function removeLoops()
const std::vector< int > CurrentNets() const override
Function CurrentNet()
const LINE reduceToNearestObstacle(const LINE &aOriginalLine)
Class LINE_PLACER.
LINE m_head
routing "head": volatile part of the track from the previously analyzed point to the current routing ...
bool rhWalkOnly(const VECTOR2I &aP, LINE &aNewHead)
route step, walkaround mode
SIZES_SETTINGS m_sizes
void simplifyNewLine(NODE *aNode, SEGMENT *aLatest)
Function simplifyNewLine()
bool checkObtusity(const SEG &aA, const SEG &aB) const
Function checkObtusity()
bool reduceTail(const VECTOR2I &aEnd)
Function reduceTail()
const LINE & Tail() const
Function Tail()
Class PLACEMENT_ALGO.
bool handlePullback()
Function handlePullback()
LINE_PLACER(ROUTER *aRouter)
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Function UpdateSizes()
DIRECTION_45 m_initial_direction
routing direction for new traces
LINE m_tail
routing "tail": part of the track that has been already fixed due to collisions with obstacles ...
const LINE & Head() const
Function Head()
void setInitialDirection(const DIRECTION_45 &aDirection)
Function setInitialDirection()
Class DIRECTION_45.
Definition: direction45.h:33
LOGGER * Logger() override
Returns the logger object, allowing to dump geometry to a file.
bool SplitAdjacentSegments(NODE *aNode, ITEM *aSeg, const VECTOR2I &aP)
Function SplitAdjacentSegments()
DIRECTION_45 m_direction
current routing direction
void initPlacement()
Function startPlacement()
bool buildInitialLine(const VECTOR2I &aP, LINE &aHead, bool aInvertPosture=false)
void updateLeadingRatLine()
Function updateLeadingRatLine()
bool routeHead(const VECTOR2I &aP, LINE &aNewHead)
Function routeHead()
bool handleSelfIntersections()
Function handleSelfIntersections()
bool route(const VECTOR2I &aP)
Function route()
std::unique_ptr< SHOVE > m_shove
The shove engine
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
bool rhMarkObstacles(const VECTOR2I &aP, LINE &aNewHead)
route step, mark obstacles mode
bool rhShoveOnly(const VECTOR2I &aP, LINE &aNewHead)
route step, shove mode
Definition: seg.h:37
NODE * m_currentNode
Current world state
void setWorld(NODE *aWorld)
Function setWorld()
bool optimizeTailHeadTransition()
Function optimizeTailHeadTransition()
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Function CurrentNode()
bool ToggleVia(bool aEnabled) override
Function ToggleVia()
void FlipPosture() override
Function FlipPosture()
const VECTOR2I & CurrentEnd() const override
Function CurrentEnd()
bool m_placingVia
Are we placing a via?
bool SetLayer(int aLayer) override
Function SetLayer()
VECTOR2I m_p_start
current routing start point (end of tail, beginning of head)
bool IsPlacingVia() const override
Function IsPlacingVia()
bool mergeHead()
Function mergeHead()
bool rhStopAtNearestObstacle(const VECTOR2I &aP, LINE &aNewHead)
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Function Start()
const VIA makeVia(const VECTOR2I &aP)
Push and Shove diff pair dimensions (gap) settings dialog.
const LINE Trace() const
Function Trace()
int CurrentLayer() const override
Function CurrentLayer()