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

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_OBJECT\_H}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_OBJECT\_H}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}AShape.hpp"{}}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <string>}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classCloneEnv}{CloneEnv}};}
\DoxyCodeLine{00009\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classVia}{Via}};}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{keyword}{class\ }Object}
\DoxyCodeLine{00012\ \{}
\DoxyCodeLine{00013\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00014\ \ \ \ \ Object(Object\ *parent,\ \textcolor{keyword}{const}\ std::string\ \&name);}
\DoxyCodeLine{00015\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00016\ \ \ \ \ \textcolor{keyword}{virtual}\ Object\ *clone(\mbox{\hyperlink{classCloneEnv}{CloneEnv}}\&)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ 0;\ \}}
\DoxyCodeLine{00017\ \ \ \ \ \textcolor{keyword}{virtual}\ \string~Object();}
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ \ \ \ \ \textcolor{keyword}{const}\ std::string\&\ name()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mName;\ \}}
\DoxyCodeLine{00020\ \ \ \ \ std::string\ getFullName()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \ \ \ \ uint\ id()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mId;\ \}}
\DoxyCodeLine{00023\ \ \ \ \ \textcolor{keywordtype}{void}\ setId(uint\ \textcolor{keywordtype}{id})\ \{\ mId\ =\ id;\ \}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \ \ \ \ \textcolor{keywordtype}{bool}\ hasParent()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ !!mParent;\ \}}
\DoxyCodeLine{00026\ \ \ \ \ Object\ *getParent()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mParent;\ \}}
\DoxyCodeLine{00027\ \ \ \ \ Object\ *getChildAt(\textcolor{keyword}{const}\ Point\_2\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00028\ }
\DoxyCodeLine{00029\ \ \ \ \ \textcolor{keyword}{const}\ std::vector<Object\ *>\&\ getChildren()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mChildren;\ \}}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keywordtype}{void}\ addChild(Object\&);}
\DoxyCodeLine{00031\ \ \ \ \ uint\ numChildren()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mChildren.size();\ \}}
\DoxyCodeLine{00032\ \ \ \ \ \textcolor{keywordtype}{bool}\ hasChildren()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ !mChildren.empty();\ \}}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordtype}{void}\ removeChild(Object\&);}
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ getCenter()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCenter;\ \}}
\DoxyCodeLine{00037\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \mbox{\hyperlink{classObject_a228d400bb68d60657903ee98e57505b2}{getCenter25}}()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keyword}{const}\ Bbox\_2\ getBbox()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mShape-\/>bbox();\ \}}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00040\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ addOccludedObject(Object\&)\ \{\ \}}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keywordtype}{void}\ translate(\textcolor{keyword}{const}\ Vector\_2\&);}
\DoxyCodeLine{00043\ \ \ \ \ \textcolor{keywordtype}{void}\ transform(\textcolor{keyword}{const}\ Aff\_transformation\_2\&);}
\DoxyCodeLine{00044\ \ \ \ \ \textcolor{keywordtype}{void}\ rotateAround(\textcolor{keyword}{const}\ Point\_2\ \&refPoint,\ Real\ angleRadians);}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keywordtype}{bool}\ isOnLayer(\textcolor{keywordtype}{int}\ z)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayerRange[0]\ <=\ z\ \&\&\ z\ <=\ mLayerRange[1];\ \}}
\DoxyCodeLine{00047\ \ \ \ \ \textcolor{keywordtype}{int}\ minLayer()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayerRange[0];\ \}}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordtype}{int}\ maxLayer()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayerRange[1];\ \}}
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keywordtype}{void}\ setLayer(\textcolor{keywordtype}{int});}
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keywordtype}{void}\ setLayerRange(\textcolor{keywordtype}{int},\ \textcolor{keywordtype}{int});}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keywordtype}{int}\ getSingleLayer()\textcolor{keyword}{\ const\ }\{\ assert(mLayerRange[0]\ ==\ mLayerRange[1]);\ \textcolor{keywordflow}{return}\ mLayerRange[0];\ \}}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keywordtype}{bool}\ sharesLayer(\textcolor{keyword}{const}\ Object\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00054\ \ \ \ \ Real\ getClearance()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mClearance;\ \}}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordtype}{void}\ setClearance(Real\ c)\ \{\ mClearance\ =\ c;\ \}}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00057\ \ \ \ \ \mbox{\hyperlink{classAShape}{AShape}}\ *getShape()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mShape.get();\ \}}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(\textcolor{keyword}{const}\ Circle\_2\&);}
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(\textcolor{keyword}{const}\ Triangle\_2\&);}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(\textcolor{keyword}{const}\ Iso\_rectangle\_2\&);}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(\textcolor{keyword}{const}\ Polygon\_2\&);}
\DoxyCodeLine{00063\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\&,\ Real\ angleTolerance\ =\ 0.0);}
\DoxyCodeLine{00064\ \ \ \ \ \textcolor{keywordtype}{void}\ setShape(Polygon\_2\&\&);}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keywordtype}{bool}\ canRouteInside()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCanRouteInside;\ \}}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{keywordtype}{void}\ setCanRouteInside(\textcolor{keywordtype}{bool}\ b)\ \{\ mCanRouteInside\ =\ b;\ \}}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keywordtype}{bool}\ canPlaceViasInside()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCanPlaceViasInside;\ \}}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keywordtype}{void}\ setCanPlaceViasInside(\textcolor{keywordtype}{bool}\ b)\ \{\ mCanPlaceViasInside\ =\ b;\ \}}
\DoxyCodeLine{00070\ \ \ \ \ \textcolor{keywordtype}{bool}\ isSelected()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mSelectionFlag;\ \}}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keywordtype}{void}\ setSelected(\textcolor{keywordtype}{bool}\ b)\ \{\ mSelectionFlag\ =\ b;\ \}}
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{keywordtype}{void}\ setSelected(\textcolor{keywordtype}{bool}\ b,\ uint\ recursion);}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ \ \ \ \ \textcolor{keywordtype}{bool}\ violatesClearance(\textcolor{keyword}{const}\ \mbox{\hyperlink{classVia}{Via}}\&,\ Real\ clearance,\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ *\ =\ 0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keywordtype}{bool}\ violatesClearance(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\&,\ Real\ clearance,\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ *\ =\ 0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \ \ \ \ Real\ distanceTo(\textcolor{keyword}{const}\ Point\_2\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ std::sqrt(mShape-\/>squared\_distance(v));\ \}}
\DoxyCodeLine{00078\ \ \ \ \ \textcolor{keywordtype}{bool}\ contains2D(\textcolor{keyword}{const}\ Point\_2\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mShape-\/>contains(v);\ \}}
\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keywordtype}{bool}\ contains3D(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mShape-\/>contains(v.xy())\ \&\&\ isOnLayer(v.z());\ \}}
\DoxyCodeLine{00080\ \ \ \ \ \textcolor{keywordtype}{bool}\ isInsideBbox(\textcolor{keyword}{const}\ Point\_2\ \&v)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00081\ \ \ \ \ \textcolor{keywordtype}{bool}\ isInsideBbox(\textcolor{keyword}{const}\ Point\_2\ \&v,\ \textcolor{keywordtype}{int}\ zmin,\ \textcolor{keywordtype}{int}\ zmax)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keywordtype}{bool}\ intersects(\textcolor{keyword}{const}\ Bbox\_2\ \&B)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mShape-\/>intersects(B);\ \}}
\DoxyCodeLine{00083\ \ \ \ \ \textcolor{keywordtype}{bool}\ intersects(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ \&s)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ isOnLayer(s.z())\ \&\&\ mShape-\/>intersects(s);\ \}}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keywordtype}{bool}\ intersects(\textcolor{keyword}{const}\ Object\ \&A)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ sharesLayer(A)\ \&\&\ mShape-\/>intersects(*A.getShape());\ \}}
\DoxyCodeLine{00085\ \ \ \ \ \textcolor{keywordtype}{bool}\ bboxTest(\textcolor{keyword}{const}\ Bbox\_2\ \&B)\ \{\ \textcolor{keywordflow}{return}\ CGAL::do\_overlap(getBbox(),\ B);\ \}}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordtype}{bool}\ bboxTest(\textcolor{keyword}{const}\ Bbox\_2\ \&B,\ \textcolor{keywordtype}{int}\ z0,\ \textcolor{keywordtype}{int}\ z1\ =\ -\/1);}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00088\ \ \ \ \ \textcolor{keywordtype}{bool}\ isContainerOf(\textcolor{keyword}{const}\ Object\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keywordtype}{void}\ copyFrom(\mbox{\hyperlink{classCloneEnv}{CloneEnv}}\&,\ \textcolor{keyword}{const}\ Object\&);}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \ \ \ \ \textcolor{keyword}{virtual}\ std::string\ str()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \textcolor{stringliteral}{"{}?"{}};\ \}}
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keyword}{virtual}\ PyObject\ *getPy(uint\ depth)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ \textcolor{keywordtype}{bool}\ is\_a()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ !!\textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }T\ *\textcolor{keyword}{>}(\textcolor{keyword}{this});\ \}}
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ \textcolor{keyword}{const}\ T\ *as()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }T\ *\textcolor{keyword}{>}(\textcolor{keyword}{this});\ \}}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ T>\ T\ *as()\ \{\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{dynamic\_cast<}T\ *\textcolor{keyword}{>}(\textcolor{keyword}{this});\ \}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00100\ \ \ \ \ std::unique\_ptr<AShape>\ mShape;}
\DoxyCodeLine{00101\ \ \ \ \ Point\_2\ mCenter;}
\DoxyCodeLine{00102\ \ \ \ \ Object\ *\textcolor{keyword}{const}\ mParent;}
\DoxyCodeLine{00103\ \ \ \ \ std::vector<Object\ *>\ mChildren;}
\DoxyCodeLine{00104\ \ \ \ \ std::string\ mName;}
\DoxyCodeLine{00105\ \ \ \ \ uint\ mId;}
\DoxyCodeLine{00106\ \ \ \ \ uint\ mChildIndex\{std::numeric\_limits<uint>::max()\};}
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{keywordtype}{int}\ mLayerRange[2]\{-\/1,-\/1\};}
\DoxyCodeLine{00108\ \ \ \ \ Real\ mClearance\{0.0\};}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keywordtype}{bool}\ mCanRouteInside\{\textcolor{keyword}{false}\};}
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{keywordtype}{bool}\ mCanPlaceViasInside\{\textcolor{keyword}{true}\};}
\DoxyCodeLine{00111\ \ \ \ \ \textcolor{keywordtype}{bool}\ mSelectionFlag\{\textcolor{keyword}{false}\};}
\DoxyCodeLine{00112\ }
\DoxyCodeLine{00113\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keywordtype}{void}\ update()\ \{\ mCenter\ =\ mShape-\/>centroid();\ \}}
\DoxyCodeLine{00115\ \};}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00117\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \mbox{\hyperlink{classObject_a228d400bb68d60657903ee98e57505b2}{Object::getCenter25}}()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00118\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{keywordtype}{int}\ z\ =\ minLayer();}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{keywordflow}{if}\ (hasParent())}
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ z\ =\ std::max(z,\ getParent()-\/>minLayer());}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(getCenter(),\ z);}
\DoxyCodeLine{00123\ \}}
\DoxyCodeLine{00124\ }
\DoxyCodeLine{00125\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}\ Object::sharesLayer(\textcolor{keyword}{const}\ \mbox{\hyperlink{classObject}{Object}}\ \&A)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00126\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{keywordflow}{return}\ minLayer()\ <=\ A.maxLayer()\ \&\&\ maxLayer()\ >=\ A.minLayer();}
\DoxyCodeLine{00128\ \}}
\DoxyCodeLine{00129\ }
\DoxyCodeLine{00130\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}\ Object::bboxTest(\textcolor{keyword}{const}\ Bbox\_2\ \&B,\ \textcolor{keywordtype}{int}\ z0,\ \textcolor{keywordtype}{int}\ z1)}
\DoxyCodeLine{00131\ \{}
\DoxyCodeLine{00132\ \ \ \ \ \textcolor{keywordflow}{if}\ (z1\ <\ 0)}
\DoxyCodeLine{00133\ \ \ \ \ \ \ \ \ z1\ =\ z0;}
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{keywordflow}{if}\ (mLayerRange[0]\ >\ z1\ ||\ mLayerRange[1]\ <\ z0)}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keywordflow}{return}\ bboxTest(B);}
\DoxyCodeLine{00137\ \}}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_OBJECT\_H}}

\end{DoxyCode}
