Beispiel #1
0
        public static Construction ToSAM(this TBD.Construction construction)
        {
            if (construction == null)
            {
                return(null);
            }

            List <TBD.material> materials = construction.Materials();

            List <ConstructionLayer> constructionLayers = null;

            if (materials != null)
            {
                constructionLayers = new List <ConstructionLayer>();
                for (int i = 0; i < materials.Count; i++)
                {
                    TBD.material material  = materials[i];
                    double       thickness = construction.materialWidth[i];

                    constructionLayers.Add(new ConstructionLayer(material.name, thickness));
                }
            }

            Construction result = new Construction(construction.name, constructionLayers);

            return(result);
        }
Beispiel #2
0
        public static bool UpdateMaterial(this TBD.material material, TransparentMaterial transparentMaterial)
        {
            if (!string.IsNullOrWhiteSpace(transparentMaterial.Name) && !transparentMaterial.Name.Equals(material.name))
            {
                material.name = transparentMaterial.Name;
            }

            material.type = (int)TBD.MaterialTypes.tcdTransparentLayer;

            material.description              = transparentMaterial.Description;
            material.width                    = System.Convert.ToSingle(transparentMaterial.GetValue <double>(MaterialParameter.DefaultThickness));
            material.conductivity             = System.Convert.ToSingle(transparentMaterial.ThermalConductivity);
            material.vapourDiffusionFactor    = System.Convert.ToSingle(transparentMaterial.GetValue <double>(MaterialParameter.VapourDiffusionFactor));
            material.solarTransmittance       = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.SolarTransmittance));
            material.externalSolarReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalSolarReflectance));
            material.internalSolarReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalSolarReflectance));
            material.lightTransmittance       = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.LightTransmittance));
            material.externalLightReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalLightReflectance));
            material.internalLightReflectance = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalLightReflectance));
            material.externalEmissivity       = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.ExternalEmissivity));
            material.internalEmissivity       = System.Convert.ToSingle(transparentMaterial.GetValue <double>(TransparentMaterialParameter.InternalEmissivity));

            if (transparentMaterial.GetValue <bool>(TransparentMaterialParameter.IsBlind))
            {
                material.isBlind = 1;
            }
            else
            {
                material.isBlind = 0;
            }

            return(true);
        }
Beispiel #3
0
        /***************************************************/

        /*
         * private List<BHS.Elements.Storey> readStorey(List<string> ids = null)
         * {
         *  TBD.BuildingStorey tbdStorey = m_TBDDocumentInstance.Building.GetStorey(0);
         *  List<BHS.Elements.Storey> storey = new List<BHS.Elements.Storey>();
         *  storey.Add(Engine.TAS.Convert.ToBHoM(tbdStorey));
         *
         *  return storey;
         * }
         *
         * /***************************************************/

        private List <Layer> ReadMaterials(List <string> ids = null)
        {
            TBD.Building building = m_tbdDocument.Building;

            List <Layer> material = new List <Layer>();

            int constructionIndex = 0;

            while (building.GetConstruction(constructionIndex) != null)
            {
                TBD.Construction currConstruction = building.GetConstruction(constructionIndex);

                int materialIndex = 1; //TAS does not have any material at index 0
                while (building.GetConstruction(constructionIndex).materials(materialIndex) != null)
                {
                    TBD.material tbdMaterial = building.GetConstruction(constructionIndex).materials(materialIndex);

                    material.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(tbdMaterial, currConstruction));
                    materialIndex++;
                }

                constructionIndex++;
            }
            return(material);
        }
Beispiel #4
0
        public static BHPC.Construction FromTAS(this TBD.Construction tbdConstruction)
        {
            if (tbdConstruction == null)
            {
                return(null);
            }

            BHPC.Construction construction = new BHPC.Construction();
            construction.Name = tbdConstruction.name;

            int mIndex = 1;

            TBD.material tbdMaterial = null;
            double       thickness   = 0;

            while ((tbdMaterial = tbdConstruction.materials(mIndex)) != null)
            {
                construction.Layers.Add(tbdMaterial.FromTAS(tbdConstruction));
                (construction.Layers.Last()).Thickness = (tbdConstruction.materialWidth[mIndex] == 0 ? (construction.Layers.Last()).Thickness : tbdConstruction.materialWidth[mIndex]); // temp solution set material thickness as value from construction.material.thickness
                thickness += construction.Layers.Last().Thickness;
                mIndex++;
            }

            //construction.FFactor = tbdConstruction.FFactor;


            TASDescription tasData = new TASDescription();

            tasData.Description = tbdConstruction.description.RemoveBrackets();
            construction.Fragments.Add(tasData);

            return(construction);
        }
