/// <summary>
        /// Make a hole in aperture
        /// </summary>
        /// <param name="metaData">Metadata</param>
        /// <param name="trace">Trace to use in partial columns</param>
        /// <param name="aperture">Aperture with hole</param>
        /// <param name="layer">Layer where merge</param>
        protected void MakeHole(GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, PlarityLayerDTO layer)
        {
            List <CoordinateDTO> hole = MidpointCircle(trace.AbsolutePointEnd.X / metaData.Scale,
                                                       trace.AbsolutePointEnd.Y / metaData.Scale,
                                                       aperture.Modifiers.Last() / metaData.Scale / 2,
                                                       topRow, bottomRow);
            var layerHole = new PlarityLayerDTO();

            layerHole.IsDarkPolarity = !layer.IsDarkPolarity;
            ResumePoints(hole, layerHole, trace);
            MergeLayers(layer, layerHole);
        }
        /// <summary>
        /// Resume points into columns in layer
        /// </summary>
        /// <param name="points">Coordinate to resume</param>
        /// <param name="layer">Layer column would be added</param>
        /// <param name="trace">Trace in partial columns</param>
        protected void ResumePoints(List <CoordinateDTO> points, PlarityLayerDTO layer, GerberTraceDTO trace)
        {
            var total         = points.Count();
            var previousPoint = points[0];
            var actualPoint   = previousPoint;
            var row           = GetRow(layer, actualPoint.Y);
            var columns       = new List <ColumnDataDTO>();
            var column        = CreateColumn(actualPoint.X, actualPoint.X, new List <GerberTraceDTO> {
                trace
            }, TypeColumn.partial);

            for (var idx = 1; idx < total; idx++)
            {
                actualPoint = points[idx];
                if (previousPoint.Y == actualPoint.Y)
                {
                    if (previousPoint.X == actualPoint.X || previousPoint.X + 1 == actualPoint.X)
                    {
                        column.Right = actualPoint.X;
                    }
                    else
                    {
                        columns.Add(column);
                        if (previousPoint.X + 1 < actualPoint.X)
                        {
                            columns.Add(
                                CreateColumn(previousPoint.X + 1, actualPoint.X - 1, null, TypeColumn.fill)
                                );
                        }
                        column = CreateColumn(actualPoint.X, actualPoint.X, new List <GerberTraceDTO> {
                            trace
                        }, TypeColumn.partial);
                    }
                }
                else
                {
                    columns.Add(column);
                    AddColumns(layer, previousPoint.Y, columns);
                    columns.Clear();
                    column = CreateColumn(actualPoint.X, actualPoint.X, new List <GerberTraceDTO> {
                        trace
                    }, TypeColumn.partial);
                }
                previousPoint = actualPoint;
            }
            columns.Add(column);
            AddColumns(layer, actualPoint.Y, columns);
        }
Esempio n. 3
0
        public override void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo)
        {
            base.Create(metaDataBase, metaData, trace, aperture, layerIndex, rowFrom, rowTo);
            var leftColumn  = trace.AbsolutePointEnd.X - aperture.Modifiers[0] / 2;
            var rightColumn = leftColumn + aperture.Modifiers[0];

            leftColumn  /= metaData.Scale;
            rightColumn /= metaData.Scale;

            var layer = new PlarityLayerDTO()
            {
                IsDarkPolarity = metaData.PolarityLayers[layerIndex].IsDarkPolarity
            };

            for (var rowIndex = topRow; rowIndex >= bottomRow; rowIndex--)
            {
                var row     = GetRow(layer, rowIndex);
                var columns = new List <ColumnDataDTO>();
                if (rowIndex == topRow || rowIndex == bottomRow)
                {
                    columns.Add(
                        CreateColumn(leftColumn, rightColumn, new List <GerberTraceDTO> {
                        trace
                    }, TypeColumn.partial)
                        );
                }
                else
                {
                    columns.Add(
                        CreateColumn(leftColumn, leftColumn, new List <GerberTraceDTO> {
                        trace
                    }, TypeColumn.partial)
                        );
                    columns.Add(
                        CreateColumn(leftColumn + 1, rightColumn - 1, null, TypeColumn.fill)
                        );
                    columns.Add(
                        CreateColumn(rightColumn, rightColumn, new List <GerberTraceDTO> {
                        trace
                    }, TypeColumn.partial)
                        );
                }
                AddColumns(layer, rowIndex, columns);
            }

            if (aperture.Modifiers.Count == 3)
            {
                MakeHole(metaData, trace, aperture, layer);
            }
            MergeLayers(metaData.PolarityLayers[layerIndex], layer);
        }
 /// <summary>
 /// It do metadata processing the draw
 /// It stablish the top and bottom row affected, wheter haven't affected row return doing nothing
 /// </summary>
 /// <param name="metaData">Meta data to update</param>
 /// <param name="trace">Trace data</param>
 /// <param name="aperture">Aperture data to draw</param>
 /// <param name="layerIndex">Layer Index</param>
 /// <param name="rowFrom">Top row index </param>
 /// <param name="rowTo">Bottom row index</param>
 virtual public void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo)
 {
     topRow     = trace.AbsolutePointEnd.Y + aperture.Modifiers[aperture.Shape == 'R' && aperture.Modifiers.Count > 1 ? 1 : 0] / 2;
     bottomRow  = topRow - aperture.Modifiers[aperture.Shape == 'R' && aperture.Modifiers.Count > 1 ? 1 : 0];
     topRow    /= metaData.Scale;
     bottomRow /= metaData.Scale;
     if (rowFrom < topRow)
     {
         topRow = rowFrom;
     }
     if (rowTo > bottomRow)
     {
         bottomRow = rowTo;
     }
     // When top and bottom are inverter means it metadata is unnecesary draw
     if (topRow < bottomRow)
     {
         return;
     }
 }
        public override void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo)
        {
            base.Create(metaDataBase, metaData, trace, aperture, layerIndex, rowFrom, rowTo);

            var points = MidpointCircle(
                trace.AbsolutePointEnd.X / metaData.Scale
                , trace.AbsolutePointEnd.Y / metaData.Scale
                , aperture.Modifiers[0] / metaData.Scale / 2,
                topRow,
                bottomRow);

            var layer = new PlarityLayerDTO()
            {
                IsDarkPolarity = metaData.PolarityLayers[layerIndex].IsDarkPolarity
            };

            ResumePoints(points, layer, trace);

            if (aperture.Modifiers.Count() == 2)
            {
                MakeHole(metaData, trace, aperture, layer);
            }
            MergeLayers(metaData.PolarityLayers[layerIndex], layer);
        }