KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fab_test_points.cpp
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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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#include "fab_test_points.h"
21
22#include <algorithm>
23#include <memory>
24#include <board.h>
26#include <footprint.h>
27#include <pad.h>
28#include <pcb_track.h>
29
30
31std::vector<FAB_TEST_POINT> FabTestPoints( const BOARD& aBoard )
32{
33 std::vector<FAB_TEST_POINT> points;
34 std::shared_ptr<CONNECTIVITY_DATA> connectivity = aBoard.GetConnectivity();
35
36 for( PCB_TRACK* track : aBoard.Tracks() )
37 {
38 if( track->Type() != PCB_VIA_T )
39 continue;
40
41 PCB_VIA* via = static_cast<PCB_VIA*>( track );
42 FAB_TEST_POINT point;
43 const LSET layers = via->GetLayerSet();
44 point.m_via = via;
45 point.m_netCode = via->GetNetCode();
46 point.m_position = via->GetPosition();
47 point.m_front = layers.test( F_Cu );
48 point.m_back = layers.test( B_Cu );
49 point.m_frontMask = layers.test( F_Mask );
50 point.m_backMask = layers.test( B_Mask );
51 point.m_drill = via->GetDrillValue();
52
53 // A via with more copper after it is a midpoint and not a net end
54 point.m_netEnd =
55 connectivity->GetConnectedItemsAtAnchor( via, point.m_position, { PCB_TRACE_T, PCB_ARC_T } ).size() < 2;
56 points.push_back( point );
57 }
58
59 for( FOOTPRINT* footprint : aBoard.Footprints() )
60 {
61 for( PAD* pad : footprint->Pads() )
62 {
63 FAB_TEST_POINT point;
64 const LSET layers = pad->GetLayerSet();
65 point.m_pad = pad;
66 point.m_netCode = pad->GetNetCode();
67 point.m_position = pad->GetPosition();
68 point.m_front = layers.test( F_Cu );
69 point.m_back = layers.test( B_Cu );
70 point.m_frontMask = layers.test( F_Mask );
71 point.m_backMask = layers.test( B_Mask );
72 point.m_drill = pad->HasHole() ? std::min( pad->GetDrillSize().x, pad->GetDrillSize().y ) : 0;
73 points.push_back( point );
74 }
75 }
76
77 return points;
78}
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
const FOOTPRINTS & Footprints() const
Definition board.h:464
const TRACKS & Tracks() const
Definition board.h:462
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:759
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
std::vector< FAB_TEST_POINT > FabTestPoints(const BOARD &aBoard)
The caller must build board connectivity before enumerating net endpoints.
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ F_Mask
Definition layer_ids.h:93
@ F_Cu
Definition layer_ids.h:60
const PCB_VIA * m_via
const PAD * m_pad
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89