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, bool aForceFinish ) override;
88 
90  bool CommitPlacement() override;
91 
93  bool AbortPlacement() override;
94 
96  bool HasPlacedAnything() const override;
97 
103  bool ToggleVia( bool aEnabled ) override;
104 
110  bool SetLayer( int aLayer ) override;
111 
117  const ITEM_SET Traces() override;
118 
125  const VECTOR2I& CurrentEnd() const override
126  {
127  return m_currentEnd;
128  }
129 
135  const std::vector<int> CurrentNets() const override;
136 
142  int CurrentLayer() const override
143  {
144  return m_currentLayer;
145  }
146 
152  NODE* CurrentNode( bool aLoopsRemoved = false ) const override;
153 
159  void FlipPosture() override;
160 
168  void UpdateSizes( const SIZES_SETTINGS& aSizes ) override;
169 
170  bool IsPlacingVia() const override { return m_placingVia; }
171 
172  void SetOrthoMode( bool aOrthoMode ) override;
173 
174  void GetModifiedNets( std::vector<int>& aNets ) const override;
175 
176 private:
177  int viaGap() const;
178  int gap() const;
179 
190  bool route( const VECTOR2I& aP );
191 
199  void updateLeadingRatLine();
200 
206  void setWorld( NODE* aWorld );
207 
213  void initPlacement( );
214 
221  void setInitialDirection( const DIRECTION_45& aDirection );
222 
223 
224  bool routeHead( const VECTOR2I& aP );
225  bool tryWalkDp( NODE* aNode, DIFF_PAIR& aPair, bool aSolidsOnly );
226 
228  bool rhWalkOnly( const VECTOR2I& aP );
229 
231  bool rhShoveOnly ( const VECTOR2I& aP );
232 
234  bool rhMarkObstacles( const VECTOR2I& aP );
235 
236  const VIA makeVia ( const VECTOR2I& aP, int aNet );
237 
238  bool findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_PRIMITIVE_PAIR& aPair, wxString* aErrorMsg = nullptr );
239  OPT_VECTOR2I getDanglingAnchor( NODE* aNode, ITEM* aItem );
240  bool attemptWalk( NODE* aNode, DIFF_PAIR* aCurrent, DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly );
241  bool propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNewP );
242 
243  enum State {
244  RT_START = 0,
245  RT_ROUTE = 1,
247  };
248 
250 
254  bool m_fitOk;
255 
257 
260 
263 
266 
269 
272 
275 
278 
280 
283 
286 
289 
292 
295 
299 
302 
305 
306  bool m_idle;
307 };
308 
309 }
310 
311 #endif // __PNS_LINE_PLACER_H
bool rhWalkOnly(const VECTOR2I &aP)
route step, walkaround mode
ITEM.
Definition: pns_item.h:53
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
NODE.
Definition: pns_node.h:145
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish) override
Function FixRoute()
PNS_MODE
Routing modes
SHOVE.
Definition: pns_shove.h:48
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)
void setInitialDirection(const DIRECTION_45 &aDirection)
Function setInitialDirection()
int m_viaDrill
current via drill
bool HasPlacedAnything() const override
bool findDpPrimitivePair(const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:37
bool ToggleVia(bool aEnabled) override
Function ToggleVia()
DIRECTION_45.
Definition: direction45.h:37
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()
bool m_placingVia
Are we placing a via?
bool IsPlacingVia() const override
Function IsPlacingVia()
DIFF_PAIR_PLACER(ROUTER *aRouter)
DIFF_PAIR.
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()
DP_PRIMITIVE_PAIR.
void initPlacement()
Function startPlacement()
boost::optional< T > OPT
Definition: optional.h:7
bool SetLayer(int aLayer) override
Function SetLayer()
const std::vector< int > CurrentNets() const override
Function CurrentNets()
OPT< DP_PRIMITIVE_PAIR > m_prevPair
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