示例#1
0
        public NeighbourCalculator(GeometricFloorplan plan)
        {
            Contract.Requires(plan != null);

            _plan = plan;

            Dirty = true;
        }
示例#2
0
        public override void Subdivide(Prism bounds, ISubdivisionGeometry geometry, INamedDataCollection hierarchicalParameters)
        {
            //Sanity checks
            if (!_floorIndex.HasValue)
            {
                throw new InvalidOperationException("Attempted to subdivide BaseFloor, but FloorIndex is not set");
            }
            if (!_floorAltitude.HasValue)
            {
                throw new InvalidOperationException("Attempted to subdivide BaseFloor, but FloorAltitude is not set");
            }

            //Calculate some handy values
            _roomHeight = bounds.Height - _floorThickness - _ceilingThickness;
            var roomOffsetY = -bounds.Height / 2 + _roomHeight / 2 + _floorThickness;

            //Find vertical elements which start on this floor
            var constrainedVerticalElements = ConstrainVerticalElements(this.SearchUp <IBuilding, IBuilding>(a => a, typeof(IBuildingContainer)));

            //Create a plan for this floor
            var plan = new Plan.Geometric.GeometricFloorplan(Bounds.Footprint);
            var overlappingVerticalRooms = InsertOverlappingVerticals(
                plan,
                this.SearchUp <IVerticalFeatureContainer, IVerticalFeatureContainer>(a => a, typeof(IBuildingContainer)).Overlapping(FloorIndex, false)
                );

            var verticals = CreateFloorPlan(plan, overlappingVerticalRooms, constrainedVerticalElements).ToArray();

            _plan = plan.Freeze();

            PlanFrozen(_plan);

            //Create nodes for all the vertical elements which started on this floor
            CreateVerticalNodes(verticals);

            //Create Floor and ceiling (with holes for vertical sections)
            CreateFloors(bounds, geometry, verticals, HierarchicalParameters.DefaultCeilingMaterial(Random));
            CreateCeilings(bounds, geometry, verticals, HierarchicalParameters.DefaultCeilingMaterial(Random));

            //Create room scripts
            CreateRoomNodes(roomOffsetY, _roomHeight, _plan);

            //Create external facades (subsections of building over this floor facade)
            var externalFacades = CreateExternalFacades(bounds, _plan);

            //Create facades for rooms
            var dist = hierarchicalParameters.ExternalWallThickness(Random);

            CreateRoomFacades(externalFacades, roomOffsetY, dist, _plan);
        }
示例#3
0
        private RoomPlan(GeometricFloorplan plan, IReadOnlyList <Vector2> outer, IReadOnlyList <Vector2> inner, IReadOnlyList <Section> sections, IReadOnlyList <IReadOnlyList <Vector2> > corners, float wallThickness, uint id)
        {
            Contract.Requires(plan != null);
            Contract.Requires(outer != null);
            Contract.Requires(inner != null);
            Contract.Requires(sections != null);
            Contract.Requires(wallThickness > 0);

            _plan = plan;
            _id   = id;

            _innerFootprint = inner;
            _outerFootprint = outer;
            _sections       = sections;
            _corners        = corners;
            _wallThickness  = wallThickness;
        }
示例#4
0
        internal static bool TryCreate(GeometricFloorplan plan, IReadOnlyList <Vector2> footprint, float wallThickness, uint id, out RoomPlan room)
        {
            Contract.Requires(plan != null);
            Contract.Requires(footprint != null);
            Contract.Requires(wallThickness > 0);

            Vector2[] inner;
            IReadOnlyList <IReadOnlyList <Vector2> > corners;
            var sections = footprint.Sections(wallThickness, out inner, out corners).ToArray();

            //No wall sections generated means this is not a valid room shape!
            if (sections.Length == 0 || inner.Length == 0)
            {
                room = null;
                return(false);
            }

            room = new RoomPlan(plan, footprint, inner, sections, corners, wallThickness, id);
            return(true);
        }