KiCad PCB EDA Suite
pns_diff_pair_placer.h
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 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_DIFF_PLACER_H
23 #define __PNS_DIFF_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_algo_base.h"
35 #include "pns_diff_pair.h"
36 
37 #include "pns_placement_algo.h"
38 
39 namespace PNS {
40 
41 class ROUTER;
42 class SHOVE;
43 class OPTIMIZER;
44 class VIA;
45 class SIZES_SETTINGS;
46 
47 
56 {
57 public:
58  DIFF_PAIR_PLACER( ROUTER* aRouter );
60 
67  bool Start( const VECTOR2I& aP, ITEM* aStartItem ) override;
68 
76  bool Move( const VECTOR2I& aP, ITEM* aEndItem ) override;
77 
87  bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) override;
88 
94  bool ToggleVia( bool aEnabled ) override;
95 
101  bool SetLayer( int aLayer ) override;
102 
108  const ITEM_SET Traces() override;
109 
116  const VECTOR2I& CurrentEnd() const override
117  {
118  return m_currentEnd;
119  }
120 
126  const std::vector<int> CurrentNets() const override;
127 
133  int CurrentLayer() const override
134  {
135  return m_currentLayer;
136  }
137 
143  NODE* CurrentNode( bool aLoopsRemoved = false ) const override;
144 
150  void FlipPosture() override;
151 
159  void UpdateSizes( const SIZES_SETTINGS& aSizes ) override;
160 
161  bool IsPlacingVia() const override { return m_placingVia; }
162 
163  void SetOrthoMode( bool aOrthoMode ) override;
164 
165  void GetModifiedNets( std::vector<int>& aNets ) const override;
166 
167 private:
168  int viaGap() const;
169  int gap() const;
170 
181  bool route( const VECTOR2I& aP );
182 
190  void updateLeadingRatLine();
191 
197  void setWorld( NODE* aWorld );
198 
204  void initPlacement( );
205 
212  void setInitialDirection( const DIRECTION_45& aDirection );
213 
214 
215  bool routeHead( const VECTOR2I& aP );
216  bool tryWalkDp( NODE* aNode, DIFF_PAIR& aPair, bool aSolidsOnly );
217 
219  bool rhWalkOnly( const VECTOR2I& aP );
220 
222  bool rhShoveOnly ( const VECTOR2I& aP );
223 
225  bool rhMarkObstacles( const VECTOR2I& aP );
226 
227  const VIA makeVia ( const VECTOR2I& aP, int aNet );
228 
229  bool findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_PRIMITIVE_PAIR& aPair );
230  OPT_VECTOR2I getDanglingAnchor( NODE* aNode, ITEM* aItem );
231  bool attemptWalk( NODE* aNode, DIFF_PAIR* aCurrent, DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly );
232  bool propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNewP );
233 
234  enum State {
235  RT_START = 0,
236  RT_ROUTE = 1,
238  };
239 
241 
245  bool m_fitOk;
246 
248 
251 
254 
257 
260 
263 
266 
269 
271 
274 
277 
280 
283 
286 
290 
293 
296 
297  bool m_idle;
298 };
299 
300 }
301 
302 #endif // __PNS_LINE_PLACER_H
bool rhWalkOnly(const VECTOR2I &aP)
route step, walkaround mode
Class ITEM.
Definition: pns_item.h:53
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
Class NODE.
Definition: pns_node.h:137
PNS_MODE
Routing modes
Class SHOVE.
Definition: pns_shove.h:46
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
bool route(const VECTOR2I &aP)
Function route()
bool rhShoveOnly(const VECTOR2I &aP)
route step, shove mode
int m_iteration
current algorithm iteration
SHOVE * m_shove
The shove engine
int m_viaDiameter
current via diameter
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Function CurrentNode()
int CurrentLayer() const override
Function CurrentLayer()
NODE * m_world
pointer to world to search colliding items
const VIA makeVia(const VECTOR2I &aP, int aNet)
bool routeHead(const VECTOR2I &aP)
Class PLACEMENT_ALGO.
void setInitialDirection(const DIRECTION_45 &aDirection)
Function setInitialDirection()
int m_viaDrill
current via drill
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem) override
Function FixRoute()
bool ToggleVia(bool aEnabled) override
Function ToggleVia()
Class DIRECTION_45.
Definition: direction45.h:33
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Function UpdateSizes()
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Function Start()
const ITEM_SET Traces() override
Function Traces()
boost::optional< DP_PRIMITIVE_PAIR > m_prevPair
bool m_placingVia
Are we placing a via?
bool IsPlacingVia() const override
Function IsPlacingVia()
DIFF_PAIR_PLACER(ROUTER *aRouter)
Class LINE_PLACER.
Class DIFF_PAIR.
bool findDpPrimitivePair(const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair)
void FlipPosture() override
Function FlipPosture()
NODE * m_currentNode
Current world state
void updateLeadingRatLine()
Function updateLeadingRatLine()
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
Class DP_PRIMITIVE_PAIR.
void initPlacement()
Function startPlacement()
bool SetLayer(int aLayer) override
Function SetLayer()
const std::vector< int > CurrentNets() const override
Function CurrentNets()
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
void setWorld(NODE *aWorld)
Function setWorld()
VECTOR2I m_p_start
current routing start point (end of tail, beginning of head)
const VECTOR2I & CurrentEnd() const override
Function CurrentEnd()
Push and Shove diff pair dimensions (gap) settings dialog.
int m_currentWidth
current track width
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
bool rhMarkObstacles(const VECTOR2I &aP)
route step, mark obstacles mode