\doxysection{Via.\+hpp}
\hypertarget{Via_8hpp_source}{}\label{Via_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Via.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Via.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_VIA\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_VIA\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ "{}Py.hpp"{}}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}Geometry.hpp"{}}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}};}
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{keyword}{class\ }Via}
\DoxyCodeLine{00010\ \{}
\DoxyCodeLine{00011\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00012\ \ \ \ \ Via()\ \{\ \}}
\DoxyCodeLine{00013\ \ \ \ \ Via(\textcolor{keyword}{const}\ Point\_2\&,\ uint\ z1,\ uint\ z2,\ Real\ r);}
\DoxyCodeLine{00014\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ location()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mPoint;\ \}}
\DoxyCodeLine{00015\ \ \ \ \ uint\ zmin()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer[0];\ \}}
\DoxyCodeLine{00016\ \ \ \ \ uint\ zmax()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer[1];\ \}}
\DoxyCodeLine{00017\ \ \ \ \ uint\ z(uint\ i)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer[i];\ \}}
\DoxyCodeLine{00018\ \ \ \ \ uint\ height()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ zmax()\ -\/\ zmin()\ +\ 1;\ \}}
\DoxyCodeLine{00019\ \ \ \ \ Real\ diameter()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mRadius\ *\ 2.0;\ \}}
\DoxyCodeLine{00020\ \ \ \ \ Real\ radius()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mRadius;\ \}}
\DoxyCodeLine{00021\ \ \ \ \ Real\ squared\_radius()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mRadius\ *\ mRadius;\ \}}
\DoxyCodeLine{00022\ \ \ \ \ \textcolor{keywordtype}{bool}\ overlaps(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\&,\ Real\ clearance,\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ *\ =\ 0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00023\ \ \ \ \ \textcolor{keywordtype}{bool}\ overlaps(\textcolor{keyword}{const}\ Via\&,\ Real\ clearance,\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ *\ =\ 0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00024\ \ \ \ \ \textcolor{keywordtype}{bool}\ contains(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00025\ \ \ \ \ Bbox\_2\ bbox()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00026\ \ \ \ \ Circle\_2\ getCircle()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Circle\_2(mPoint,\ mRadius\ *\ mRadius);\ \}}
\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keywordtype}{bool}\ onLayer(uint\ z)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer[0]\ <=\ z\ \&\&\ z\ <=\ mLayer[1];\ \}}
\DoxyCodeLine{00029\ \ \ \ \ uint\ \mbox{\hyperlink{classVia_a4fc42a6fd2de3b959fcb8dd0d06fdddc}{otherEnd}}(uint\ z)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00030\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \mbox{\hyperlink{classVia_a4fc42a6fd2de3b959fcb8dd0d06fdddc}{otherEnd}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00031\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ zminEnd()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(mPoint,\ zmin());\ \}}
\DoxyCodeLine{00032\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ zmaxEnd()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(mPoint,\ zmax());\ \}}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordtype}{void}\ extendTo(uint\ z);}
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{keywordtype}{void}\ merge(\textcolor{keyword}{const}\ Via\&);}
\DoxyCodeLine{00035\ \ \ \ \ uint\ cutLayers(uint\ zmin,\ uint\ zmax);\ \textcolor{comment}{//\ returns\ height\ left}}
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordtype}{void}\ setRange(uint\ zmin,\ uint\ zmax);}
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keyword}{static}\ Via\ fromPy(PyObject\ *);}
\DoxyCodeLine{00038\ \ \ \ \ std::string\ str()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00039\ \ \ \ \ PyObject\ *getPy()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00040\ \ \ \ \ PyObject\ *getShortPy()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00041\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00042\ \ \ \ \ Point\_2\ mPoint;}
\DoxyCodeLine{00043\ \ \ \ \ uint\ mLayer[2];}
\DoxyCodeLine{00044\ \ \ \ \ Real\ mRadius;}
\DoxyCodeLine{00045\ \};}
\DoxyCodeLine{00046\ \textcolor{keyword}{inline}\ Via::Via(\textcolor{keyword}{const}\ Point\_2\ \&v,\ uint\ z1,\ uint\ z2,\ Real\ r)\ :\ mPoint(v),\ mRadius(r)}
\DoxyCodeLine{00047\ \{}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordflow}{if}\ (z1\ ==\ z2)}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::invalid\_argument(\textcolor{stringliteral}{"{}via\ of\ 0\ height"{}});}
\DoxyCodeLine{00050\ \ \ \ \ mLayer[0]\ =\ std::min(z1,\ z2);}
\DoxyCodeLine{00051\ \ \ \ \ mLayer[1]\ =\ std::max(z1,\ z2);}
\DoxyCodeLine{00052\ \}}
\DoxyCodeLine{00053\ \textcolor{keyword}{inline}\ uint\ \mbox{\hyperlink{classVia_a4fc42a6fd2de3b959fcb8dd0d06fdddc}{Via::otherEnd}}(uint\ z)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00054\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordflow}{if}\ (z\ !=\ zmin()\ \&\&\ z\ !=\ zmax())}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}the\ other\ end\ of\ this\ via\ from\ the\ specified\ point\ is\ not\ clearly\ defined"{}});}
\DoxyCodeLine{00057\ \ \ \ \ \textcolor{keywordflow}{return}\ z\ ==\ zmin()\ ?\ zmax()\ :\ zmin();}
\DoxyCodeLine{00058\ \}}
\DoxyCodeLine{00059\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \mbox{\hyperlink{classVia_a4fc42a6fd2de3b959fcb8dd0d06fdddc}{Via::otherEnd}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \&v)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00060\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00061\ \ \ \ \ assert(contains(v));}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(v.xy(),\ \mbox{\hyperlink{classVia_a4fc42a6fd2de3b959fcb8dd0d06fdddc}{otherEnd}}(v.z()));}
\DoxyCodeLine{00063\ \}}
\DoxyCodeLine{00064\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ Via::extendTo(uint\ z)}
\DoxyCodeLine{00065\ \{}
\DoxyCodeLine{00066\ \ \ \ \ mLayer[0]\ =\ std::min(mLayer[0],\ z);}
\DoxyCodeLine{00067\ \ \ \ \ mLayer[1]\ =\ std::max(mLayer[1],\ z);}
\DoxyCodeLine{00068\ \}}
\DoxyCodeLine{00069\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ Via::setRange(uint\ zmin,\ uint\ zmax)}
\DoxyCodeLine{00070\ \{}
\DoxyCodeLine{00071\ \ \ \ \ assert(zmin\ <=\ zmax);}
\DoxyCodeLine{00072\ \ \ \ \ mLayer[0]\ =\ zmin;}
\DoxyCodeLine{00073\ \ \ \ \ mLayer[1]\ =\ zmax;}
\DoxyCodeLine{00074\ \}}
\DoxyCodeLine{00075\ }
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_VIA\_H}}

\end{DoxyCode}
