KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fab_drill_model.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
21
22#include <board.h>
24
25#include <utility>
26
27
29{
30 for( const DRILL_SPAN& span : EnumerateDrillSpans( aBoard, true ) )
31 {
32 DRILL_QUERY query;
33 query.m_Span = span;
34 query.m_MergePTHNPTH = true;
35 query.m_PadMachining = true;
36
37 FAB_DRILL_LAYER layer;
38 layer.m_Span = span;
39
40 for( DRILL_OPERATION& operation : EnumerateDrillOperations( aBoard, query ) )
41 {
42 if( operation.m_IsSlot )
43 layer.m_Slots.push_back( std::move( operation ) );
44 else
45 layer.m_Holes.push_back( std::move( operation ) );
46 }
47
48 m_layers.push_back( std::move( layer ) );
49 }
50
51 for( const FAB_DRILL_LAYER& layer : m_layers )
52 {
53 auto& items = m_index[indexKey( layer.m_Span )];
54
55 for( const DRILL_OPERATION& op : layer.m_Holes )
56 items.try_emplace( op.m_SourceItem, &op );
57
58 for( const DRILL_OPERATION& op : layer.m_Slots )
59 items.try_emplace( op.m_SourceItem, &op );
60
61 for( const auto* operations : { &layer.m_Holes, &layer.m_Slots } )
62 {
63 for( const DRILL_OPERATION& op : *operations )
64 {
65 if( op.IsBackdrill() )
66 continue;
67
68 m_facts.m_platedSlots |= op.m_IsSlot && !op.m_NotPlated;
70
71 for( const DRILL_POST_MACHINING& machining : { op.m_FrontPostMachining, op.m_BackPostMachining } )
72 {
73 m_facts.m_counterbore |= machining.m_Mode == PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE;
74 m_facts.m_countersink |= machining.m_Mode == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK;
75 }
76 }
77 }
78 }
79}
80
81
86
87
89 bool aIgnorePlating ) const
90{
91 auto layer = m_index.find( indexKey( aSpan ) );
92
93 if( layer == m_index.end() )
94 return nullptr;
95
96 auto item = layer->second.find( aItem );
97
98 if( item == layer->second.end() )
99 return nullptr;
100
101 const DRILL_OPERATION* op = item->second;
102 return aIgnorePlating || op->m_NotPlated == aSpan.m_IsNonPlatedFile ? op : nullptr;
103}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
std::map< INDEX_KEY, std::unordered_map< const BOARD_ITEM *, const DRILL_OPERATION * > > m_index
static INDEX_KEY indexKey(const DRILL_SPAN &aSpan)
std::vector< FAB_DRILL_LAYER > m_layers
FAB_DRILL_MODEL(const BOARD &aBoard)
const DRILL_OPERATION * Find(const DRILL_SPAN &aSpan, const BOARD_ITEM *aItem, bool aIgnorePlating=false) const
FAB_DRILL_FACTS m_facts
std::tuple< DRILL_LAYER_PAIR, bool, PCB_LAYER_ID > INDEX_KEY
Backdrills keep their start layer so a reverse backdrill on the same item stays separate.
std::vector< DRILL_SPAN > EnumerateDrillSpans(const BOARD &aBoard, bool aPadBackdrills)
Every drill span present on the board, through-holes first.
std::vector< DRILL_OPERATION > EnumerateDrillOperations(const BOARD &aBoard, const DRILL_QUERY &aQuery)
The one place that decides what the board's holes are.
@ UNDEFINED_LAYER
Definition layer_ids.h:57
One machining action, which is also one NC hit and one tool assignment.
bool IsBackdrill() const
DRILL_POST_MACHINING m_BackPostMachining
BOARD_ITEM * m_SourceItem
non-owning, valid only for this enumeration
DRILL_POST_MACHINING m_FrontPostMachining
HOLE_ATTRIBUTE m_Attribute
Selects which operations EnumerateDrillOperations() returns.
bool m_MergePTHNPTH
Emit plated and non-plated together, as the merged drill file does.
DRILL_SPAN m_Span
bool m_PadMachining
Include pad backdrills and post-machining, kept off for NC drill output.
DRILL_LAYER_PAIR Pair() const
Definition drill_span.h:93
PCB_LAYER_ID DrillStartLayer() const
Definition drill_span.h:83
bool m_IsNonPlatedFile
Definition drill_span.h:131
bool m_IsBackdrill
Definition drill_span.h:130
std::vector< DRILL_OPERATION > m_Slots
std::vector< DRILL_OPERATION > m_Holes