示例#1
0
文件: Panel.cs 项目: BHoM/TAS_Toolkit
        public static TBD.buildingElement ToTAS(this BHE.Panel buildingElement, TBD.buildingElement tbdBuildingElement, TBD.Construction tbdConstruction)
        {
            if (buildingElement == null)
            {
                return(tbdBuildingElement);
            }
            tbdBuildingElement.name = buildingElement.Name;

            BHP.OriginContextFragment envContextProperties = buildingElement.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
            if (envContextProperties != null)
            {
                tbdBuildingElement.GUID        = envContextProperties.ElementID;
                tbdBuildingElement.description = envContextProperties.Description;
            }

            tbdBuildingElement.BEType = (int)buildingElement.Type.ToTAS();

            TBD.Construction construction = buildingElement.Construction.ToTAS(tbdConstruction);
            tbdBuildingElement.AssignConstruction(construction);
            return(tbdBuildingElement);

            //TODO: Make Colour, GUID work for Pushing. Assign Construction.
            //TODO:Number of BuildingElements on the TAS Building Summary is too high
            //TODO:BuildingElements are showing up as duplicated in the TAS folder
            //TODO:What about ApertureType, FeatureShading, SubstituteElement?

            //BHP.BuildingElementContextProperties BEContextProperties = buildingElement.ContextProperties() as BHP.BuildingElementContextProperties;
            //if (BEContextProperties != null)
            /*tbdBuildingElement.colour = BEContextProperties.Colour(); *///BH.Engine.Environment.Query.GetRGB((uint)BEContextProperties.Colour);
        }
示例#2
0
        /// <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));
        }
示例#3
0
        public static TBD.buildingElement ToTAS(this BHE.Opening opening, TBD.buildingElement tbdBuildingElement, TBD.Construction tbdConstruction)
        {
            BHE.Panel openingAsElement = new BHE.Panel();
            openingAsElement.ExternalEdges = new List <BHE.Edge>(opening.Edges);
            openingAsElement.Fragments     = opening.Fragments;
            openingAsElement.BHoM_Guid     = opening.BHoM_Guid;
            openingAsElement.Name          = opening.Name;

            tbdBuildingElement = openingAsElement.ToTAS(tbdBuildingElement, tbdConstruction);

            return(tbdBuildingElement);
        }
示例#4
0
        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 Elemnts
        /// </summary>
        /// <param name="Building">Building</param>
        /// <returns name="Building Element">Building Element List</returns>
        /// <search>
        /// TAS, Building, Building Element, BuildingElements
        /// </search>
        public static List <BuildingElement> BuildingElements(Building Building)
        {
            List <BuildingElement> aBuildingElementList = new List <BuildingElement>();

            int aIndex = 0;

            TBD.buildingElement aBuildingElement = Building.pBuilding.GetBuildingElement(aIndex);
            while (aBuildingElement != null)
            {
                aBuildingElementList.Add(new BuildingElement(aBuildingElement));
                aIndex++;
                aBuildingElement = Building.pBuilding.GetBuildingElement(aIndex);
            }
            return(aBuildingElementList);
        }
        /// <summary>
        /// Gets all TAS TBD Substitute Element Day Types
        /// </summary>
        /// <param name="SubstituteElement">Substitute Element</param>
        /// <returns name="DayTypes">Day Type List</returns>
        /// <search>
        /// TAS, TBD, SubstituteElement, Substitute Element, DayTypes, GetDayTypes, Day Types
        /// </search>
        public static List <BuildingElement> BuildingElements(SubstituteElement SubstituteElement)
        {
            List <BuildingElement> aBuildingElementList = new List <BuildingElement>();

            int aIndex = 0;

            TBD.buildingElement aBuildingElement = SubstituteElement.pSubstituteElement.GetBuildingElement(aIndex);
            while (aBuildingElement != null)
            {
                aBuildingElementList.Add(new BuildingElement(aBuildingElement));
                aIndex++;
                aBuildingElement = SubstituteElement.pSubstituteElement.GetBuildingElement(aIndex);
            }
            return(aBuildingElementList);
        }
示例#7
0
 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);
 }
示例#8
0
        public static TBD.buildingElement BuildingElement(TBD.Building tbdBuilding, string name)
        {
            int index = 0;

            TBD.buildingElement tbdBuildingElement = null;
            while ((tbdBuildingElement = tbdBuilding.GetBuildingElement(index)) != null)
            {
                if (tbdBuildingElement.name == name)
                {
                    return(tbdBuildingElement);
                }
                index++;
            }

            return(null);
        }
示例#9
0
        public static List <TBD.buildingElement> BuildingElements(this TBD.Building building)
        {
            List <TBD.buildingElement> result = new List <TBD.buildingElement>();

            int index = 0;

            TBD.buildingElement buildingElement = building.GetBuildingElement(index);
            while (buildingElement != null)
            {
                result.Add(buildingElement);
                index++;

                buildingElement = building.GetBuildingElement(index);
            }

            return(result);
        }
示例#10
0
        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);
        }
示例#11
0
文件: Name.cs 项目: HoareLea/SAM_Tas
 public static string Name(TBD.buildingElement buildingElement)
 {
     return(Name(buildingElement?.name));
 }
 internal BuildingElement(TBD.buildingElement BuildingElement)
 {
     pBuildingElement = BuildingElement;
 }
