Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.1 Deployment #211

Merged
merged 27 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b1b04e0
Upgrade AssemblyFileVersion to 6.1.0.0
BHoMBot Jan 3, 2023
5e5db91
Update copyright headers to 2023
BHoMBot Jan 4, 2023
cbbbd9a
Initial commit of clean up for Karolina to take on in opening conversion
Jan 24, 2023
021beda
Creating new methods
kprusicka Jan 24, 2023
72c2852
Creating new methods v2
kprusicka Jan 24, 2023
5f7b8dc
Modifying new methods
kprusicka Jan 25, 2023
71a84f5
Update csproj
kprusicka Jan 25, 2023
832a6fd
Make work in adapter - lots of incompliant code though
Jan 25, 2023
eeadc82
Trying to fix the windows
kprusicka Jan 27, 2023
9e76caf
Implementation of coordinate system from @isaknaslundbh and tidy up o…
Jan 31, 2023
8a8903f
Add copyright headers to new files
Jan 31, 2023
fc14de9
Update formatting
Jan 31, 2023
29fbc56
Make use of templates for Space and Shade
Jan 31, 2023
534a808
Include some versioning for the deleted methods
Jan 31, 2023
61a7a3d
Fix normal away from space check
Feb 1, 2023
4a50a6d
Adding pull
kprusicka Feb 2, 2023
01b97c2
Adding pull tolerances
kprusicka Feb 3, 2023
bf77785
Turning on the 2D shades
kprusicka Feb 3, 2023
2513f9b
Layer was attribute was already changed to Layer 64, and I have chang…
EKAdebo Feb 24, 2023
e4859e2
Changed Shade layer in GEMTemplate
EKAdebo Feb 24, 2023
64519fc
Call me GhostBusters because we just removed some Ghost Spaces #212
Mar 16, 2023
e616fd0
Tidy up properties
Mar 16, 2023
5482865
Set AdapterID to false
CKBoulter Mar 17, 2023
3170721
Fixed punctuation.
CKBoulter Mar 17, 2023
84b1947
Fix #218
Mar 21, 2023
e89f2a8
Fix #217
Mar 21, 2023
2ecd9d4
Fix formatting issues in GEM create
Mar 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions IES_Adapter/CRUD/Create.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -30,7 +30,6 @@
using System.IO;

using System.Linq;
using BH.Engine.Adapters.IES;

using BH.oM.Adapter;
using BH.Engine.Adapter;
Expand Down Expand Up @@ -58,6 +57,11 @@ protected override bool ICreate<T>(IEnumerable<T> 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<Panel> space in panelsAsSpaces)
Expand All @@ -83,3 +87,4 @@ protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionCo
}



4 changes: 2 additions & 2 deletions IES_Adapter/CRUD/Read.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -32,7 +32,6 @@
using BH.oM.Environment;

using System.IO;
using BH.Engine.Adapters.IES;

using BH.oM.Adapter;
using BH.Engine.Adapter;
Expand Down Expand Up @@ -185,3 +184,4 @@ private List<Space> ReadSpaces(List<Panel> panels)
}



75 changes: 75 additions & 0 deletions IES_Adapter/Convert/Environment/Opening.cs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

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<string> ToIES(this Opening opening, Panel hostPanel, SettingsIES settingsIES)
{
List<string> rtn = new List<string>();

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<string> 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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,32 +20,28 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

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:
Expand Down Expand Up @@ -80,4 +76,3 @@ public static OpeningType FromIESOpeningType(this string iesOpeningType, Setting
}
}
}

Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
{
Expand All @@ -53,25 +53,12 @@ public static List<string> ToIESShading(this List<Panel> 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<Point> points = panels[x].Vertices().Select(y => y.RoundCoordinates(settingsIES.DecimalPlaces)).ToList();
Expand All @@ -80,14 +67,14 @@ public static List<string> ToIESShading(this List<Panel> 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");
Expand All @@ -96,11 +83,11 @@ public static List<string> ToIESShading(this List<Panel> 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<Panel> { 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")]
Expand All @@ -116,17 +103,17 @@ public static Panel FromIESShading(this List<string> iesPanel, SettingsIES setti
List<string> iesPoints = new List<string>(); //Add the coordinate pts to a list
for (int x = 0; x < numCoordinates; x++)
iesPoints.Add(iesPanel[x + 2]);

List<Point> 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
List<string> panelCoord = iesPanel[count].Trim().Split(' ').ToList();
List<Point> pLinePts = new List<Point>();
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, };
Expand All @@ -150,13 +137,13 @@ public static Panel FromIESShading(this List<string> 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
Expand All @@ -172,10 +159,11 @@ public static Panel FromIESShading(this List<string> iesPanel, SettingsIES setti
else
{
panel.Openings = new List<Opening>();
}
}*/

return panel;
}
}
}


Loading