示例#1
0
        private List <PointD> setFirstPoint(List <PointD> points, MarkPoint mark1, MarkPoint mark2)
        {
            if (points == null || points.Count <= 0)
            {
                return(null);
            }
            List <PointD> res = new List <PointD>();

            res.AddRange(points);
            if (mark2 == null)
            {
                if (mark1 == null)
                {
                    PointD firstPoint = this.nearestTo(points, new PointD(0, 0));
                    res.Clear();
                    res.Add(firstPoint);
                    points.Remove(firstPoint);
                    res.AddRange(points);
                }
                else if (mark1.IsSpray)
                {
                    res.Clear();
                    res.Add(mark1.Mark);
                    points.Remove(mark1.Mark);
                    res.AddRange(points);
                }
                else if (!mark1.IsSpray)
                {
                    PointD firstPoint = this.nearestTo(points, mark1.Mark);
                    res.Clear();
                    res.Add(firstPoint);
                    points.Remove(firstPoint);
                    res.AddRange(points);
                }
            }
            else
            {
                if (mark2.IsSpray)
                {
                    res.Clear();
                    res.Add(mark2.Mark);
                    points.Remove(mark2.Mark);
                    res.AddRange(points);
                }
                else
                {
                    PointD firstPoint = this.nearestTo(points, mark2.Mark);
                    res.Clear();
                    res.Add(firstPoint);
                    points.Remove(firstPoint);
                    res.AddRange(points);
                }
            }
            return(res);
        }
示例#2
0
 public void setMark(MarkPoint mark, string markName)
 {
     if (markName == "Mark1")
     {
         this.currPInfo.Mark1 = mark;
     }
     else if (markName == "Mark2")
     {
         this.currPInfo.Mark2 = mark;
     }
     this.showMarks();
 }
示例#3
0
        public void TrajOptimize(MarkPoint mark1, MarkPoint mark2)
        {
            List <PointD> points = new List <PointD>();

            foreach (var p in this.PointList)
            {
                if (mark1 != null)
                {
                    if (!mark1.IsSpray && mark1.Mark == p.Mid)
                    {
                        continue;
                    }
                }
                if (mark2 != null)
                {
                    if (!mark2.IsSpray && p.Mid == mark2.Mark)
                    {
                        continue;
                    }
                }
                points.Add(p.Mid);
            }
            points = this.setFirstPoint(points, mark1, mark2);
            double[] data = new double[points.Count * 2];
            for (int i = 0; i < points.Count; i++)
            {
                data[i * 2]     = points[i].X;
                data[i * 2 + 1] = points[i].Y;
            }
            int[] routeIndexArr = new int[points.Count];
            OptimalRoute.initializeAll();
            OptimalRoute.autoRunAntColonyx86(data, points.Count, routeIndexArr);
            this.PointsOptimized.Clear();
            for (int i = 0; i < routeIndexArr.Length; i++)
            {
                this.PointsOptimized.Add(points[routeIndexArr[i]]);
            }
            this.CurPoints = this.PointsOptimized;
            this.GetDistance();
            this.sortPoints(this.PointsOptimized);
        }