KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_tracks_spreader.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 * Author: Tomasz Wlostowski <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef __PNS_TRACKS_SPREADER_H
23#define __PNS_TRACKS_SPREADER_H
24
25#include <math/vector2d.h>
26
28
29#include "pns_node.h"
30#include "pns_line.h"
31#include "pns_placement_algo.h"
32#include <unordered_set>
33
34namespace PNS
35{
36
37class ROUTER;
38class SHOVE;
39class OPTIMIZER;
40
42{
43public:
44 TRACKS_SPREADER( ROUTER* aRouter );
45 virtual ~TRACKS_SPREADER();
46
48 virtual bool Start( const VECTOR2I& aP, ITEM* aStartItem ) override;
49
51 virtual bool Move( const VECTOR2I& aP, ITEM* aEndItem ) override;
52
54 virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) override;
55
57 bool CommitPlacement() override;
58
60 bool AbortPlacement() override;
61
63 bool HasPlacedAnything() const override;
64
66 NODE* CurrentNode( bool aLoopsRemoved = false ) const override;
67
69 const ITEM_SET Traces() override;
70
72 const VECTOR2I& CurrentStart() const override;
73
75 const VECTOR2I& CurrentEnd() const override;
76
78 const std::vector<NET_HANDLE> CurrentNets() const override;
79
81 int CurrentLayer() const override;
82
83 void SetSpreadableItems( const ITEM_SET& aAuxItems );
84 const ITEM_SET& GetSpreadableItems() const { return m_auxItems; }
85
86
87private:
97
98 static std::optional<LINE> breakAndReassemble( NODE* aNode, LINE* aOrigLine, const VECTOR2I& aP1,
99 const VECTOR2I& aP2 );
101 void determineWalkOrder();
102 const std::vector<SEG> findNoOptSegments( const LINE& aClippedHead,
103 const TRACKS_SPREADER::SPREADABLE_LINE& aEntry ) const;
104
105
111
113 std::vector<SPREADABLE_LINE> m_lines;
114 std::unordered_set<const LINKED_ITEM*> m_spreadableItems;
115};
116
117} // namespace PNS
118
119#endif // __PNS_TRACKS_SPREADER_H
Base class for PNS router board items.
Definition pns_item.h:98
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
Keep the router "world" - i.e.
Definition pns_node.h:274
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
PLACEMENT_ALGO(ROUTER *aRouter)
The actual Push and Shove algorithm.
Definition pns_shove.h:48
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent board state.
std::vector< SPREADABLE_LINE > m_lines
virtual bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start placement/drag operation at point aP, taking item aStartItem as anchor (unless NULL).
const std::vector< NET_HANDLE > CurrentNets() const override
Returns the net(s) of currently routed track(s).
void SetSpreadableItems(const ITEM_SET &aAuxItems)
const VECTOR2I & CurrentStart() const override
Return the current start of the line(s) being placed/tuned.
TRACKS_SPREADER(ROUTER *aRouter)
const std::vector< SEG > findNoOptSegments(const LINE &aClippedHead, const TRACKS_SPREADER::SPREADABLE_LINE &aEntry) const
virtual bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Move the end of the currently routed primtive(s) to the point aP, taking aEndItem as the anchor (if n...
std::unordered_set< const LINKED_ITEM * > m_spreadableItems
const ITEM_SET Traces() override
Return all routed/tuned traces.
const ITEM_SET & GetSpreadableItems() const
int CurrentLayer() const override
Return the layer of currently routed track.
virtual bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish=false) override
Commit the currently routed items to the parent node, taking aP as the final end point and aEndItem a...
static std::optional< LINE > breakAndReassemble(NODE *aNode, LINE *aOrigLine, const VECTOR2I &aP1, const VECTOR2I &aP2)
const VECTOR2I & CurrentEnd() const override
Return the current end of the line(s) being placed/tuned.
bool HasPlacedAnything() const override
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708