コード例 #1
0
ファイル: ReadGBXML.cs プロジェクト: BHoM/XML_Toolkit
        private List <BHE.Space> ReadSpaces(BHX.GBXML gbx, List <string> ids = null)
        {
            //ToDo - Fix this!
            List <BHE.Space> s = new List <BHE.Space>();

            if (gbx.Campus != null)
            {
                foreach (BHX.Building b in gbx.Campus.Building)
                {
                    foreach (BHX.Space space in b.Space)
                    {
                        BHE.Space bhomS = space.FromGBXML();
                        if (bhomS.Perimeter.IControlPoints().Count == 1)
                        {
                            //Pulling from IES probably means it's wrong...
                            List <Panel> panelsAsSpace = space.SpaceBoundary.Select(x => gbx.Campus.Surface.Where(y => y.ID == x.SurfaceIDRef).FirstOrDefault().FromGBXML()).ToList();
                            bhomS.Perimeter = panelsAsSpace.FloorGeometry();
                        }
                        s.Add(bhomS);
                    }
                }
            }

            return(s);
        }
コード例 #2
0
        /***************************************************/

        public static string CADObjectID(this BHE.Space space)
        {
            BHP.OriginContextFragment contextProp = space.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment));
            if (contextProp == null)
            {
                return("");
            }

            return(contextProp.TypeName + " [" + contextProp.ElementID + "]");
        }
コード例 #3
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static BHG.Point Centre(this BHE.Space space) //TODO: This does only work for convex spaces. we need to change this method later
        {
            /*List<BHE.BuildingElement> buildingElements = space.BuildingElements;
             * List<BHG.Point> pts = new List<BHG.Point>();
             *
             * foreach (BHE.BuildingElement element in buildingElements)
             * {
             *  pts.AddRange(Engine.Geometry.Query.IControlPoints(element.BuildingElementGeometry.ICurve()));
             * }
             *
             * BHG.Point centrePt = BH.Engine.Geometry.Query.Bounds(pts).Centre();
             * return centrePt;*/

            return(new oM.Geometry.Point());
        }
コード例 #4
0
        public static TBD.zone ToTAS(this BHE.Space space, TBD.zone tbdSpace)
        {
            //TODO:Assign Internal Conditions to Zones
            //TODO:Assign Building Elements (Surfaces) to Zones

            if (space == null)
            {
                return(tbdSpace);
            }
            tbdSpace.name = space.Name;

            BHP.LoadFragment loads = space.FindFragment <BHP.LoadFragment>(typeof(BHP.LoadFragment));

            if (loads != null)
            {
                tbdSpace.maxHeatingLoad = (float)loads.HeatingLoad;
                tbdSpace.maxCoolingLoad = (float)loads.CoolingLoad;
            }

            TASSpaceData tasFragment = space.FindFragment <TASSpaceData>(typeof(TASSpaceData));

            if (tasFragment != null)
            {
                tbdSpace.colour                     = tasFragment.Colour;
                tbdSpace.daylightFactor             = (float)tasFragment.DaylightFactor;
                tbdSpace.exposedPerimeter           = (float)tasFragment.ExposedPerimeter;
                tbdSpace.external                   = tasFragment.External;
                tbdSpace.facadeLength               = (float)tasFragment.FacadeLength;
                tbdSpace.fixedConvectionCoefficient = (float)tasFragment.FixedConvectionCoefficient;
                tbdSpace.floorArea                  = (float)tasFragment.FloorArea;
                tbdSpace.GUID               = tasFragment.TASID;
                tbdSpace.length             = (float)tasFragment.Length;
                tbdSpace.sizeCooling        = tasFragment.SizeCooling;
                tbdSpace.sizeHeating        = tasFragment.SizeHeating;
                tbdSpace.volume             = (float)tasFragment.Volume;
                tbdSpace.wallFloorAreaRatio = (float)tasFragment.WallFloorAreaRatio;
            }

            TASDescription tasDescription = space.FindFragment <TASDescription>(typeof(TASDescription));

            if (tasFragment != null)
            {
                tbdSpace.description = tasDescription.Description;
            }

            return(tbdSpace);
        }
