From 7d00ca4ffe12503e05f9431fa1fed80f02a7ebc0 Mon Sep 17 00:00:00 2001 From: Erik Narhi Date: Wed, 24 Jun 2020 17:01:30 -0700 Subject: [PATCH] Stories tweaked and check added for overlapping wall openings --- RAM_Adapter/CRUD/Create.cs | 63 +++++++++++++++++++++++++---------- RAM_Adapter/Convert/ToBHoM.cs | 2 +- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/RAM_Adapter/CRUD/Create.cs b/RAM_Adapter/CRUD/Create.cs index 54432a7..ca0cc27 100644 --- a/RAM_Adapter/CRUD/Create.cs +++ b/RAM_Adapter/CRUD/Create.cs @@ -523,22 +523,46 @@ private bool CreateCollection(IEnumerable bhomPanels) if ((openMin.Z.ToInch() >= ramStory.dElevation - ramStory.dFlrHeight) && (openMin.Z.ToInch() < ramStory.dElevation)) { - //Get opening on wall extents - if (!(outline.IsContaining(openOutline, false))) + IFinalWallOpenings ramWallOpenings = ramWall.GetFinalOpenings(); + + int openOverlapCount = 0; + + for (int j = 0; i < ramWallOpenings.GetCount(); j++) { - openOutline = outline.BooleanIntersection(openOutline)[0]; - Engine.Reflection.Compute.RecordWarning("Panel " + name + " opening intersects wall boundary. Boolean intersection was used to get opening extents on panel."); + IFinalWallOpening testOpen = ramWallOpenings.GetAt(j); + IPoints openingPts = testOpen.GetOpeningVertices(); + + //Re-add first point to close Polygon + IPoint firstOPt = openingPts.GetAt(0); + SCoordinate firstOCoord = new SCoordinate(); + firstOPt.GetCoordinate(ref firstOCoord); + openingPts.Add(firstOCoord); + + Polyline wallOpeningOutline = openingPts.ToPolyline(); + List intPts = wallOpeningOutline.ICurveIntersections(openOutline); + if (wallOpeningOutline.IsContaining(openOutline) || openOutline.IsContaining(wallOpeningOutline) || intPts.Count > 0) + { openOverlapCount += 1; } } - Point closestOpenPt = BH.Engine.Geometry.Query.ClosestPoint(wallMin, openOutline.ControlPoints()); - double distX = Math.Sqrt(Math.Pow(closestOpenPt.X - wallMin.X, 2) + Math.Pow(closestOpenPt.Y - wallMin.Y, 2)); - double distZinch = openBounds.Min.Z.ToInch() - (ramStory.dElevation - ramStory.dFlrHeight); - double openWidth = Math.Sqrt(Math.Pow(openBounds.Max.X - openBounds.Min.X, 2) + Math.Pow(openBounds.Max.Y - openBounds.Min.Y, 2)); - double openHt = openBounds.Max.Z - openBounds.Min.Z; - - //Add opening to RAM - IRawWallOpenings ramWallOpenings = ramWall.GetRawOpenings(); - ramWallOpenings.Add(EDA_MEMBER_LOC.eBottomStart, distX.ToInch(), distZinch, openWidth.ToInch(), openHt.ToInch()); + if (openOverlapCount == 0) + { + //Get opening on wall extents + if (!(outline.IsContaining(openOutline, false))) + { + openOutline = outline.BooleanIntersection(openOutline)[0]; + Engine.Reflection.Compute.RecordWarning("Panel " + name + " opening intersects wall boundary. Boolean intersection was used to get opening extents on panel."); + } + + Point closestOpenPt = BH.Engine.Geometry.Query.ClosestPoint(wallMin, openOutline.ControlPoints()); + double distX = Math.Sqrt(Math.Pow(closestOpenPt.X - wallMin.X, 2) + Math.Pow(closestOpenPt.Y - wallMin.Y, 2)); + double distZinch = openBounds.Min.Z.ToInch() - (ramStory.dElevation - ramStory.dFlrHeight); + double openWidth = Math.Sqrt(Math.Pow(openBounds.Max.X - openBounds.Min.X, 2) + Math.Pow(openBounds.Max.Y - openBounds.Min.Y, 2)); + double openHt = openBounds.Max.Z - openBounds.Min.Z; + + //Add opening to RAM + IRawWallOpenings ramRawWallOpenings = ramWall.GetRawOpenings(); + ramRawWallOpenings.Add(EDA_MEMBER_LOC.eBottomStart, distX.ToInch(), distZinch, openWidth.ToInch(), openHt.ToInch()); + } } } } @@ -592,17 +616,20 @@ private bool CreateCollection(IEnumerable bhomLevels) for (int i = 0; i < sortedBhomLevels.Count(); i++) { Level level = sortedBhomLevels.ElementAt(i); - double levelHt = level.Elevation.ToInch(); + double levelHtDbl = level.Elevation.ToInch(); + double levelHt = Math.Round(levelHtDbl, 3); // Get elevations and skip if level elevation already in RAM ramStories = m_Model.GetStories(); List ramElevs = new List(); + List ramStoryNames = new List(); for (int j = 0; j < ramStories.GetCount(); j++) { ramElevs.Add(ramStories.GetAt(j).dElevation); + ramStoryNames.Add(ramStories.GetAt(j).strLabel); } - if (ramElevs.Contains(levelHt) != true) + if (ramElevs.Contains(levelHt) != true && ramStoryNames.Contains(level.Name) != true) { double height; // Ground floor ht = 0 for RAM @@ -631,9 +658,10 @@ private bool CreateCollection(IEnumerable bhomLevels) Boolean floorTypeExists = false; for (int j = 0; j < ramFloorTypes.GetCount(); j++) { - if (ramFloorTypes.GetAt(j).strLabel == level.Name) + IFloorType testFloorType = ramFloorTypes.GetAt(j); + if (testFloorType.strLabel == level.Name) { - ramFloorType = ramFloorTypes.GetAt(j); + ramFloorType = testFloorType; floorTypeExists = true; } } @@ -653,7 +681,6 @@ private bool CreateCollection(IEnumerable bhomLevels) { IStory ramStoryBelow = ramStories.GetAt(newIndex - 1); height = levelHt - ramStoryBelow.dElevation; - } // Insert story at index diff --git a/RAM_Adapter/Convert/ToBHoM.cs b/RAM_Adapter/Convert/ToBHoM.cs index bdc91aa..92ba6be 100644 --- a/RAM_Adapter/Convert/ToBHoM.cs +++ b/RAM_Adapter/Convert/ToBHoM.cs @@ -537,7 +537,7 @@ public static Panel ToBHoMObject(this IWall ramWall) List wallOpeningPLs = new List(); List bhomWallOpenings = new List(); - // Create openings (disabled, causing database freeze) + // Create openings IFinalWallOpenings IFinalWallOpenings = ramWall.GetFinalOpenings(); IRawWallOpenings rawOpenings = ramWall.GetRawOpenings(); if (rawOpenings.GetCount() > 0)