\doxysection{Rasterizer\+Midpoint.\+hpp}
\hypertarget{RasterizerMidpoint_8hpp_source}{}\label{RasterizerMidpoint_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/RasterizerMidpoint.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/RasterizerMidpoint.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}Log.hpp"{}}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ "{}Rasterizer.hpp"{}}}
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ "{}Track.hpp"{}}}
\DoxyCodeLine{00005\ }
\DoxyCodeLine{00006\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ Bbox\_2\ \&box,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00007\ \{}
\DoxyCodeLine{00008\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00009\ \ \ \ \ \textcolor{keywordflow}{if}\ (Z1\ <\ Z0\ ||\ Z1\ >=\ mGrid.getSize(2))}
\DoxyCodeLine{00010\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00011\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mExpansion\ -\/\ mGrid.EdgeLen05\ -\/\ mTolerance;}
\DoxyCodeLine{00012\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ eh\ =\ std::max(ex,\ box.xmin()\ -\/\ box.xmax());}
\DoxyCodeLine{00013\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ev\ =\ std::max(ex,\ box.ymin()\ -\/\ box.ymax());}
\DoxyCodeLine{00014\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X0\ =\ mGrid.XIndexBounded(box.xmin(),\ -\/eh);}
\DoxyCodeLine{00015\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X1\ =\ mGrid.XIndexBounded(box.xmax(),\ +eh);}
\DoxyCodeLine{00016\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(box.ymin(),\ -\/ev);}
\DoxyCodeLine{00017\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(box.ymax(),\ +ev);}
\DoxyCodeLine{00018\ \ \ \ \ OP.writeRangeZYX(Z0,\ Z1,\ Y0,\ Y1,\ X0,\ X1);}
\DoxyCodeLine{00019\ \}}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ Bbox\_2\ \&box,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00022\ \{}
\DoxyCodeLine{00023\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00024\ \ \ \ \ \textcolor{keywordflow}{if}\ (Z1\ <\ Z0\ ||\ Z1\ >=\ mGrid.getSize(2))}
\DoxyCodeLine{00025\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00026\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mExpansion\ -\/\ mGrid.EdgeLen05\ -\/\ mTolerance;}
\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ eh\ =\ std::max(ex,\ box.xmin()\ -\/\ box.xmax());}
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ev\ =\ std::max(ex,\ box.ymin()\ -\/\ box.ymax());}
\DoxyCodeLine{00029\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X0\ =\ mGrid.XIndexBounded(box.xmin(),\ -\/eh);}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X1\ =\ mGrid.XIndexBounded(box.xmax(),\ +eh);}
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(box.ymin(),\ -\/ev);}
\DoxyCodeLine{00032\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(box.ymax(),\ +ev);}
\DoxyCodeLine{00033\ \ \ \ \ OP.reserve(4);}
\DoxyCodeLine{00034\ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y0,\ X0,\ X1);}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordflow}{if}\ (Y1\ ==\ Y0)}
\DoxyCodeLine{00036\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00037\ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y1,\ X0,\ X1);}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordflow}{if}\ (Y1\ ==\ (Y0\ +\ 1))}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00040\ \ \ \ \ OP.writeRangeZY(Z0,\ Z1,\ Y0+1,\ Y1-\/1,\ X0);}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keywordflow}{if}\ (X0\ !=\ X1)}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ OP.writeRangeZY(Z0,\ Z1,\ Y0+1,\ Y1-\/1,\ X1);}
\DoxyCodeLine{00043\ \}}
\DoxyCodeLine{00044\ }
\DoxyCodeLine{00045\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ Circle\_2\ \&C,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00046\ \{}
\DoxyCodeLine{00047\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&O\ =\ C.center();}
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ r\ \ =\ std::sqrt(C.squared\_radius())\ +\ mExpansion;}
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ r2\ =\ r\ *\ r;}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ std::min(mGrid.EdgeLen05\ +\ mTolerance,\ r);\ \textcolor{comment}{//\ ensure\ Y0\ <=\ Y1}}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(O.y()\ -\/\ r,\ +ex);}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(O.y()\ +\ r,\ -\/ex);}
\DoxyCodeLine{00054\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}rasterizeCircle:\ O="{}}\ <<\ O\ <<\ \textcolor{stringliteral}{"{}\ r="{}}\ <<\ r\ <<\ \textcolor{stringliteral}{"{}\ Z=["{}}\ <<\ Z0\ <<\ \textcolor{charliteral}{','}\ <<\ Z1\ <<\ \textcolor{stringliteral}{"{}]\ Y=["{}}\ <<\ Y0\ <<\ \textcolor{charliteral}{','}\ <<\ Y1\ <<\ \textcolor{charliteral}{']'});}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keyword}{auto}\ cY\ =\ mGrid.MidPointY(Y0)\ -\/\ O.y();\ \textcolor{comment}{//\ y-\/distance\ from\ circle\ center\ to\ midpoint\ of\ lowest\ row}}
\DoxyCodeLine{00056\ \ \ \ \ assert(Y0\ <=\ Y1);}
\DoxyCodeLine{00057\ \ \ \ \ assert(cY\ <=\ mGrid.EdgeLen05);\ \textcolor{comment}{//\ can\ be\ >\ 0\ for\ small\ circles\ centered\ below\ the\ midpoint}}
\DoxyCodeLine{00058\ \ \ \ \ OP.reserve(Y1\ -\/\ Y0\ +\ 1);}
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ Y\ =\ Y0;\ Y\ <=\ Y1;\ ++Y,\ cY\ +=\ mGrid.EdgeLen)\ \{}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ cX\ =\ std::sqrt(std::max(r2\ -\/\ cY\ *\ cY,\ 0.0));\ \textcolor{comment}{//\ x-\/distance\ corresponding\ to\ y-\/distance\ on\ circle}}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X0\ =\ mGrid.XIndexBounded(O.x()\ -\/\ cX,\ +ex);}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X1\ =\ mGrid.XIndexBounded(O.x()\ +\ cX,\ -\/ex);}
\DoxyCodeLine{00063\ \ \ \ \ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y,\ X0,\ X1);}
\DoxyCodeLine{00064\ \ \ \ \ \}}
\DoxyCodeLine{00065\ \}}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00067\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ Circle\_2\&,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00068\ \{}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}FIXME:\ circle\ border\ rasterization"{}});}
\DoxyCodeLine{00070\ \}}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00072\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ \&s,\ uint\ capsMask)}
\DoxyCodeLine{00073\ \{}
\DoxyCodeLine{00074\ \ \ \ \ rasterizeFill(s,\ capsMask,\ s.z(),\ s.z());}
\DoxyCodeLine{00075\ \}}
\DoxyCodeLine{00076\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ \&s,\ uint\ capsMask,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00077\ \{}
\DoxyCodeLine{00078\ \ \ \ \ assert(Z0\ >=\ 0\ \&\&\ Z0\ <=\ Z1\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \ \ \ \ \textcolor{keywordflow}{if}\ (capsMask\ \&\ RASTERIZE\_CAPS\_MASK\_SOURCE)}
\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ rasterizeFill(s.sourceCap(),\ Z0,\ Z1);}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keywordflow}{if}\ (capsMask\ \&\ RASTERIZE\_CAPS\_MASK\_TARGET)}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ rasterizeFill(s.targetCap(),\ Z0,\ Z1);}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00085\ \ \ \ \ \textcolor{keyword}{const}\ Real\ ex\ =\ s.halfWidth()\ +\ mExpansion;}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{if}\ (s.base().is\_horizontal())}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ rasterizeHSegment(s.base().s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00088\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (s.base().is\_vertical())}
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ rasterizeVSegment(s.base().s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keywordflow}{else}\ rasterizeDSegment(s.base().s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00091\ \}}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ \&s,\ uint\ capsMask)}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \ rasterizeLine(capsMask\ ?\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}(s.\mbox{\hyperlink{classWideSegment__25_a3fe8f9228b57aa9fb29c7171c676658f}{s2\_extended}}(capsMask),\ s.z())\ :\ s.base());}
\DoxyCodeLine{00096\ \}}
\DoxyCodeLine{00097\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ \&s,\ uint\ capsMask,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00098\ \{}
\DoxyCodeLine{00099\ \ \ \ \ rasterizeLine(capsMask\ ?\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}(s.\mbox{\hyperlink{classWideSegment__25_a3fe8f9228b57aa9fb29c7171c676658f}{s2\_extended}}(capsMask),\ s.z())\ :\ s.base(),\ Z0,\ Z1);}
\DoxyCodeLine{00100\ \}}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00102\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s)}
\DoxyCodeLine{00103\ \{}
\DoxyCodeLine{00104\ \ \ \ \ rasterizeFill(s,\ s.z(),\ s.z());}
\DoxyCodeLine{00105\ \}}
\DoxyCodeLine{00106\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00107\ \{}
\DoxyCodeLine{00108\ \ \ \ \ assert(Z0\ >=\ 0\ \&\&\ Z0\ <=\ Z1\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keyword}{const}\ Real\ ex\ =\ mExpansion;}
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{keywordflow}{if}\ (s.is\_horizontal())}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ rasterizeHSegment(s.s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (s.is\_vertical())}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ rasterizeVSegment(s.s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keywordflow}{else}\ rasterizeDSegment(s.s2(),\ Z0,\ Z1,\ ex);}
\DoxyCodeLine{00115\ \}}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00117\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s)}
\DoxyCodeLine{00118\ \{}
\DoxyCodeLine{00119\ \ \ \ \ rasterizeLine(s,\ s.z(),\ s.z());}
\DoxyCodeLine{00120\ \}}
\DoxyCodeLine{00121\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00122\ \{}
\DoxyCodeLine{00123\ \ \ \ \ assert(Z0\ >=\ 0\ \&\&\ Z0\ <=\ Z1\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00124\ \ \ \ \ \textcolor{keywordflow}{if}\ (s.is\_horizontal())}
\DoxyCodeLine{00125\ \ \ \ \ \ \ \ \ rasterizeHSegmentLine(s.s2(),\ Z0,\ Z1);}
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (s.is\_vertical())}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ rasterizeVSegmentLine(s.s2(),\ Z0,\ Z1);}
\DoxyCodeLine{00128\ \ \ \ \ \textcolor{keywordflow}{else}\ rasterizeDSegmentLine(s.s2(),\ Z0,\ Z1);}
\DoxyCodeLine{00129\ \}}
\DoxyCodeLine{00130\ }
\DoxyCodeLine{00131\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ Triangle\_2\ \&T,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00132\ \{}
\DoxyCodeLine{00133\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{keywordflow}{if}\ (mExpansion)}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}FIXME:\ triangle\ rasterization\ with\ dilation"{}});}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mGrid.EdgeLen05\ +\ mTolerance;}
\DoxyCodeLine{00137\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ box\ =\ T.bbox();}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ XL\ =\ mGrid.XIndexBounded(box.xmin(),\ +ex);}
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ XR\ =\ mGrid.XIndexBounded(box.xmax(),\ -\/ex);}
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ xL\ =\ mGrid.MidPointX(XL);}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ xR\ =\ mGrid.MidPointX(XR);}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(box.ymin(),\ +ex);}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(box.ymax(),\ -\/ex);}
\DoxyCodeLine{00144\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y0\ =\ mGrid.MidPointY(Y0);}
\DoxyCodeLine{00145\ \ \ \ \ OP.reserve(Y1\ -\/\ Y0\ +\ 1);}
\DoxyCodeLine{00146\ \ \ \ \ Point\_2\ v(xL,\ y0);}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ Y\ =\ Y0;\ Y\ <=\ Y1;\ ++Y,\ v\ =\ Point\_2(xL,\ v.y()\ +\ mGrid.EdgeLen))\ \{}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ uint\ X0,\ X1;}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (X0\ =\ XL,\ v\ =\ Point\_2(xL,\ v.y());\ X0\ <=\ XR\ \&\&\ T.has\_on\_unbounded\_side(v);\ ++X0)}
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ Point\_2(v.x()\ +\ mGrid.EdgeLen,\ v.y());}
\DoxyCodeLine{00151\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (X0\ >\ XR)}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00153\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (X1\ =\ XR,\ v\ =\ Point\_2(xR,\ v.y());\ X1\ >\ \ X0\ \&\&\ T.has\_on\_unbounded\_side(v);\ -\/-\/X1)}
\DoxyCodeLine{00154\ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ Point\_2(v.x()\ -\/\ mGrid.EdgeLen,\ v.y());}
\DoxyCodeLine{00155\ \ \ \ \ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y,\ X0,\ X1);}
\DoxyCodeLine{00156\ \ \ \ \ \}}
\DoxyCodeLine{00157\ \}}
\DoxyCodeLine{00158\ }
\DoxyCodeLine{00159\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ Triangle\_2\ \&T,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00160\ \{}
\DoxyCodeLine{00161\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mExpansion;}
\DoxyCodeLine{00163\ \ \ \ \ mExpansion\ =\ 0.0;}
\DoxyCodeLine{00164\ \ \ \ \ rasterizeLine(Segment\_2(T.vertex(0),\ T.vertex(1)),\ Z0,\ Z1);}
\DoxyCodeLine{00165\ \ \ \ \ rasterizeLine(Segment\_2(T.vertex(1),\ T.vertex(2)),\ Z0,\ Z1);}
\DoxyCodeLine{00166\ \ \ \ \ rasterizeLine(Segment\_2(T.vertex(2),\ T.vertex(0)),\ Z0,\ Z1);}
\DoxyCodeLine{00167\ \ \ \ \ mExpansion\ =\ ex;}
\DoxyCodeLine{00168\ \}}
\DoxyCodeLine{00169\ }
\DoxyCodeLine{00170\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ Polygon\_2\ \&\_G,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00171\ \{}
\DoxyCodeLine{00172\ \ \ \ \ Polygon\_2\ G\_ex;}
\DoxyCodeLine{00173\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00174\ \ \ \ \ \textcolor{keywordflow}{if}\ (mExpansion)}
\DoxyCodeLine{00175\ \ \ \ \ \ \ \ \ G\_ex\ =\ \mbox{\hyperlink{classPolygonEx_aca375299510998c8ed21b72e26d4a577}{PolygonEx::grow}}(\_G,\ mExpansion);}
\DoxyCodeLine{00176\ \ \ \ \ \textcolor{keyword}{const}\ Polygon\_2\ *G\ =\ mExpansion\ ?\ \&G\_ex\ :\ \&\_G;}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mGrid.EdgeLen05\ +\ mTolerance;}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ box\ =\ G-\/>bbox();}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ XL\ =\ mGrid.XIndexBounded(box.xmin(),\ +ex);}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ XR\ =\ mGrid.XIndexBounded(box.xmax(),\ -\/ex);}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ xL\ =\ mGrid.MidPointX(XL);}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ xR\ =\ mGrid.MidPointX(XR);}
\DoxyCodeLine{00183\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(box.ymin(),\ +ex);}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(box.ymax(),\ -\/ex);}
\DoxyCodeLine{00185\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y0\ =\ mGrid.MidPointY(Y0);}
\DoxyCodeLine{00186\ \ \ \ \ OP.reserve(Y1\ -\/\ Y0\ +\ 1);}
\DoxyCodeLine{00187\ \ \ \ \ Point\_2\ v(xL,\ y0);}
\DoxyCodeLine{00188\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ Y\ =\ Y0;\ Y\ <=\ Y1;\ ++Y,\ v\ =\ Point\_2(xL,\ v.y()\ +\ mGrid.EdgeLen))\ \{}
\DoxyCodeLine{00189\ \ \ \ \ \ \ \ \ uint\ X0,\ X1;}
\DoxyCodeLine{00190\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (X0\ =\ XL,\ v\ =\ Point\_2(xL,\ v.y());\ X0\ <=\ XR\ \&\&\ G-\/>has\_on\_unbounded\_side(v);\ ++X0)}
\DoxyCodeLine{00191\ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ Point\_2(v.x()\ +\ mGrid.EdgeLen,\ v.y());}
\DoxyCodeLine{00192\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (X0\ >\ XR)}
\DoxyCodeLine{00193\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00194\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (X1\ =\ XR,\ v\ =\ Point\_2(xR,\ v.y());\ X1\ >\ \ X0\ \&\&\ G-\/>has\_on\_unbounded\_side(v);\ -\/-\/X1)}
\DoxyCodeLine{00195\ \ \ \ \ \ \ \ \ \ \ \ \ v\ =\ Point\_2(v.x()\ -\/\ mGrid.EdgeLen,\ v.y());}
\DoxyCodeLine{00196\ \ \ \ \ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y,\ X0,\ X1);}
\DoxyCodeLine{00197\ \ \ \ \ \}}
\DoxyCodeLine{00198\ \}}
\DoxyCodeLine{00199\ }
\DoxyCodeLine{00200\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ Polygon\_2\ \&G,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00201\ \{}
\DoxyCodeLine{00202\ \ \ \ \ assert(Z1\ >=\ Z0\ \&\&\ Z1\ <\ mGrid.getSize(2));}
\DoxyCodeLine{00203\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ E\ =\ G.edges\_begin();\ E\ !=\ G.edges\_end();\ ++E)}
\DoxyCodeLine{00204\ \ \ \ \ \ \ \ \ rasterizeLine(*E,\ Z0,\ Z1);}
\DoxyCodeLine{00205\ \}}
\DoxyCodeLine{00206\ }
\DoxyCodeLine{00207\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeHSegment(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ uint\ Z0,\ uint\ Z1,\ Real\ \_ex)}
\DoxyCodeLine{00208\ \{}
\DoxyCodeLine{00209\ \ \ \ \ \textcolor{comment}{//\ Midpoint\ rasterization:}}
\DoxyCodeLine{00210\ \ \ \ \ \textcolor{comment}{//\ 0.5\ to\ 1.5\ with\ shifting\ by\ 0.5\ becomes\ 1\ to\ 1\ but\ we\ want\ to\ draw\ both\ 0\ and\ 1\ so\ we\ subtract\ tolerance\ on\ the\ left.}}
\DoxyCodeLine{00211\ \ \ \ \ \textcolor{comment}{//\ 0.5\ to\ 1.4\ becomes\ 1-\/TOL\ to\ 0.9\ so\ we\ correctly\ only\ draw\ on\ 0.}}
\DoxyCodeLine{00212\ \ \ \ \ \textcolor{comment}{//\ 0.0\ to\ 0.4\ becomes\ 0.2-\/TOL\ to\ 0.2,\ but\ we\ draw\ on\ 0\ anyway\ because\ we\ always\ draw\ at\ least\ 1\ cell.}}
\DoxyCodeLine{00213\ \ \ \ \ \textcolor{comment}{//\ We\ also\ need\ to\ add\ tolerance\ on\ the\ right\ because\ there\ can\ be\ tiny\ errors\ such\ that\ we\ get\ 0\ to\ 0.99999999999994\ which\ should\ really\ be\ 1\ with\ exact\ calculations.}}
\DoxyCodeLine{00214\ \ \ \ \ \textcolor{comment}{//\ Something\ will\ always\ be\ off\ somewhere\ :(}}
\DoxyCodeLine{00215\ \ \ \ \ assert(s.source().y()\ ==\ s.target().y());}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ x0\ =\ std::min(s.source().x(),\ s.target().x());}
\DoxyCodeLine{00217\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ x1\ =\ std::max(s.source().x(),\ s.target().x());}
\DoxyCodeLine{00218\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ hex\ =\ std::min(mGrid.EdgeLen05\ -\/\ mTolerance,\ (x1\ -\/\ x0)\ *\ 0.5);}
\DoxyCodeLine{00219\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ vex\ =\ std::min(mGrid.EdgeLen05\ +\ mTolerance\ -\/\ \_ex,\ 0.0);}
\DoxyCodeLine{00220\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X0\ =\ mGrid.XIndexBounded(x0,\ +hex);}
\DoxyCodeLine{00221\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X1\ =\ mGrid.XIndexBounded(x1,\ -\/hex);}
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(s.source().y(),\ +vex);}
\DoxyCodeLine{00223\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(s.source().y(),\ -\/vex);}
\DoxyCodeLine{00224\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}rasterizeSegmentH\ rect["{}}\ <<\ X0\ <<\ \textcolor{charliteral}{','}\ <<\ X1\ <<\ \textcolor{stringliteral}{"{}]x["{}}\ <<\ Y0\ <<\ \textcolor{charliteral}{','}\ <<\ Y1\ <<\ \textcolor{stringliteral}{"{}]\ x=("{}}\ <<\ (x0\ +\ hex\ -\/\ mTolerance)\ <<\ \textcolor{charliteral}{','}\ <<\ (x1\ -\/\ hex)\ <<\ \textcolor{charliteral}{')'});}
\DoxyCodeLine{00225\ \ \ \ \ OP.writeRangeZYX(Z0,\ Z1,\ Y0,\ Y1,\ X0,\ X1);}
\DoxyCodeLine{00226\ \}}
\DoxyCodeLine{00227\ }
\DoxyCodeLine{00228\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeHSegmentLine(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00229\ \{}
\DoxyCodeLine{00230\ \ \ \ \ rasterizeHSegment(s,\ Z0,\ Z1,\ 0.0);}
\DoxyCodeLine{00231\ \}}
\DoxyCodeLine{00232\ }
\DoxyCodeLine{00233\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeVSegment(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ uint\ Z0,\ uint\ Z1,\ Real\ \_ex)}
\DoxyCodeLine{00234\ \{}
\DoxyCodeLine{00235\ \ \ \ \ assert(s.source().x()\ ==\ s.target().x());}
\DoxyCodeLine{00236\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y0\ =\ std::min(s.source().y(),\ s.target().y());}
\DoxyCodeLine{00237\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y1\ =\ std::max(s.source().y(),\ s.target().y());}
\DoxyCodeLine{00238\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ vex\ =\ std::min(mGrid.EdgeLen05\ -\/\ mTolerance,\ (y1\ -\/\ y0)\ *\ 0.5);}
\DoxyCodeLine{00239\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ hex\ =\ std::min(mGrid.EdgeLen05\ +\ mTolerance\ -\/\ \_ex,\ 0.0);}
\DoxyCodeLine{00240\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X0\ =\ mGrid.XIndexBounded(s.source().x(),\ +hex);}
\DoxyCodeLine{00241\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ X1\ =\ mGrid.XIndexBounded(s.source().x(),\ -\/hex);}
\DoxyCodeLine{00242\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(y0,\ +vex);}
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(y1,\ -\/vex);}
\DoxyCodeLine{00244\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}rasterizeSegmentV\ rect["{}}\ <<\ X0\ <<\ \textcolor{charliteral}{','}\ <<\ X1\ <<\ \textcolor{stringliteral}{"{}]x["{}}\ <<\ Y0\ <<\ \textcolor{charliteral}{','}\ <<\ Y1\ <<\ \textcolor{stringliteral}{"{}]\ y=("{}}\ <<\ (y0\ +\ vex\ -\/\ mTolerance)\ <<\ \textcolor{charliteral}{','}\ <<\ (y1\ -\/\ vex)\ <<\ \textcolor{charliteral}{')'});}
\DoxyCodeLine{00245\ \ \ \ \ OP.writeRangeZYX(Z0,\ Z1,\ Y0,\ Y1,\ X0,\ X1);}
\DoxyCodeLine{00246\ \}}
\DoxyCodeLine{00247\ }
\DoxyCodeLine{00248\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeVSegmentLine(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00249\ \{}
\DoxyCodeLine{00250\ \ \ \ \ rasterizeVSegment(s,\ Z0,\ Z1,\ 0.0);}
\DoxyCodeLine{00251\ \}}
\DoxyCodeLine{00252\ }
\DoxyCodeLine{00253\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeDSegment(\textcolor{keyword}{const}\ Segment\_2\ \&\_s,\ uint\ Z0,\ uint\ Z1,\ Real\ \_ex)}
\DoxyCodeLine{00254\ \{}
\DoxyCodeLine{00255\ \ \ \ \ \textcolor{comment}{//\ TODO:\ Verify\ rasterization\ rules.}}
\DoxyCodeLine{00256\ \ \ \ \ \textcolor{keyword}{auto}\ s\ =\ \mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}(\_s,\ Z0,\ \_ex);}
\DoxyCodeLine{00257\ \ \ \ \ \textcolor{keywordflow}{if}\ (s.widerThanBaseLen())}
\DoxyCodeLine{00258\ \ \ \ \ \ \ \ \ s\ =\ s.swapWL(mTolerance,\ -\/2.0\ *\ mTolerance);\ \textcolor{comment}{//\ we\ have\ to\ increase\ the\ width\ a\ bit\ or\ we\ miss\ the\ start\ and\ end\ points\ of\ route\ segments}}
\DoxyCodeLine{00259\ \ \ \ \ s\ =\ s.orderedY();}
\DoxyCodeLine{00260\ \ \ \ \ \textcolor{keywordflow}{if}\ (std::abs(s.base().s2().to\_vector().y())\ <\ 0x1.0p-\/7)}
\DoxyCodeLine{00261\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}FIXME:\ rasterizing\ nearly\ horizontal\ segment\ requires\ special\ handling"{}});}
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mGrid.EdgeLen05;}
\DoxyCodeLine{00263\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ uT\ =\ s.getHalfWidthSpan();}
\DoxyCodeLine{00264\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ vT\ =\ uT.x()\ <\ 0.0\ ?\ -\/uT\ :\ uT;\ \textcolor{comment}{//\ perpendicular\ (half-\/width)\ vector\ with\ dx\ >=\ 0}}
\DoxyCodeLine{00265\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ sL\ =\ Segment\_2(s.source\_2()\ -\/\ vT,\ s.target\_2()\ -\/\ vT);\ \textcolor{comment}{//\ left\ track\ boundary}}
\DoxyCodeLine{00266\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ sR\ =\ Segment\_2(s.source\_2()\ +\ vT,\ s.target\_2()\ +\ vT);\ \textcolor{comment}{//\ right\ track\ boundary}}
\DoxyCodeLine{00267\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ LL\ =\ sL.supporting\_line();}
\DoxyCodeLine{00268\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ LR\ =\ sR.supporting\_line();}
\DoxyCodeLine{00269\ \ \ \ \ \textcolor{comment}{//\ Create\ a\ triangulation\ of\ the\ segment.\ sL\ and\ sR\ have\ the\ same\ endpoint\ order\ so\ the\ edges\ fit.}}
\DoxyCodeLine{00270\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ AL\ =\ Triangle\_2(sL.source(),\ sL.target(),\ sR.source());}
\DoxyCodeLine{00271\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ AR\ =\ Triangle\_2(sR.source(),\ sR.target(),\ sL.target());}
\DoxyCodeLine{00272\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y0\ =\ std::min(sL.source().y(),\ sR.source().y());}
\DoxyCodeLine{00273\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y1\ =\ std::max(sL.target().y(),\ sR.target().y());}
\DoxyCodeLine{00274\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ yA0\ =\ std::max(sL.source().y(),\ sR.source().y());\ \textcolor{comment}{//\ y-\/range\ that\ is\ delimited\ by\ LL\ and\ LR}}
\DoxyCodeLine{00275\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ yA1\ =\ std::min(sL.target().y(),\ sR.target().y());}
\DoxyCodeLine{00276\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y0\ =\ mGrid.YIndexBounded(y0,\ +ex\ -\/\ mTolerance);}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y1\ =\ mGrid.YIndexBounded(y1,\ -\/ex);}
\DoxyCodeLine{00278\ \ \ \ \ \textcolor{keyword}{auto}\ y\ =\ mGrid.MidPointY(Y0);}
\DoxyCodeLine{00279\ \ \ \ \ OP.reserve(Y1\ -\/\ Y0\ +\ 1);}
\DoxyCodeLine{00280\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ Y\ =\ Y0;\ Y\ <=\ Y1;\ ++Y,\ y\ +=\ mGrid.EdgeLen)\ \{}
\DoxyCodeLine{00281\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ X0\ =\ mGrid.XIndexBounded(LL.x\_at\_y(y),\ +ex\ -\/\ mTolerance);}
\DoxyCodeLine{00282\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ X1\ =\ mGrid.XIndexBounded(LR.x\_at\_y(y),\ -\/ex);}
\DoxyCodeLine{00283\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (y\ <\ yA0\ ||\ y\ >\ yA1)\ \{}
\DoxyCodeLine{00284\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ m\ =\ Point\_2(mGrid.MidPointX(X0),\ y);}
\DoxyCodeLine{00285\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ X0\ <\ X1\ \&\&\ AL.has\_on\_unbounded\_side(m)\ \&\&\ AR.has\_on\_unbounded\_side(m);\ ++X0)}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ m\ =\ Point\_2(m.x()\ +\ mGrid.EdgeLen,\ m.y());}
\DoxyCodeLine{00287\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (X0\ !=\ X1)}
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ m\ =\ Point\_2(mGrid.MidPointX(X1),\ m.y());}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (;\ X1\ >=\ X0\ \&\&\ AL.has\_on\_unbounded\_side(m)\ \&\&\ AR.has\_on\_unbounded\_side(m);\ -\/-\/X1)}
\DoxyCodeLine{00290\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ m\ =\ Point\_2(m.x()\ -\/\ mGrid.EdgeLen,\ m.y());}
\DoxyCodeLine{00291\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00292\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (X0\ <=\ X1)}
\DoxyCodeLine{00293\ \ \ \ \ \ \ \ \ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y,\ X0,\ X1);}
\DoxyCodeLine{00294\ \ \ \ \ \}}
\DoxyCodeLine{00295\ \}}
\DoxyCodeLine{00296\ }
\DoxyCodeLine{00297\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeDSegmentLine(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00298\ \{}
\DoxyCodeLine{00299\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ ex\ =\ mTolerance\ +\ mGrid.EdgeLen05;}
\DoxyCodeLine{00300\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ x0\ =\ mGrid.XfIndex(std::min(s.source().x(),\ s.target().x()),\ +ex);}
\DoxyCodeLine{00301\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y0\ =\ mGrid.YfIndex(std::min(s.source().y(),\ s.target().y()),\ +ex);}
\DoxyCodeLine{00302\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ x1\ =\ std::max(mGrid.XfIndex(std::max(s.source().x(),\ s.target().x()),\ -\/ex),\ x0);\ \textcolor{comment}{//\ ==\ if\ within\ tolerance}}
\DoxyCodeLine{00303\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ y1\ =\ std::max(mGrid.YfIndex(std::max(s.source().y(),\ s.target().y()),\ -\/ex),\ y0);}
\DoxyCodeLine{00304\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ \ xR\ =\ std::min(\textcolor{keywordtype}{int}(mGrid.getSize(0))\ -\/\ 1,\ \textcolor{keywordtype}{int}(x1));\ \textcolor{comment}{//\ don't\ overshoot\ ...}}
\DoxyCodeLine{00305\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ \ xL\ =\ std::max(0,\ \textcolor{keywordtype}{int}(x0));\ \textcolor{comment}{//\ or\ undershoot\ on\ nearly\ horizontal\ lines}}
\DoxyCodeLine{00306\ \ \ \ \ \textcolor{keywordflow}{if}\ (xL\ >\ xR)}
\DoxyCodeLine{00307\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00308\ \ \ \ \ OP.reserve(\textcolor{keywordtype}{int}(y1\ -\/\ y0\ +\ 1));}
\DoxyCodeLine{00309\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ xrev\ =\ (s.source().x()\ >\ s.target().x())\ \string^\ (s.source().y()\ >\ s.target().y());}
\DoxyCodeLine{00310\ \ \ \ \ \textcolor{keyword}{const}\ Real\ dxdy\ =\ (s.target().x()\ -\/\ s.source().x())\ /\ (s.target().y()\ -\/\ s.source().y());}
\DoxyCodeLine{00311\ \ \ \ \ Real\ x\ =\ xrev\ ?\ x1\ :\ x0;}
\DoxyCodeLine{00312\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ y\ =\ y0;\ y\ <=\ y1;\ y\ +=\ 1.0,\ x\ +=\ dxdy)\ \{}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ Y\ =\ int(y);}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (Y\ <\ 0\ ||\ Y\ >=\ \textcolor{keywordtype}{int}(mGrid.getSize(1)))}
\DoxyCodeLine{00315\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00316\ \ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ X0\ =\ std::max(xL,\ std::min(xR,\ \textcolor{keywordtype}{int}(x)));}
\DoxyCodeLine{00317\ \ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ X1\ =\ std::max(xL,\ std::min(xR,\ \textcolor{keywordtype}{int}(x\ +\ dxdy)));}
\DoxyCodeLine{00318\ \ \ \ \ \ \ \ \ OP.writeRangeZX(Z0,\ Z1,\ Y,\ std::min(X0,\ X1),\ std::max(X0,\ X1));}
\DoxyCodeLine{00319\ \ \ \ \ \}}
\DoxyCodeLine{00320\ \}}
\DoxyCodeLine{00321\ }
\DoxyCodeLine{00322\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classAShape}{AShape}}\ *H,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00323\ \{}
\DoxyCodeLine{00324\ \ \ \ \ assert(H);}
\DoxyCodeLine{00325\ \ \ \ \ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ R\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Iso\_rectangle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00326\ \ \ \ \ \ \ \ \ rasterizeFill(R-\/>bbox(),\ Z0,\ Z1);}
\DoxyCodeLine{00327\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ C\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Circle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00328\ \ \ \ \ \ \ \ \ rasterizeFill(*C,\ Z0,\ Z1);}
\DoxyCodeLine{00329\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ T\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Triangle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ rasterizeFill(*T,\ Z0,\ Z1);}
\DoxyCodeLine{00331\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ G\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Polygon\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00332\ \ \ \ \ \ \ \ \ rasterizeFill(*G,\ Z0,\ Z1);}
\DoxyCodeLine{00333\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ S\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }\mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00334\ \ \ \ \ \ \ \ \ rasterizeFill(*S,\ 0x3,\ Z0,\ Z1);}
\DoxyCodeLine{00335\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (H)}
\DoxyCodeLine{00336\ \ \ \ \ \ \ \ \ rasterizeFill(H-\/>bbox(),\ Z0,\ Z1);}
\DoxyCodeLine{00337\ \}}
\DoxyCodeLine{00338\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classAShape}{AShape}}\ *H,\ uint\ Z0,\ uint\ Z1)}
\DoxyCodeLine{00339\ \{}
\DoxyCodeLine{00340\ \ \ \ \ assert(H);}
\DoxyCodeLine{00341\ \ \ \ \ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ R\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Iso\_rectangle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00342\ \ \ \ \ \ \ \ \ rasterizeLine(R-\/>bbox(),\ Z0,\ Z1);}
\DoxyCodeLine{00343\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ C\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Circle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00344\ \ \ \ \ \ \ \ \ rasterizeLine(*C,\ Z0,\ Z1);}
\DoxyCodeLine{00345\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ T\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Triangle\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00346\ \ \ \ \ \ \ \ \ rasterizeLine(*T,\ Z0,\ Z1);}
\DoxyCodeLine{00347\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ G\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }Polygon\_2\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00348\ \ \ \ \ \ \ \ \ rasterizeLine(*G,\ Z0,\ Z1);}
\DoxyCodeLine{00349\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ S\ =\ \textcolor{keyword}{dynamic\_cast<}\textcolor{keyword}{const\ }\mbox{\hyperlink{classWideSegment__25}{WideSegment\_25}}\ *\textcolor{keyword}{>}(H))}
\DoxyCodeLine{00350\ \ \ \ \ \ \ \ \ rasterizeLine(*S,\ 0x3,\ Z0,\ Z1);}
\DoxyCodeLine{00351\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (H)}
\DoxyCodeLine{00352\ \ \ \ \ \ \ \ \ rasterizeLine(H-\/>bbox(),\ Z0,\ Z1);}
\DoxyCodeLine{00353\ \}}
\DoxyCodeLine{00354\ }
\DoxyCodeLine{00355\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeFill(\textcolor{keyword}{const}\ \mbox{\hyperlink{classTrack}{Track}}\ \&T,\ uint\ itemsMask)}
\DoxyCodeLine{00356\ \{}
\DoxyCodeLine{00357\ \ \ \ \ \textcolor{keywordflow}{if}\ (itemsMask\ \&\ RASTERIZE\_MASK\_VIAS)}
\DoxyCodeLine{00358\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&v\ :\ T.getVias())}
\DoxyCodeLine{00359\ \ \ \ \ \ \ \ \ \ \ \ \ rasterizeFill(v.getCircle(),\ v.zmin(),\ v.zmax());}
\DoxyCodeLine{00360\ \ \ \ \ \textcolor{keywordflow}{if}\ (!T.hasSegments()\ ||\ !(itemsMask\ \&\ RASTERIZE\_MASK\_SEGMENTS))}
\DoxyCodeLine{00361\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00362\ \ \ \ \ \textcolor{keywordflow}{if}\ (!(itemsMask\ \&\ RASTERIZE\_MASK\_CAPS\_AND\_JUNCTIONS)\ ||\ !T.hasSegmentJoints())\ \{\ \textcolor{comment}{//\ it's\ simpler\ if\ we\ don't\ have\ to\ draw\ any\ caps}}
\DoxyCodeLine{00363\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&s\ :\ T.getSegments())}
\DoxyCodeLine{00364\ \ \ \ \ \ \ \ \ \ \ \ \ rasterizeFill(s,\ 0x0);}
\DoxyCodeLine{00365\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{00366\ \ \ \ \ \}}
\DoxyCodeLine{00367\ \ \ \ \ uint\ mask\ =\ (T.hasStartCap()\ \&\&\ !T.startsWithVia())\ ?\ 0x0\ :\ 0x2;}
\DoxyCodeLine{00368\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint\ i\ =\ 0;\ i\ <\ T.numSegments()\ -\/\ 1;\ ++i)\ \{}
\DoxyCodeLine{00369\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&s\ =\ T.getSegment(i);}
\DoxyCodeLine{00370\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&t\ =\ T.getSegment(i+1);}
\DoxyCodeLine{00371\ \ \ \ \ \ \ \ \ mask\ =\ (mask\ \&\ 0x2)\ ?\ 0x0\ :\ 0x1;}
\DoxyCodeLine{00372\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ If\ the\ next\ segment\ is\ narrower\ and\ there\ is\ no\ via,\ rasterize\ the\ target\ cap\ and\ skip\ the\ next\ source\ cap.}}
\DoxyCodeLine{00373\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (s.halfWidth()\ >\ t.halfWidth()\ \&\&\ s.z()\ ==\ t.z())}
\DoxyCodeLine{00374\ \ \ \ \ \ \ \ \ \ \ \ \ mask\ |=\ 0x2;}
\DoxyCodeLine{00375\ \ \ \ \ \ \ \ \ rasterizeFill(s,\ mask);}
\DoxyCodeLine{00376\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (s.z()\ !=\ t.z())}
\DoxyCodeLine{00377\ \ \ \ \ \ \ \ \ \ \ \ \ mask\ |=\ 0x2;\ \textcolor{comment}{//\ s\ ends\ in\ a\ via,\ so\ skip\ the\ next\ source\ cap}}
\DoxyCodeLine{00378\ \ \ \ \ \}}
\DoxyCodeLine{00379\ \ \ \ \ \textcolor{comment}{//\ Last\ segment.}}
\DoxyCodeLine{00380\ \ \ \ \ mask\ =\ (mask\ \&\ 0x2)\ ?\ 0x0\ :\ 0x1;}
\DoxyCodeLine{00381\ \ \ \ \ \textcolor{keywordflow}{if}\ (T.hasEndCap()\ \&\&\ !T.endsWithVia())}
\DoxyCodeLine{00382\ \ \ \ \ \ \ \ \ mask\ |=\ 0x2;}
\DoxyCodeLine{00383\ \ \ \ \ rasterizeFill(T.getSegments().back(),\ mask);}
\DoxyCodeLine{00384\ \}}
\DoxyCodeLine{00385\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeLine(\textcolor{keyword}{const}\ \mbox{\hyperlink{classTrack}{Track}}\ \&T)}
\DoxyCodeLine{00386\ \{}
\DoxyCodeLine{00387\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ \&s\ :\ T.getSegments())}
\DoxyCodeLine{00388\ \ \ \ \ \ \ \ \ rasterizeLine(s.base());}
\DoxyCodeLine{00389\ \}}
\DoxyCodeLine{00390\ }
\DoxyCodeLine{00391\ \textcolor{keyword}{template}<\textcolor{keyword}{class}\ ROP>\ \textcolor{keywordtype}{void}\ Rasterizer<ROP>::rasterizeRanges(\textcolor{keyword}{const}\ std::vector<IndexRange>\ \&ranges)}
\DoxyCodeLine{00392\ \{}
\DoxyCodeLine{00393\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{const}\ \mbox{\hyperlink{structIndexRange}{IndexRange}}\ \&R\ :\ ranges)}
\DoxyCodeLine{00394\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint\ Z\ =\ R.Z0;\ Z\ <=\ R.Z1;\ ++Z)}
\DoxyCodeLine{00395\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint\ Y\ =\ R.Y0;\ Y\ <=\ R.Y1;\ ++Y)}
\DoxyCodeLine{00396\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (uint\ I\ =\ mGrid.LinearIndex(Z,Y,R.X0),\ I1\ =\ I\ +\ (R.X1\ -\/\ R.X0);\ I\ <=\ I1;\ ++I)}
\DoxyCodeLine{00397\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ OP.writeIndex(I);}
\DoxyCodeLine{00398\ \}}

\end{DoxyCode}