コード例 #5
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static List <BHG.Point> UnmatchedElementPoints(BHE.Space space, double tolerance = BHG.Tolerance.MacroDistance)
        {
            List <BHG.Point> nonMatchingPoints = new List <oM.Geometry.Point>();

            /*foreach(BHE.BuildingElement be in space.BuildingElements)
             * {
             *  if (be == null) continue;
             *
             *  foreach(BHG.Point pt in be.BuildingElementGeometry.ICurve().ICollapseToPolyline(BHG.Tolerance.Angle).IDiscontinuityPoints())
             *  {
             *      List<BHE.BuildingElement> elementCompare = space.BuildingElements.Where(x => x != null).ToList().FindAll(x => x.BHoM_Guid != be.BHoM_Guid);
             *
             *      BHE.BuildingElement matchingBE = elementCompare.Find(x => x.BuildingElementGeometry.ICurve().ICollapseToPolyline(BHG.Tolerance.Angle).DiscontinuityPoints().ClosestDistance(new List<BHG.Point>() { pt }) < tolerance && (x.BHoM_Guid != be.BHoM_Guid));
             *
             *      if (matchingBE == null)
             *          nonMatchingPoints.Add(pt);
             *  }
             * }*/

            return(nonMatchingPoints);
        }
コード例 #6
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static SpaceBoundary[] SpaceBoundaries(this BHE.Space bHoMSpace, List <BHE.Panel> be)
        {
            /*List<BH.oM.XML.Polyloop> ploops = new List<Polyloop>();
             * IEnumerable<BHG.PolyCurve> bePanel = bHoMSpace.BuildingElements.Select(x => x.BuildingElementGeometry.ICurve() as BHG.PolyCurve);
             *
             * foreach (BHG.PolyCurve pCrv in bePanel)
             * {
             *  // Ensure that all of the surface coordinates are listed in a counterclockwise order
             *  //* This is a requirement of GBXML Polyloop definitions
             *  BHG.Polyline pline = new BHG.Polyline() { ControlPoints = pCrv.ControlPoints() };
             *
             *  if (!BH.Engine.Environment.Query.NormalAwayFromSpace(pline, bHoMSpace))
             *      ploops.Add(BH.Engine.XML.Convert.ToGBXML(pline.Flip()));
             *  else
             *      ploops.Add(BH.Engine.XML.Convert.ToGBXML(pline));
             * }
             *
             * SpaceBoundary[] spaceBound = new SpaceBoundary[ploops.Count()];
             *
             * for (int i = 0; i < ploops.Count(); i++)
             * {
             *  PlanarGeometry planarGeom = new PlanarGeometry();
             *  planarGeom.PolyLoop = ploops[i];
             *  SpaceBoundary bound = new SpaceBoundary { PlanarGeometry = planarGeom };
             *  spaceBound[i] = bound;
             *
             *  //Get the id from the referenced panel
             *  string refPanel = "Panel-" + be.FindIndex(x => x.BHoM_Guid.ToString() == bHoMSpace.BuildingElements[i].BHoM_Guid.ToString()).ToString();
             *  spaceBound[i].SurfaceConstructionID = refPanel;
             * }
             *
             * return spaceBound;*/
            return(null);

            /***************************************************/
        }
コード例 #7
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static double FloorArea(this BHEE.Space bHoMSpace)
        {
            throw new NotImplementedException("Calculating the area in the space has not been implemented");
        }
コード例 #8
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static BHG.Polyline FloorGeometry(this BHE.Space space)
        {
            throw new NotImplementedException("Calculating the floor geometry in the space has not been implemented");
        }
コード例 #9
0
 public static global::OpenStudio.Zone ToOSM(this BHE.Space zone, global::OpenStudio.Zone osmZone)
 {
     osmZone.setName(zone.Name);
     return(osmZone);
 }
