예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
파일: Panel.cs 프로젝트: BHoM/XML_Toolkit
        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);
        }
예제 #5
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);
        }
예제 #6
0
파일: Panel.cs 프로젝트: BHoM/XML_Toolkit
        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);
        }
예제 #7
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);
        }