/// <summary>
        /// Gets all minimal cycles in the XZ-plane where the road network's XZ-projection intersections are found.
        /// </summary>
        /// <returns>All minimal cycles in the XZ-plane</returns>
        private IEnumerable <IReadOnlyCollection <Vector3> > GetMinimalCyclesInXZ()
        {
            // XZ-projection of the undirected road network
            var roadNetwork = Injector.Get().GetXZProjection().GetAsUndirected();

            // If there aren't at least three vertices in the road network, there can't possibly be a cycle in it
            if (roadNetwork.VertexCount < 3)
            {
                return(new List <IReadOnlyCollection <Vector3> >());
            }

            // Get all cycles in the road network and sort them from the smallest area
            // to the largest in order to later only save the minimal cycles
            var cycles = GetAllCycles(roadNetwork).ToList();

            cycles.Sort((cycle1, cycle2) =>
            {
                var area1 = Maths2D.CalculatePolygonArea(cycle1.Select(Vec3ToVec2));
                var area2 = Maths2D.CalculatePolygonArea(cycle2.Select(Vec3ToVec2));
                return(area1 <area2 ? -1 : area1> area2 ? 1 : 0);
            });

            return(ExtractMinimalCycles(cycles));
        }
Beispiel #2
0
        internal Lot(IList <Vector3> vertices)
        {
            Vertices = vertices;

            this.area = Maths2D.CalculatePolygonArea((IEnumerable <Vector2>)ToXZ(vertices));
        }