Пример #1
0
        public ParcourChannel(Vector Start, Vector End, LineType type, List<Line> lines, Converter c)
        {
            this.Start = Start;
            this.End = End;
            List<Line> pointLine = lines.Where(p => p.Type == (int)LineType.Point).ToList();
            int i = 0;
            if (type == LineType.START_B)
            {
                i = 9;
            }
            else if (type == LineType.START_C)
            {
                i = 18;
            }
            else if (type == LineType.START_D)
            {
                i = 27;
            }
            List<Line> corridorPoints = new List<Line>();
            for (int j = 0; j < 9; j++)
            {
                corridorPoints.Add(pointLine[i + j]);
            }
            foreach (Line l in corridorPoints)
            {
                Vector v = ParcourModel.getVector(c, l.A);

                if (isEdited(l))
                {
                    ImmutablePoints.Add(v);
                }
                LinearCombinations.Add(v);
            }
            LinearCombinations.Add(End);
        }
Пример #2
0
 public ParcourChannelSingle(Vector Start, Vector End, Converter c)
 {
     this.Start = Start;
     this.End = End;
     Vector StartEnd = Vector.Direction(Start, End);
     for (int i = 0; i < 10; i++)
     {
         Vector linComb = Start + (StartEnd * (i / 9.0));
         LinearCombinations.Add(linComb);
     }
     double dist = getDistance(c);
     double straightDist = getDistanceStraight(c);
     if (dist - straightDist > 0.1)
     {
         System.Console.Out.WriteLine("ERROR");
     }
 }
Пример #3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListItem li = listBox1.SelectedItem as ListItem;
            if (li != null)
            {
                deleteToolStripMenuItem.Enabled = true;
                Map map = li.getParcour().Map;

                MemoryStream ms = new MemoryStream(map.Picture.Data);
                PictureBox1.Image = System.Drawing.Image.FromStream(ms);
                c = new Converter(map);
                PictureBox1.SetConverter(c);

                PictureBox1.SetParcour(li.getParcour());
                activeParcour = li.getParcour();
                PictureBox1.Invalidate();
            }
        }
Пример #4
0
 public void SetConverter(Converter iConverter)
 {
     c = iConverter;
 }
Пример #5
0
 private void comboBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItem li = comboBoxMaps.SelectedItem as ListItem;
     if (li != null)
     {
         MemoryStream ms = new MemoryStream(li.getMap().Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(li.getMap());
         PictureBox1.SetConverter(c);
         CurrentMap = li.getMap();
     }
 }
Пример #6
0
 private void comboBoxParcours_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItem li = comboBoxParcours.SelectedItem as ListItem;
     if (li != null)
     {
         Parcour p = li.getParcour();
         Map m = p.Map;
         MemoryStream ms = new MemoryStream(m.Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(m);
         PictureBox1.SetConverter(c);
         CurrentMap = m;
         List<Line> toDelete =  p.Line.Where(pp=> pp.Type == (int)LineType.START || pp.Type == (int)LineType.END).ToList();
         foreach(Line l in toDelete)
         {
             p.Line.Remove(l);
         }
         activeParcour = p;
         PictureBox1.SetParcour(activeParcour);
         bool generatedParcour = activeParcour.Line.Count(pp => pp.Type == (int)LineType.Point) > 0;
         btnRecalc.Enabled = generatedParcour;
         chkAutocalc.Enabled = generatedParcour;
         chkAutocalc.Checked = generatedParcour;
     }
 }
Пример #7
0
        public double getDistance(Converter c)
        {
            double result = 0;
            Vector last = Start;
            foreach (Vector v in LinearCombinations)
            {
                Point Ende = new Point();
                Ende.longitude = c.XtoLongitude(last.X);
                Ende.latitude = c.YtoLatitude(last.Y);
                Point ss = new Point();
                ss.longitude = c.XtoLongitude(v.X);
                ss.latitude = c.YtoLatitude(v.Y);
                double dist = Converter.Distance(Ende, ss);

                result += dist;
                last = v;
            }
            return result;
        }
Пример #8
0
 private void AddLineAsCorridor(Converter c, Line start, Line end, List<Line> lines, LineType lineType)
 {
     Vector MiddleStart = Vector.Middle(getVector(c, start.A), getVector(c, start.B));
     Vector MiddleEnd = Vector.Middle(getVector(c, end.A), getVector(c, end.B));
     Channel = new ParcourChannelSingle(MiddleStart, MiddleEnd, lineType, lines, c);
 }
Пример #9
0
 public ParcourModel(ParcourModel pm, double firstWeight)
 {
     this.desiredLengthFactor = pm.desiredLengthFactor;
     this.channel = pm.channel;
     this.c = pm.c;
     foreach (ParcourChannel pc in pm.Channels)
     {
         AddCorridor(pc);
     }
     Randomize(firstWeight);
 }
