Exemplo n.º 1
0
        private void button10_Click(object sender, EventArgs e)
        {
            if (!(dataModel.SelectedItem is PolygonHelper ph2))
            {
                return;
            }

            var hull = DeepNest.getHull(new NFP()
            {
                Points = ph2.TransformedPoints().ToArray()
            });
            PolygonHelper ph = new PolygonHelper();

            ph.Polygon = hull;

            var           mar = GeometryUtil.GetMinimumBox(hull.Points.Select(z => new Vector2d(z.X, z.Y)).ToArray());
            PolygonHelper ph3 = new PolygonHelper();

            ph3.Polygon = new NFP()
            {
                Points = mar.Select(z => new SvgPoint(z.X, z.Y)).ToArray()
            };

            ph3.Name = "minRect";
            dataModel.AddItem(ph3);
        }
Exemplo n.º 2
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (!(dataModel.SelectedItem is PolygonHelper ph2))
            {
                return;
            }

            var           hull = DeepNest.getHull(ph2.TransformedNfp());
            PolygonHelper ph   = new PolygonHelper();

            ph.Polygon = hull;
            var           box = ph.BoundingBox().Value;
            PolygonHelper ph3 = new PolygonHelper();

            ph3.Polygon = new NFP()
            {
                Points = new SvgPoint[] {
                    new SvgPoint(box.Left, box.Top),
                    new SvgPoint(box.Left, box.Bottom),
                    new SvgPoint(box.Right, box.Bottom),
                    new SvgPoint(box.Right, box.Top),
                }
            };

            ph3.Name = "AABB";
            dataModel.AddItem(ph3);
        }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (!(dataModel.SelectedItem is PolygonHelper ph2))
            {
                return;
            }

            var hull = DeepNest.getHull(new NFP()
            {
                Points = ph2.TransformedPoints()
            });
            PolygonHelper ph = new PolygonHelper();

            ph.Polygon = hull;
            ph.Name    = "hull";
            dataModel.AddItem(ph);
        }
Exemplo n.º 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (!(dataModel.SelectedItem is PolygonHelper ph2))
            {
                return;
            }

            double clipperScale = 10000000;
            var    hull         = DeepNest.simplifyFunction(new NFP()
            {
                Points = ph2.TransformedPoints()
            }, false, clipperScale);
            PolygonHelper ph = new PolygonHelper();

            ph.Polygon = hull;
            ph.Name    = "simplify";

            dataModel.AddItem(ph);
        }
Exemplo n.º 5
0
        private void extractChildsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataModel.SelectedItems.Length == 0)
            {
                return;
            }
            var hh = dataModel.SelectedItem;

            if (!(hh is PolygonHelper ph))
            {
                return;
            }

            foreach (var item in ph.Polygon.Childrens)
            {
                PolygonHelper ph2 = new PolygonHelper();
                ph2.Polygon = DeepNest.clone(item);
                dataModel.AddItem(ph2);
            }
        }
Exemplo n.º 6
0
        private void button12_Click(object sender, EventArgs e)
        {
            var res = dataModel.GetPairOfSelectedNfps();

            if (res == null)
            {
                return;
            }
            NFP offs = null;

            offs = ClipperHelper.MinkowskiSum(res[0], res[1], checkBox2.Checked, checkBox3.Checked);
            if (offs != null)
            {
                PolygonHelper ph = new PolygonHelper();
                //ph.Polygon.Points = offs.Points.Select(z => new SvgPoint(z.X, z.Y)).ToArray();
                ph.Polygon = DeepNest.clone2(offs);

                dataModel.AddItem(ph);
            }
        }
Exemplo n.º 7
0
        private void button13_Click(object sender, EventArgs e)
        {
            var res = dataModel.GetPairOfSelectedNfps();

            if (res == null)
            {
                return;
            }
            var p    = res[0];
            var p2   = res[1];
            var offs = DeepNest.getOuterNfp(p, p2);

            if (offs != null)
            {
                PolygonHelper ph = new PolygonHelper();
                //ph.Polygon.Points = offs.Points.Select(z => new SvgPoint(z.X, z.Y)).ToArray();
                ph.Polygon = DeepNest.clone2(offs);

                dataModel.AddItem(ph);
            }
        }
Exemplo n.º 8
0
        private void button15_Click(object sender, EventArgs e)
        {
            var res = dataModel.GetPairOfSelectedNfps();

            if (res == null)
            {
                return;
            }
            var p    = res[0];
            var p2   = res[1];
            var offs = DeepNest.Convolve(p2, p);

            if (offs != null)
            {
                foreach (var item in offs)
                {
                    PolygonHelper ph = new PolygonHelper();
                    //ph.Polygon.Points = item.Points.Select(z => new SvgPoint(z.X, z.Y)).ToArray();
                    ph.Polygon = DeepNest.clone2(item);
                    dataModel.AddItem(ph);
                }
            }
        }