KiCad PCB EDA Suite
Loading...
Searching...
No Matches
via_cross_section_geometry.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
9 * option) 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#ifndef VIA_CROSS_SECTION_GEOMETRY_H
21#define VIA_CROSS_SECTION_GEOMETRY_H
22
23#include <optional>
24#include <vector>
25#include <padstack.h>
26
27class BOARD_STACKUP;
28
29
42{
43public:
47 {
48 std::optional<PAD_DRILL_POST_MACHINING_MODE> m_Mode = PAD_DRILL_POST_MACHINING_MODE::NOT_POST_MACHINED;
49
50 double m_WidthRatio = 2.0; // cut width over hole diameter
51 double m_DepthFraction = 0.1; // cut depth over board thickness
52 };
53
54 struct STATE
55 {
56 std::optional<bool> m_TentFront;
57 std::optional<bool> m_TentBack;
58 std::optional<bool> m_CoverFront;
59 std::optional<bool> m_CoverBack;
60 std::optional<bool> m_PlugFront;
61 std::optional<bool> m_PlugBack;
62 std::optional<bool> m_Filled;
63 std::optional<bool> m_Capped;
64
67 std::vector<double> m_LayerDepths;
68 std::vector<double> m_LayerThicknesses;
70
73 int m_TopLayer = 0;
74 std::optional<int> m_BottomLayer;
75
77 std::vector<bool> m_RingLayers;
78
80 double m_PadRatio = 2.8;
81
84 std::optional<int> m_BackdrillFrontLayers = 0;
85 std::optional<int> m_BackdrillBackLayers = 0;
88
91 };
92
103
106 enum class CLIP
107 {
110 };
111
112 struct POINT
113 {
114 double x;
115 double y;
116 };
117
118 struct PIECE
119 {
121 bool m_Rect = true;
122 std::vector<POINT> m_Points;
123 bool m_Mixed = false;
124
125 double Left() const { return m_Points[0].x; }
126 double Top() const { return m_Points[0].y; }
127 double Right() const { return m_Points[1].x; }
128 double Bottom() const { return m_Points[1].y; }
129 };
130
131 struct BODY
132 {
135 std::vector<PIECE> m_Pieces;
136 };
137
138 static constexpr double GRID_W = 220.0;
139
141 static double GridHeightFor( int aInnerLayers );
142
145 static int SetLayersFromStackup( STATE& aState, const BOARD_STACKUP& aStackup, int aCopperLayerCount );
146
147 explicit VIA_CROSS_SECTION_GEOMETRY( const STATE& aState );
148
149 double GridHeight() const { return m_gridHeight; }
150 int InnerLayers() const { return m_innerLayers; }
151
153 double LayerCentre( int aOrdinal ) const;
154
155 const std::vector<PIECE>& Bores() const { return m_bores; }
156 const std::vector<PIECE>& Cuts() const { return m_cuts; }
157 const std::vector<BODY>& Bodies() const { return m_bodies; }
158
159 const BODY& Body( MATERIAL aMaterial ) const;
160
161private:
162 void build( const STATE& aState );
163
166 std::vector<double> m_layerCentres;
167 std::vector<PIECE> m_bores;
168 std::vector<PIECE> m_cuts;
169 std::vector<BODY> m_bodies;
170};
171
172#endif
Manage layers needed to make a physical board.
Base material class that can be used to derive other material implementations.
Definition material.h:236
double LayerCentre(int aOrdinal) const
Grid height of the centre of a copper layer, by ordinal.
const std::vector< PIECE > & Bores() const
CLIP
What is clipped out of a body.
static double GridHeightFor(int aInnerLayers)
Grid height for a board with the given number of inner copper layers.
const BODY & Body(MATERIAL aMaterial) const
MATERIAL
The materials, in the order they are painted.
const std::vector< PIECE > & Cuts() const
static int SetLayersFromStackup(STATE &aState, const BOARD_STACKUP &aStackup, int aCopperLayerCount)
Fill the layer depths and thicknesses from a stackup, or leave them empty when it does not match the ...
const std::vector< BODY > & Bodies() const
bool m_Rect
A rectangle holds its top left and bottom right corners, a polygon its outline.
std::optional< PAD_DRILL_POST_MACHINING_MODE > m_Mode
std::vector< bool > m_RingLayers
Which spanned copper layers keep an annular ring. Empty means all of them.
std::vector< double > m_LayerDepths
Depth of each copper layer centre and its thickness, as fractions of the board thickness,...
int m_TopLayer
Copper layers the via spans, as ordinals where 0 is the front layer and the inner count plus one is t...
std::optional< int > m_BackdrillFrontLayers
Copper layers removed from that side by the backdrill, 0 for no backdrill, and the backdrill diameter...
double m_PadRatio
Pad diameter over hole diameter.
VIA_CROSS_SECTION_GEOMETRY::STATE STATE
VIA_CROSS_SECTION_GEOMETRY::BODY BODY