Beispiel #1
0
        public void LoosingPartOfLineIfSelfIntersects()
        {
            var line1 = new PointF[] { new Vector2(117f, 199f), new Vector2(31f, 210f), new Vector2(35f, 191f), new Vector2(117f, 199f), new Vector2(2f, 9f) };
            var path  = new Path(new LinearLineSegment(line1));

            IPath outline = path.GenerateOutline(5f);

            // all points must not be in the outline;
            foreach (PointF v in line1)
            {
                Assert.True(outline.Contains(v), $"Outline does not contain {v}");
            }
        }
Beispiel #2
0
        public void ClippedTriangle()
        {
            var simplePath = new Polygon(new LinearLineSegment(
                                             new PointF(10, 10),
                                             new PointF(200, 150),
                                             new PointF(50, 300)));

            var hole1 = new Polygon(new LinearLineSegment(
                                        new PointF(37, 85),
                                        new PointF(93, 85),
                                        new PointF(65, 137)));

            IPath clippedPath = simplePath.Clip(hole1);
            IPath outline     = clippedPath.GenerateOutline(5, new[] { 1f });

            Assert.False(outline.Contains(new PointF(74, 97)));
        }
        public virtual IPath <T> Solve()
        {
            IPath <T> start = problem.CreatePath();

            for (int j = 0; j < problem.GetLocationsCount(); j++)
            {
                List <IPath <T> > neighbors = new List <IPath <T> >();
                for (int i = 0; i < problem.GetLocationsCount(); i++)
                {
                    if (!start.Contains(i))
                    {
                        neighbors.Add(start.To(i));
                    }
                }
                problem.CalculateLengths(neighbors);
                neighbors.Sort();
                start = neighbors[0];
            }
            return(start);
        }
        private IPath <T> CreateNearest()
        {
            IPath <T> result = problem.CreatePath();

            for (int j = 0; j < problem.GetLocationsCount(); j++)
            {
                List <IPath <T> > neighbors = new List <IPath <T> >();
                for (int i = 0; i < problem.GetLocationsCount(); i++)
                {
                    if (!result.Contains(i))
                    {
                        neighbors.Add(result.To(i));
                    }
                }
                problem.CalculateLengths(neighbors);
                neighbors.Sort();
                result = neighbors[0];
            }
            return(result);
        }
Beispiel #5
0
 public bool Contains(ref Point p)
 {
     return(path.Contains(ref p));
 }