Beispiel #5
0
        public static TBD.material ToTAS(this BHPMC.Layer layer, TBD.material tbdMaterial)
        {
            if (layer == null)
            {
                return(tbdMaterial);
            }
            if (layer.Material != null)
            {
                tbdMaterial.name = layer.Material.Name;
            }
            tbdMaterial.width = (float)layer.Thickness;

            tbdMaterial.type = (int)layer.Material.ToTASType();

            BHM.IEnvironmentMaterial envMat = layer.Material.Properties.Where(x => x.GetType() == typeof(BHM.IEnvironmentMaterial)).FirstOrDefault() as BHM.IEnvironmentMaterial;

            if (envMat != null)
            {
                switch ((TBD.MaterialTypes)tbdMaterial.type)
                {
                case TBD.MaterialTypes.tcdGasLayer:
                    tbdMaterial.convectionCoefficient = (float)((BHM.GasMaterial)envMat).ConvectionCoefficient;
                    tbdMaterial.vapourDiffusionFactor = (float)(((BHM.GasMaterial)envMat).VapourResistivity / 5 / layer.Thickness);     //Vapour Resistivity / 5GN·s/kg·m / material thickness
                    tbdMaterial.description           = ((BHM.GasMaterial)envMat).Description;

                    break;

                case TBD.MaterialTypes.tcdOpaqueLayer:     //Thickness not showing
                    tbdMaterial.conductivity             = (float)((BHM.SolidMaterial)envMat).Conductivity;
                    tbdMaterial.specificHeat             = (float)((BHM.SolidMaterial)envMat).SpecificHeat;
                    tbdMaterial.density                  = (float)((BHM.SolidMaterial)envMat).Density;
                    tbdMaterial.vapourDiffusionFactor    = (float)(((BHM.SolidMaterial)envMat).VapourResistivity / 5 / layer.Thickness);  //Vapour Resistivity / 5GN·s/kg·m / material thickness
                    tbdMaterial.externalSolarReflectance = (float)((BHM.SolidMaterial)envMat).SolarReflectanceExternal;
                    tbdMaterial.internalSolarReflectance = (float)((BHM.SolidMaterial)envMat).SolarReflectanceInternal;
                    tbdMaterial.externalLightReflectance = (float)((BHM.SolidMaterial)envMat).LightReflectanceExternal;
                    tbdMaterial.internalLightReflectance = (float)((BHM.SolidMaterial)envMat).LightReflectanceInternal;
                    tbdMaterial.externalEmissivity       = (float)((BHM.SolidMaterial)envMat).EmissivityExternal;
                    tbdMaterial.internalEmissivity       = (float)((BHM.SolidMaterial)envMat).EmissivityInternal;
                    tbdMaterial.description              = ((BHM.SolidMaterial)envMat).Description;

                    break;

                case TBD.MaterialTypes.tcdTransparentLayer:
                    tbdMaterial.conductivity             = (float)((BHM.SolidMaterial)envMat).Conductivity;
                    tbdMaterial.vapourDiffusionFactor    = (float)(((BHM.SolidMaterial)envMat).VapourResistivity / 5 / layer.Thickness);  //Vapour Resistivity / 5GN·s/kg·m / material thickness
                    tbdMaterial.solarTransmittance       = (float)((BHM.SolidMaterial)envMat).SolarTransmittance;
                    tbdMaterial.externalSolarReflectance = (float)((BHM.SolidMaterial)envMat).SolarReflectanceExternal;
                    tbdMaterial.internalSolarReflectance = (float)((BHM.SolidMaterial)envMat).SolarReflectanceInternal;
                    tbdMaterial.lightTransmittance       = (float)((BHM.SolidMaterial)envMat).LightTransmittance;
                    tbdMaterial.externalLightReflectance = (float)((BHM.SolidMaterial)envMat).LightReflectanceExternal;
                    tbdMaterial.internalLightReflectance = (float)((BHM.SolidMaterial)envMat).LightReflectanceInternal;
                    tbdMaterial.externalEmissivity       = (float)((BHM.SolidMaterial)envMat).EmissivityExternal;
                    tbdMaterial.internalEmissivity       = (float)((BHM.SolidMaterial)envMat).EmissivityInternal;
                    tbdMaterial.description = ((BHM.SolidMaterial)envMat).Description;
                    break;
                }
            }
            return(tbdMaterial);
        }