示例#13
0
文件: Panel.cs 项目: BHoM/TAS_Toolkit
        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);
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
0
 public static double TotalSolarEnergyTransmittance(this TBD.buildingElement buildingElement, double tolerance = Core.Tolerance.MacroDistance)
 {
     return(TotalSolarEnergyTransmittance(buildingElement?.GetConstruction(), tolerance));
 }
示例#17
0
        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);
        }
示例#18
0
        public static bool AssignOpeningTypes(this TBD.Building building, TBD.buildingElement buildingElement, IEnumerable <TBD.dayType> dayTypes, OpeningType openingType)
        {
            if (building == null || buildingElement == null || openingType == null || dayTypes == null)
            {
                return(false);
            }

            TBD.ApertureType apertureType_Day = null;
            string           function;

            function = null;
            if (openingType.TryGetValue("SAM_ApertureFunctionDay", out function, true) && !string.IsNullOrWhiteSpace(function))
            {
                apertureType_Day      = building.AddApertureType(null);
                apertureType_Day.name = buildingElement.name + "_Day";
                foreach (TBD.dayType aDayType in dayTypes)
                {
                    apertureType_Day.SetDayType(aDayType, true);
                }

                int sheltered;
                if (openingType.TryGetValue("SAM_ApertureShelteredDay", out sheltered, true))
                {
                    apertureType_Day.sheltered = sheltered;
                }
                else
                {
                    apertureType_Day.sheltered = 0;
                }

                string description_ApertureType;
                if (openingType.TryGetValue("SAM_ApertureDescriptionDay", out description_ApertureType, true))
                {
                    apertureType_Day.description = description_ApertureType;
                }

                TBD.profile profile = apertureType_Day.GetProfile();
                profile.type     = TBD.ProfileTypes.ticFunctionProfile;
                profile.function = function;

                double factor;
                if (openingType.TryGetValue("SAM_ApertureOpeningProportionDay", out factor, true))
                {
                    profile.factor = (float)factor;
                }

                double setbackValue;
                if (openingType.TryGetValue("SAM_ApertureOpeningProportionDaySetBack", out setbackValue, true))
                {
                    profile.setbackValue = (float)setbackValue;
                }

                string description_Profile;
                if (openingType.TryGetValue("SAM_ApertureProfileDescriptionDay", out description_Profile, true))
                {
                    profile.description = description_Profile;
                }

                string scheduleValues;
                if (openingType.TryGetValue("SAM_ApertureScheduleDay", out scheduleValues, true))
                {
                    string name_Schedule = string.Format("{0}_{1}", apertureType_Day.name, "APSCHED");

                    List <int> values = scheduleValues.Ints();

                    TBD.schedule schedule = Create.Schedule(building, name_Schedule, values);
                    if (schedule != null)
                    {
                        profile.schedule = schedule;
                    }
                }
            }

            TBD.ApertureType apertureType_Night = null;
            function = null;
            if (openingType.TryGetValue("SAM_ApertureFunctionNight", out function, true) && !string.IsNullOrWhiteSpace(function))
            {
                apertureType_Day      = building.AddApertureType(null);
                apertureType_Day.name = buildingElement.name + "_Night";
                foreach (TBD.dayType aDayType in dayTypes)
                {
                    apertureType_Day.SetDayType(aDayType, true);
                }

                int sheltered;
                if (openingType.TryGetValue("SAM_ApertureShelteredNight", out sheltered, true))
                {
                    apertureType_Day.sheltered = sheltered;
                }
                else
                {
                    apertureType_Day.sheltered = 0;
                }

                string description_ApertureType;
                if (openingType.TryGetValue("SAM_ApertureDescriptionNight", out description_ApertureType, true))
                {
                    apertureType_Day.description = description_ApertureType;
                }

                TBD.profile profile = apertureType_Day.GetProfile();
                profile.type     = TBD.ProfileTypes.ticFunctionProfile;
                profile.function = function;

                double factor;
                if (openingType.TryGetValue("SAM_ApertureOpeningProportionNight", out factor, true))
                {
                    profile.factor = (float)factor;
                }

                double setbackValue;
                if (openingType.TryGetValue("SAM_ApertureOpeningProportionNightSetBack", out setbackValue, true))
                {
                    profile.setbackValue = (float)setbackValue;
                }

                string description_Profile;
                if (openingType.TryGetValue("SAM_ApertureProfileDescriptionNight", out description_Profile, true))
                {
                    profile.description = description_Profile;
                }

                string scheduleValues;
                if (openingType.TryGetValue("SAM_ApertureScheduleNight", out scheduleValues, true))
                {
                    string name_Schedule = string.Format("{0}_{1}", apertureType_Day.name, "APSCHED");

                    List <int> values = scheduleValues.Ints();

                    TBD.schedule schedule = Create.Schedule(building, name_Schedule, values);
                    if (schedule != null)
                    {
                        profile.schedule = schedule;
                    }
                }
            }

            if (apertureType_Day != null)
            {
                buildingElement.AssignApertureType(apertureType_Day);
            }

            if (apertureType_Night != null)
            {
                buildingElement.AssignApertureType(apertureType_Night);
            }

            return(true);
        }