/// <summary> /// Light Transmittance (LT Value) [-] /// </summary> /// <param name="buildingElement">TBD buildingElement</param> /// <param name="tolerance">Tolerance</param> /// <returns>LightTransmittance [-]</returns> public static double LightTransmittance(this TBD.buildingElement buildingElement, double tolerance = Core.Tolerance.MacroDistance) { TBD.Construction construction = buildingElement?.GetConstruction(); if (construction == null) { return(double.NaN); } return(LightTransmittance(construction, tolerance)); }
public static BHE.Opening FromTASOpening(this TBD.Polygon tbdPolygon, TBD.RoomSurface roomSurface, TASSettings tasSettings) { BHE.Opening opening = new oM.Environment.Elements.Opening(); //roomSurface.parentSurface if (roomSurface != null) { TBD.zoneSurface tbdSurface = roomSurface.zoneSurface; TBD.buildingElement tbdElement = tbdSurface.buildingElement; //EnvironmentContextProperties BH.oM.Environment.Fragments.OriginContextFragment environmentContextProperties = new oM.Environment.Fragments.OriginContextFragment(); environmentContextProperties.ElementID = tbdSurface.GUID.RemoveBrackets(); environmentContextProperties.Description = tbdSurface.buildingElement.name + " - " + tbdSurface.buildingElement.GUID.RemoveBrackets(); environmentContextProperties.TypeName = tbdSurface.buildingElement.name; opening.Fragments.Add(environmentContextProperties); opening.Name = environmentContextProperties.TypeName; opening.Type = ((TBD.BuildingElementType)tbdElement.BEType).FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface); opening.OpeningConstruction = tbdElement.GetConstruction().FromTAS(); //BuildingElementAnalyticalProperties BH.oM.Environment.Fragments.PanelAnalyticalFragment buildingElementAnalyticalProperties = new oM.Environment.Fragments.PanelAnalyticalFragment(); buildingElementAnalyticalProperties.Altitude = tbdSurface.altitude.Round(); buildingElementAnalyticalProperties.AltitudeRange = tbdSurface.altitudeRange.Round(); buildingElementAnalyticalProperties.Inclination = tbdSurface.inclination.Round(); buildingElementAnalyticalProperties.Orientation = tbdSurface.orientation.Round(); buildingElementAnalyticalProperties.GValue = tbdElement.GValue().Round(); buildingElementAnalyticalProperties.LTValue = tbdElement.LTValue().Round(); buildingElementAnalyticalProperties.UValue = tbdElement.UValue().Round(); opening.Fragments.Add(buildingElementAnalyticalProperties); if (tbdPolygon != null) { opening.Edges = tbdPolygon.FromTAS().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } else { opening.Edges = roomSurface.GetPerimeter().FromTAS().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } if (roomSurface.parentSurface != null && roomSurface.parentSurface.zoneSurface != null && roomSurface.parentSurface.zoneSurface.buildingElement != null) { TASOpeningData tasData = new TASOpeningData(); tasData.ParentGUID = roomSurface.parentSurface.zoneSurface.GUID.RemoveBrackets(); tasData.ParentName = roomSurface.parentSurface.zoneSurface.buildingElement.name; opening.Fragments.Add(tasData); } } return(opening); }
public static double GValue(this TBD.buildingElement tbdBuildingElement, int decimals = 3) { TBD.Construction aConstruction = tbdBuildingElement.GetConstruction(); if (aConstruction == null) { return(-1); } TBD.ConstructionTypes aConstructionTypes = aConstruction.type; if (aConstructionTypes == TBD.ConstructionTypes.tcdTransparentConstruction) { object aObject = aConstruction.GetGlazingValues(); List <float> aValueList = Convert.ToFloatList(aObject); return(Math.Round(aValueList[5], decimals)); } return(0); }
public static AdjacencyCluster ToSAM(this TBD.Building building) { if (building == null) { return(null); } AdjacencyCluster adjacencyCluster = new AdjacencyCluster(); Dictionary <string, Construction> dictionary_Construction = new Dictionary <string, Construction>(); foreach (TBD.Construction construction_TBD in building.Constructions()) { Construction construction = construction_TBD.ToSAM(); if (construction == null) { continue; } dictionary_Construction[construction_TBD.GUID] = construction; adjacencyCluster.AddObject(construction); } foreach (TBD.zone zone in building.Zones()) { Space space = zone.ToSAM(out List <InternalCondition> internalConditions); if (space == null) { continue; } adjacencyCluster.AddObject(space); foreach (TBD.IZoneSurface zoneSurface in zone.ZoneSurfaces()) { TBD.buildingElement buildingElement = zoneSurface.buildingElement; TBD.Construction construction_TBD = buildingElement.GetConstruction(); PanelType panelType = Query.PanelType(buildingElement.BEType); Construction construction = null; if (construction_TBD != null) { construction = dictionary_Construction[construction_TBD.GUID]; } foreach (TBD.IRoomSurface roomSurface in zoneSurface.RoomSurfaces()) { Geometry.Spatial.Polygon3D polygon3D = Geometry.Tas.Convert.ToSAM(roomSurface?.GetPerimeter()?.GetFace()); if (polygon3D == null) { continue; } Panel panel = Analytical.Create.Panel(construction, panelType, new Geometry.Spatial.Face3D(polygon3D)); if (panel == null) { continue; } adjacencyCluster.AddObject(panel); adjacencyCluster.AddRelation(panel, space); } } if (internalConditions != null) { foreach (InternalCondition internalCondition in internalConditions) { adjacencyCluster.AddObject(internalCondition); adjacencyCluster.AddRelation(space, internalCondition); } } } return(adjacencyCluster); }
public static double TotalSolarEnergyTransmittance(this TBD.buildingElement buildingElement, double tolerance = Core.Tolerance.MacroDistance) { return(TotalSolarEnergyTransmittance(buildingElement?.GetConstruction(), tolerance)); }
public static double UValue(this TBD.buildingElement tbdBuildingElement, int decimals = 3) { TBD.Construction aConstruction = tbdBuildingElement.GetConstruction(); if (aConstruction == null) { return(-1); } object aObject = aConstruction.GetUValue(); List <float> aValueList = Convert.ToFloatList(aObject); switch ((TBD.BuildingElementType)tbdBuildingElement.BEType) { case TBD.BuildingElementType.CEILING: return(Math.Round(aValueList[4], decimals)); case TBD.BuildingElementType.CURTAINWALL: return(Math.Round(aValueList[6], decimals)); case TBD.BuildingElementType.DOORELEMENT: return(Math.Round(aValueList[0], decimals)); case TBD.BuildingElementType.EXPOSEDFLOOR: return(Math.Round(aValueList[2], decimals)); case TBD.BuildingElementType.EXTERNALWALL: return(Math.Round(aValueList[0], decimals)); case TBD.BuildingElementType.FRAMEELEMENT: return(Math.Round(aValueList[0], decimals)); case TBD.BuildingElementType.GLAZING: return(Math.Round(aValueList[6], decimals)); case TBD.BuildingElementType.INTERNALFLOOR: return(Math.Round(aValueList[5], decimals)); case TBD.BuildingElementType.INTERNALWALL: return(Math.Round(aValueList[3], decimals)); case TBD.BuildingElementType.NOBETYPE: return(-1); case TBD.BuildingElementType.NULLELEMENT: return(-1); case TBD.BuildingElementType.RAISEDFLOOR: return(Math.Round(aValueList[5], decimals)); case TBD.BuildingElementType.ROOFELEMENT: return(Math.Round(aValueList[1], decimals)); case TBD.BuildingElementType.ROOFLIGHT: return(Math.Round(aValueList[6], decimals)); case TBD.BuildingElementType.SHADEELEMENT: return(-1); case TBD.BuildingElementType.SLABONGRADE: return(Math.Round(aValueList[2], decimals)); case TBD.BuildingElementType.SOLARPANEL: return(-1); case TBD.BuildingElementType.UNDERGROUNDCEILING: return(Math.Round(aValueList[2], decimals)); case TBD.BuildingElementType.UNDERGROUNDSLAB: return(Math.Round(aValueList[2], decimals)); case TBD.BuildingElementType.UNDERGROUNDWALL: return(Math.Round(aValueList[0], decimals)); case TBD.BuildingElementType.VEHICLEDOOR: return(Math.Round(aValueList[0], decimals)); } return(-1); }
public static BHE.Panel FromTAS(this TBD.buildingElement tbdElement, TBD.zoneSurface tbdSurface, TASSettings tasSettings) { BHE.Panel element = new BHE.Panel(); TBD.BuildingElementType tbdElementType = ((TBD.BuildingElementType)tbdElement.BEType); TASPanelData tasData = new TASPanelData(); tasData.PanelIsOpening = tbdElementType.ElementIsOpening(); //Add a flag on the element for the final read if (tbdElementType.ElementIsOpening()) { //Find out what the fix was - frame or pane? BHE.OpeningType fixedOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface); tasData.OpeningIsFrame = fixedOpeningType.OpeningIsFrame(); } BHE.PanelType elementType = ((TBD.BuildingElementType)tbdElement.BEType).FromTAS(); BHPC.Construction elementConstruction = tbdElement.GetConstruction().FromTAS(); element.Name = tbdElement.name; element.Type = elementType; element.Construction = elementConstruction; element.Fragments.Add(tasData); //EnvironmentContextProperties BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment(); environmentContextProperties.ElementID = tbdSurface.GUID.RemoveBrackets(); environmentContextProperties.Description = tbdElement.description; environmentContextProperties.TypeName = tbdSurface.buildingElement.name; element.Fragments.Add(environmentContextProperties); //BuildingElementContextProperties BHP.PanelContextFragment buildingElementContextProperties = new BHP.PanelContextFragment(); element.ConnectedSpaces.Add(tbdSurface.zone.name); if ((int)tbdSurface.type == 3) { element.ConnectedSpaces.Add(tbdSurface.linkSurface.zone.name); } else { element.ConnectedSpaces.Add("-1"); } buildingElementContextProperties.IsAir = tbdElement.ghost != 0; buildingElementContextProperties.IsGround = tbdElement.ground != 0; buildingElementContextProperties.Colour = BH.Engine.Adapters.TAS.Query.GetRGB(tbdElement.colour).ToString(); buildingElementContextProperties.Reversed = tbdSurface.reversed != 0; element.Fragments.Add(buildingElementContextProperties); //BuildingElementAnalyticalProperties BHP.PanelAnalyticalFragment buildingElementAnalyticalProperties = new BHP.PanelAnalyticalFragment(); buildingElementAnalyticalProperties.Altitude = tbdSurface.altitude.Round(); buildingElementAnalyticalProperties.AltitudeRange = tbdSurface.altitudeRange.Round(); buildingElementAnalyticalProperties.Inclination = tbdSurface.inclination.Round(); buildingElementAnalyticalProperties.Orientation = tbdSurface.orientation.Round(); buildingElementAnalyticalProperties.GValue = tbdElement.GValue().Round(); buildingElementAnalyticalProperties.LTValue = tbdElement.LTValue().Round(); buildingElementAnalyticalProperties.UValue = tbdElement.UValue().Round(); element.Fragments.Add(buildingElementAnalyticalProperties); List <BHG.Polyline> panelCurve = new List <BHG.Polyline>(); int surfaceIndex = 0; TBD.RoomSurface roomSurface = null; while ((roomSurface = tbdSurface.GetRoomSurface(surfaceIndex)) != null) { TBD.Perimeter tbdPerimeter = roomSurface.GetPerimeter(); if (tbdPerimeter != null) { panelCurve.Add(tbdPerimeter.FromTAS()); //Add openings int openingIndex = 0; TBD.Polygon openingPolygon = null; while ((openingPolygon = tbdPerimeter.GetHole(openingIndex)) != null) { element.Openings.Add(openingPolygon.FromTASOpening(roomSurface, tasSettings)); openingIndex++; } } surfaceIndex++; } if (panelCurve.Count == 1) { element.ExternalEdges = panelCurve.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } else { try { List <BHG.Polyline> polylines = Geometry.Compute.BooleanUnion(panelCurve, 1e-3); if (polylines.Count == 1) { element.ExternalEdges = polylines.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } else { element.ExternalEdges = Geometry.Create.PolyCurve(polylines).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } } catch (Exception e) { BH.Engine.Base.Compute.RecordWarning("An error occurred in building buildingElement ID - " + element.BHoM_Guid + " - error was: " + e.ToString()); element.ExternalEdges = Geometry.Create.PolyCurve(panelCurve).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } } tasData.TASID = tbdSurface.GUID.RemoveBrackets(); tasData.TASName = "Z_" + tbdSurface.zone.number + "_" + tbdSurface.number + "_" + tbdSurface.zone.name; tasData.Type = System.Convert.ToString(tbdSurface.type); tasData.Area = tbdSurface.area.Round(); tasData.InternalArea = tbdSurface.internalArea.Round(); tasData.Width = tbdElement.width.Round(); tasData.MaterialLayersThickness = tbdElement.GetConstruction().ConstructionThickness().Round(); element.Fragments.Add(tasData); //AddingExtended Properties for a frame BHE.OpeningType elementOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface); if (elementOpeningType == BHE.OpeningType.RooflightWithFrame || elementOpeningType == BHE.OpeningType.WindowWithFrame) { if (element.Openings.FirstOrDefault() != null) { element.Openings[0].FrameConstruction = elementConstruction; } } return(element); }