Example #1
0
        private void refreshOfffsetLines()
        {
            var itemPoints = scaledOnlyDefinitionTransformation(_shapeDefinition);

            itemPoints = OffsetCalculator.Join(itemPoints);
            var offsetClusters    = new List <Point2Dmm[]>();
            var remainingClusters = new HashSet <Point2Dmm[]>(itemPoints);

            for (var i = 0; i < 10; ++i)
            {
                if (remainingClusters.Count == 0)
                {
                    break;
                }

                foreach (var cluster in remainingClusters.ToArray())
                {
                    var offsetCalculator = new OffsetCalculator(cluster);
                    var offsetPoints     = offsetCalculator.WithOffset(1.0 + 1 * i);
                    if (offsetPoints.Any())
                    {
                        offsetClusters.AddRange(offsetPoints);
                    }
                    else
                    {
                        remainingClusters.Remove(cluster);
                    }
                }
            }

            _currentOffsetLines = offsetClusters.OrderByDescending(c => c.Select(p => p.C2).Min()).ToArray();
        }
Example #2
0
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (_drawEvents == null)
            {
                var loader = new ShapeFactory3D();
                //var points = loader.Load("./test_offset3.png", out _).First().Reverse();
                var points = OffsetCalculator.Join(loader.Load("./test_islands.png", out _).Reverse()).First().ToArray();

                /*/
                 * points = new Point2Dmm[]
                 * {
                 *    new Point2Dmm(0,0),
                 *    new Point2Dmm(100, 0),
                 *    new Point2Dmm(100, 100),
                 *    new Point2Dmm(60, 100),
                 *    new Point2Dmm(80, 110),
                 *    new Point2Dmm(30, 110),
                 *    new Point2Dmm(20, 100),
                 *    new Point2Dmm(0, 100),
                 *
                 *    new Point2Dmm(0,0),
                 * };/**/
                /*/
                 * points = new Point2Dmm[]
                 * {
                 *  new Point2Dmm(70,60),
                 *  new Point2Dmm(40,20),
                 *  new Point2Dmm(120,20),
                 *  new Point2Dmm(100,60),
                 *  new Point2Dmm(105,25),
                 *  new Point2Dmm(60,25),
                 *  new Point2Dmm(140,140),
                 *  new Point2Dmm(70,140),
                 *
                 *  new Point2Dmm(70,60),
                 * };/**/
                var offset = new OffsetCalculator(points, true);

                offset.WithOffset(40);
                _drawEvents     = offset.GetUpdateSnapshots().ToArray();
                _slider.Maximum = _drawEvents.Length - 1;
                _slider.Value   = _slider.Maximum;
            }

            var snapshotToDisplay = _drawEvents[(int)_slider.Value];

            foreach (var evt in snapshotToDisplay)
            {
                evt.Draw(dc);
            }
        }