Exemplo n.º 1
0
        public void GetMinMaxT(IFillerVertex fillerVertex, MarkupLine line, out float resultT, out float resultMinT, out float resultMaxT)
        {
            fillerVertex.GetT(line, out float t);
            var minT = -1f;
            var maxT = 2f;

            foreach (var linePart in LineParts)
            {
                linePart.GetFromT(out float fromT);
                linePart.GetToT(out float toT);

                if (linePart.Line == line)
                {
                    Set(fromT, false);
                    Set(toT, false);
                }
                else if (Markup.GetIntersect(new MarkupLinePair(line, linePart.Line)) is MarkupLinesIntersect intersect && intersect.IsIntersect)
                {
                    var linePartT = intersect[linePart.Line];

                    if ((fromT <= linePartT && linePartT <= toT) || (toT <= linePartT && linePartT <= fromT))
                    {
                        Set(intersect[line], true);
                    }
                }
Exemplo n.º 2
0
        private void RemoveLine(MarkupLine line)
        {
            foreach (var intersect in GetExistIntersects(line).ToArray())
            {
                if (intersect.Pair.GetOther(line) is MarkupRegularLine regularLine)
                {
                    regularLine.RemoveRules(line);
                }

                LineIntersects.Remove(intersect.Pair);
            }
            foreach (var filler in GetLineFillers(line).ToArray())
            {
                FillersList.Remove(filler);
            }

            if (CrosswalksDictionary.ContainsKey(line))
            {
                CrosswalksDictionary.Remove(line);
            }
            else
            {
                foreach (var crosswalk in GetLinesIsBorder(line))
                {
                    crosswalk.RemoveBorder(line);
                }
            }

            LinesDictionary.Remove(line.PointPair.Hash);
        }
Exemplo n.º 3
0
        public static bool FromXml(XElement config, Markup makrup, ObjectsMap map, out MarkupLine line, out bool invert)
        {
            var lineId = config.GetAttrValue <ulong>(nameof(Id));

            if (!MarkupPointPair.FromHash(lineId, makrup, map, out MarkupPointPair pointPair, out invert))
            {
                line = null;
                return(false);
            }

            if (!makrup.TryGetLine(pointPair, out line))
            {
                var type = (LineType)config.GetAttrValue("T", (int)pointPair.DefaultType);
                switch (type)
                {
                case LineType.Regular:
                    line = new MarkupRegularLine(makrup, pointPair);
                    break;

                case LineType.Stop:
                    line = new MarkupStopLine(makrup, pointPair);
                    break;

                case LineType.Crosswalk:
                    line = new MarkupCrosswalkLine(makrup, pointPair);
                    break;

                default:
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public void FromXml(string version, XElement config, Dictionary <ObjectId, ObjectId> map = null)
        {
            if (VersionComparer.Instance.Compare(version, "1.2") < 0)
            {
                map = VersionMigration.Befor1_2(this, map);
            }

            foreach (var pointConfig in config.Elements(MarkupPoint.XmlName))
            {
                MarkupPoint.FromXml(pointConfig, this, map);
            }

            var toInit = new Dictionary <MarkupLine, XElement>();

            foreach (var lineConfig in config.Elements(MarkupLine.XmlName))
            {
                if (MarkupLine.FromXml(lineConfig, this, map, out MarkupLine line))
                {
                    LinesDictionary[line.Id] = line;
                    toInit[line]             = lineConfig;
                }
            }
            foreach (var pair in toInit)
            {
                pair.Key.FromXml(pair.Value, map);
            }

            foreach (var fillerConfig in config.Elements(MarkupFiller.XmlName))
            {
                if (MarkupFiller.FromXml(fillerConfig, this, map, out MarkupFiller filler))
                {
                    FillersList.Add(filler);
                }
            }
        }
Exemplo n.º 5
0
        public static bool FromXml(XElement config, MarkupLine mainLine, ObjectsMap map, out ILinePartEdge supportPoint)
        {
            var type = (SupportType)config.GetAttrValue <int>("T");

            switch (type)
            {
            case SupportType.EnterPoint when EnterPointEdge.FromXml(config, mainLine.Markup, map, out EnterPointEdge enterPoint):
                supportPoint = enterPoint;

                return(true);

            case SupportType.LinesIntersect when LinesIntersectEdge.FromXml(config, mainLine, map, out LinesIntersectEdge linePoint):
                supportPoint = linePoint;

                return(true);

            case SupportType.CrosswalkBorder when CrosswalkBorderEdge.FromXml(config, mainLine, map, out CrosswalkBorderEdge borderPoint):
                supportPoint = borderPoint;

                return(true);

            default:
                supportPoint = null;
                return(false);
            }
        }
Exemplo n.º 6
0
        public override IStyleData Calculate(MarkupLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var solidOffset  = CenterSolid ? 0 : Invert ? Offset : -Offset;
            var dashedOffset = (Invert ? -Offset : Offset) * (CenterSolid ? 2 : 1);
            var borders      = line.Borders;

            var dashes = new List <MarkupStylePart>();

            dashes.AddRange(StyleHelper.CalculateSolid(trajectory, lod, CalculateSolidDash));
            if (CheckDashedLod(lod, Width, DashLength))
            {
                dashes.AddRange(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashedDash));
            }

            return(new MarkupStyleParts(dashes));

            IEnumerable <MarkupStylePart> CalculateSolidDash(ITrajectory lineTrajectory)
            {
                if (StyleHelper.CalculateSolidPart(borders, lineTrajectory, solidOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                if (StyleHelper.CalculateDashedParts(borders, lineTrajectory, startT, endT, DashLength, dashedOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }
        }
Exemplo n.º 7
0
        public void Update(MarkupLine line, bool recalculate = false)
        {
            line.Update(true);

            foreach (var intersect in GetExistIntersects(line).ToArray())
            {
                LineIntersects.Remove(intersect.Pair);
                intersect.Pair.GetOther(line).Update();
            }

            foreach (var filler in GetLineFillers(line))
            {
                filler.Update();
            }

            foreach (var crosswalk in GetLinesIsBorder(line))
            {
                crosswalk.Update();
            }

            if (recalculate)
            {
                RecalculateDashes();
            }
        }
Exemplo n.º 8
0
        public override IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory)
        {
            var borders = line.Borders;

            return(StyleHelper.CalculateSolid(trajectory, GetDashes));

            IEnumerable <MarkupStyleDash> GetDashes(ILineTrajectory trajectory) => CalculateDashes(trajectory, borders);
        }
Exemplo n.º 9
0
        public override IStyleData Calculate(MarkupLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateSolid(trajectory, lod, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory) => CalculateDashes(trajectory, borders);
        }
Exemplo n.º 10
0
 public IEnumerable <MarkupLinesIntersect> GetIntersects(MarkupLine line)
 {
     foreach (var otherLine in Lines)
     {
         if (otherLine != line)
         {
             yield return(GetIntersect(new MarkupLinePair(line, otherLine)));
         }
     }
 }
Exemplo n.º 11
0
 protected static IEnumerable <ILinePartEdge> GetEdges(XElement config, MarkupLine line, ObjectsMap map)
 {
     foreach (var supportConfig in config.Elements(LinePartEdge.XmlName))
     {
         if (LinePartEdge.FromXml(supportConfig, line, map, out ILinePartEdge edge))
         {
             yield return(edge);
         }
     }
 }
Exemplo n.º 12
0
        public void RemoveRules(MarkupLine intersectLine)
        {
            RawRules.RemoveAll(r => Match(r.From) || Match(r.To));
            bool Match(ISupportPoint supportPoint) => supportPoint is IntersectSupportPoint lineRuleEdge && lineRuleEdge.LinePair.ContainLine(intersectLine);

            if (!RawRules.Any())
            {
                AddRule(false);
            }
        }
Exemplo n.º 13
0
 public MarkupLine GetOther(MarkupLine line)
 {
     if (!ContainLine(line))
     {
         return(null);
     }
     else
     {
         return(line == First ? Second : First);
     }
 }
Exemplo n.º 14
0
 public override bool GetT(MarkupLine line, out float t)
 {
     if (line is MarkupCrosswalkLine crosswalkLine)
     {
         t = crosswalkLine.GetT(Border);
         return(true);
     }
     else
     {
         t = -1;
         return(false);
     }
 }
Exemplo n.º 15
0
 public override bool GetT(MarkupLine line, out float t)
 {
     if (line.ContainsPoint(Point))
     {
         t = line.Start == Point ? 0 : 1;
         return(true);
     }
     else
     {
         t = -1;
         return(false);
     }
 }
Exemplo n.º 16
0
 public static bool FromXml(XElement config, MarkupLine line, ObjectsMap map, out CrosswalkBorderEdge borderPoint)
 {
     if (line is MarkupCrosswalkLine crosswalkLine)
     {
         var border = (config.GetAttrValue("B", (int)BorderPosition.Right) == (int)BorderPosition.Left) ^ map.IsMirror ? BorderPosition.Left : BorderPosition.Right;
         borderPoint = new CrosswalkBorderEdge(crosswalkLine, border);
         return(true);
     }
     else
     {
         borderPoint = null;
         return(false);
     }
 }
Exemplo n.º 17
0
        public void RemoveRules(MarkupLine intersectLine)
        {
            if (!RawRules.Any())
            {
                return;
            }

            RawRules.RemoveAll(r => Match(intersectLine, r.From) || Match(intersectLine, r.To));

            if (!RawRules.Any())
            {
                AddRule(false, false);
            }
        }
Exemplo n.º 18
0
        public override IStyleData Calculate(MarkupLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!CheckDashedLod(lod, Width, DashLength))
            {
                return(new MarkupStyleParts());
            }

            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory, float startT, float endT)
            => CalculateDashes(trajectory, startT, endT, borders);
        }
Exemplo n.º 19
0
 public static bool FromXml(XElement config, MarkupLine line, Dictionary <ObjectId, ObjectId> map, out CrosswalkBorderEdge borderPoint)
 {
     if (line is MarkupCrosswalkLine crosswalkLine)
     {
         var border = (BorderPosition)config.GetAttrValue("B", (int)BorderPosition.Right);
         borderPoint = new CrosswalkBorderEdge(crosswalkLine, border);
         return(true);
     }
     else
     {
         borderPoint = null;
         return(false);
     }
 }
Exemplo n.º 20
0
        private void RemoveLine(MarkupLine line)
        {
            foreach (var intersect in GetExistIntersects(line).ToArray())
            {
                intersect.Pair.GetOther(line).RemoveRules(line);
                LineIntersects.Remove(intersect.Pair);
            }
            foreach (var filler in GetLineFillers(line).ToArray())
            {
                FillersList.Remove(filler);
            }

            LinesDictionary.Remove(line.PointPair.Hash);
        }
Exemplo n.º 21
0
 public MarkupLine ToggleConnection(MarkupPointPair pointPair, Style.StyleType style)
 {
     if (LinesDictionary.TryGetValue(pointPair.Hash, out MarkupLine line))
     {
         RemoveConnect(line);
         return(null);
     }
     else
     {
         line = MarkupLine.FromStyle(this, pointPair, style);
         LinesDictionary[pointPair.Hash] = line;
         NeedRecalculateBatches          = true;
         return(line);
     }
 }
Exemplo n.º 22
0
        public static bool FromXml(XElement config, Markup makrup, Dictionary <ObjectId, ObjectId> map, out MarkupLine line)
        {
            var lineId = config.GetAttrValue <ulong>(nameof(Id));

            MarkupPointPair.FromHash(lineId, makrup, map, out MarkupPointPair pointPair);
            if (!makrup.TryGetLine(pointPair.Hash, out line))
            {
                line = new MarkupLine(makrup, pointPair);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 23
0
        public static bool FromXml(XElement config, MarkupLine mainLine, ObjectsMap map, out LinesIntersectEdge linePoint)
        {
            var lineId = config.GetAttrValue <ulong>(MarkupLine.XmlName);

            if (mainLine.Markup.TryGetLine(lineId, map, out MarkupLine line))
            {
                linePoint = new LinesIntersectEdge(mainLine, line);
                return(true);
            }
            else
            {
                linePoint = null;
                return(false);
            }
        }
Exemplo n.º 24
0
        public override bool GetT(MarkupLine line, out float t)
        {
            var intersect = line.Markup.GetIntersect(LinePair);

            if (intersect.IsIntersect)
            {
                t = intersect[line];
                return(true);
            }
            else
            {
                t = -1;
                return(false);
            }
        }
Exemplo n.º 25
0
        public bool RemoveRules(MarkupLine intersectLine)
        {
            if (!RawRules.Any())
            {
                return(false);
            }

            var removed = RawRules.RemoveAll(r => Match(intersectLine, r.From) || Match(intersectLine, r.To));

            if (!RawRules.Any())
            {
                AddRule(false, false);
            }

            return(removed != 0);
        }
Exemplo n.º 26
0
        public static bool FromXml(XElement config, MarkupLine mainLine, Dictionary <ObjectId, ObjectId> map, out LinesIntersectEdge linePoint)
        {
            var lineId = config.GetAttrValue <ulong>(MarkupLine.XmlName);

            MarkupPointPair.FromHash(lineId, mainLine.Markup, map, out MarkupPointPair pair);
            if (mainLine.Markup.TryGetLine(pair.Hash, out MarkupLine line))
            {
                linePoint = new LinesIntersectEdge(mainLine, line);
                return(true);
            }
            else
            {
                linePoint = null;
                return(false);
            }
        }
Exemplo n.º 27
0
        public void FromXml(Version version, XElement config, Dictionary <ObjectId, ObjectId> map = null)
        {
            if (version < new Version("1.2"))
            {
                map = VersionMigration.Befor1_2(this, map);
            }

            foreach (var pointConfig in config.Elements(MarkupPoint.XmlName))
            {
                MarkupPoint.FromXml(pointConfig, this, map);
            }

            var toInit = new Dictionary <MarkupLine, XElement>();

            foreach (var lineConfig in config.Elements(MarkupLine.XmlName))
            {
                if (MarkupLine.FromXml(lineConfig, this, map, out MarkupLine line))
                {
                    LinesDictionary[line.Id] = line;
                    toInit[line]             = lineConfig;
                }
            }

            foreach (var pair in toInit)
            {
                pair.Key.FromXml(pair.Value, map);
            }

            foreach (var fillerConfig in config.Elements(MarkupFiller.XmlName))
            {
                if (MarkupFiller.FromXml(fillerConfig, this, map, out MarkupFiller filler))
                {
                    FillersList.Add(filler);
                }
            }
            foreach (var crosswalkConfig in config.Elements(MarkupCrosswalk.XmlName))
            {
                if (MarkupCrosswalk.FromXml(crosswalkConfig, this, map, out MarkupCrosswalk crosswalk))
                {
                    CrosswalksDictionary[crosswalk.Line] = crosswalk;
                }
            }

            Update();
        }
Exemplo n.º 28
0
 public override bool GetT(MarkupLine line, out float t)
 {
     if (line.IsStart(Point))
     {
         t = 0;
         return(true);
     }
     else if (line.IsEnd(Point))
     {
         t = 1;
         return(true);
     }
     else
     {
         t = -1;
         return(false);
     }
 }
Exemplo n.º 29
0
 public override bool GetT(MarkupLine line, out float t)
 {
     if (line is MarkupEnterLine enterLine && line.Start == line.End)
     {
         if (enterLine.StartAlignment == Alignment)
         {
             t = 0f;
             return(true);
         }
         else if (enterLine.EndAlignment == Alignment)
         {
             t = 1f;
             return(true);
         }
         else
         {
             t = -1f;
             return(false);
         }
     }
Exemplo n.º 30
0
        public MarkupLine ToggleConnection(MarkupPointPair pointPair, Style.StyleType style)
        {
            if (LinesDictionary.TryGetValue(pointPair.Hash, out MarkupLine line))
            {
                RemoveConnect(line);
                return(null);
            }
            else
            {
                if (pointPair.IsNormal && !EarlyAccess.CheckFunctionAccess(Localize.EarlyAccess_Function_PerpendicularLines))
                {
                    return(null);
                }

                line = MarkupLine.FromStyle(this, pointPair, style);
                LinesDictionary[pointPair.Hash] = line;
                NeedRecalculateBatches          = true;
                return(line);
            }
        }