Пример #1
0
        public static List <ThermalBridgeNames> ThermalBridgeNames(List <ThermalBridgesCurves> thermalBridgesCurves)
        {
            List <ThermalBridgeNames> thermalBridges = new List <ThermalBridgeNames>();

            for (int x = 0; x < thermalBridgesCurves.Count; x++)
            {
                ThermalBridgesCurves thermalBridgeCurves = thermalBridgesCurves[x];
                ThermalBridgeNames   thermalBridge       = new ThermalBridgeNames();
                thermalBridge.DwellingName = thermalBridgeCurves.Name;
                thermalBridge.Reference    = thermalBridgeCurves.Reference;
                thermalBridge.ID           = thermalBridgeCurves.ID;

                thermalBridge.E2 = thermalBridgeCurves.E2.Select(y => y.Length()).Sum();
                thermalBridge.E3 = thermalBridgeCurves.E3.Select(y => y.Length()).Sum();
                thermalBridge.E4 = thermalBridgeCurves.E4.Select(y => y.Length()).Sum();
                thermalBridge.E7 = thermalBridgeCurves.E7.Select(y => y.Length()).Sum();

                if (thermalBridgeCurves.E23 != null)
                {
                    thermalBridge.E23 = thermalBridgeCurves.E23.Select(y => y.Length()).Sum();
                }

                //if (thermalBridgeCurves.E10 != null)
                //{
                //    thermalBridge.E10 = thermalBridgeCurves.E10.Select(y => y.Length()).Sum();
                //}

                if (thermalBridgeCurves.E15 != null)
                {
                    thermalBridge.E15 = thermalBridgeCurves.E15.Select(y => y.Length()).Sum();
                }

                if (thermalBridgeCurves.E16 != null)
                {
                    thermalBridge.E16 = thermalBridgeCurves.E16.Select(y => y.Length()).Sum();
                }

                if (thermalBridgeCurves.E17 != null)
                {
                    thermalBridge.E17 = thermalBridgeCurves.E17.Select(y => y.Length()).Sum();
                }

                if (thermalBridgeCurves.E18 != null)
                {
                    thermalBridge.E18 = thermalBridgeCurves.E18.Select(y => y.Length()).Sum();
                }

                if (thermalBridgeCurves.E25 != null)
                {
                    thermalBridge.E25 = thermalBridgeCurves.E25.Select(y => y.Length()).Sum();
                }
                thermalBridges.Add(thermalBridge);
            }

            return(thermalBridges);
        }
