Esempio n. 1
0
        public static BHX.RectangularGeometry ToGBXMLGeometry(this BHE.Panel element, GBXMLSettings settings)
        {
            BHX.RectangularGeometry geom = new BHX.RectangularGeometry();

            BHG.Polyline pLine = element.Polyline();

            geom.Tilt           = Math.Round(element.Tilt(settings.AngleTolerance), settings.RoundingSettings.GeometryTilt);
            geom.Azimuth        = Math.Round(element.Azimuth(BHG.Vector.YAxis), settings.RoundingSettings.GeometryAzimuth);
            geom.Height         = Math.Round(element.Height(), settings.RoundingSettings.GeometryHeight);
            geom.Width          = Math.Round(element.Width(), settings.RoundingSettings.GeometryWidth);
            geom.CartesianPoint = pLine.ControlPoints.First().ToGBXML(settings);
            geom.ID             = "geom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            if (geom.Height == 0)
            {
                geom.Height = Math.Round(element.Area() / geom.Width, settings.RoundingSettings.GeometryHeight);
            }
            if (geom.Width == 0)
            {
                geom.Width = Math.Round(element.Area() / geom.Height, settings.RoundingSettings.GeometryWidth);
            }
            if (geom.Tilt == -1)
            {
                BH.Engine.Reflection.Compute.RecordWarning("Warning, panel " + element.BHoM_Guid + " has been calculated to have a tilt of -1.");
            }

            return(geom);
        }
Esempio n. 2
0
        public static TBD.BuildingElementType ToTASBuildingElementType(this BHE.Panel element, List <List <BHE.Panel> > spaces = null)
        {
            TBD.BuildingElementType tbdType = TBD.BuildingElementType.NULLELEMENT;
            if (element == null)
            {
                return(tbdType);
            }

            if (spaces == null)
            {
                spaces = new List <List <BHE.Panel> >();
            }

            int adjacentSpaces = element.AdjacentSpaces(spaces).Count;

            if (adjacentSpaces == 0)
            {
                tbdType = TBD.BuildingElementType.SHADEELEMENT;
            }
            else
            {
                tbdType = TBD.BuildingElementType.NULLELEMENT;
            }

            return(tbdType);
        }
Esempio n. 3
0
        public static BHX.Surface ToGBXML(this BHE.Panel element)
        {
            BHP.OriginContextFragment contextProperties = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            BHX.Surface surface = new BHX.Surface();
            surface.CADObjectID       = element.CADObjectID();
            surface.ConstructionIDRef = (contextProperties == null ? element.ConstructionID() : contextProperties.TypeName.CleanName());

            BHX.RectangularGeometry geom       = element.ToGBXMLGeometry();
            BHX.PlanarGeometry      planarGeom = new BHX.PlanarGeometry();
            planarGeom.ID = "PlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            BHG.Polyline pLine = element.Polyline();
            planarGeom.PolyLoop = pLine.ToGBXML();

            surface.PlanarGeometry      = planarGeom;
            surface.RectangularGeometry = geom;

            surface.Opening = new BHX.Opening[element.Openings.Count];
            for (int x = 0; x < element.Openings.Count; x++)
            {
                if (element.Openings[x].Polyline().IControlPoints().Count != 0)
                {
                    surface.Opening[x] = element.Openings[x].ToGBXML();
                }
            }

            return(surface);
        }