Beispiel #6
0
        public static BHM.IEnvironmentMaterial FromTASProperties(this TBD.material tbdMaterial, TBD.Construction tbdConstruction)
        {
            if (tbdMaterial == null)
            {
                return(null);
            }

            TBD.MaterialTypes matType = (TBD.MaterialTypes)tbdMaterial.type;

            switch (matType)
            {
            case TBD.MaterialTypes.tcdOpaqueLayer:
            case TBD.MaterialTypes.tcdOpaqueMaterial:
                return(new BHM.SolidMaterial
                {
                    Name = tbdMaterial.name,
                    Description = tbdMaterial.description,
                    Conductivity = tbdMaterial.conductivity,
                    SpecificHeat = tbdMaterial.specificHeat,
                    VapourResistivity = (tbdMaterial.width * 5 * tbdMaterial.vapourDiffusionFactor),     //Thickness * 5GN·s/kg·m * vapour diffusion factor
                    SolarReflectanceExternal = tbdMaterial.externalSolarReflectance,
                    SolarReflectanceInternal = tbdMaterial.internalSolarReflectance,
                    LightReflectanceExternal = tbdMaterial.externalLightReflectance,
                    LightReflectanceInternal = tbdMaterial.internalLightReflectance,
                    EmissivityExternal = tbdMaterial.externalEmissivity,
                    EmissivityInternal = tbdMaterial.internalEmissivity,
                });

            case TBD.MaterialTypes.tcdTransparentLayer:
                return(new BHM.SolidMaterial
                {
                    Name = tbdMaterial.name,
                    Description = tbdMaterial.description,
                    Conductivity = tbdMaterial.conductivity,
                    VapourResistivity = (tbdMaterial.width * 5 * tbdMaterial.vapourDiffusionFactor),     //Thickness * 5GN·s/kg·m * vapour diffusion factor
                    SolarTransmittance = tbdMaterial.solarTransmittance,
                    SolarReflectanceExternal = tbdMaterial.externalSolarReflectance,
                    SolarReflectanceInternal = tbdMaterial.internalSolarReflectance,
                    LightTransmittance = tbdMaterial.lightTransmittance,
                    LightReflectanceExternal = tbdMaterial.externalLightReflectance,
                    LightReflectanceInternal = tbdMaterial.internalLightReflectance,
                    EmissivityExternal = tbdMaterial.externalEmissivity,
                    EmissivityInternal = tbdMaterial.internalEmissivity,
                });

            case TBD.MaterialTypes.tcdGasLayer:
                return(new BHM.GasMaterial
                {
                    Name = tbdMaterial.name,
                    Description = tbdMaterial.description,
                    ConvectionCoefficient = tbdMaterial.convectionCoefficient,
                    VapourResistivity = (tbdMaterial.width * 5 * tbdMaterial.vapourDiffusionFactor),     //Thickness * 5GN·s/kg·m * vapour diffusion factor
                });

            default:
                return(new BHM.SolidMaterial());
            }
        }
Beispiel #7
0
        public static bool UpdateMaterial(this TBD.material material_TBD, IMaterial material)
        {
            if (material == null || material_TBD == null)
            {
                return(false);
            }

            return(UpdateMaterial(material_TBD, material as dynamic));
        }
        /// <summary>
        /// Gets TAS Construction Materials
        /// </summary>
        /// <param name="Construction">TAS Construction</param>
        /// <returns name="Materials">Construction Materials</returns>
        /// <search>
        /// TAS, Builidng, Construction, Get Construction Materials, builidng, construction, get construction materials
        /// </search>
        public static List <Material> Materials(Construction Construction)
        {
            List <Material> aMaterialList = new List <Material>();

            int aIndex = 1;

            TBD.material aMaterial = Construction.pConstruction.materials(aIndex);
            while (aMaterial != null)
            {
                aMaterialList.Add(new Material(aMaterial));
                aIndex++;
                aMaterial = Construction.pConstruction.materials(aIndex);
            }
            return(aMaterialList);
        }
Beispiel #9
0
        public static bool UpdateMaterial(this TBD.material material, GasMaterial gasMaterial)
        {
            if (!string.IsNullOrWhiteSpace(gasMaterial.Name) && !gasMaterial.Name.Equals(material.name))
            {
                material.name = gasMaterial.Name;
            }

            material.type = (int)TBD.MaterialTypes.tcdGasLayer;

            material.description           = gasMaterial.Description;
            material.width                 = System.Convert.ToSingle(gasMaterial.GetValue <double>(MaterialParameter.DefaultThickness));
            material.convectionCoefficient = System.Convert.ToSingle(gasMaterial.GetValue <double>(GasMaterialParameter.HeatTransferCoefficient));
            material.vapourDiffusionFactor = System.Convert.ToSingle(gasMaterial.GetValue <double>(MaterialParameter.VapourDiffusionFactor));

            return(true);
        }
