Пример #1
0
        public override void Subdivide(Prism bounds, ISubdivisionGeometry geometry, INamedDataCollection hierarchicalParameters)
        {
            //Create land parcels
            var nodes = CreateParcelNodes(GenerateParcels(bounds.Footprint).ToArray(), bounds.Height).ToArray();

            //Set ground height (for nodes which care)
            foreach (var grounded in nodes.Select(node => node.Value).OfType <IGrounded>())
            {
                grounded.GroundHeight = GroundHeight;
            }

            //Build neighbour set
            var neighbours = new NeighbourSet <ISubdivisionContext>();

            foreach (var keyValuePair in nodes)
            {
                foreach (var edge in keyValuePair.Key.Edges)
                {
                    neighbours.Add(new LineSegment2(edge.Start, edge.End), keyValuePair.Value);
                }
            }

            //Associate node with their neighbours (for nodes which care)
            foreach (var neighbour in nodes.Where(node => node.Value is INeighbour))
            {
                ((INeighbour)neighbour.Value).Neighbours = CalculateNeighbours(neighbour, neighbours).ToArray();
            }
        }
Пример #2
0
        private NeighbourSet <RoomPlanSegment> CreateNeighbourSet()
        {
            var sides = new NeighbourSet <RoomPlanSegment>();

            //Add the room sides
            foreach (var room in _plan.Rooms)
            {
                for (ushort i = 0; i < room.OuterFootprint.Count; i++)
                {
                    var a = room.OuterFootprint[i];
                    var b = room.OuterFootprint[(i + 1) % room.OuterFootprint.Count];
                    sides.Add(new LineSegment2(a, b), new RoomPlanSegment(room, i));
                }
            }
            return(sides);
        }
Пример #3
0
        private IEnumerable <NeighbourInfo> CalculateNeighbours(KeyValuePair <Parcel, ISubdivisionContext> subject, NeighbourSet <ISubdivisionContext> nodes)
        {
            foreach (var edge in subject.Key.Edges)
            {
                var query      = new LineSegment2(edge.Start, edge.End);
                var neighbours = nodes.Neighbours(query, MathHelper.ToRadians(5), 1);
                foreach (var neighbour in neighbours)
                {
                    //Do not add self as a neighbour!
                    if (neighbour.Value.Equals(subject.Value))
                    {
                        continue;
                    }

                    yield return(new NeighbourInfo(
                                     neighbour.Value,
                                     neighbour.Segment.Transform(WorldTransformation),
                                     neighbour.SegmentOverlapStart,
                                     neighbour.SegmentOverlapEnd,
                                     query.Transform(WorldTransformation),
                                     neighbour.QueryOverlapStart,
                                     neighbour.QueryOverlapEnd
                                     ));
                }
            }
        }