Exemplo n.º 1
0
        protected override IStyleData Calculate(MarkupRegularLine 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.º 2
0
        private List <List <ITrajectory> > GetParts(List <ITrajectory> trajectories, MarkupLOD lod)
        {
            var parts = trajectories.Select(t => StyleHelper.CalculateSolid(t, lod, (tr) => tr, MinAngle, MinLength, MaxLength)).ToList();

            for (var i = 0; i < parts.Count; i += 1)
            {
                var xm = (i - 1 + parts.Count) % parts.Count;
                var x  = i;
                var y  = (i + 1) % parts.Count;
                var yp = (i + 2) % parts.Count;

                if (FindIntersects(parts[x], parts[y], true, 1))
                {
                    continue;
                }
                if (parts.Count > 3 && parts[y].Count == 1 && FindIntersects(parts[x], parts[yp], true, 0))
                {
                    parts.RemoveAt(y);
                    continue;
                }
                if (FindIntersects(parts[y], parts[x], false, 1))
                {
                    continue;
                }
                if (parts.Count > 3 && parts[x].Count == 1 && FindIntersects(parts[y], parts[xm], false, 0))
                {
                    parts.RemoveAt(x);
                    i -= 1;
                    continue;
                }
            }

            return(parts);
        }
Exemplo n.º 3
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            var offset = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized * (Width / 2);

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

            MarkupStylePart CalculateDashes(ITrajectory dashTrajectory) => StyleHelper.CalculateSolidPart(dashTrajectory, offset, offset, Width, Color);
        }
Exemplo n.º 4
0
        protected override IStyleData Calculate(MarkupRegularLine 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.º 5
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.º 6
0
        protected override IEnumerable <MarkupStyleDash> Calculate(MarkupStopLine stopLine, ILineTrajectory trajectory)
        {
            var offset = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized * (Width / 2);

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

            IEnumerable <MarkupStyleDash> CalculateDashes(ILineTrajectory dashTrajectory)
            {
                yield return(StyleHelper.CalculateSolidDash(dashTrajectory, offset, offset, Width, Color));
            }
        }
Exemplo n.º 7
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            var offsetNormal = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized;
            var offsetLeft   = offsetNormal * (Width / 2);
            var offsetRight  = offsetNormal * (Width / 2 + 2 * Offset);

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

            IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory dashTrajectory)
            {
                yield return(StyleHelper.CalculateSolidPart(dashTrajectory, offsetLeft, offsetLeft, Width, Color));

                yield return(StyleHelper.CalculateSolidPart(dashTrajectory, offsetRight, offsetRight, Width, Color));
            }
        }
Exemplo n.º 8
0
        public override IEnumerable <MarkupStylePart> Calculate(MarkupCrosswalk crosswalk, MarkupLOD lod)
        {
            var middleOffset     = GetVisibleWidth(crosswalk) / 2 + OffsetBefore;
            var deltaOffset      = (Width - LineWidth) / 2 / Mathf.Sin(crosswalk.CornerAndNormalAngle);
            var firstTrajectory  = crosswalk.GetTrajectory(middleOffset - deltaOffset);
            var secondTrajectory = crosswalk.GetTrajectory(middleOffset + deltaOffset);

            foreach (var dash in StyleHelper.CalculateSolid(firstTrajectory, lod, CalculateDashes))
            {
                yield return(dash);
            }

            foreach (var dash in StyleHelper.CalculateSolid(secondTrajectory, lod, CalculateDashes))
            {
                yield return(dash);
            }

            MarkupStylePart CalculateDashes(ITrajectory dashTrajectory) => StyleHelper.CalculateSolidPart(dashTrajectory, 0, LineWidth, Color);
        }
Exemplo n.º 9
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            var offsetNormal = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized;
            var solidOffset  = offsetNormal * (Width / 2);
            var dashedOffset = offsetNormal * (Width / 2 + 2 * Offset);

            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));

            MarkupStylePart CalculateSolidDash(ITrajectory lineTrajectory) => StyleHelper.CalculateSolidPart(lineTrajectory, solidOffset, solidOffset, Width, Color);

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                yield return(StyleHelper.CalculateDashedPart(lineTrajectory, startT, endT, DashLength, dashedOffset, dashedOffset, Width, Color));
            }
        }
Exemplo n.º 10
0
        public override IStyleData Calculate(MarkupFiller filler, MarkupLOD lod)
        {
            var contour = filler.IsMedian ? SetMedianOffset(filler) : filler.Contour.Trajectories.ToArray();

            if (NeedReverse(contour))
            {
                contour = contour.Select(t => t.Invert()).Reverse().ToArray();
            }

            var parts = contour.Select(t => StyleHelper.CalculateSolid(t, lod, (tr) => tr, MinAngle, MinLength, MaxLength)).ToArray();

            for (var i = 0; i < parts.Length; i += 1)
            {
                var partI = parts[i];
                var partJ = parts[(i + 1) % parts.Length];

                if (!FindIntersects(partI, partJ, false))
                {
                    FindIntersects(partJ, partI, true);
                }
            }


            var points = parts.SelectMany(p => p).Select(t => t.StartPosition).ToArray();

            if (points.Length < 3)
            {
                return(null);
            }

            var polygon = new Polygon(points.Select(p => new PolygonPoint(p.x, p.z)));

            P2T.Triangulate(polygon);
            var triangles = polygon.Triangles.SelectMany(t => t.Points.Select(p => polygon.IndexOf(p))).ToArray();

            return(new MarkupStylePolygonMesh(filler.Markup.Height, Elevation, parts.Select(g => g.Count).ToArray(), points, triangles, MaterialType));
        }
Exemplo n.º 11
0
 public override IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory) => StyleHelper.CalculateSolid(trajectory, CalculateDashes);