Beispiel #10
0
        public static bool RemoveMaterials(this TBD.Construction construction)
        {
            if (construction == null)
            {
                return(false);
            }

            TBD.material material = construction.materials(1);
            while (material != null)
            {
                construction.RemoveMaterial(0);
                material = construction.materials(1);
            }

            return(true);
        }
Beispiel #11
0
        public static List <TBD.material> Materials(this TBD.Construction construction)
        {
            List <TBD.material> result = new List <TBD.material>();

            int index = 1;

            TBD.material material = construction.materials(index);
            while (material != null)
            {
                result.Add(material);
                index++;

                material = construction.materials(index);
            }

            return(result);
        }
Beispiel #12
0
        public static TBD.material AddMaterial(this TBD.Construction construction, Core.Material material)
        {
            if (construction == null || material == null)
            {
                return(null);
            }

            TBD.material result = construction.AddMaterial();
            if (result == null)
            {
                return(result);
            }

            result.UpdateMaterial(material);

            return(result);
        }
Beispiel #13
0
        public static BHPMC.Layer FromTAS(this TBD.material tbdMaterial, TBD.Construction tbdConstruction)
        {
            if (tbdMaterial == null)
            {
                return(null);
            }

            BHPMC.Layer layer = new BHPMC.Layer();
            layer.Thickness = tbdMaterial.width;

            BHPM.Material material = new BHPM.Material();
            material.Name = tbdMaterial.name;
            material.Properties.Add(tbdMaterial.FromTASProperties(tbdConstruction));

            layer.Material = material;

            return(layer);
        }
        public static double ConstructionThickness(this TBD.Construction tbdConstruction, int decimals = 3)
        {
            double tbdMaterialThickness = 0;

            if (tbdConstruction != null)
            {
                int          aIndex      = 1;
                TBD.material tbdMaterial = null;
                while ((tbdMaterial = tbdConstruction.materials(aIndex)) != null)
                {
                    tbdMaterial           = tbdConstruction.materials(aIndex);
                    tbdMaterialThickness += tbdMaterial.width;
                    aIndex++;
                }
            }

            return(tbdMaterialThickness);
        }
Beispiel #15
0
        public static List <ConstructionLayer> ConstructionLayers(this TBD.Construction construction)
        {
            List <ConstructionLayer> result = new List <ConstructionLayer>();

            int index = 1;

            TBD.material material = construction.materials(index);
            while (material != null)
            {
                ConstructionLayer constructionLayer = new ConstructionLayer(material.name, construction.materialWidth[index]);

                result.Add(constructionLayer);
                index++;

                material = construction.materials(index);
            }

            return(result);
        }
Beispiel #16
0
        public static bool UpdateMaterial(this TBD.material material, OpaqueMaterial opaqueMaterial)
        {
            if (!string.IsNullOrWhiteSpace(opaqueMaterial.Name) && !opaqueMaterial.Name.Equals(material.name))
            {
                material.name = opaqueMaterial.Name;
            }

            material.type = (int)TBD.MaterialTypes.tcdOpaqueMaterial;

            material.description              = opaqueMaterial.Description;
            material.width                    = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(MaterialParameter.DefaultThickness));
            material.conductivity             = System.Convert.ToSingle(opaqueMaterial.ThermalConductivity);
            material.specificHeat             = System.Convert.ToSingle(opaqueMaterial.SpecificHeatCapacity);
            material.density                  = System.Convert.ToSingle(opaqueMaterial.Density);
            material.vapourDiffusionFactor    = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(MaterialParameter.VapourDiffusionFactor));
            material.externalSolarReflectance = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.ExternalSolarReflectance));
            material.internalSolarReflectance = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.InternalSolarReflectance));
            material.externalLightReflectance = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.ExternalLightReflectance));
            material.internalLightReflectance = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.InternalLightReflectance));
            material.externalEmissivity       = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.ExternalEmissivity));
            material.internalEmissivity       = System.Convert.ToSingle(opaqueMaterial.GetValue <double>(OpaqueMaterialParameter.InternalEmissivity));

            return(true);
        }
Beispiel #17
0
 internal Material(TBD.material Material)
 {
     pMaterial = Material;
 }
