KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_wire_detour.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <vector>
23
24#include <geometry/seg.h>
25#include <math/vector2d.h>
26
35{
36public:
37 struct RESULT
38 {
40 std::vector<SEG> Pieces;
41
43 bool Failed = false;
44 };
45
49 int AnonymousNet() { return --m_anonymousNets; }
50
54 void AddWire( const SEG& aWire, int aNet );
55
59 void AddContact( const VECTOR2I& aPos, int aNet );
60
67 RESULT Route( const SEG& aWire, int aNet );
68
72 bool TouchesOtherNet( const VECTOR2I& aPos, int aNet ) const;
73
74private:
75 struct WIRE
76 {
78 int Net;
79 };
80
81 struct CONTACT
82 {
84 int Net;
85 };
86
87 std::vector<CONTACT> contacts() const;
88
90 bool joinsOtherNet( const SEG& aPiece, const SEG& aWire, int aNet, const std::vector<CONTACT>& aContacts ) const;
91
93 std::vector<SEG> detour( const SEG& aWire, const VECTOR2I& aEnter, const VECTOR2I& aLeave, int aNet,
94 const std::vector<CONTACT>& aContacts ) const;
95
96 std::vector<WIRE> m_wires;
97 std::vector<CONTACT> m_contacts;
99};
Keeps wires of one net from touching pins, junctions and wire ends of other nets on import.
std::vector< WIRE > m_wires
std::vector< CONTACT > m_contacts
void AddContact(const VECTOR2I &aPos, int aNet)
Register a pin or junction.
RESULT Route(const SEG &aWire, int aNet)
Detour a wire around foreign items lying on it and register the result as the wire's geometry.
void AddWire(const SEG &aWire, int aNet)
Register a wire as an obstacle for the wires of other nets.
bool TouchesOtherNet(const VECTOR2I &aPos, int aNet) const
bool joinsOtherNet(const SEG &aPiece, const SEG &aWire, int aNet, const std::vector< CONTACT > &aContacts) const
True if a detour piece would join another net.
std::vector< CONTACT > contacts() const
std::vector< SEG > detour(const SEG &aWire, const VECTOR2I &aEnter, const VECTOR2I &aLeave, int aNet, const std::vector< CONTACT > &aContacts) const
Detour the stretch of a wire between two points, or an empty vector if there is no safe place for it.
Definition seg.h:38
bool Failed
A foreign item lies on the wire and no safe detour was found, the wire is left as it was.
std::vector< SEG > Pieces
The wire itself when nothing lies on it, otherwise the pieces of the detoured wire in order.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708