コード例 #10
0
        public static BHE.Space FromTAS(this TBD.zone tbdSpace, TBD.TBDDocument tbdDocument)
        {
            BHE.Space space = new BHE.Space();
            space.Name = tbdSpace.name + tbdSpace.number.ToString();

            BHP.LoadFragment loads = new BHP.LoadFragment();
            loads.CoolingLoad = tbdSpace.maxCoolingLoad;
            loads.HeatingLoad = tbdSpace.maxHeatingLoad;
            space.Fragments.Add(loads);

            //Adding data to Extended Poroperties--------------------------------------------------------------------------------------------------------------

            //EnvironmentContextProperties
            BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment();
            environmentContextProperties.ElementID   = tbdSpace.GUID.RemoveBrackets();
            environmentContextProperties.Description = tbdSpace.description;
            environmentContextProperties.TypeName    = tbdSpace.name;
            space.Fragments.Add(environmentContextProperties);

            //SpaceContextProperties
            BHP.SpaceContextFragment spaceContextProperties = new BHP.SpaceContextFragment();
            spaceContextProperties.Colour     = BH.Engine.Adapters.TAS.Query.GetRGB(tbdSpace.colour).ToString();
            spaceContextProperties.IsExternal = tbdSpace.external != 0;

            //spaceContextProperties.ConnectedElements = tbdSpace.external != 0;
            space.Fragments.Add(spaceContextProperties);

            //SpaceAnalyticalProperties
            BHP.SpaceAnalyticalFragment spaceAnalyticalProperties = new BHP.SpaceAnalyticalFragment();
            spaceAnalyticalProperties.DaylightFactor             = tbdSpace.daylightFactor;
            spaceAnalyticalProperties.FacadeLength               = tbdSpace.facadeLength;
            spaceAnalyticalProperties.FixedConvectionCoefficient = tbdSpace.fixedConvectionCoefficient;
            spaceAnalyticalProperties.SizeCoolingMethod          = ((TBD.SizingType)tbdSpace.sizeCooling).FromTAS();
            spaceAnalyticalProperties.SizeHeatingMethod          = ((TBD.SizingType)tbdSpace.sizeCooling).FromTAS();
            space.Fragments.Add(spaceAnalyticalProperties);

            //Extended Properties

            TASSpaceData tasData = new TASSpaceData();

            tasData.Colour                     = System.Convert.ToUInt32(tbdSpace.colour);
            tasData.DaylightFactor             = tbdSpace.daylightFactor;
            tasData.ExposedPerimeter           = tbdSpace.exposedPerimeter;
            tasData.External                   = tbdSpace.external;
            tasData.FacadeLength               = tbdSpace.facadeLength;
            tasData.FixedConvectionCoefficient = tbdSpace.fixedConvectionCoefficient;
            tasData.FloorArea                  = tbdSpace.floorArea;
            tasData.TASID              = tbdSpace.GUID.RemoveBrackets();
            tasData.Length             = tbdSpace.length;
            tasData.SizeCooling        = tbdSpace.sizeCooling;
            tasData.SizeHeating        = tbdSpace.sizeHeating;
            tasData.Volume             = tbdSpace.volume;
            tasData.WallFloorAreaRatio = tbdSpace.wallFloorAreaRatio;

            TASDescription tasDescription = new TASDescription();

            tasDescription.Description = tbdSpace.description;

            //Proces to extract Number of people directly into space if needed
            //double[] YearlyPeopleSensibleSepcificGain = Query.GetNumberOfPeople(tbdDocument, tbdSpace);
            //double MaxSpecificSensibleGain = YearlyPeopleSensibleSepcificGain.Max();
            //double[] YearlyPeopleLatenteSepcificGain = Query.GetNumberOfPeople(tbdDocument, tbdSpace, TBD.Profiles.ticOLG);
            //double MaxSpecificLatentGain = YearlyPeopleLatenteSepcificGain.Max();
            //double NumberOfPeople = PeopleDesity / tbdSpace.floorArea;

            space.Fragments.Add(tasData);
            space.Fragments.Add(tasDescription);

            return(space);
        }