Пример #10
0
 public static Vector getVector(Converter c, Point point)
 {
     return new Vector(c.LongitudeToX(point.longitude), c.LatitudeToY(point.latitude), 0);
 }
Пример #11
0
 public ParcourModelSingle(ParcourModelSingle pm, double firstWeight)
 {
     this.desiredLength = pm.desiredLength;
     this.channelWidth = pm.channelWidth;
     this.c = pm.c;
     AddCorridor(pm.Channel);
     Randomize(firstWeight);
 }
Пример #12
0
 public ParcourModelSingle(Parcour parcour, Converter c, double channel, double channelLength, bool regenerate)
 {
     this.desiredLength = Converter.NMtoM(channelLength);
     this.channelWidth = Converter.NMtoM(channel);
     this.c = c;
     List<Line> lines = new List<Line>(parcour.Line);
     AddLineAsCorridor(c, lines.Single(p => p.Type == (int)LineType.START_A), lines.Single(p => p.Type == (int)LineType.END_A), lines, LineType.START_A);
 }
Пример #13
0
        public double getDistanceStraight(Converter c)
        {
            Point Ende = new Point();
            Ende.longitude = c.XtoLongitude(Start.X);
            Ende.latitude = c.YtoLatitude(Start.Y);
            Point ss = new Point();
            ss.longitude = c.XtoLongitude(End.X);
            ss.latitude = c.YtoLatitude(End.Y);
            double dist = Converter.Distance(Ende, ss);

            return dist;
        }
Пример #14
0
 private void AddLineAsCorridor(Converter c, Line start, Line end)
 {
     Vector MiddleStart = Vector.Middle(getVector(c, start.A), getVector(c, start.B));
     Vector MiddleEnd = Vector.Middle(getVector(c, end.A), getVector(c, end.B));
     Channels.Add(new ParcourChannel(MiddleStart, MiddleEnd));
 }
Пример #15
0
 private void comboBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItemMap limm = comboBoxMaps.SelectedItem as ListItemMap;
     if (limm != null)
     {
         activeParcour = new Parcour();
         CurrentMap = limm.getMap();
         MemoryStream ms = new MemoryStream(CurrentMap.Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(CurrentMap);
         PictureBox1.SetParcour(activeParcour);
         PictureBox1.SetConverter(c);
     }
 }
Пример #16
0
 public double Weight(Converter c)
 {
     if (weight == double.MinValue)
     {
         straightLength = Channel.getDistanceStraight(c);
         lenght = Channel.getDistance(c);
         weight = Math.Abs(lenght - desiredLength);
     }
     return weight;
 }
Пример #17
0
        private void comboBoxParcours_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListItem li = comboBoxParcours.SelectedItem as ListItem;
            if (li != null)
            {
                Parcour p = li.getParcour();
                Map m = null;
                comboBoxMaps.SelectedItem = null;
                if (p.Map!=null)
                {
                    m = p.Map;
                    MemoryStream ms = new MemoryStream(m.Picture.Data);
                    PictureBox1.Image = System.Drawing.Image.FromStream(ms);
                    c = new Converter(m);
                    PictureBox1.SetConverter(c);
                    CurrentMap = m;
                    foreach (Object lim in comboBoxMaps.Items)
                    {
                        ListItemMap limm = lim as ListItemMap;
                        if (limm.getMap() == m)
                        {
                            comboBoxMaps.SelectedItem = lim;
                            break;
                        }
                    }
                }
                else
                {
                    p = new Parcour();
                }

                List<Line> toDelete = p.Line.Where(pp => pp.Type == (int)LineType.START || pp.Type == (int)LineType.END).ToList();
                foreach (Line l in toDelete)
                {
                    p.Line.Remove(l);
                }
                activeParcour = p;
                PictureBox1.SetParcour(activeParcour);
                generatedParcour = activeParcour.Line.Count(pp => pp.Type == (int)LineType.Point) > 0;
            }
        }
Пример #18
0
 public ParcourModel(Parcour parcour, Converter c, double desiredLengthFactor, double channel, bool regenerate)
 {
     this.desiredLengthFactor = desiredLengthFactor;
     this.channel = Converter.NMtoM(channel);
     this.c = c;
     List<Line> lines = new List<Line>(parcour.Line);
     AddLineAsCorridor(c, lines.Single(p => p.Type == (int)LineType.START_A), lines.Single(p => p.Type == (int)LineType.END_A), lines, LineType.START_A);
     AddLineAsCorridor(c, lines.Single(p => p.Type == (int)LineType.START_B), lines.Single(p => p.Type == (int)LineType.END_B), lines, LineType.START_B);
     AddLineAsCorridor(c, lines.Single(p => p.Type == (int)LineType.START_C), lines.Single(p => p.Type == (int)LineType.END_C), lines, LineType.START_C);
     AddLineAsCorridor(c, lines.Single(p => p.Type == (int)LineType.START_D), lines.Single(p => p.Type == (int)LineType.END_D), lines, LineType.START_D);
 }