/***************************************************/ private List <Panel> ReadPanels(List <string> ids = null) { List <Panel> panels = new List <Panel>(); int zoneIndex = 0; while (m_tbdDocument.Building.GetZone(zoneIndex) != null) { int panelIndex = 0; while (m_tbdDocument.Building.GetZone(zoneIndex).GetSurface(panelIndex) != null) { TBD.zoneSurface zonesurface = m_tbdDocument.Building.GetZone(zoneIndex).GetSurface(panelIndex); int roomSurfaceIndex = 0; while (zonesurface.GetRoomSurface(roomSurfaceIndex) != null) { TBD.RoomSurface currRoomSrf = zonesurface.GetRoomSurface(roomSurfaceIndex); //if (currRoomSrf.GetPerimeter() != null) //panels.Add(BH.Engine.Adapters.TAS.Convert.(currRoomSrf)); roomSurfaceIndex++; } panelIndex++; } zoneIndex++; } return(panels); }
public static Space UpdateFacingExternal(this Space space, TBD.zone zone) { if (space == null || zone == null) { return(null); } int index = 0; TBD.zoneSurface zoneSurface = zone.GetSurface(index); bool facingExternal = false; bool facingExternalGlazing = false; while (zoneSurface != null) { if (zoneSurface.buildingElement != null) { string name = zoneSurface.buildingElement.name; if (!string.IsNullOrEmpty(name) && name.ToUpper().Contains("ADIABATIC")) { zoneSurface.type = TBD.SurfaceType.tbdNullLink; } if (!facingExternal) { facingExternal = !string.IsNullOrEmpty(name) && name.ToUpper().Contains("EXT") && !name.ToUpper().Contains("GRD"); } if (!facingExternalGlazing) { facingExternalGlazing = !string.IsNullOrEmpty(name) && name.ToUpper().Contains("EXT_GLZ"); } } if (facingExternal && facingExternalGlazing) { zoneSurface = null; } else { index++; zoneSurface = zone.GetSurface(index); } } Space space_New = new Space(space); space_New.SetValue(SpaceParameter.FacingExternal, facingExternal); space_New.SetValue(SpaceParameter.FacingExternalGlazing, facingExternalGlazing); return(space_New); }
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); }
/// <summary> /// Gets Building Element Zone Surfaces /// </summary> /// <param name="BuildingElement">TAS Building Element</param> /// <returns name="ZoneSurfaces">Zone Surface List</returns> /// <search> /// TAS, BuildingElement, Building Element, buildingelement, building element, ZoneSurfaces, Zone Surfaces, zonesurfaces, zone surfaces /// </search> public static List <ZoneSurface> ZoneSurfaces(BuildingElement BuildingElement) { List <ZoneSurface> aZoneSurfaceList = new List <ZoneSurface>(); int aIndex = 0; TBD.zoneSurface aZoneSurface = BuildingElement.pBuildingElement.zoneSurfaces(aIndex); while (aZoneSurface != null) { aZoneSurfaceList.Add(new ZoneSurface(aZoneSurface)); aIndex++; aZoneSurface = BuildingElement.pBuildingElement.zoneSurfaces(aIndex); } return(aZoneSurfaceList); }
/// <summary> /// Gets TAS Zone surfaces /// </summary> /// <param name="Zone">TAS Zone</param> /// <returns name="Surfaces">Surface List</returns> /// <search> /// TAS, Zone, Surfaces, ZoneSurfaces, Zone Surfaces, zonesurfaces, zone surfaces, GetZoneSurfaces, getzonesurfaces /// </search> public static List <ZoneSurface> ZoneSurfaces(Zone Zone) { List <ZoneSurface> aZoneSurfaceList = new List <ZoneSurface>(); int aIndex = 0; TBD.zoneSurface aZoneSurface = Zone.pZone.GetSurface(aIndex); while (aZoneSurface != null) { aZoneSurfaceList.Add(new ZoneSurface(aZoneSurface)); aIndex++; aZoneSurface = Zone.pZone.GetSurface(aIndex); } return(aZoneSurfaceList); }
internal ZoneSurface(TBD.zoneSurface ZoneSurface) { pZoneSurface = ZoneSurface; }
/***************************************************/ public List <Panel> ReadBuildingElements(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Panel> buildingElements = new List <Panel>(); int zoneIndex = 0; TBD.zone zone = null; while ((zone = building.GetZone(zoneIndex)) != null) { int zoneSurfaceIndex = 0; TBD.zoneSurface zoneSrf = null; while ((zoneSrf = zone.GetSurface(zoneSurfaceIndex)) != null) { //check to exlude tine area if (zoneSrf.internalArea > 0 || zoneSrf.area > 0.2) { buildingElements.Add(zoneSrf.buildingElement.FromTAS(zoneSrf, _tasSettings)); } zoneSurfaceIndex++; } zoneIndex++; } //Clean up building elements with openings and constructions List <Panel> nonOpeningElements = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening); }).ToList(); List <Panel> frameElements = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening && fragment.OpeningIsFrame); }).ToList(); List <Panel> panes = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening && !fragment.OpeningIsFrame); }).ToList(); foreach (Panel element in nonOpeningElements) { //Sort out opening construction OriginContextFragment originContext = element.FindFragment <OriginContextFragment>(typeof(OriginContextFragment)); string elementID = (originContext != null ? originContext.ElementID : ""); element.Openings = new List <Opening>(); List <Panel> frames = frameElements.Where(x => { return(x.Openings.Where(y => { TASOpeningData fragment = y.FindFragment <TASOpeningData>(typeof(TASOpeningData)); return fragment.ParentGUID == elementID; }).Count() > 0); }).ToList(); foreach (Panel frame in frames) { Panel pane = panes.Where(x => (x.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName == frame.Name.Replace("frame", "pane")).FirstOrDefault(); if (pane != null) { Opening newOpening = new Opening(); newOpening.Edges = frame.ExternalEdges; newOpening.Fragments = new FragmentSet(pane.Fragments); string oldname = (newOpening.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName; (newOpening.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName = oldname.RemoveStringPart(" -pane"); newOpening.Name = oldname.RemoveStringPart(" -pane"); element.Openings.Add(newOpening); } } } return(nonOpeningElements); }
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); }
public static List <TBD.SurfaceShade> UpdateSurfaceShades(this TBD.Building building, List <TBD.DaysShade> daysShades, TBD.zoneSurface zoneSurface, AnalyticalModel analyticalModel, Geometry.SolarCalculator.SolarFaceSimulationResult solarFaceSimulationResult, double tolerance = 0.01) { if (daysShades == null || analyticalModel == null || solarFaceSimulationResult == null || zoneSurface == null) { return(null); } Panel panel = analyticalModel.GetRelatedObjects <Panel>(solarFaceSimulationResult)?.FirstOrDefault(); if (panel == null) { return(null); } Geometry.Spatial.Face3D face3D = panel.Face3D; if (face3D == null) { return(null); } double area = face3D.GetArea(); if (double.IsNaN(area) || area == 0) { return(null); } List <TBD.SurfaceShade> result = new List <TBD.SurfaceShade>(); List <DateTime> dateTimes = solarFaceSimulationResult.DateTimes; if (dateTimes == null || dateTimes.Count == 0) { return(result); } foreach (DateTime dateTime in dateTimes) { double sunExposureArea = solarFaceSimulationResult.GetSunExposureArea(dateTime); if (double.IsNaN(sunExposureArea) || sunExposureArea == 0) { continue; } int dayIndex = dateTime.DayOfYear; TBD.DaysShade daysShade = daysShades.Find(x => x.day == dayIndex); if (daysShade == null) { daysShade = building.AddDaysShade(); daysShade.day = dayIndex; daysShades.Add(daysShade); } float proportion = System.Convert.ToSingle(Core.Query.Round(sunExposureArea / area, tolerance)); if (proportion <= tolerance) { proportion = 0; } TBD.SurfaceShade surfaceShade = daysShade.AddSurfaceShade(System.Convert.ToInt16(dateTime.Hour)); surfaceShade.proportion = proportion; surfaceShade.surface = zoneSurface; result.Add(surfaceShade); } return(result); }
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); }
public static OpeningType FixBuildingElementType(this OpeningType bHoMBuildingElementType, TBD.buildingElement tbdBuildingElement, TBD.zoneSurface tbdZoneSurface) { if (bHoMBuildingElementType == OpeningType.Frame) { if (tbdBuildingElement.name.Contains("-frame")) { if (tbdZoneSurface.inclination == 0) { bHoMBuildingElementType = OpeningType.RooflightWithFrame; } else { bHoMBuildingElementType = OpeningType.WindowWithFrame; } } } return(bHoMBuildingElementType); }