Beispiel #18
0
        public static TBD.Building ToTBD(this AnalyticalModel analyticalModel, TBD.TBDDocument tBDDocument)
        {
            if (analyticalModel == null)
            {
                return(null);
            }

            TBD.Building result = tBDDocument.Building;
            if (result == null)
            {
                return(null);
            }

            AdjacencyCluster adjacencyCluster = analyticalModel.AdjacencyCluster;

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

            List <Space> spaces = adjacencyCluster.GetSpaces();

            if (spaces == null)
            {
                return(result);
            }

            MaterialLibrary materialLibrary = analyticalModel.MaterialLibrary;

            Plane plane = Plane.WorldXY;

            List <TBD.DaysShade> daysShades = new List <TBD.DaysShade>();

            result.ClearShadingData();

            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Panel    = new Dictionary <System.Guid, List <TBD.zoneSurface> >();
            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Aperture = new Dictionary <System.Guid, List <TBD.zoneSurface> >();

            foreach (Space space in spaces)
            {
                Shell shell = adjacencyCluster.Shell(space);
                if (shell == null)
                {
                    return(null);
                }

                TBD.zone zone = result.AddZone();
                zone.name   = space.Name;
                zone.volume = System.Convert.ToSingle(shell.Volume());

                if (space.TryGetValue(SpaceParameter.Color, out SAMColor sAMColor) && sAMColor != null)
                {
                    zone.colour = Core.Convert.ToUint(sAMColor.ToColor());
                }

                List <Face3D> face3Ds = Geometry.Spatial.Query.Section(shell, 0.01, false);
                if (face3Ds != null && face3Ds.Count != 0)
                {
                    face3Ds.RemoveAll(x => x == null || !x.IsValid());
                    zone.floorArea        = System.Convert.ToSingle(face3Ds.ConvertAll(x => x.GetArea()).Sum());
                    zone.exposedPerimeter = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Planar.Query.Perimeter(x.ExternalEdge2D)).Sum());
                    zone.length           = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Tas.Query.Length(x)).Sum());
                }

                TBD.room room = zone.AddRoom();

                List <TBD.buildingElement> buildingElements = result.BuildingElements();
                List <TBD.Construction>    constructions    = result.Constructions();

                List <Panel> panels = adjacencyCluster?.GetPanels(space);
                if (panels != null || panels.Count != 0)
                {
                    foreach (Panel panel in panels)
                    {
                        string name_Panel = panel.Name;
                        if (string.IsNullOrWhiteSpace(name_Panel))
                        {
                            continue;
                        }

                        Face3D face3D_Panel = panel.Face3D;
                        if (face3D_Panel == null)
                        {
                            continue;
                        }

                        BoundingBox3D boundingBox3D_Panel = face3D_Panel.GetBoundingBox();

                        TBD.zoneSurface zoneSurface_Panel = zone.AddSurface();
                        zoneSurface_Panel.orientation = System.Convert.ToSingle(Geometry.Spatial.Query.Azimuth(panel, Vector3D.WorldY));
                        zoneSurface_Panel.inclination = System.Convert.ToSingle(Geometry.Spatial.Query.Tilt(panel));

                        zoneSurface_Panel.altitude              = System.Convert.ToSingle(boundingBox3D_Panel.GetCentroid().Z);
                        zoneSurface_Panel.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Panel.Max.Z - boundingBox3D_Panel.Min.Z);
                        zoneSurface_Panel.area                  = System.Convert.ToSingle(face3D_Panel.GetArea());
                        zoneSurface_Panel.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Panel));

                        TBD.RoomSurface roomSurface_Panel = room.AddSurface();
                        roomSurface_Panel.area        = zoneSurface_Panel.area;
                        roomSurface_Panel.zoneSurface = zoneSurface_Panel;

                        Geometry.SolarCalculator.SolarFaceSimulationResult solarFaceSimulationResult = analyticalModel.GetResults <Geometry.SolarCalculator.SolarFaceSimulationResult>(panel)?.FirstOrDefault();
                        if (solarFaceSimulationResult != null)
                        {
                            List <TBD.SurfaceShade> surfaceShades = Modify.UpdateSurfaceShades(result, daysShades, zoneSurface_Panel, analyticalModel, solarFaceSimulationResult);
                        }

                        TBD.Perimeter perimeter_Panel = Geometry.Tas.Convert.ToTBD(panel.GetFace3D(true), roomSurface_Panel);
                        if (perimeter_Panel == null)
                        {
                            continue;
                        }

                        PanelType panelType = panel.PanelType;

                        TBD.buildingElement buildingElement_Panel = buildingElements.Find(x => x.name == name_Panel);
                        if (buildingElement_Panel == null)
                        {
                            TBD.Construction construction_TBD = null;

                            Construction construction = panel.Construction;
                            if (construction != null)
                            {
                                construction_TBD = constructions.Find(x => x.name == construction.Name);
                                if (construction_TBD == null)
                                {
                                    construction_TBD      = result.AddConstruction(null);
                                    construction_TBD.name = construction.Name;

                                    if (construction.Transparent(materialLibrary))
                                    {
                                        construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                    }

                                    List <ConstructionLayer> constructionLayers = construction.ConstructionLayers;
                                    if (constructionLayers != null && constructionLayers.Count != 0)
                                    {
                                        int index = 1;
                                        foreach (ConstructionLayer constructionLayer in constructionLayers)
                                        {
                                            Material material = analyticalModel?.MaterialLibrary?.GetMaterial(constructionLayer.Name) as Core.Material;
                                            if (material == null)
                                            {
                                                continue;
                                            }

                                            TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                            if (material_TBD != null)
                                            {
                                                material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                index++;
                                            }
                                        }
                                    }

                                    constructions.Add(construction_TBD);
                                }

                                if (panelType == PanelType.Undefined && construction != null)
                                {
                                    panelType = construction.PanelType();
                                    if (panelType == PanelType.Undefined && construction.TryGetValue(ConstructionParameter.DefaultPanelType, out string panelTypeString))
                                    {
                                        panelType = Core.Query.Enum <PanelType>(panelTypeString);
                                    }
                                }
                            }

                            buildingElement_Panel        = result.AddBuildingElement();
                            buildingElement_Panel.name   = name_Panel;
                            buildingElement_Panel.colour = Core.Convert.ToUint(Analytical.Query.Color(panelType));
                            buildingElement_Panel.BEType = Query.BEType(panelType.Text());
                            buildingElement_Panel.AssignConstruction(construction_TBD);
                            buildingElements.Add(buildingElement_Panel);
                        }

                        if (buildingElement_Panel != null)
                        {
                            zoneSurface_Panel.buildingElement = buildingElement_Panel;
                        }

                        zoneSurface_Panel.type = TBD.SurfaceType.tbdExposed;

                        List <Aperture> apertures = panel.Apertures;
                        if (apertures != null && apertures.Count != 0)
                        {
                            bool @internal = adjacencyCluster.Internal(panel);

                            foreach (Aperture aperture in apertures)
                            {
                                string name_Aperture = aperture.Name;
                                if (string.IsNullOrWhiteSpace(name_Aperture))
                                {
                                    continue;
                                }

                                name_Aperture = string.Format("{0} -pane", aperture.Name);

                                Face3D face3D_Aperture = aperture.Face3D;
                                if (face3D_Aperture == null)
                                {
                                    continue;
                                }

                                BoundingBox3D boundingBox3D_Aperture = face3D_Aperture.GetBoundingBox();

                                float area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                TBD.zoneSurface zoneSurface_Aperture = zoneSurface_Panel.AddChildSurface(area);
                                if (zoneSurface_Aperture == null)
                                {
                                    continue;
                                }

                                zoneSurface_Aperture.orientation           = zoneSurface_Panel.orientation;
                                zoneSurface_Aperture.inclination           = zoneSurface_Panel.inclination;
                                zoneSurface_Aperture.altitude              = System.Convert.ToSingle(boundingBox3D_Aperture.GetCentroid().Z);
                                zoneSurface_Aperture.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Aperture.Max.Z - boundingBox3D_Aperture.Min.Z);
                                zoneSurface_Aperture.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Aperture));
                                //zoneSurface_Aperture.area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                zoneSurface_Aperture.type = @internal ? TBD.SurfaceType.tbdLink : zoneSurface_Panel.type;

                                TBD.RoomSurface roomSurface_Aperture = room.AddSurface();
                                roomSurface_Aperture.area        = zoneSurface_Aperture.area;
                                roomSurface_Aperture.zoneSurface = zoneSurface_Aperture;

                                TBD.Perimeter perimeter_Aperture = Geometry.Tas.Convert.ToTBD(face3D_Aperture, roomSurface_Aperture);
                                if (perimeter_Aperture == null)
                                {
                                    continue;
                                }

                                TBD.buildingElement buildingElement_Aperture = buildingElements.Find(x => x.name == name_Aperture);
                                if (buildingElement_Aperture == null)
                                {
                                    TBD.Construction construction_TBD = null;

                                    ApertureConstruction apertureConstruction = aperture.ApertureConstruction;
                                    if (apertureConstruction != null)
                                    {
                                        construction_TBD = constructions.Find(x => x.name == apertureConstruction.Name);
                                        if (construction_TBD == null)
                                        {
                                            construction_TBD      = result.AddConstruction(null);
                                            construction_TBD.name = name_Aperture;

                                            if (apertureConstruction.Transparent(materialLibrary))
                                            {
                                                construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                            }

                                            List <ConstructionLayer> constructionLayers = apertureConstruction.PaneConstructionLayers;
                                            if (constructionLayers != null && constructionLayers.Count != 0)
                                            {
                                                int index = 1;
                                                foreach (ConstructionLayer constructionLayer in constructionLayers)
                                                {
                                                    Core.Material material = materialLibrary?.GetMaterial(constructionLayer.Name) as Material;
                                                    if (material == null)
                                                    {
                                                        continue;
                                                    }

                                                    TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                                    if (material_TBD != null)
                                                    {
                                                        material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        index++;
                                                    }
                                                }
                                            }

                                            constructions.Add(construction_TBD);
                                        }
                                    }

                                    ApertureType apertureType = aperture.ApertureType;

                                    buildingElement_Aperture        = result.AddBuildingElement();
                                    buildingElement_Aperture.name   = name_Aperture;
                                    buildingElement_Aperture.colour = Core.Convert.ToUint(Analytical.Query.Color(apertureType));
                                    buildingElement_Aperture.BEType = Query.BEType(apertureType, false);
                                    buildingElement_Aperture.AssignConstruction(construction_TBD);
                                    buildingElements.Add(buildingElement_Aperture);
                                }

                                if (buildingElement_Aperture != null)
                                {
                                    zoneSurface_Aperture.buildingElement = buildingElement_Aperture;
                                }

                                if (!dictionary_Aperture.TryGetValue(aperture.Guid, out List <TBD.zoneSurface> zoneSurfaces_Aperture) || zoneSurfaces_Aperture == null)
                                {
                                    zoneSurfaces_Aperture = new List <TBD.zoneSurface>();
                                    dictionary_Aperture[aperture.Guid] = zoneSurfaces_Aperture;
                                }

                                zoneSurfaces_Aperture.Add(zoneSurface_Aperture);
                            }
                        }

                        zoneSurface_Panel.type = Query.SurfaceType(panelType);

                        if (!dictionary_Panel.TryGetValue(panel.Guid, out List <TBD.zoneSurface> zoneSurfaces_Panel) || zoneSurfaces_Panel == null)
                        {
                            zoneSurfaces_Panel           = new List <TBD.zoneSurface>();
                            dictionary_Panel[panel.Guid] = zoneSurfaces_Panel;
                        }

                        zoneSurfaces_Panel.Add(zoneSurface_Panel);
                    }
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Panel)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[1].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[1].inclination = inclination;
                    keyValuePair.Value[1].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;

                    float inclination = keyValuePair.Value[1].inclination;
                    if (inclination > 180)
                    {
                        inclination -= 180;
                    }
                    keyValuePair.Value[1].inclination = inclination;
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Aperture)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[0].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[0].inclination = inclination;
                    keyValuePair.Value[0].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;
                }
            }

            return(result);
        }
