コード例 #1
0
 public Door(List <Point3D> boundary)
 {
     Geometry = new Face3D {
         Boundary = boundary
     };
     BoundaryCondition = new Outdoors();
     Properties        = new HB.DoorPropertiesAbridged();
 }
コード例 #2
0
        public static HoneybeeSchema.Door ToLadybugTools_Door(this Aperture aperture, MaterialLibrary materialLibrary = null, int index = -1, int index_Adjacent = -1, string adjacentPanelUniqueName = null, string adjacentSpaceUniqueName = null)
        {
            if (aperture == null)
            {
                return(null);
            }

            ApertureConstruction apertureConstruction = aperture.ApertureConstruction;

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

            MaterialType materialType = apertureConstruction.PaneConstructionLayers.MaterialType(materialLibrary);

            if (aperture.ApertureType != ApertureType.Door)
            {
                //Opaque Windows to be replaced by Doors
                if (materialType != MaterialType.Opaque)
                {
                    return(null);
                }
            }

            PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D;

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

            HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = new Outdoors();

            Face3D face3D = planarBoundary3D.ToLadybugTools();

            if (!string.IsNullOrEmpty(adjacentPanelUniqueName) && !string.IsNullOrEmpty(adjacentSpaceUniqueName))
            {
                List <string> uniqueNames = new List <string>();
                uniqueNames.Add(Core.LadybugTools.Query.UniqueName(aperture, index_Adjacent));
                uniqueNames.Add(adjacentPanelUniqueName);
                uniqueNames.Add(adjacentSpaceUniqueName);

                anyOf = new Surface(uniqueNames);
            }

            DoorEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(Query.UniqueName(apertureConstruction, !(index_Adjacent != -1 && index <= index_Adjacent)));

            HoneybeeSchema.Door door = new HoneybeeSchema.Door(
                identifier: Core.LadybugTools.Query.UniqueName(aperture, index),
                geometry: face3D,
                boundaryCondition: anyOf,
                properties: new DoorPropertiesAbridged(apertureEnergyPropertiesAbridged),
                displayName: aperture.Name);

            door.IsGlass = materialType == MaterialType.Transparent;
            return(door);
        }
コード例 #3
0
        public void ToJsonTest()
        {
            var j = this.instance.ToJson();

            var obj = Outdoors.FromJson(j);

            var vF = obj.ViewFactor.Obj;

            Assert.IsTrue(vF is Autocalculate);
        }
コード例 #4
0
        public void ToJsonViewFactorTest()
        {
            this.instance.ViewFactor = 0.5;
            var j = this.instance.ToJson();

            var obj = Outdoors.FromJson(j);

            Assert.IsFalse(obj.SunExposure);

            var vF     = obj.ViewFactor;
            var isTrue = vF == 0.5;

            Assert.IsTrue(isTrue);
        }
コード例 #5
0
        private void OnTypeChanged(TypeChanged msg)
        {
            // (Konrad) Find the Object Wrapper with matching Id.
            var found = SpatialObjectsModels.FirstOrDefault(x =>
                                                            x.Room2D.Annotations.FirstOrDefault(y => y.UniqueId == msg.Annotation.UniqueId) != null);

            if (found == null)
            {
                return;
            }

            var index = found.Room2D.Annotations.IndexOf(msg.Annotation);

            // (Konrad) Type changed so we need a new Boundary Condition.
            BoundaryConditionBase newBc;

            switch (msg.Annotation.FamilySymbolName)
            {
            case "Ground":
                newBc = new Ground();
                break;

            case "Surface":
                newBc = new Surface(new Tuple <string, string, string>(string.Empty, "-1", string.Empty));
                break;

            case "Outdoors":
                newBc = new Outdoors();
                break;

            case "Adiabatic":
                newBc = new Adiabatic();
                break;

            default:
                newBc = new Outdoors();
                break;
            }

            // (Konrad) Update Boundary Condition and Annotation references.
            found.Room2D.BoundaryConditions[index] = newBc;
            found.Room2D.Annotations[index]        = msg.Annotation;
        }
コード例 #6
0
ファイル: Door.cs プロジェクト: HoareLea/SAM_LadybugTools
        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));
        }
コード例 #7
0
 public void Init()
 {
     instance             = new Outdoors();
     instance.SunExposure = false;
 }
コード例 #8
0
        //private static DynamicLayout EmptyLayout()
        //{
        //    return new DynamicLayout();
        //}

        public static DynamicLayout CreateOutdoorLayout(Outdoors bcOutdoors)
        {
            var layout = new DynamicLayout()
            {
                Spacing = new Size(8, 8)
            };
            var sun_CB = new CheckBox();

            sun_CB.CheckedBinding.Bind(bcOutdoors, v => v.SunExposure);
            sun_CB.Text = "Sun Exposure";

            var wind_CB = new CheckBox();

            wind_CB.CheckedBinding.Bind(bcOutdoors, v => v.WindExposure);
            wind_CB.Text = "Wind Exposure";

            // View Factor number
            var vF_NS = new NumericStepper();

            vF_NS.DecimalPlaces = 2;
            vF_NS.MinValue      = 0;
            vF_NS.MaxValue      = 1;
            vF_NS.ValueBinding.Bind(
                () => {
                if (bcOutdoors.ViewFactor.Obj is double v)
                {
                    return(v);
                }
                return(1.0);
            },
                (d) => bcOutdoors.ViewFactor = d
                );
            vF_NS.Enabled         = bcOutdoors.ViewFactor.Obj is double;
            vF_NS.EnabledChanged += (s, e) =>
            {
                if (vF_NS.Enabled)
                {
                    bcOutdoors.ViewFactor = vF_NS.Value;
                }
                else
                {
                    bcOutdoors.ViewFactor = new Autocalculate();
                }
            };

            // View Factor Autocalculate
            var vF_CB = new CheckBox();

            vF_CB.CheckedBinding.Bind(bcOutdoors, v => v.ViewFactor.Obj is Autocalculate);
            vF_CB.Text            = "Autocalculate";
            vF_CB.CheckedChanged += (s, e) =>
            {
                vF_NS.Enabled = !vF_CB.Checked.Value;
                if (vF_CB.Checked.Value)
                {
                    bcOutdoors.ViewFactor = new Autocalculate();
                }
            };

            layout.AddRow("Outdoors:");
            layout.AddRow(sun_CB);
            layout.AddRow(wind_CB);
            layout.AddRow("View Factor:");
            layout.AddRow(vF_CB);
            layout.AddRow(vF_NS);

            return(layout);
        }