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(); } }
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); }
public void AssertThat_AddEdges_IncreasesCount() { var r = new Random(123); for (var i = 0; i < 3000; i++) { _set.Add(new LineSegment2( new Vector2(RandomUtilities.RandomSingle(r.NextDouble, -100, 100), RandomUtilities.RandomSingle(r.NextDouble, -100, 100)), new Vector2(RandomUtilities.RandomSingle(r.NextDouble, -100, 100), RandomUtilities.RandomSingle(r.NextDouble, -100, 100)) ), 1); Assert.AreEqual(i + 1, _set.Count); } }