Beispiel #19
0
        public static bool UpdateConstruction(this TBD.Construction construction_TBD, IEnumerable <ConstructionLayer> constructionLayers, MaterialLibrary materialLibrary)
        {
            List <ConstructionLayer> constructionLayers_TBD = construction_TBD.ConstructionLayers();

            if (constructionLayers_TBD == null && constructionLayers == null)
            {
                return(false);
            }

            bool update = true;

            if (constructionLayers_TBD != null && constructionLayers != null && constructionLayers_TBD.Count == constructionLayers.Count())
            {
                update = false;
                for (int i = 0; i < constructionLayers.Count(); i++)
                {
                    if (!constructionLayers.ElementAt(i).Name.Equals(constructionLayers_TBD[i].Name) || !Core.Query.AlmostEqual(constructionLayers.ElementAt(i).Thickness, constructionLayers_TBD[i].Thickness))
                    {
                        update = true;
                        break;
                    }
                }
            }

            if (update)
            {
                construction_TBD.RemoveMaterials();
                if (constructionLayers != null)
                {
                    for (int i = 0; i < constructionLayers.Count(); i++)
                    {
                        ConstructionLayer constructionLayer = constructionLayers.ElementAt(i);
                        string            name = constructionLayer.Name;
                        if (string.IsNullOrWhiteSpace(name))
                        {
                            continue;
                        }

                        TBD.material material_TBD = construction_TBD.AddMaterial();
                        material_TBD.name = name;

                        float thickness = System.Convert.ToSingle(constructionLayer.Thickness);

                        IMaterial material = constructionLayer.Material(materialLibrary);
                        if (material != null)
                        {
                            material_TBD.UpdateMaterial(material);

                            if (material is TransparentMaterial)
                            {
                                material_TBD.width = thickness;
                            }
                        }

                        construction_TBD.materialWidth[i + 1] = thickness;
                    }
                }
            }

            return(update);
        }
