diff --git a/IES_Adapter/CRUD/Create.cs b/IES_Adapter/CRUD/Create.cs index 60a5fff..0c40298 100644 --- a/IES_Adapter/CRUD/Create.cs +++ b/IES_Adapter/CRUD/Create.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -30,7 +30,6 @@ using System.IO; using System.Linq; -using BH.Engine.Adapters.IES; using BH.oM.Adapter; using BH.Engine.Adapter; @@ -58,6 +57,11 @@ protected override bool ICreate(IEnumerable objects, ActionConfig actionCo StreamWriter sw = new StreamWriter(_fileSettings.GetFullFileName()); + sw.WriteLine("COM GEM data file exported by BHoM"); + sw.WriteLine("CAT"); //Lol - Default GEM files use ANT + sw.WriteLine("SITE"); + sw.WriteLine("51.378 2.3648 0.000 0.000"); + try { foreach (List space in panelsAsSpaces) @@ -83,3 +87,4 @@ protected override bool ICreate(IEnumerable objects, ActionConfig actionCo } + diff --git a/IES_Adapter/CRUD/Read.cs b/IES_Adapter/CRUD/Read.cs index 0332f48..6df7d87 100644 --- a/IES_Adapter/CRUD/Read.cs +++ b/IES_Adapter/CRUD/Read.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -32,7 +32,6 @@ using BH.oM.Environment; using System.IO; -using BH.Engine.Adapters.IES; using BH.oM.Adapter; using BH.Engine.Adapter; @@ -185,3 +184,4 @@ private List ReadSpaces(List panels) } + diff --git a/IES_Adapter/Convert/Environment/Opening.cs b/IES_Adapter/Convert/Environment/Opening.cs new file mode 100644 index 0000000..bfa17c3 --- /dev/null +++ b/IES_Adapter/Convert/Environment/Opening.cs @@ -0,0 +1,75 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BH.Engine.Environment; +using BH.oM.Environment.Elements; +using BH.oM.Geometry; +using BH.Engine.Geometry; +using BH.oM.IES.Settings; + +namespace BH.Adapter.IES +{ + public static partial class Convert + { + public static List ToIES(this Opening opening, Panel hostPanel, SettingsIES settingsIES) + { + List rtn = new List(); + + var coordSystem = hostPanel.Polyline().CoordinateSystem(settingsIES.DistanceTolerance, settingsIES.AngleTolerance); + var localToGlobal = BH.Engine.Geometry.Create.OrientationMatrixLocalToGlobal(coordSystem); + + var polyline = opening.Polyline().Transform(localToGlobal); + + rtn.Add($"{polyline.ControlPoints.Count.ToString()} {opening.Type.ToIES(settingsIES)}\n"); + + foreach (var cPoint in polyline.ControlPoints) + rtn.Add($" {cPoint.ToIES(settingsIES, false)}"); + + return rtn; + } + public static Opening FromIESOpening(this List openingPts, string openingType, Polyline hostPanel, SettingsIES settingsIES ) + { + + var polyline = new Polyline(); + + foreach (var iesPt in openingPts) + polyline.ControlPoints.Add(iesPt.FromIES(settingsIES)); + + polyline.ControlPoints.Add(polyline.ControlPoints[0]); + + var coordSystem = hostPanel.CoordinateSystem(settingsIES.DistanceTolerance, settingsIES.AngleTolerance); + var globalToLocal = BH.Engine.Geometry.Create.OrientationMatrixGlobalToLocal(coordSystem); + + Opening opening = new Opening(); + + opening.Edges = polyline.Transform(globalToLocal).ToEdges(); + opening.Type = openingType.FromIESOpeningType(settingsIES); + + return opening; + } + } +} diff --git a/IES_Engine/Convert/Environment/OpeningType.cs b/IES_Adapter/Convert/Environment/OpeningType.cs similarity index 93% rename from IES_Engine/Convert/Environment/OpeningType.cs rename to IES_Adapter/Convert/Environment/OpeningType.cs index b5de197..8c2cb82 100644 --- a/IES_Engine/Convert/Environment/OpeningType.cs +++ b/IES_Adapter/Convert/Environment/OpeningType.cs @@ -1,6 +1,6 @@ -/* +/* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,32 +20,28 @@ * along with this code. If not, see . */ +using BH.oM.Base.Attributes; +using BH.oM.IES.Settings; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using BH.oM.Geometry; -using BH.oM.Base.Attributes; -using System.ComponentModel; using BH.oM.Environment.Elements; -using BH.Engine.Environment; -using BH.Engine.Geometry; -using BH.oM.IES.Settings; -namespace BH.Engine.Adapters.IES +namespace BH.Adapter.IES { public static partial class Convert { - [Description("Convert a BHoM Opening Type to an IES string representation for GEM format")] [Input("type", "The BHoM Opening Type to convert")] [Input("settingsIES", "The IES settings to use with the IES adapter")] [Output("iesOpeningType", "The IES string representation of the BHoM opening type")] public static string ToIES(this OpeningType type, SettingsIES settingsIES) { - switch(type) + switch (type) { case OpeningType.CurtainWall: case OpeningType.Glazing: @@ -80,4 +76,3 @@ public static OpeningType FromIESOpeningType(this string iesOpeningType, Setting } } } - diff --git a/IES_Engine/Convert/Environment/Panel.cs b/IES_Adapter/Convert/Environment/Panel.cs similarity index 85% rename from IES_Engine/Convert/Environment/Panel.cs rename to IES_Adapter/Convert/Environment/Panel.cs index da45e28..be1b009 100644 --- a/IES_Engine/Convert/Environment/Panel.cs +++ b/IES_Adapter/Convert/Environment/Panel.cs @@ -1,6 +1,6 @@ -/* +/* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -34,7 +34,7 @@ using BH.Engine.Geometry; using BH.oM.IES.Settings; -namespace BH.Engine.Adapters.IES +namespace BH.Adapter.IES { public static partial class Convert { @@ -53,25 +53,12 @@ public static List ToIESShading(this List panelsAsShade, Settings for (int x = 0; x < panels.Count; x++) { - gemPanel.Add("LAYER\n"); - gemPanel.Add("64\n"); - gemPanel.Add("COLOUR\n"); - gemPanel.Add("0\n"); - gemPanel.Add("CATEGORY\n"); - gemPanel.Add("1\n"); - gemPanel.Add("TYPE\n"); - if (panels[x].Type == PanelType.Shade) - { - gemPanel.Add("4\n"); - } - else - { - gemPanel.Add("1\n"); - gemPanel.Add("SUBTYPE\n"); - gemPanel.Add("2102\n"); - } - gemPanel.Add("COLOURRGB\n"); - gemPanel.Add("65280\n"); + var template = Create.ShadeTemplate(); + template.Layer = "64"; + template.Colour = "65280"; + + gemPanel.AddRange(template.ToIES()); + gemPanel.Add("IES IES_SHD_" + (x + 1).ToString() + "\n"); List points = panels[x].Vertices().Select(y => y.RoundCoordinates(settingsIES.DecimalPlaces)).ToList(); @@ -80,14 +67,14 @@ public static List ToIESShading(this List panelsAsShade, Settings string s = points.Count.ToString(); - foreach(Point p in points) + foreach (Point p in points) { gemPanel.Add(p.ToIES(settingsIES)); s += " " + (points.IndexOf(p) + 1).ToString(); } s += "\n"; gemPanel.Add(s); - + // Add Openings if (panels[x].Openings.Count == 0) gemPanel.Add("0\n"); @@ -96,11 +83,11 @@ public static List ToIESShading(this List panelsAsShade, Settings gemPanel.Add(panels[x].Openings.Count.ToString() + "\n"); foreach (Opening o in panels[x].Openings) - gemPanel.AddRange(o.ToIES(panels[x], new List { panels[x] }, settingsIES)); + gemPanel.AddRange(o.ToIES(panels[x], settingsIES)); } } - return gemPanel; + return gemPanel; } [Description("Convert an IES string representation of a space into a collection of BHoM Environment Panels")] @@ -116,9 +103,9 @@ public static Panel FromIESShading(this List iesPanel, SettingsIES setti List iesPoints = new List(); //Add the coordinate pts to a list for (int x = 0; x < numCoordinates; x++) iesPoints.Add(iesPanel[x + 2]); - + List bhomPoints = iesPoints.Select(x => x.FromIES(settingsIES)).ToList(); - + int count = numCoordinates + 2; //Number of coordinates + 2 to get on to the line of the panel in GEM //Convert to panels @@ -126,7 +113,7 @@ public static Panel FromIESShading(this List iesPanel, SettingsIES setti List pLinePts = new List(); for (int y = 1; y < panelCoord.Count; y++) pLinePts.Add(bhomPoints[System.Convert.ToInt32(panelCoord[y]) - 1]); //Add coordinate points in order - + pLinePts.Add(pLinePts.First()); //Add first point to close polyline Polyline pLine = new Polyline { ControlPoints = pLinePts, }; @@ -150,13 +137,13 @@ public static Panel FromIESShading(this List iesPanel, SettingsIES setti for (int x = 0; x < numCoords; x++) openingPts.Add(iesPanel[count + x]); - panel.Openings.Add(openingPts.FromIES(openingData.Split(' ')[1], settingsIES)); + //panel.Openings.Add(openingPts.FromIES(openingData.Split(' ')[1], settingsIES)); count += numCoords; countOpenings++; } - if (settingsIES.PullOpenings) + /*if (settingsIES.PullOpenings) { //This if-statement is a fix for the IES implementation of translucent shades, // where these shades contain openings defined by 3d coordinates, which differs from how @@ -172,10 +159,11 @@ public static Panel FromIESShading(this List iesPanel, SettingsIES setti else { panel.Openings = new List(); - } + }*/ return panel; } } } + diff --git a/IES_Engine/Convert/Environment/Space.cs b/IES_Adapter/Convert/Environment/Space.cs similarity index 79% rename from IES_Engine/Convert/Environment/Space.cs rename to IES_Adapter/Convert/Environment/Space.cs index b398acf..67d723e 100644 --- a/IES_Engine/Convert/Environment/Space.cs +++ b/IES_Adapter/Convert/Environment/Space.cs @@ -1,6 +1,6 @@ -/* +/* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,36 +20,34 @@ * along with this code. If not, see . */ +using BH.oM.Base.Attributes; +using BH.oM.Environment.Elements; +using BH.oM.Geometry; +using BH.oM.IES.Fragments; +using BH.oM.IES.Settings; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; - -using BH.oM.Geometry; -using BH.oM.Base.Attributes; -using System.ComponentModel; -using BH.oM.Environment.Elements; using BH.Engine.Environment; using BH.Engine.Geometry; -using BH.oM.IES.Settings; -using BH.oM.IES.Fragments; -using BH.Engine.Base; -namespace BH.Engine.Adapters.IES +namespace BH.Adapter.IES { public static partial class Convert - { + { [Description("Convert a collection of BHoM Environment Panels that represent a single volumetric space into the IES string representation for GEM format")] [Input("panelsAsSpace", "The collection of BHoM Environment Panels that represent a space")] [Input("settingsIES", "The IES settings to use with the IES adapter")] [Output("iesSpace", "The IES string representation of the space for GEM")] - public static List ToIES(this List panelsAsSpace, SettingsIES settingsIES) + public static List ToIES(this List panelsAsSpace, SettingsIES settingsIES) { if (panelsAsSpace == null || panelsAsSpace.Count == 0) return new List(); - if(settingsIES == null) + if (settingsIES == null) { BH.Engine.Base.Compute.RecordWarning("A null set of IES Settings was provided when attempting to convert a collection of panels (forming a closed space or 3D shade) to GEM. As such, default settings have been applied."); settingsIES = new SettingsIES(); @@ -60,32 +58,12 @@ public static List ToIES(this List panelsAsSpace, SettingsIES set if (panels.Count != panelsAsSpace.Count) BH.Engine.Base.Compute.RecordWarning("The space " + panelsAsSpace.ConnectedSpaceName() + " has panels which did not contain geometry. Panels without valid geometry cannot be converted for IES to handle and have been ignored."); - List gemSpace = new List(); - - gemSpace.Add("LAYER\n"); - gemSpace.Add("1\n"); - gemSpace.Add("COLOUR\n"); - gemSpace.Add("1\n"); - gemSpace.Add("CATEGORY\n"); - gemSpace.Add("1\n"); + List gemSpace = new List(); if (panels.First().IsShade()) - { - gemSpace.Add("TYPE\n"); - gemSpace.Add("4\n"); - gemSpace.Add("SUBTYPE\n"); - gemSpace.Add("0\n"); - } + gemSpace.AddRange(Create.ShadeTemplate().ToIES()); else - { - gemSpace.Add("TYPE\n"); - gemSpace.Add("1\n"); - gemSpace.Add("SUBTYPE\n"); - gemSpace.Add("2001\n"); - } - - gemSpace.Add("COLOURRGB\n"); - gemSpace.Add("16711690\n"); + gemSpace.AddRange(Create.SpaceTemplate().ToIES()); gemSpace.Add("IES " + panels.ConnectedSpaceName() + "\n"); @@ -107,14 +85,14 @@ public static List ToIES(this List panelsAsSpace, SettingsIES set if (p.Type == PanelType.Air && p.Openings.Count == 0) p.Openings.Add(new Opening { Edges = new List(p.ExternalEdges), Type = OpeningType.Hole }); //Air walls need the polyline adding as an opening of type hole + if(!p.NormalAwayFromSpace(panels, settingsIES.PlanarTolerance)) + p.ExternalEdges = p.Polyline().Flip().ToEdges(); //Reverse the point order if the normal is not away from the space but the first adjacency is this space + List v = p.Vertices(); v.RemoveAt(v.Count - 1); //Remove the last point because we don't need duplicated points - if (!p.NormalAwayFromSpace(panels, settingsIES.PlanarTolerance)) - v.Reverse(); //Reverse the point order if the normal is not away from the space but the first adjacency is this space - string s = v.Count.ToString() + " "; - foreach(Point pt in v) + foreach (Point pt in v) s += (spaceVertices.IndexOf(pt.RoundCoordinates(settingsIES.DecimalPlaces)) + 1) + " "; s += "\n"; @@ -127,13 +105,13 @@ public static List ToIES(this List panelsAsSpace, SettingsIES set gemSpace.Add(p.Openings.Count.ToString() + "\n"); foreach (Opening o in p.Openings) - gemSpace.AddRange(o.ToIES(p, panels, settingsIES)); + gemSpace.AddRange(o.ToIES(p, settingsIES)); } } return gemSpace; } - + [Description("Convert an IES string representation of a space into a collection of BHoM Environment Panels")] [Input("iesSpace", "The IES representation of a space")] [Input("settingsIES", "The IES settings to use with the IES adapter")] @@ -144,7 +122,7 @@ public static List FromIES(this List iesSpace, SettingsIES settin //Convert the strings which make up the IES Gem file back into BHoM panels. string spaceName = iesSpace[0]; //First string is the name - if(spaceName.StartsWith("IES")) + if (spaceName.StartsWith("IES")) { spaceName = spaceName.Substring(3); spaceName = spaceName.Trim(); @@ -161,7 +139,7 @@ public static List FromIES(this List iesSpace, SettingsIES settin //Number of coordinated + 2 to get on to the line of the fist panel in GEM int count = numCoordinates + 2; - while(count < iesSpace.Count) + while (count < iesSpace.Count) { //Convert to panels List panelCoord = iesSpace[count].Trim().Split(' ').ToList(); @@ -174,6 +152,7 @@ public static List FromIES(this List iesSpace, SettingsIES settin Polyline pLine = new Polyline { ControlPoints = pLinePts, }; + Panel panel = new Panel(); panel.ExternalEdges = pLine.ToEdges(); panel.Openings = new List(); @@ -188,7 +167,7 @@ public static List FromIES(this List iesSpace, SettingsIES settin int numOpenings = System.Convert.ToInt32(iesSpace[count]); count++; int countOpenings = 0; - while(countOpenings < numOpenings) + while (countOpenings < numOpenings) { string openingData = iesSpace[count]; int numCoords = System.Convert.ToInt32(openingData.Split(' ')[0]); @@ -198,7 +177,8 @@ public static List FromIES(this List iesSpace, SettingsIES settin for (int x = 0; x < numCoords; x++) openingPts.Add(iesSpace[count + x]); - panel.Openings.Add(openingPts.FromIES(openingData.Split(' ')[1], settingsIES)); + if(settingsIES.PullOpenings) + panel.Openings.Add(openingPts.FromIESOpening(openingData.Split(' ')[1], pLine, settingsIES)); count += numCoords; countOpenings++; @@ -207,25 +187,7 @@ public static List FromIES(this List iesSpace, SettingsIES settin panels.Add(panel); } - if (settingsIES.PullOpenings) - { - //Fix the openings now - foreach (Panel p in panels) - { - for (int x = 0; x < p.Openings.Count; x++) - { - p.Openings[x] = p.Openings[x].RepairOpening(p, panels); - } - } - } - else - { - foreach(Panel p in panels) - p.Openings = new List(); - } - return panels; } } } - diff --git a/IES_Engine/Convert/Geometry/Point.cs b/IES_Adapter/Convert/Geometry/Point.cs similarity index 84% rename from IES_Engine/Convert/Geometry/Point.cs rename to IES_Adapter/Convert/Geometry/Point.cs index 353e99e..437e9c0 100644 --- a/IES_Engine/Convert/Geometry/Point.cs +++ b/IES_Adapter/Convert/Geometry/Point.cs @@ -1,6 +1,6 @@ -/* +/* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -34,7 +34,7 @@ using BH.Engine.Geometry; using BH.oM.IES.Settings; -namespace BH.Engine.Adapters.IES +namespace BH.Adapter.IES { public static partial class Convert { @@ -42,9 +42,12 @@ public static partial class Convert [Input("pt", "BHoM Geometry Point to convert")] [Input("settingsIES", "The IES settings to use with the IES adapter")] [Output("iesPt", "The IES string representation of the point")] - public static string ToIES(this Point pt, SettingsIES settingsIES) + public static string ToIES(this Point pt, SettingsIES settingsIES, bool allCoords = true) { - return " " + Math.Round(pt.X, settingsIES.DecimalPlaces).ToString() + " " + Math.Round(pt.Y, settingsIES.DecimalPlaces).ToString() + " " + Math.Round(pt.Z, settingsIES.DecimalPlaces).ToString() + "\n"; + if (allCoords) + return " " + Math.Round(pt.X, settingsIES.DecimalPlaces).ToString() + " " + Math.Round(pt.Y, settingsIES.DecimalPlaces).ToString() + " " + Math.Round(pt.Z, settingsIES.DecimalPlaces).ToString() + "\n"; + else + return " " + Math.Round(Math.Abs(pt.X), settingsIES.DecimalPlaces).ToString() + " " + Math.Round(Math.Abs(pt.Y), settingsIES.DecimalPlaces).ToString() + "\n"; } [Description("Convert an IES point representation to a BHoM point")] @@ -64,7 +67,7 @@ public static Point FromIES(this string iesPt, SettingsIES settingsIES) Z = (split.Length > 2 ? System.Convert.ToDouble(split[2]) : 0), }; } - catch(Exception e) + catch (Exception e) { BH.Engine.Base.Compute.RecordError("An error occurred in parsing that IES string to a BHoM point. Error was: " + e.ToString()); return null; @@ -73,3 +76,4 @@ public static Point FromIES(this string iesPt, SettingsIES settingsIES) } } + diff --git a/IES_Adapter/Convert/Objects/GEMTemplate.cs b/IES_Adapter/Convert/Objects/GEMTemplate.cs new file mode 100644 index 0000000..b3dac5b --- /dev/null +++ b/IES_Adapter/Convert/Objects/GEMTemplate.cs @@ -0,0 +1,58 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BH.Adapter.IES +{ + public static partial class Convert + { + public static List ToIES(this GEMTemplate gemTemplate) + { + List gemLines = new List(); + + gemLines.Add("LAYER\n"); + gemLines.Add($"{gemTemplate.Layer}\n"); + + gemLines.Add("COLOUR\n"); + gemLines.Add($"{gemTemplate.Colour}\n"); + + gemLines.Add("CATEGORY\n"); + gemLines.Add($"{gemTemplate.Category}\n"); + + gemLines.Add("TYPE\n"); + gemLines.Add($"{gemTemplate.Type}\n"); + + gemLines.Add("SUBTYPE\n"); + gemLines.Add($"{gemTemplate.SubType}\n"); + + gemLines.Add("COLOURRGB\n"); + gemLines.Add($"{gemTemplate.ColourRGB}\n"); + + return gemLines; + } + } +} diff --git a/IES_Adapter/Create/ShadeTemplate.cs b/IES_Adapter/Create/ShadeTemplate.cs new file mode 100644 index 0000000..3d9a9aa --- /dev/null +++ b/IES_Adapter/Create/ShadeTemplate.cs @@ -0,0 +1,46 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BH.Adapter.IES +{ + public static partial class Create + { + public static GEMTemplate ShadeTemplate() + { + return new GEMTemplate() + { + Layer = "64", + Colour = "62", + Category = "1", + Type = "4", + SubType = "0", + ColourRGB = "65280" + }; + } + } +} diff --git a/IES_Adapter/Create/SpaceTemplate.cs b/IES_Adapter/Create/SpaceTemplate.cs new file mode 100644 index 0000000..01a2303 --- /dev/null +++ b/IES_Adapter/Create/SpaceTemplate.cs @@ -0,0 +1,46 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BH.Adapter.IES +{ + public static partial class Create + { + public static GEMTemplate SpaceTemplate() + { + return new GEMTemplate() + { + Layer = "1", + Colour = "0", + Category = "1", + Type = "1", + SubType = "2001", + ColourRGB = "16711690" + }; + } + } +} diff --git a/IES_Adapter/IESAdapter.cs b/IES_Adapter/IESAdapter.cs index f9fa06e..6cd1bf7 100644 --- a/IES_Adapter/IESAdapter.cs +++ b/IES_Adapter/IESAdapter.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -34,8 +34,6 @@ using System.ComponentModel; using BH.oM.Base.Attributes; -using BH.Engine.Adapters.IES; - namespace BH.Adapter.IES { public partial class IESAdapter : BHoMAdapter @@ -44,14 +42,15 @@ public partial class IESAdapter : BHoMAdapter /**** Constructors ****/ /***************************************************/ - [Description("Produces an IES Adapter to allow interopability with IES GEM files and the BHoM")] - [Input("fileSettings", "Input fileSettings to get the file name and directory the IES Adapter should use")] + [Description("Produces an IES Adapter to allow interopability with IES GEM files and the BHoM.")] + [Input("fileSettings", "Input fileSettings to get the file name and directory the IES Adapter should use.")] [Input("settingsIES", "Input additional settings the adapter should use.")] - [Output("adapter", "Adapter to IES GEM")] + [Output("adapter", "Adapter to IES GEM.")] public IESAdapter(BH.oM.Adapter.FileSettings fileSettings = null, SettingsIES settingsIES = null) { // This asks the base adapter to only Create the objects. m_AdapterSettings.DefaultPushType = oM.Adapter.PushType.CreateOnly; + m_AdapterSettings.UseAdapterId = false; if (fileSettings == null) { @@ -86,3 +85,4 @@ public IESAdapter(BH.oM.Adapter.FileSettings fileSettings = null, SettingsIES se + diff --git a/IES_Adapter/IES_Adapter.csproj b/IES_Adapter/IES_Adapter.csproj index e510140..23170a3 100644 --- a/IES_Adapter/IES_Adapter.csproj +++ b/IES_Adapter/IES_Adapter.csproj @@ -1,4 +1,4 @@ - + @@ -117,10 +117,20 @@ + + + + + + + + + + @@ -137,6 +147,7 @@ False + @@ -150,4 +161,4 @@ xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y --> - + \ No newline at end of file diff --git a/IES_Adapter/Objects/GEMTemplate.cs b/IES_Adapter/Objects/GEMTemplate.cs new file mode 100644 index 0000000..d26c2c9 --- /dev/null +++ b/IES_Adapter/Objects/GEMTemplate.cs @@ -0,0 +1,40 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BH.Adapter.IES +{ + public class GEMTemplate + { + public virtual string Layer { get; set; } + public virtual string Colour { get; set; } + public virtual string Category { get; set; } + public virtual string Type { get; set; } + public virtual string SubType { get; set; } + public virtual string ColourRGB { get; set; } + } +} diff --git a/IES_Adapter/Properties/AssemblyInfo.cs b/IES_Adapter/Properties/AssemblyInfo.cs index e46d579..e0a57ed 100644 --- a/IES_Adapter/Properties/AssemblyInfo.cs +++ b/IES_Adapter/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -55,6 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.0.0")] +[assembly: AssemblyFileVersion("6.1.0.0")] + diff --git a/IES_Adapter/Query/CoordinateSystem.cs b/IES_Adapter/Query/CoordinateSystem.cs new file mode 100644 index 0000000..202e42c --- /dev/null +++ b/IES_Adapter/Query/CoordinateSystem.cs @@ -0,0 +1,60 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Geometry.CoordinateSystem; +using BH.oM.Geometry; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using BH.Engine.Geometry; + +namespace BH.Adapter.IES +{ + public static partial class Query + { + public static Cartesian CoordinateSystem(this Polyline pLine, double distanceTolerance = Tolerance.MacroDistance, double angleTolerance = Tolerance.Angle) + { + Vector locZ = pLine.Normal(distanceTolerance); + + Cartesian baseCartesiean; + + if (locZ.IsParallel(Vector.ZAxis, angleTolerance) != 0) + baseCartesiean = new Cartesian(pLine.ControlPoints[0], -Vector.XAxis, locZ.CrossProduct(-Vector.XAxis), locZ); + else + { + Vector locY = (Vector.ZAxis - Vector.ZAxis.DotProduct(locZ) * locZ).Normalise(); + Vector locX = locY.CrossProduct(locZ); + baseCartesiean = new Cartesian(pLine.ControlPoints[0], locX, locY, locZ); + } + + TransformMatrix locGlob1 = BH.Engine.Geometry.Create.OrientationMatrixLocalToGlobal(baseCartesiean); + Point minPtLocal = pLine.ControlPoints.Select(x => x.Transform(locGlob1)).ToList().Bounds().Min; + TransformMatrix globToLoc = BH.Engine.Geometry.Create.OrientationMatrixGlobalToLocal(baseCartesiean); + baseCartesiean.Origin = minPtLocal.Transform(globToLoc); + + return baseCartesiean; + } + } +} diff --git a/IES_Engine/Convert/Environment/Opening.cs b/IES_Engine/Convert/Environment/Opening.cs deleted file mode 100644 index f9db9b5..0000000 --- a/IES_Engine/Convert/Environment/Opening.cs +++ /dev/null @@ -1,155 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using BH.oM.Geometry; -using BH.oM.Base.Attributes; -using System.ComponentModel; -using BH.oM.Environment.Elements; -using BH.Engine.Environment; -using BH.Engine.Geometry; -using BH.oM.IES.Settings; - -using BH.oM.Geometry.CoordinateSystem; - -namespace BH.Engine.Adapters.IES -{ - public static partial class Convert - { - - [Description("Convert a BHoM Environment Opening to an IES string representation of an opening for GEM format - this is for vertical openings (openings on walls)")] - [Input("opening", "The BHoM Environment Opening to convert")] - [Input("panelsAsSpace", "The panels representing a single space which hosts this opening, used to check the orientation of the opening")] - [Input("settingsIES", "The IES settings to use with the IES adapter")] - [Output("iesOpening", "The string representation for IES GEM format")] - public static List ToIES(this Opening opening, Panel hostPanel, List panelsAsSpace, SettingsIES settingsIES) - { - List gemOpening = new List(); - - Polyline openingCurve = opening.Polyline(); - Polyline hostCurve = hostPanel.Polyline(); - - if (hostCurve.ControlPoints.Select(x => x.Z).Max() == hostCurve.ControlPoints.Select(x => x.Z).Min()) - return opening.ToIES(hostPanel, settingsIES); //Horizontal openings are handled slightly differently - - Point panelBottomRightReference = hostPanel.BottomRight(panelsAsSpace); - Point panelBottomLeftReference = hostPanel.BottomLeft(panelsAsSpace); - Point panelTopRightReference = hostPanel.TopRight(panelsAsSpace); - - Vector xVector = panelBottomLeftReference - panelBottomRightReference; - xVector.Z = 0; - Vector yVector = panelTopRightReference - panelBottomRightReference; - - Point worldOrigin = new Point { X = 0, Y = 0, Z = 0 }; - Cartesian worldCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(worldOrigin, Vector.XAxis, Vector.YAxis); - Cartesian localCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(panelBottomRightReference, xVector, yVector); - - Polyline hostTransformed = hostCurve.Orient(localCartesian, worldCartesian); - Polyline openingTranslated = openingCurve.Orient(localCartesian, worldCartesian); - - //If the orientation to 0,0,0 returns a negative X or Y point, translate the opening appropriately so that the bottom right reference would (if we wanted it) become 0,0,0 of the bounds of the host panel - double minX = hostTransformed.ControlPoints.Select(x => x.X).Min(); - double minY = hostTransformed.ControlPoints.Select(x => x.Y).Min(); - if (minX < 0) - { - Vector translateVectorX = new Vector { X = -minX, Y = 0, Z = 0 }; - openingTranslated = openingTranslated.Translate(translateVectorX); - } - if (minY < 0) - { - Vector translateVectorY = new Vector { X = 0, Y = -minY, Z = 0 }; - openingTranslated = openingTranslated.Translate(translateVectorY); - } - - List vertices = openingTranslated.IDiscontinuityPoints(); - gemOpening.Add(vertices.Count.ToString() + " " + opening.Type.ToIES(settingsIES) + "\n"); - - foreach (Point p in vertices) - gemOpening.Add(" " + Math.Abs(Math.Round(p.X, settingsIES.DecimalPlaces)).ToString() + " " + Math.Abs(Math.Round(p.Y, settingsIES.DecimalPlaces)).ToString() + "\n"); - - return gemOpening; - } - - [Description("Convert a BHoM Environment Opening to an IES string representation of an opening for GEM format - this is for horizontal openings (openings on roofs and floors)")] - [Input("opening", "The BHoM Environment Opening to convert")] - [Input("settingsIES", "The IES settings to use with the IES adapter")] - [Output("iesOpening", "The string representation for IES GEM format")] - public static List ToIES(this Opening opening, Panel hostPanel, SettingsIES settingsIES) - { - List gemOpening = new List(); - - Point zeroReference = null; - BoundingBox bounds = hostPanel.Bounds(); - Vector xVector = new Vector { X = -1, Y = 0, Z = 0 }; - Vector yVector = new Vector { X = 0, Y = 1, Z = 0 }; - - if (hostPanel.Type == PanelType.Floor || hostPanel.Type == PanelType.FloorExposed || hostPanel.Type == PanelType.FloorRaised) - zeroReference = new Point { X = bounds.Max.X, Y = bounds.Min.Y, Z = bounds.Min.Z }; - else - { - zeroReference = new Point { X = bounds.Max.X, Y = bounds.Max.Y, Z = bounds.Max.Z }; - yVector.Y = -1; - } - - Polyline openingCurve = opening.Polyline(); - - Point worldOrigin = new Point { X = 0, Y = 0, Z = 0 }; - Cartesian worldCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(worldOrigin, Vector.XAxis, Vector.YAxis); - Cartesian localCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(zeroReference, xVector, yVector); - - Polyline openingTranslated = openingCurve.Orient(localCartesian, worldCartesian); - - List vertices = openingTranslated.IDiscontinuityPoints(); - gemOpening.Add(vertices.Count.ToString() + " " + opening.Type.ToIES(settingsIES) + "\n"); - - foreach (Point p in vertices) - gemOpening.Add(" " + Math.Abs(p.X).ToString() + " " + Math.Abs(p.Y).ToString() + "\n"); - - return gemOpening; - } - - [Description("Convert an IES string representation of an opening to a BHoM Environment Opening")] - [Input("openingPts", "The string representations of coordinates that make up the opening")] - [Input("openingType", "The IES representation of the opening type")] - [Input("settingsIES", "The IES settings to use with the IES adapter")] - [Output("opening", "The BHoM Environment Opening converted from IES GEM format")] - public static Opening FromIES(this List openingPts, string openingType, SettingsIES settingsIES) - { - List points = openingPts.Select(x => x.FromIES(settingsIES)).ToList(); - points.Add(points.First()); - - Polyline pLine = new Polyline { ControlPoints = points, }; - - Opening opening = new Opening(); - opening.Edges = pLine.ToEdges(); - opening.Type = openingType.FromIESOpeningType(settingsIES); - - return opening; - } - } -} - diff --git a/IES_Engine/IES_Engine.csproj b/IES_Engine/IES_Engine.csproj index 2992e4a..2eb4dca 100644 --- a/IES_Engine/IES_Engine.csproj +++ b/IES_Engine/IES_Engine.csproj @@ -1,4 +1,4 @@ - + @@ -85,14 +85,7 @@ - - - - - - - @@ -118,4 +111,4 @@ xcopy "$(ProjectDir)Extensions" "C:\ProgramData\BHoM\Extensions\CFD" /E /Y /I --> - + \ No newline at end of file diff --git a/IES_Engine/Modify/RepairOpening.cs b/IES_Engine/Modify/RepairOpening.cs deleted file mode 100644 index a8a1907..0000000 --- a/IES_Engine/Modify/RepairOpening.cs +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using BH.oM.Geometry; -using BH.oM.Environment.Elements; - -using BH.Engine.Environment; -using BH.Engine.Geometry; - -using System.ComponentModel; -using BH.oM.Base.Attributes; - -using BH.oM.Geometry.CoordinateSystem; - -using BH.Engine.Base; - -namespace BH.Engine.Adapters.IES -{ - public static partial class Modify - { - [Description("The openings when converted from IES do not have the right coordinates for 3D space, this method will repair them.")] - [Input("opening", "The broken environment opening pulled from IES.")] - [Input("host", "The host panel for the opening.")] - [Input("panelsAsSpace", "A collection of panels defining the space around the opening.")] - [Output("repairedOpening", "The repaired environment opening.")] - public static Opening RepairOpening(this Opening opening, Panel host, List panelsAsSpace) - { - Polyline openingCurve = opening.Polyline(); - Polyline hostCurve = host.Polyline(); - - if (hostCurve.ControlPoints.Select(x => x.Z).Max() == hostCurve.ControlPoints.Select(x => x.Z).Min()) - { - //Horizontal openings are handled slightly differently - if (panelsAsSpace.Select(x => x.Polyline().ControlPoints.Select(y => y.Z).Max()).Max() == hostCurve.ControlPoints.Select(x => x.Z).Max()) - return opening.RepairOpening(host, PanelType.Roof); //If the maximum Z level of the space is equal to the Z level of this panel - else - return opening.RepairOpening(host, PanelType.Floor); - } - - Point panelBottomRightReference = host.BottomRight(panelsAsSpace); - Point panelBottomLeftReference = host.BottomLeft(panelsAsSpace); - Point panelTopRightReference = host.TopRight(panelsAsSpace); - - if(panelBottomRightReference == null || panelBottomLeftReference == null || panelTopRightReference == null) - { - BH.Engine.Base.Compute.RecordWarning("An error occurred in attempting to repair opening with GUID " + opening.BHoM_Guid + " hosted by the panel with GUID " + host.BHoM_Guid + " . The opening on this panel may not be correctly pulled and should be investigated."); - return opening; - } - - Vector xVector = panelBottomLeftReference - panelBottomRightReference; - xVector.Z = 0; - Vector yVector = panelTopRightReference - panelBottomRightReference; - - Point worldOrigin = new Point { X = 0, Y = 0, Z = 0 }; - Cartesian worldCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(worldOrigin, Vector.XAxis, Vector.YAxis); - Cartesian localCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(panelBottomRightReference, xVector, yVector); - - Polyline hostTransformed = hostCurve.Orient(localCartesian, worldCartesian); - Polyline openingTranslated = openingCurve.DeepClone(); - - //If the orientation to 0,0,0 returns a negative X or Y point, translate the opening appropriately so that the bottom right reference would (if we wanted it) become 0,0,0 of the bounds of the host panel - double minX = hostTransformed.ControlPoints.Select(x => x.X).Min(); - double minY = hostTransformed.ControlPoints.Select(x => x.Y).Min(); - if (minX < 0) - { - Vector translateVectorX = new Vector { X = minX, Y = 0, Z = 0 }; - openingTranslated = openingTranslated.Translate(translateVectorX); - } - if(minY < 0) - { - Vector translateVectorY = new Vector { X = 0, Y = minY, Z = 0 }; - openingTranslated = openingTranslated.Translate(translateVectorY); - } - - Polyline openingTransformed = openingTranslated.Orient(worldCartesian, localCartesian); - - Opening newOpening = opening.ShallowClone(); - newOpening.Edges = openingTransformed.ToEdges(); - - return newOpening; - } - - [Description("The openings when converted from IES do not have the right coordinates for 3D space, this method will repair them. This method is for horizontal openings (openings on roofs and floors)")] - [Input("opening", "The broken environment opening pulled from IES.")] - [Input("hostPanel", "The host panel for the opening.")] - [Input("hostType", "Determines whether the host panel is the floor of the space it is part of, or the ceiling.")] - [Output("repairedOpening", "The repaired environment opening.")] - public static Opening RepairOpening(this Opening opening, Panel hostPanel, PanelType hostType) - { - Point zeroReference = null; - BoundingBox bounds = hostPanel.Bounds(); - Vector xVector = new Vector { X = -1, Y = 0, Z = 0 }; - Vector yVector = new Vector { X = 0, Y = 1, Z = 0 }; - - if (hostType == PanelType.Floor || hostType == PanelType.FloorExposed || hostType == PanelType.FloorRaised) - zeroReference = new Point { X = bounds.Max.X, Y = bounds.Min.Y, Z = bounds.Min.Z }; - else - { - zeroReference = new Point { X = bounds.Max.X, Y = bounds.Max.Y, Z = bounds.Max.Z }; - yVector.Y = -1; - } - - Polyline openingCurve = opening.Polyline(); - - Point worldOrigin = new Point { X = 0, Y = 0, Z = 0 }; - Cartesian worldCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(worldOrigin, Vector.XAxis, Vector.YAxis); - Cartesian localCartesian = BH.Engine.Geometry.Create.CartesianCoordinateSystem(zeroReference, xVector, yVector); - - Polyline openingTranslated = openingCurve.Orient(worldCartesian, localCartesian); - - Opening newOpening = opening.ShallowClone(); - newOpening.Edges = openingTranslated.ToEdges(); - - return newOpening; - } - } -} - diff --git a/IES_Engine/Properties/AssemblyInfo.cs b/IES_Engine/Properties/AssemblyInfo.cs index 0801227..255eca6 100644 --- a/IES_Engine/Properties/AssemblyInfo.cs +++ b/IES_Engine/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -55,6 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.0.0")] +[assembly: AssemblyFileVersion("6.1.0.0")] + diff --git a/IES_Engine/Query/Polyline.cs b/IES_Engine/Query/Polyline.cs deleted file mode 100644 index dd5a78c..0000000 --- a/IES_Engine/Query/Polyline.cs +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using BH.oM.Geometry; -using System; -using System.Collections.Generic; -using System.Linq; - -using BH.oM.Base.Attributes; -using System.ComponentModel; -using BH.Engine.Geometry; - -namespace BH.Engine.Adapters.IES -{ - public static partial class Query - { - /***************************************************/ - /**** Public Methods - Bounding Box ****/ - /***************************************************/ - - [Description("Get a 2d polyline representation of a BHoM BoundingBox")] - [Input("box", "The BHoM bounding box")] - [Output("polyline", "The 2d polyline representation of the box")] - public static Polyline Polyline(this BoundingBox box) - { - Point min = box.Min.RoundCoordinates(); - Point max = box.Max.RoundCoordinates(); - - double minDist = Math.Min(max.X - min.X, max.Y - min.Y); - minDist = Math.Min(minDist, max.Z - min.Z); - - List pnts = new List(); - pnts.Add(min); - - if((max.X - min.X) == minDist || (max.Z - min.Z) == minDist) - { - //YZ plane - double x1 = min.Z; - double x2 = max.Z; - double y1 = min.Y; - double y2 = max.Y; - - double xc = (x1 + x2) / 2; - double xd = (x1 - x2) / 2; - - double yc = (y1 + y2) / 2; - double yd = (y1 - y2) / 2; - - double x3 = xc - yd; - double x4 = xc + yd; - double y3 = yc + xd; - double y4 = yc - xd; - - pnts.Add(new Point { X = min.X, Y = y3, Z = x3 }); - pnts.Add(max); - pnts.Add(new Point { X = max.X, Y = y4, Z = x4 }); - } - else if ((max.Y - min.Y) == minDist) - { - //XZ - double x1 = min.X; - double x2 = max.X; - double y1 = min.Z; - double y2 = max.Z; - - double xc = (x1 + x2) / 2; - double xd = (x1 - x2) / 2; - - double yc = (y1 + y2) / 2; - double yd = (y1 - y2) / 2; - - double x3 = xc - yd; - double x4 = xc + yd; - double y3 = yc + xd; - double y4 = yc - xd; - - pnts.Add(new Point { X = x3, Y = min.Y, Z = y3 }); - pnts.Add(max); - pnts.Add(new Point { X = x4, Y = max.Y, Z = y4 }); - } - else - { - double x1 = min.X; - double x2 = max.X; - double y1 = min.Y; - double y2 = max.Y; - - double xc = (x1 + x2) / 2; - double xd = (x1 - x2) / 2; - - double yc = (y1 + y2) / 2; - double yd = (y1 - y2) / 2; - - double x3 = xc - yd; - double x4 = xc + yd; - double y3 = yc + xd; - double y4 = yc - xd; - - pnts.Add(new Point { X = x3, Y = y3, Z = min.Z }); - pnts.Add(max); - pnts.Add(new Point { X = x4, Y = y4, Z = max.Z }); - } - - pnts.Add(min); - - return new Polyline { ControlPoints = pnts }; - } - } -} - - diff --git a/IES_Engine/Versioning_61.json b/IES_Engine/Versioning_61.json new file mode 100644 index 0000000..18ef4f0 --- /dev/null +++ b/IES_Engine/Versioning_61.json @@ -0,0 +1,50 @@ +{ + "Namespace": { + "ToNew": { + }, + "ToOld": { + } + }, + "Type": { + "ToNew": { + + }, + "ToOld": { + + } + }, + "Method": { + "ToNew": { + + }, + "ToOld": { + } + }, + "Property": { + "ToNew": { + + }, + "ToOld": { + + } + }, + "MessageForDeleted": { + "BH.Engine.Adapters.IES.Convert.ToIES(BH.oM.Geometry.Point, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.ToIES(System.Collections.Generic.List, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.ToIES(BH.oM.Environment.Elements.OpeningType, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.ToIES(BH.oM.Environment.Elements.Opening, BH.oM.Environment.Elements.Panel, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.ToIES(BH.oM.Environment.Elements.Opening, BH.oM.Environment.Elements.Panel, System.Collections.Generic.List, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.FromIES(System.String, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.FromIES(System.Collections.Generic.List, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.FromIES(System.Collections.Generic.List, System.String, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.FromIESOpeningType(System.String, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.FromIESShading(System.Collections.Generic.List, BH.oM.IES.Settings.SettingsIES, BH.oM.Environment.Elements.PanelType)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Convert.ToIESShading(System.Collections.Generic.List, BH.oM.IES.Settings.SettingsIES)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Query.Polyline(BH.oM.Geometry.BoundingBox)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Modify.RepairOpening(BH.oM.Environment.Elements.Opening, BH.oM.Environment.Elements.Panel, BH.oM.Environment.Elements.PanelType)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + "BH.Engine.Adapters.IES.Modify.RepairOpening(BH.oM.Environment.Elements.Opening, BH.oM.Environment.Elements.Panel, System.Collections.Generic.List)" : "This method has been moved into the adapter to be handled internally and prevent UI clutter of methods. If this method is needed for script work independently of the adapter, please raise an issue at: https://github.com/BHoM/IES_Toolkit", + }, + "MessageForNoUpgrade": { + + } +} \ No newline at end of file diff --git a/IES_oM/Fragments/SurfaceIndexFragment.cs b/IES_oM/Fragments/SurfaceIndexFragment.cs index d099b67..0a8b933 100644 --- a/IES_oM/Fragments/SurfaceIndexFragment.cs +++ b/IES_oM/Fragments/SurfaceIndexFragment.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -38,3 +38,4 @@ public class SurfaceIndexFragment : IFragment } } + diff --git a/IES_oM/Properties/AssemblyInfo.cs b/IES_oM/Properties/AssemblyInfo.cs index fbfe063..38ccb0f 100644 --- a/IES_oM/Properties/AssemblyInfo.cs +++ b/IES_oM/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -55,6 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.0.0")] +[assembly: AssemblyFileVersion("6.1.0.0")] + diff --git a/IES_oM/SettingsIES.cs b/IES_oM/SettingsIES.cs index a0c9734..15b1fbe 100644 --- a/IES_oM/SettingsIES.cs +++ b/IES_oM/SettingsIES.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -24,6 +24,7 @@ using System.Collections.Generic; using BH.oM.Base; using System.ComponentModel; +using BH.oM.Geometry; namespace BH.oM.IES.Settings { @@ -45,8 +46,13 @@ public class SettingsIES : BHoMObject public virtual bool ShadesAs3D { get; set; } = true; + public virtual double AngleTolerance { get; set; } = BH.oM.Geometry.Tolerance.Angle; + + public virtual double DistanceTolerance { get; set; } = BH.oM.Geometry.Tolerance.MacroDistance; + /***************************************************/ } } +