Пример #2
0
        public static List <ThermalBridgesCurves> ThermalBridgesCurves(List <Zone> dwellings, List <Space> spaces, List <Panel> allPanels, List <Panel> balconyShades, List <Level> levels, List <Polyline> baseCurves, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double numericalTolerance = BH.oM.Geometry.Tolerance.Distance)
        {
            List <ThermalBridgesCurves> thermalBridgesCurves = new List <ThermalBridgesCurves>();

            levels = levels.OrderBy(x => x.Elevation).ToList();
            for (int x = 0; x < dwellings.Count; x++)
            {
                ThermalBridgesCurves thermalBridgeCurves = new ThermalBridgesCurves();
                Zone     dwelling          = dwellings[x];
                Polyline dwellingPerimeter = dwelling.Perimeter.ICollapseToPolyline(angleTolerance);

                thermalBridgeCurves.DwellingName = dwelling.Name;
                thermalBridgeCurves.Reference    = dwelling.Reference;

                Level dwellingLevel = dwelling.RegionLevel(levels, distanceTolerance, angleTolerance);

                Polyline baseCurve = baseCurves.Where(y => y.IsOnLevel(dwellingLevel)).FirstOrDefault();
                if (baseCurve == null)
                {
                    BH.Engine.Base.Compute.RecordError("Please make sure there is a basecurve on the same elevation as the dwellings");
                }

                Output <List <List <IRegion> >, List <List <double> >, List <IRegion>, List <IRegion> > mappedRegions = BH.Engine.Environment.Compute.MapRegions(spaces.Select(y => y as IRegion).ToList(), new List <IRegion> {
                    dwelling
                }, distanceTolerance, angleTolerance);
                List <Space> spacesInDwelling = mappedRegions.Item1[0].Cast <Space>().ToList();

                List <Panel> panelsInDwelling = new List <Panel>();
                foreach (Space s in spacesInDwelling)
                {
                    panelsInDwelling.AddRange(allPanels.Where(y => y.ConnectedSpaces.Contains(s.Name)).ToList());
                }

                List <BH.oM.Environment.Elements.Opening> openings = panelsInDwelling.OpeningsFromElements();
                Output <List <Polyline>, List <Polyline>, List <Polyline> > openingParts = new Output <List <Polyline>, List <Polyline>, List <Polyline> >();
                foreach (BH.oM.Environment.Elements.Opening o in openings)
                {
                    Output <List <ICurve>, List <ICurve>, List <ICurve> > outputFromExplode = o.ExplodeToParts(distanceTolerance, angleTolerance, numericalTolerance);
                    thermalBridgeCurves.E2.AddRange(outputFromExplode.Item3.Select(y => y.ICollapseToPolyline(angleTolerance)));
                    thermalBridgeCurves.E4.AddRange(outputFromExplode.Item2.Select(y => y.ICollapseToPolyline(angleTolerance)));

                    if (!(o.Bottom().ICollapseToPolyline(angleTolerance).Centre().IIsOnCurve(dwellingPerimeter)))
                    {
                        thermalBridgeCurves.E3.AddRange(outputFromExplode.Item1.Select(y => y.ICollapseToPolyline(angleTolerance)));
                    }
                }

                //Sort out party floors - curves that go along the perimeter of the building
                List <Panel> wallPanels    = panelsInDwelling.Where(y => y.Type == PanelType.Wall || y.Type == PanelType.WallExternal || y.Type == PanelType.WallInternal).ToList();
                List <Panel> exteriorWalls = wallPanels.Where(y => y.Bottom().IControlPoints().Where(z => (z.IIsOnCurve(baseCurve))).Count() == y.Bottom().IControlPoints().Count()).ToList();
                Output <List <Polyline>, List <Polyline>, List <Polyline> > exteriorWallParts = new Output <List <Polyline>, List <Polyline>, List <Polyline> >();
                exteriorWallParts.Item1 = new List <Polyline>();
                exteriorWallParts.Item2 = new List <Polyline>();
                exteriorWallParts.Item3 = new List <Polyline>();

                foreach (Panel p in exteriorWalls)
                {
                    Output <List <ICurve>, List <ICurve>, List <ICurve> > outputFromExplode = p.ExplodeToParts();
                    exteriorWallParts.Item1.AddRange(outputFromExplode.Item1.Select(y => y.ICollapseToPolyline(angleTolerance)));
                    exteriorWallParts.Item2.AddRange(outputFromExplode.Item2.Select(y => y.ICollapseToPolyline(angleTolerance)));
                    exteriorWallParts.Item3.AddRange(outputFromExplode.Item3.Select(y => y.ICollapseToPolyline(angleTolerance)));
                }

                List <Polyline> partyFloorBottom = exteriorWallParts.Item1;
                List <Polyline> partyFloorTop    = new List <Polyline>();

                List <Panel> balconiesOnDwelling = balconyShades.Where(y => (y.Polyline()).LineIntersections(dwellingPerimeter).Count > 0).ToList();

                partyFloorBottom = PartyFloors.CalculatePartyFloors(balconiesOnDwelling, partyFloorBottom);

                thermalBridgeCurves.E23 = BalconyLines.ComputeBalconyLines(balconiesOnDwelling, baseCurve, dwelling.Perimeter.ICollapseToPolyline(angleTolerance));

                if (dwellingLevel != levels.Last())
                {
                    partyFloorTop = exteriorWallParts.Item3;
                    //There may be a balcony above us, find out
                    Level levelAbove = levels[levels.IndexOf(dwellingLevel) + 1];

                    Polyline dwellingCurveAbove = dwellingPerimeter.DeepClone();
                    dwellingCurveAbove.ControlPoints = dwellingCurveAbove.ControlPoints.Select(y => new Point {
                        X = y.X, Y = y.Y, Z = levelAbove.Elevation
                    }).ToList();

                    Polyline        baseCurveAbove  = baseCurves.Where(y => y.IsOnLevel(levelAbove)).FirstOrDefault();
                    List <Polyline> baseCurvesAbove = new List <Polyline>();
                    baseCurvesAbove.Add(baseCurveAbove);

                    List <Panel> balconiesAttached = balconyShades.Where(y => (y.Polyline()).LineIntersections(dwellingCurveAbove).Count > 0).ToList();

                    partyFloorTop = PartyFloors.CalculatePartyFloors(balconiesAttached, partyFloorTop);

                    //Work out balcony lines on the upper perimeter
                    thermalBridgeCurves.E23.AddRange(BalconyLines.ComputeBalconyLines(balconiesAttached, baseCurveAbove, dwellingCurveAbove));


                    foreach (Space room in spacesInDwelling)
                    {
                        Polyline roomClone = room.Perimeter.ICollapseToPolyline(angleTolerance).DeepClone();
                        roomClone.ControlPoints = roomClone.IControlPoints().Select(y => new Point {
                            X = y.X, Y = y.Y, Z = levelAbove.Elevation
                        }).ToList();                                                                                                                         //Pull the space down to the level below
                        List <Polyline> externalCurves = roomClone.BooleanDifference(baseCurvesAbove);
                        List <Polyline> externalParts  = externalCurves.SelectMany(y => y.SplitAtPoints(y.ControlPoints())).ToList();
                        Polyline        baseCurveClone = baseCurve.DeepClone();
                        baseCurveClone.ControlPoints = baseCurveClone.IControlPoints().Select(y => new Point {
                            X = y.X, Y = y.Y, Z = levelAbove.Elevation
                        }).ToList();

                        List <Polyline> topLines = externalParts.Where(y => y.ControlPoints.Where(z => z.IsOnCurve(baseCurveClone)).Count() == y.ControlPoints().Count()).ToList();

                        thermalBridgeCurves.E15.AddRange(topLines);
                    }
                }
                else //This is the top level
                {
                    thermalBridgeCurves.E15 = exteriorWallParts.Item3;
                }

                thermalBridgeCurves.E7 = partyFloorBottom;
                if (partyFloorTop != null)
                {
                    thermalBridgeCurves.E7.AddRange(partyFloorTop);
                }

                List <Zone> dwellingsOnLevel   = dwellings.Where(y => y.Perimeter.ICollapseToPolyline(angleTolerance).IsOnLevel(dwellingLevel)).Where(y => y != dwelling).ToList(); //Available dwellings not including the one being thermal bridged
                List <Zone> connectedDwellings = dwellingsOnLevel.Where(y =>
                {
                    List <ICurve> curves = new List <ICurve>()
                    {
                        y.Perimeter, dwellingPerimeter
                    };
                    List <PolyCurve> union = curves.BooleanUnion();
                    return(union.Count == 1);
                }).ToList(); //Only the dwellings which are connected to the current dwelling

                List <Point> connectionPointsToNeighbours = connectedDwellings.SelectMany(y => y.Perimeter.ICurveIntersections(dwelling.Perimeter).Where(z => z.IsOnCurve(baseCurve))).ToList();

                foreach (Point p in connectionPointsToNeighbours)
                {
                    List <Point> ctrlPoints = new List <Point>()
                    {
                        p
                    };
                    ctrlPoints.Add(new Point()
                    {
                        X = p.X, Y = p.Y, Z = p.Z + exteriorWalls[0].Height()
                    });;
                    Polyline line = new Polyline()
                    {
                        ControlPoints = ctrlPoints
                    };
                    if (baseCurve.IControlPoints().Contains(p))
                    {
                        thermalBridgeCurves.E25.Add(line);
                    }
                    else
                    {
                        thermalBridgeCurves.E18.Add(line);
                    }
                }

                List <Point> baseCurveCornerPoints = baseCurve.CleanPolyline().ControlPoints();
                baseCurveCornerPoints.RemoveAt(baseCurveCornerPoints.Count - 1);
                List <Point> cornerInDwelling = baseCurveCornerPoints.Where(y => y.IIsOnCurve(dwelling.Perimeter)).ToList();

                List <Point> e16Pts = new List <Point>();
                List <Point> e17Pts = new List <Point>();

                foreach (Point pt in cornerInDwelling)
                {
                    List <Polyline> cornerLines = exteriorWallParts.Item1.Where(y => pt.IsOnCurve(y)).ToList();
                    if (cornerLines.Count < 2)
                    {
                        e17Pts.Add(pt);
                    }
                    else
                    {
                        Point centre1 = cornerLines[0].Centre();
                        Point centre2 = cornerLines[1].Centre();
                        Line  joined  = new Line()
                        {
                            Start = centre1, End = centre2
                        };

                        if (baseCurve.IIsContaining(new List <Point>()
                        {
                            joined.Centroid()
                        }))
                        {
                            e16Pts.Add(pt);
                        }
                        else
                        {
                            e17Pts.Add(pt);
                        }
                    }
                }

                List <Polyline> e16Lines = new List <Polyline>();
                foreach (Point p in e16Pts)
                {
                    List <Point> ctrlPts = new List <Point>()
                    {
                        p
                    };
                    ctrlPts.Add(new Point()
                    {
                        X = p.X, Y = p.Y, Z = p.Z + exteriorWalls[0].Height()
                    });
                    Polyline pl = new Polyline()
                    {
                        ControlPoints = ctrlPts
                    };
                    thermalBridgeCurves.E16.Add(pl);
                }

                List <Polyline> e17Lines = new List <Polyline>();
                foreach (Point p in e17Pts)
                {
                    List <Point> ctrlPts = new List <Point>()
                    {
                        p
                    };
                    ctrlPts.Add(new Point()
                    {
                        X = p.X, Y = p.Y, Z = p.Z + exteriorWalls[0].Height()
                    });
                    Polyline pl = new Polyline()
                    {
                        ControlPoints = ctrlPts
                    };
                    thermalBridgeCurves.E17.Add(pl);
                }

                thermalBridgesCurves.Add(thermalBridgeCurves);
            }

            return(thermalBridgesCurves);
        }