Beispiel #20
0
        public static TBD.Construction ToTAS(this BHPC.Construction construction, TBD.Construction tbdConstruction)
        {
            if (construction == null)
            {
                return(tbdConstruction);
            }
            if (construction.Layers == null)
            {
                return(tbdConstruction);
            }
            if (tbdConstruction == null)
            {
                return(tbdConstruction);
            }

            tbdConstruction.name = construction.Name;
            //tbdConstruction.additionalHeatTransfer = (float)construction.AdditionalHeatTransfer();
            //tbdConstruction.FFactor = (float)construction.FFactor; //ToDo: Fix these from the fragment after fragment implementation

            if (construction.Layers.Count > 0 && construction.Layers[0].Material != null)
            {
                if (construction.Layers[0].Material.IsTransparent())
                {
                    tbdConstruction.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                }
                else
                {
                    tbdConstruction.type = TBD.ConstructionTypes.tcdOpaqueConstruction;
                }
            }

            //tbdConstruction.GUID = construction.BHoM_Guid.ToString();

            foreach (BH.oM.Physical.Constructions.Layer layer in construction.Layers)
            {
                layer.ToTAS(tbdConstruction.AddMaterial());
            }

            ////copy construction thickness to material thickness
            //if (tbdConstruction.type == TBD.ConstructionTypes.tcdOpaqueConstruction)
            //{
            //    int mIndex = 1;
            //    TBD.material m = null;
            //    while ((m = tbdConstruction.materials(mIndex)) != null)
            //    {
            //        tbdConstruction.materials = tbdConstruction.materialWidth[mIndex];
            //        //tbdConstruction.materialWidth[mIndex] = (float)((construction.Materials.Where(x => x.Name == m.name).FirstOrDefault() as BHM.Material).Thickness);
            //        mIndex++;
            //    }
            //}

            //if (tbdConstruction.type == TBD.ConstructionTypes.tcdOpaqueConstruction)
            //{
            int mIndex = 1;

            TBD.material m = null;
            while ((m = tbdConstruction.materials(mIndex)) != null)
            {
                if (construction.Layers.Where(x => x.Material.Name == m.name).FirstOrDefault() != null)
                {
                    tbdConstruction.materialWidth[mIndex] = (float)(construction.Layers.Where(x => x.Material.Name == m.name).FirstOrDefault().Thickness);
                }

                mIndex++;
            }

            TASDescription tasFragment = construction.FindFragment <TASDescription>(typeof(TASDescription));

            if (tasFragment != null)
            {
                tbdConstruction.description = tasFragment.Description;
            }

            return(tbdConstruction);
        }