Esempio n. 4
0
        public static BHX.Surface ToGBXML(this BHE.Panel element, List <List <BHE.Panel> > adjacentSpaces, List <BHE.Panel> space)
        {
            BHX.Surface surface = element.ToGBXML();

            surface.SurfaceType  = element.ToGBXMLType(adjacentSpaces);
            surface.ExposedToSun = Query.ExposedToSun(surface.SurfaceType).ToString().ToLower();

            BHG.Polyline pLine = element.Polyline();
            if (!pLine.NormalAwayFromSpace(space))
            {
                pLine = pLine.Flip();
                surface.PlanarGeometry.PolyLoop     = pLine.ToGBXML();
                surface.RectangularGeometry.Tilt    = Math.Round(pLine.Tilt(), 3);
                surface.RectangularGeometry.Azimuth = Math.Round(pLine.Azimuth(BHG.Vector.YAxis), 3);
            }

            List <BHX.AdjacentSpaceId> adjIDs = new List <BHX.AdjacentSpaceId>();

            foreach (List <BHE.Panel> sp in adjacentSpaces)
            {
                adjIDs.Add(sp.AdjacentSpaceID());
            }
            surface.AdjacentSpaceID = adjIDs.ToArray();

            return(surface);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public static string ToGBXMLType(this BHE.Panel element, List <List <BHE.Panel> > adjacentSpaces = null, ExportType exportType = ExportType.gbXMLTAS)
        {
            if (adjacentSpaces == null)
            {
                adjacentSpaces = new List <List <BHE.Panel> >();
            }

            string type = "Air";

            if (element == null)
            {
                return(type);
            }

            if (adjacentSpaces.Count == 0)
            {
                type = "Shade";
            }
            else
            {
                type = element.Type.ToGBXML();
            }

            return(type);
        }
Esempio n. 7
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static string ConstructionID(this BHE.Panel panel)
        {
            if (panel == null || panel.Construction == null)
            {
                return(null);
            }
            return(panel.Construction.ConstructionID());
        }
Esempio n. 8
0
        public static BHE.Panel OffsetOpening(BHE.Panel panel)
        {
            BHE.Panel energyPlusPanel = new BHE.Panel();
            //Checking if there are openings
            if (panel.Openings.Count == 0)
            {
                return(panel);
            }
            else
            {
                //OpeningArea
                List <BHE.Opening> openings          = panel.Openings;
                List <double>      openingAreas      = new List <double>();
                List <PolyCurve>   openingPolyCurves = new List <PolyCurve>();
                foreach (BHE.Opening opening in panel.Openings)
                {
                    List <ICurve> openingCrvs    = opening.Edges.Select(x => x.Curve).ToList();
                    PolyCurve     openingOutline = BH.Engine.Geometry.Create.PolyCurve(openingCrvs);
                    double        openingArea    = openingOutline.Area();
                    openingAreas.Add(openingArea);
                    openingPolyCurves.Add(openingOutline);
                }
                double totalOpeningArea = openingAreas.Sum();

                //PanelArea
                List <ICurve> panelCrvs    = panel.ExternalEdges.Select(x => x.Curve).ToList();
                PolyCurve     panelOutline = BH.Engine.Geometry.Create.PolyCurve(panelCrvs);
                double        panelArea    = panelOutline.Area();

                //Comparing the total opening area to the panel area, if equal: reduce the area of the opening(s).
                if (totalOpeningArea != panelArea)
                {
                    return(panel);
                }
                else
                {
                    List <BH.oM.Geometry.Polyline>         openingPolylines = new List <BH.oM.Geometry.Polyline>();
                    List <List <BH.oM.Geometry.Polyline> > offsetPolylines  = new List <List <BH.oM.Geometry.Polyline> >();
                    List <BHE.Opening> newOpenings = new List <BHE.Opening>();
                    double             distance    = new double();
                    distance = -0.01;
                    panel.Openings.Clear();
                    foreach (BH.oM.Geometry.PolyCurve openingPolyCurve in openingPolyCurves)
                    {
                        List <BH.oM.Geometry.Point> polyPoints      = openingPolyCurve.IDiscontinuityPoints();
                        BH.oM.Geometry.Polyline     openingPolyLine = BH.Engine.Geometry.Create.Polyline(polyPoints);
                        Polyline        offsetPolyline = Geometry.Modify.Offset(openingPolyLine, distance);
                        List <BHE.Edge> edges          = offsetPolyline.ToEdges().ToList();
                        BHE.Opening     newOpening     = new BHE.Opening()
                        {
                            Edges = edges
                        };
                        panel.Openings.Add(newOpening);
                    }
                    return(panel);
                }
            }
        }
Esempio n. 9
0
        public static bool SunWindExposure(this BHE.Panel panel)
        {
            if ((panel.Type == BHE.PanelType.Roof) || (panel.Type == BHE.PanelType.WallExternal) || (panel.Type == BHE.PanelType.FloorExposed) || (panel.Type == BHE.PanelType.Wall) || (panel.Type == BHE.PanelType.Shade))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 10
0
        public static IGeometry GeometricalRepresentation(this BH.oM.Environment.Elements.Panel panel, RepresentationOptions reprOptions = null)
        {
            if (panel == null)
            {
                BH.Engine.Base.Compute.RecordError("Cannot compute the geometrical representation of a null Environmental Panel.");
                return(null);
            }

            reprOptions = reprOptions ?? new RepresentationOptions();

            PlanarSurface centralPlanarSurface = Engine.Geometry.Create.PlanarSurface(
                Engine.Geometry.Compute.IJoin(panel.ExternalEdges.Select(x => x.Curve).ToList()).FirstOrDefault(),
                panel.Openings.SelectMany(x => Engine.Geometry.Compute.IJoin(x.Edges.Select(y => y.Curve).ToList())).Cast <ICurve>().ToList());

            if (!reprOptions.Detailed2DElements) //simple representation
            {
                return(centralPlanarSurface);
            }
            else
            {
                CompositeGeometry compositeGeometry = new CompositeGeometry();

                double thickness     = BH.Engine.Environment.Query.Thickness(panel);
                Vector translateVect = new Vector()
                {
                    Z = -thickness / 2
                };
                Vector extrudeVect = new Vector()
                {
                    Z = thickness
                };

                PlanarSurface topSrf = centralPlanarSurface.ITranslate(new Vector()
                {
                    Z = thickness / 2
                }) as PlanarSurface;
                PlanarSurface botSrf = centralPlanarSurface.ITranslate(new Vector()
                {
                    Z = -thickness / 2
                }) as PlanarSurface;

                IEnumerable <ICurve>    internalEdgesBot        = panel.Openings.SelectMany(o => o.Edges.Select(e => e.Curve.ITranslate(translateVect)));
                IEnumerable <Extrusion> internalEdgesExtrusions = internalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                IEnumerable <ICurve>    externalEdgesBot        = panel.ExternalEdges.Select(c => c.Curve.ITranslate(translateVect));
                IEnumerable <Extrusion> externalEdgesExtrusions = externalEdgesBot.Select(c => BH.Engine.Geometry.Create.Extrusion(c, extrudeVect));

                compositeGeometry.Elements.Add(topSrf);
                compositeGeometry.Elements.Add(botSrf);
                compositeGeometry.Elements.AddRange(internalEdgesExtrusions);
                compositeGeometry.Elements.AddRange(externalEdgesExtrusions);

                return(compositeGeometry);
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public static string OutsideBoundaryCondition(this BHE.Panel panel, List <List <BHE.Panel> > adjacentSpaces)
        {
            if (panel.Type == BHE.PanelType.Roof || panel.Type == BHE.PanelType.WallExternal)
            {
                return("Outdoors");
            }

            if (adjacentSpaces.Count == 2)
            {
                return("Zone");
            }

            return("");
        }
Esempio n. 13
0
        public static BHX.Surface ToGBXMLShade(this BHE.Panel element, GBXMLSettings settings)
        {
            BHP.OriginContextFragment envContextProperties = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            BHX.Surface gbSrf = new BHX.Surface();
            gbSrf.CADObjectID       = element.CADObjectID();
            gbSrf.ConstructionIDRef = (envContextProperties == null ? element.ConstructionID() : envContextProperties.TypeName.CleanName());

            BHX.RectangularGeometry geom       = element.ToGBXMLGeometry(settings);
            BHX.PlanarGeometry      planarGeom = new BHX.PlanarGeometry();
            planarGeom.ID = "PlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            BHG.Polyline pLine = element.Polyline();
            planarGeom.PolyLoop = pLine.ToGBXML(settings);

            gbSrf.PlanarGeometry      = planarGeom;
            gbSrf.RectangularGeometry = geom;

            gbSrf.Opening = new BHX.Opening[element.Openings.Count];
            for (int x = 0; x < element.Openings.Count; x++)
            {
                if (element.Openings[x].Polyline().IControlPoints().Count != 0)
                {
                    gbSrf.Opening[x] = element.Openings[x].ToGBXML(element, settings);
                }
            }

            string idName = "Panel_" + element.BHoM_Guid.ToString().Replace(" ", "").Replace("-", "").Substring(0, 10);

            gbSrf.ID   = idName;
            gbSrf.Name = idName;

            gbSrf.SurfaceType  = "Shade";
            gbSrf.ExposedToSun = BH.Engine.Environment.Query.ExposedToSun(element).ToString().ToLower();

            if (settings.IncludeConstructions)
            {
                gbSrf.ConstructionIDRef = element.ConstructionID();
            }
            else //We have to force null otherwise Construction will be created
            {
                gbSrf.ConstructionIDRef = null;
            }

            return(gbSrf);
        }
Esempio n. 14
0
        public static OutsideBoundaryCondition BoundaryCondition(this BHE.Panel panel)
        {
            if ((panel.Type == BHE.PanelType.Roof) || (panel.Type == BHE.PanelType.WallExternal) || (panel.Type == BHE.PanelType.FloorExposed) || (panel.Type == BHE.PanelType.Wall))
            {
                return(OutsideBoundaryCondition.Outdoors);
            }

            if ((panel.Type == BHE.PanelType.SlabOnGrade) || (panel.Type == BHE.PanelType.UndergroundSlab) || (panel.Type == BHE.PanelType.UndergroundWall) || (panel.Type == BHE.PanelType.Floor))
            {
                return(OutsideBoundaryCondition.Ground);
            }

            if ((panel.ConnectedSpaces.Count == 2) & ((panel.Type == BHE.PanelType.Ceiling) || (panel.Type == BHE.PanelType.FloorInternal) || (panel.Type == BHE.PanelType.WallInternal)))
            {
                return(OutsideBoundaryCondition.Zone);
            }

            return(OutsideBoundaryCondition.Undefined);
        }
Esempio n. 15
0
        public static BHE.Panel ToBHoM(this BHX.Surface surface)
        {
            BHE.Panel panel = new BHE.Panel();

            surface.Opening = surface.Opening ?? new List <BHX.Opening>().ToArray();

            panel.ExternalEdges = surface.PlanarGeometry.PolyLoop.ToBHoM().ToEdges();
            foreach (BHX.Opening opening in surface.Opening)
            {
                panel.Openings.Add(opening.ToBHoM());
            }

            string[] cadSplit = surface.CADObjectID.Split('[');
            if (cadSplit.Length > 0)
            {
                panel.Name = cadSplit[0].Trim();
            }
            if (cadSplit.Length > 1)
            {
                BHP.OriginContextFragment envContext = new BHP.OriginContextFragment();
                envContext.ElementID = cadSplit[1].Split(']')[0].Trim();
                envContext.TypeName  = panel.Name;

                if (panel.Fragments == null)
                {
                    panel.Fragments = new List <IBHoMFragment>();
                }
                panel.Fragments.Add(envContext);
            }

            panel.Type            = surface.SurfaceType.ToBHoMPanelType();
            panel.ConnectedSpaces = new List <string>();
            if (surface.AdjacentSpaceID != null)
            {
                foreach (BHX.AdjacentSpaceId adjacent in surface.AdjacentSpaceID)
                {
                    panel.ConnectedSpaces.Add(adjacent.SpaceIDRef);
                }
            }

            return(panel);
        }
Esempio n. 16
0
        public static BHX.Construction ToGBXML(this BHC.Construction construction, BHE.Panel element = null)
        {
            BHX.Construction gbConstruction = new BHX.Construction();

            BHP.OriginContextFragment   contextProperties  = null;
            BHP.PanelAnalyticalFragment analysisProperties = null;
            if (element != null)
            {
                contextProperties  = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
                analysisProperties = element.FindFragment <BHP.PanelAnalyticalFragment>(typeof(BHP.PanelAnalyticalFragment));
            }

            gbConstruction.ID = (contextProperties == null ? construction.ConstructionID() : contextProperties.TypeName.CleanName().Replace(" ", "-"));
            gbConstruction.Absorptance.Value = construction.Absorptance().ToString();
            gbConstruction.Name         = (contextProperties == null ? construction.Name : contextProperties.TypeName);
            gbConstruction.Roughness    = construction.Roughness().ToGBXML();
            gbConstruction.UValue.Value = (analysisProperties == null || analysisProperties.UValue == 0 ? construction.UValue() : analysisProperties.UValue).ToString();

            return(gbConstruction);
        }
Esempio n. 17
0
        private List <BHE.Panel> ReadPanels(BHX.GBXML gbx, List <string> ids = null)
        {
            List <BHE.Panel> panels = new List <BHE.Panel>();

            if (gbx.Campus != null && gbx.Campus.Surface != null)
            {
                foreach (BHX.Surface s in gbx.Campus.Surface)
                {
                    BHE.Panel p = s.ToBHoM();
                    if (gbx.Construction != null)
                    {
                        BHX.Construction c = gbx.Construction.Where(x => x.ID == s.ConstructionIDRef).FirstOrDefault();
                        if (c != null)
                        {
                            BHX.Layer gbLayer = gbx.Layer.Where(x => x.ID == c.LayerID.LayerIDRef).FirstOrDefault();
                            if (gbLayer != null)
                            {
                                List <BHX.Material> gbMaterials = gbx.Material.Where(x => gbLayer.MaterialID.Where(y => y.MaterialIDRef == x.ID).FirstOrDefault() != null).ToList();
                                if (gbMaterials.Count > 0)
                                {
                                    List <BHC.Layer> layers = gbMaterials.Select(x => x.ToBHoM()).ToList();
                                    p.Construction = c.ToBHoM(layers);
                                }
                            }
                        }
                    }

                    foreach (BHX.Opening gbxOpening in s.Opening)
                    {
                        p.Openings.Add(gbxOpening.ToBHoM());
                    }
                    panels.Add(p);
                }
            }

            return(panels);
        }
Esempio n. 18
0
        public static BHX.RectangularGeometry ToGBXMLGeometry(this BHE.Panel element)
        {
            BHX.RectangularGeometry geom = new BHX.RectangularGeometry();

            BHG.Polyline pLine = element.Polyline();

            geom.Tilt           = Math.Round(element.Tilt(), 3);
            geom.Azimuth        = Math.Round(element.Azimuth(BHG.Vector.YAxis), 3);
            geom.Height         = Math.Round(element.Height(), 3);
            geom.Width          = Math.Round(element.Width(), 3);
            geom.CartesianPoint = pLine.ControlPoints.First().ToGBXML();
            geom.ID             = "geom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            if (geom.Height == 0)
            {
                geom.Height = Math.Round(element.Area() / geom.Width, 3);
            }
            if (geom.Width == 0)
            {
                geom.Width = Math.Round(element.Area() / geom.Height, 3);
            }

            return(geom);
        }
Esempio n. 19
0
        public static List <IEnergyPlusClass> ToEnergyPlus(this BHE.Panel panel)
        {
            List <IEnergyPlusClass> classes = new List <IEnergyPlusClass>();

            List <Point> vertices = BH.Engine.Environment.Query.Polyline(panel).ControlPoints();

            vertices.RemoveAt(vertices.Count - 1);
            int    vertexCount  = vertices.Count;
            string panelName    = panel.Name == "" ? panel.BHoM_Guid.ToString() : panel.Name;
            string zoneName     = panel.ConnectedSpaces[0];
            string sunExposure  = panel.SunWindExposure() ? "SunExposed" : "NoSun";
            string windExposure = panel.SunWindExposure() ? "WindExposed" : "NoWind";

            GlobalGeometryRules globalGeometryRules = new GlobalGeometryRules();

            classes.Add(globalGeometryRules);

            if (panel.Type == BHE.PanelType.Shade)
            {
                ShadingBuildingDetailed shadingSurface = new ShadingBuildingDetailed();
                shadingSurface.Name             = panelName;
                shadingSurface.Vertices         = vertices;
                shadingSurface.NumberOfVertices = vertexCount;
                classes.Add(shadingSurface);
            }
            else
            {
                Zone zone = new Zone();
                zone.Name = zoneName;
                classes.Add(zone);

                ZoneList zoneList = new ZoneList();
                zoneList.ZoneNames.Add(zoneName);
                classes.Add(zoneList);

                if (panel.Construction == null)
                {
                    panel = panel.AssignGenericConstructions(assignOpenings: true);
                }

                classes.AddRange(((Construction)panel.Construction).ToEnergyPlus());

                BuildingSurfaceDetailed buildingSurface = new BuildingSurfaceDetailed();
                string surfaceName = panelName;
                buildingSurface.Name                     = surfaceName;
                buildingSurface.SurfaceType              = panel.Type.ToEnergyPlus();
                buildingSurface.ConstructionName         = panel.Construction.Name;
                buildingSurface.ZoneName                 = zoneName;
                buildingSurface.OutsideBoundaryCondition = panel.BoundaryCondition();

                if (buildingSurface.OutsideBoundaryCondition == OutsideBoundaryCondition.Zone)
                {
                    buildingSurface.OutsideBoundaryConditionObject = panel.ConnectedSpaces[-1];
                }
                else
                {
                    buildingSurface.OutsideBoundaryConditionObject = "";
                }

                buildingSurface.SunExposure      = sunExposure;
                buildingSurface.WindExposure     = windExposure;
                buildingSurface.Vertices         = vertices;
                buildingSurface.NumberOfVertices = vertexCount;
                classes.Add(buildingSurface);

                foreach (BHE.Opening o in panel.Openings)
                {
                    classes.AddRange(o.ToEnergyPlus(panelName));
                }
            }

            return(classes);
        }
Esempio n. 20
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static string CADObjectID(this BHE.Panel element, bool replaceCurtainWalls = false)
        {
            string CADObjectID = "";

            if (element == null)
            {
                return(CADObjectID);
            }

            BHP.OriginContextFragment contextProperties = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            if (contextProperties != null && contextProperties.ElementID != "")
            {
                // change only Basic Wall and keep Curtain as it is
                if (replaceCurtainWalls && element.Name.Contains("GLZ") && (element.Name.Contains("Basic Wall") || element.Name.Contains("Floor") || element.Name.Contains("Roof")))
                {
                    element.Name = "Curtain " + element.Name;
                }

                CADObjectID = element.Name + " [" + contextProperties.ElementID + "]";
            }
            else
            {
                //Use a default object ID
                switch (element.Type)
                {
                case BHE.PanelType.Ceiling:
                    CADObjectID += "Compound Ceiling: SIM_INT_SLD";
                    break;

                case BHE.PanelType.CurtainWall:
                    if (element.ConnectedSpaces.Count == 2)
                    {
                        CADObjectID += "Curtain Wall: SIM_INT_GLZ";
                    }
                    else
                    {
                        CADObjectID += "Curtain Wall: SIM_EXT_GLZ";
                    }
                    break;

                case BHE.PanelType.Floor:
                case BHE.PanelType.FloorInternal:
                    CADObjectID += "Floor: SIM_INT_SLD";
                    break;

                case BHE.PanelType.FloorExposed:
                case BHE.PanelType.FloorRaised:
                    CADObjectID += "Floor: SIM_EXT_SLD";
                    break;

                case BHE.PanelType.Roof:
                    CADObjectID += "Basic Roof: SIM_EXT_SLD";
                    break;

                case BHE.PanelType.Shade:
                    CADObjectID += "Basic Roof: SIM_EXT_SHD_Roof";
                    break;

                case BHE.PanelType.SlabOnGrade:
                    CADObjectID += "Floor: SIM_EXT_GRD";
                    break;

                case BHE.PanelType.UndergroundCeiling:
                    CADObjectID += "Floor: SIM_INT_SLD_Parking";
                    break;

                case BHE.PanelType.UndergroundSlab:
                    CADObjectID += "Floor: SIM_EXT_GRD";
                    break;

                case BHE.PanelType.UndergroundWall:
                    CADObjectID += "Basic Wall: SIM_EXT_GRD";
                    break;

                case BHE.PanelType.Wall:
                case BHE.PanelType.WallExternal:
                    CADObjectID += "Basic Wall: SIM_EXT_SLD";
                    break;

                case BHE.PanelType.WallInternal:
                    CADObjectID += "Basic Wall: SIM_INT_SLD";
                    break;

                default:
                    CADObjectID += "Undefined";
                    break;
                }
                CADObjectID += " BHoM [000000]";
            }

            return(CADObjectID);
        }
Esempio n. 21
0
        public static TBD.zoneSurfaceClass ToTASSurface(this BHE.Panel element)
        {
            //ToDo: Finish this, connect the geometry to the zoneSurface and other additional data as appropriate

            throw new NotImplementedException("Not yet implemented");
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        public static BHX.Opening ToGBXML(this BHE.Opening opening, BHE.Panel hostPanel, GBXMLSettings settings)
        {
            BHX.Opening gbOpening = new BHX.Opening();

            BHG.Polyline pLine = opening.Polyline();

            gbOpening.Name = opening.Name;
            gbOpening.ID   = "opening" + opening.BHoM_Guid.ToString().Replace("-", "").Substring(0, 5);
            gbOpening.PlanarGeometry.PolyLoop            = pLine.ToGBXML(settings);
            gbOpening.PlanarGeometry.ID                  = "openingPGeom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5);
            gbOpening.RectangularGeometry.CartesianPoint = BH.Engine.Geometry.Query.Centroid(pLine).ToGBXML(settings);
            gbOpening.RectangularGeometry.Height         = Math.Round(opening.Height(), settings.RoundingSettings.GeometryHeight);
            //TODO: temporary solution to get valid file to be replaced with correct height
            if (opening.Height() == 0)
            {
                gbOpening.RectangularGeometry.Height = 0.1;
            }
            gbOpening.RectangularGeometry.Width = Math.Round(opening.Width(), settings.RoundingSettings.GeometryWidth);
            gbOpening.RectangularGeometry.ID    = "rGeomOpening-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5);

            pLine = pLine.CleanPolyline(minimumSegmentLength: settings.DistanceTolerance);
            double openingArea = pLine.Area();
            double panelArea   = hostPanel.Polyline().Area();

            if (openingArea >= panelArea)
            {
                pLine = BH.Engine.Geometry.Modify.Offset(pLine, settings.OffsetDistance);

                if (pLine == null)
                {
                    pLine = opening.Polyline(); //Reset the polyline if something went wrong with the offset
                }
                gbOpening.PlanarGeometry.PolyLoop = pLine.ToGBXML(settings);
            }

            //Normals away from space
            //if (!BH.Engine.Environment.Query.NormalAwayFromSpace(pLine, hostSpace, settings.PlanarTolerance))
            //gbOpening.PlanarGeometry.PolyLoop = pLine.Flip().ToGBXML();

            gbOpening.CADObjectID = opening.CADObjectID();
            gbOpening.OpeningType = opening.Type.ToGBXML();

            BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
            string elementID  = "";
            string familyName = "";

            if (contextProperties != null)
            {
                elementID  = contextProperties.ElementID;
                familyName = contextProperties.TypeName;
            }

            if (gbOpening.OpeningType.ToLower() == "fixedwindow" && contextProperties != null && contextProperties.TypeName.ToLower().Contains("skylight"))
            {
                gbOpening.OpeningType = "FixedSkylight";
            }

            if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm
            {
                gbOpening.OpeningType = "FixedWindow";
            }

            if (settings.ReplaceSolidOpeningsIntoDoors && gbOpening.OpeningType.Contains("Window") && (opening.OpeningConstruction != null && opening.OpeningConstruction.Name.Contains("SLD"))) //Change windows with SLD construction into doors for IES
            {
                gbOpening.OpeningType = "NonSlidingDoor";
            }

            if (settings.IncludeConstructions)
            {
                gbOpening.WindowTypeIDRef = "window-" + (contextProperties != null ? contextProperties.TypeName.CleanName() : (opening.OpeningConstruction != null ? opening.OpeningConstruction.Name.CleanName() : ""));
            }
            else
            {
                gbOpening.WindowTypeIDRef = null;
            }

            gbOpening.ConstructionIDRef = null; //ToDo review having this property on an opening?

            return(gbOpening);
        }
Esempio n. 24
0
 public static BHX.Construction ToGBXMLConstruction(this BHE.Panel element)
 {
     return(element.Construction.ToGBXML(element));
 }
Esempio n. 25
0
 public static BHX.Construction ToGBXML(this BHC.IConstruction construction, BHE.Panel panel = null)
 {
     return(ToGBXML(construction as dynamic, panel));
 }
Esempio n. 26
0
        public static BHX.Surface ToGBXML(this BHE.Panel element, GBXMLSettings settings, List <BHE.Panel> space = null)
        {
            BHE.Panel panel = element.DeepClone <BHE.Panel>();

            BHP.OriginContextFragment contextProperties = panel.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            BHX.Surface surface = new BHX.Surface();

            string idName = "Panel-" + panel.BHoM_Guid.ToString().Replace(" ", "").Replace("-", "").Substring(0, 10);

            surface.ID   = idName;
            surface.Name = idName;

            surface.SurfaceType  = panel.Type.ToGBXML();
            surface.ExposedToSun = BH.Engine.Environment.Query.ExposedToSun(panel).ToString().ToLower();

            surface.CADObjectID = panel.CADObjectID(settings.ReplaceCurtainWalls);

            if (settings.IncludeConstructions)
            {
                surface.ConstructionIDRef = panel.ConstructionID();
            }
            else
            {
                surface.ConstructionIDRef = null;
            }

            BHX.RectangularGeometry geom       = panel.ToGBXMLGeometry(settings);
            BHX.PlanarGeometry      planarGeom = new BHX.PlanarGeometry();
            planarGeom.ID = "PlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            surface.RectangularGeometry = geom;

            BHG.Polyline pLine = panel.Polyline();
            if (space != null && panel.ConnectedSpaces[0] == space.ConnectedSpaceName() && !pLine.NormalAwayFromSpace(space, settings.PlanarTolerance))
            {
                pLine = pLine.Flip();
                surface.PlanarGeometry.PolyLoop     = pLine.ToGBXML(settings);
                surface.RectangularGeometry.Tilt    = Math.Round(pLine.Tilt(settings.AngleTolerance), settings.RoundingSettings.GeometryTilt);
                surface.RectangularGeometry.Azimuth = Math.Round(pLine.Azimuth(BHG.Vector.YAxis), settings.RoundingSettings.GeometryAzimuth);
            }
            planarGeom.PolyLoop = pLine.ToGBXML(settings);

            surface.PlanarGeometry = planarGeom;

            if (settings.ReplaceCurtainWalls)
            {
                //If the surface is a basic Wall: SIM_EXT_GLZ so Curtain Wall after CADObjectID translation add the wall as an opening
                if (surface.CADObjectID.Contains("Curtain") && surface.CADObjectID.Contains("GLZ"))
                {
                    List <BHG.Polyline> newOpeningBounds = new List <oM.Geometry.Polyline>();
                    if (panel.Openings.Count > 0)
                    {
                        //This surface already has openings - cut them out of the new opening
                        List <BHG.Polyline> refRegion = panel.Openings.Where(y => y.Polyline() != null).ToList().Select(z => z.Polyline()).ToList();

                        newOpeningBounds.AddRange(BH.Engine.Geometry.Triangulation.Compute.DelaunayTriangulation(panel.Polyline(), refRegion, conformingDelaunay: false));
                        BHG.Polyline outer     = panel.Polyline();
                        double       outerArea = panel.Area();
                        for (int z = 0; z > panel.Openings.Count; z++)
                        {
                            BHG.Polyline poly = outer.BooleanDifference(new List <BHG.Polyline> {
                                panel.Openings[z].Polyline()
                            })[0];
                            if (poly.Area() != outerArea)
                            {
                                panel.Openings[z].Edges = panel.Openings[z].Polyline().Offset(settings.OffsetDistance).ToEdges();
                            }
                        }
                    }
                    else
                    {
                        newOpeningBounds.Add(panel.Polyline());
                    }

                    foreach (BHG.Polyline b in newOpeningBounds)
                    {
                        BH.oM.Environment.Elements.Opening curtainWallOpening = new BHE.Opening()
                        {
                            Edges = b.ToEdges()
                        };
                        curtainWallOpening.Name = panel.Name;
                        BHP.OriginContextFragment curtainWallProperties = new BHP.OriginContextFragment();
                        if (contextProperties != null)
                        {
                            curtainWallProperties.ElementID = contextProperties.ElementID;
                            curtainWallProperties.TypeName  = contextProperties.TypeName;
                        }

                        curtainWallOpening.Type = BHE.OpeningType.CurtainWall;
                        curtainWallOpening.OpeningConstruction = panel.Construction;

                        curtainWallOpening.Fragments.Add(curtainWallProperties);

                        panel.Openings.Add(curtainWallOpening);
                    }
                    //Update the host elements element type
                    surface.SurfaceType  = (panel.ConnectedSpaces.Count == 1 ? BHE.PanelType.WallExternal : BHE.PanelType.WallInternal).ToGBXML();
                    surface.ExposedToSun = BH.Engine.Adapters.XML.Query.ExposedToSun(surface.SurfaceType).ToString().ToLower();
                }
            }
            else
            {
                //Fix surface type for curtain walls
                if (panel.Type == BHE.PanelType.CurtainWall)
                {
                    surface.SurfaceType  = (panel.ConnectedSpaces.Count == 1 ? BHE.PanelType.WallExternal : BHE.PanelType.WallInternal).ToGBXML();
                    surface.ExposedToSun = BH.Engine.Adapters.XML.Query.ExposedToSun(surface.SurfaceType).ToString().ToLower();
                }
            }

            if (settings.FixIncorrectAirTypes && panel.Type == BHE.PanelType.Undefined && panel.ConnectedSpaces.Count == 1)
            {
                //Fix external air types
                if (panel.Tilt(settings.AngleTolerance) == 0)
                {
                    surface.SurfaceType = BHE.PanelType.Roof.ToGBXML();
                }
                else if (panel.Tilt(settings.AngleTolerance) == 90)
                {
                    surface.SurfaceType = BHE.PanelType.WallExternal.ToGBXML();
                }
                else if (panel.Tilt(settings.AngleTolerance) == 180)
                {
                    surface.SurfaceType = BHE.PanelType.SlabOnGrade.ToGBXML();
                }
            }

            surface.Opening = new BHX.Opening[panel.Openings.Count];
            for (int x = 0; x < panel.Openings.Count; x++)
            {
                if (panel.Openings[x].Polyline().IControlPoints().Count != 0)
                {
                    surface.Opening[x] = panel.Openings[x].ToGBXML(panel, settings);
                }
            }

            List <BHX.AdjacentSpaceID> adjIDs = new List <BHX.AdjacentSpaceID>();

            foreach (string s in panel.ConnectedSpaces)
            {
                BHX.AdjacentSpaceID adjId = new BHX.AdjacentSpaceID();
                adjId.SpaceIDRef = "Space" + s.Replace(" ", "").Replace("-", "");
                adjIDs.Add(adjId);
            }
            surface.AdjacentSpaceID = adjIDs.ToArray();

            return(surface);
        }
Esempio n. 27
0
        public static global::OpenStudio.Surface ToOSM(this BHE.Panel panel, global::OpenStudio.Model modelReference, global::OpenStudio.Space osmSpace, Dictionary <string, global::OpenStudio.Construction> uniqueConstructions, string outsideBoundaryCondition)
        {
            Surface osmElement = new Surface(panel.Polyline().ToOSM(), modelReference);

            osmElement.setName(panel.Name);
            osmElement.setSpace(osmSpace);
            if (outsideBoundaryCondition != "")
            {
                osmElement.setOutsideBoundaryCondition(outsideBoundaryCondition);
            }

            osmElement.setSurfaceType(panel.Type.ToOSMSurfaceType());
            osmElement.setConstruction(uniqueConstructions[panel.Construction.UniqueConstructionName()]);

            BHP.OriginContextFragment envContextProperties = panel.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));

            //Fix curtain wall
            if (panel.Type == BHE.PanelType.CurtainWall)
            {
                osmElement.setConstruction(uniqueConstructions["CurtainWallReplacementConstruction"]); //No need for construction on a curtain wall as the opening will handle it

                List <BHG.Polyline> newOpeningBounds = new List <BHG.Polyline>();
                if (panel.Openings.Count > 0)
                {
                    //This surface already has openings - cut them out of the new opening
                    List <BHG.Polyline> refRegion = panel.Openings.Where(y => y.Polyline() != null).ToList().Select(z => z.Polyline()).ToList();
                    newOpeningBounds.AddRange((panel.Polyline().BooleanDifference(refRegion, 0.01)));
                }
                else
                {
                    newOpeningBounds.Add(panel.Polyline());
                }

                BHE.Opening curtainWallOpening = new BHE.Opening()
                {
                    Edges = BH.Engine.Geometry.Create.PolyCurve(newOpeningBounds).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).ToEdges()
                };

                //Scale the bounding curve to comply with IDF rules
                BHG.Polyline crv = curtainWallOpening.Polyline();
                curtainWallOpening.Edges = crv.Scale(crv.Centre(), BH.Engine.Geometry.Create.Vector(0.95, 0.95, 0.95)).ToEdges();

                curtainWallOpening.Name = panel.Name;
                BHP.OriginContextFragment curtainWallProperties = new BHP.OriginContextFragment();

                if (envContextProperties != null)
                {
                    curtainWallProperties.ElementID = envContextProperties.ElementID;
                    curtainWallProperties.TypeName  = envContextProperties.TypeName;
                }

                curtainWallOpening.Type = BHE.OpeningType.CurtainWall;
                curtainWallOpening.OpeningConstruction = panel.Construction;

                panel.Openings = new List <BHE.Opening> {
                    curtainWallOpening
                };
            }

            return(osmElement);
        }