public static AnyOf <Ground, Outdoors, Adiabatic, Surface> ToLadybugTools_BoundaryCondition(this IPartition partition, BuildingModel buildingModel, Space space)
        {
            if (partition == null || buildingModel == null)
            {
                return(null);
            }

            if (partition is IHostPartition)
            {
                if (((IHostPartition)partition).Adiabatic())
                {
                    return(new Adiabatic());
                }
            }

            if (buildingModel.External(partition))
            {
                return(new Outdoors());
            }

            if (buildingModel.Underground(partition))
            {
                if (!buildingModel.Internal(partition))
                {
                    return(new Ground());
                }
            }

            int          index_Adjacent = -1;
            List <Space> spaces         = null;

            if (partition != null)
            {
                spaces = buildingModel.GetSpaces(partition);
                if (spaces != null && spaces.Count != 0)
                {
                    index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid);
                    index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]);
                }
            }

            if (index_Adjacent == -1)
            {
                return(null);
            }

            //boundaryConditionObjects have to be provided
            //https://www.ladybug.tools/honeybee-schema/model.html#tag/surface_model

            List <string> uniqueNames = new List <string>();

            uniqueNames.Add(Query.UniqueName(partition, index_Adjacent));
            uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent]));
            return(new Surface(uniqueNames));
        }
예제 #2
0
        public static HoneybeeSchema.Door ToLadybugTools(this IOpening opening, BuildingModel buildingModel, Space space)
        {
            if (opening == null || buildingModel == null)
            {
                return(null);
            }

            OpeningType openingType = opening.Type();

            if (openingType == null)
            {
                return(null);
            }

            //Opaque Windows to be replaced by Doors
            if (opening is Window && buildingModel.GetMaterialType(openingType.PaneMaterialLayers) != MaterialType.Opaque)
            {
                return(null);
            }

            IHostPartition hostPartition = buildingModel.GetHostPartition(opening);

            int          index          = -1;
            int          index_Adjacent = -1;
            List <Space> spaces         = null;

            if (hostPartition != null)
            {
                spaces = buildingModel.GetSpaces(hostPartition);
                if (spaces != null && spaces.Count != 0)
                {
                    index = spaces.FindIndex(x => x.Guid == space.Guid);
                    index = buildingModel.UniqueIndex(spaces[index]);

                    index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid);
                    index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]);
                }
            }

            HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = null;
            if (index == -1 || index_Adjacent == -1)
            {
                anyOf = new Outdoors();
            }
            else
            {
                bool          reversed    = index_Adjacent < index;
                List <string> uniqueNames = new List <string>();
                uniqueNames.Add(Core.LadybugTools.Query.UniqueName(opening as SAMObject, index_Adjacent));
                uniqueNames.Add(Query.UniqueName(hostPartition, index_Adjacent));
                uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent]));
                anyOf = new Surface(uniqueNames);
            }

            Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(opening);

            DoorEnergyPropertiesAbridged doorEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(construction: Query.UniqueName(opening.Type(), !(index_Adjacent != -1 && index <= index_Adjacent)));

            return(new HoneybeeSchema.Door(
                       identifier: Core.LadybugTools.Query.UniqueName(opening as SAMObject, index),
                       geometry: face3D,
                       boundaryCondition: anyOf,
                       properties: new DoorPropertiesAbridged(doorEnergyPropertiesAbridged),
                       displayName: opening.Name));
        }
예제 #3
0
        public static Face ToLadybugTools_Face(this IPartition partition, BuildingModel buildingModel, Space space)
        {
            Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(partition?.Face3D);

            if (face3D == null)
            {
                return(null);
            }

            FaceType?faceType = partition.FaceType();

            if (faceType == null || !faceType.HasValue)
            {
                return(null);
            }

            int          index          = -1;
            int          index_Adjacent = -1;
            bool         reverse        = true;
            List <Space> spaces         = buildingModel.GetSpaces(partition);

            if (spaces != null && spaces.Count != 0)
            {
                index = spaces.FindIndex(x => x.Guid == space.Guid);
                index = buildingModel.UniqueIndex(spaces[index]);

                index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid);
                index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]);

                reverse = buildingModel.UniqueIndex(spaces[0]) != index;
            }

            AnyOf <Ground, Outdoors, Adiabatic, Surface> boundaryCondition = partition.ToLadybugTools_BoundaryCondition(buildingModel, space);

            FaceEnergyPropertiesAbridged faceEnergyPropertiesAbridged = new FaceEnergyPropertiesAbridged();

            if (partition is IHostPartition)
            {
                faceEnergyPropertiesAbridged.Construction = Query.UniqueName(((IHostPartition)partition).Type(), reverse);
            }

            Face face = new Face(Query.UniqueName(partition, index), face3D, faceType.Value, boundaryCondition, new FacePropertiesAbridged(faceEnergyPropertiesAbridged), partition.Name);

            if (partition is IHostPartition)
            {
                List <IOpening> openings = ((IHostPartition)partition).GetOpenings();
                if (openings != null && openings.Count != 0)
                {
                    List <HoneybeeSchema.Aperture> apertures = new List <HoneybeeSchema.Aperture>();
                    List <HoneybeeSchema.Door>     doors     = new List <HoneybeeSchema.Door>();

                    foreach (IOpening opening in openings)
                    {
                        MaterialType materialType = MaterialType.Opaque;

                        OpeningType openingType = opening.Type();
                        if (openingType != null)
                        {
                            materialType = buildingModel.GetMaterialType(openingType.PaneMaterialLayers);
                        }


                        if (opening is Window && materialType != MaterialType.Opaque)
                        {
                            HoneybeeSchema.Aperture aperture = ((Window)opening).ToLadybugTools(buildingModel, space);
                            if (aperture != null)
                            {
                                apertures.Add(aperture);
                            }
                        }
                        else
                        {
                            HoneybeeSchema.Door door = opening.ToLadybugTools(buildingModel, space);
                            if (door != null)
                            {
                                doors.Add(door);
                            }
                        }
                    }

                    if (apertures != null && apertures.Count != 0)
                    {
                        face.Apertures = apertures;
                    }

                    if (doors != null && doors.Count != 0)
                    {
                        face.Doors = doors;
                    }
                }
            }

            return(face);
        }