Beispiel #21
0
        public static Core.IMaterial ToSAM(this TBD.material material)
        {
            if (material == null)
            {
                return(null);
            }

            Core.IMaterial result = null;
            switch ((TBD.MaterialTypes)material.type)
            {
            case TBD.MaterialTypes.tcdGasLayer:
                result = Analytical.Create.GasMaterial(
                    material.name,
                    string.Empty,
                    material.name,
                    material.description,
                    material.width,
                    material.vapourDiffusionFactor,
                    double.NaN);
                break;

            case TBD.MaterialTypes.tcdOpaqueLayer:
                result = Analytical.Create.OpaqueMaterial(
                    material.name,
                    string.Empty,
                    material.name,
                    material.description,
                    material.conductivity,
                    material.specificHeat,
                    material.density,
                    material.width,
                    material.vapourDiffusionFactor,
                    material.externalSolarReflectance,
                    material.internalSolarReflectance,
                    material.externalLightReflectance,
                    material.externalLightReflectance,
                    material.externalEmissivity,
                    material.internalEmissivity,
                    false);
                break;

            case TBD.MaterialTypes.tcdOpaqueMaterial:
                result = Analytical.Create.OpaqueMaterial(
                    material.name,
                    string.Empty,
                    material.name,
                    material.description,
                    material.conductivity,
                    material.specificHeat,
                    material.density,
                    material.width,
                    material.vapourDiffusionFactor,
                    material.externalSolarReflectance,
                    material.internalSolarReflectance,
                    material.externalLightReflectance,
                    material.externalLightReflectance,
                    material.externalEmissivity,
                    material.internalEmissivity,
                    false);
                break;

            case TBD.MaterialTypes.tcdTransparentLayer:
                result = Analytical.Create.TransparentMaterial(
                    material.name,
                    string.Empty,
                    material.name,
                    material.description,
                    material.conductivity,
                    material.width,
                    material.vapourDiffusionFactor,
                    material.solarTransmittance,
                    material.lightTransmittance,
                    material.externalSolarReflectance,
                    material.internalSolarReflectance,
                    material.externalLightReflectance,
                    material.internalLightReflectance,
                    material.externalEmissivity,
                    material.internalEmissivity,
                    material.isBlind == 1);
                break;
            }


            return(result);
        }