/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess"> /// The DA object is used to retrieve from inputs and store in outputs. /// </param> protected override void SolveInstance(IGH_DataAccess dataAccess) { bool run = false; if (!dataAccess.GetData(6, ref run)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); dataAccess.SetData(2, false); return; } if (!run) { return; } List <Panel> panels = new List <Panel>(); if (!dataAccess.GetDataList(0, panels) || panels == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); dataAccess.SetData(2, false); return; } List <Space> spaces = new List <Space>(); dataAccess.GetDataList(1, spaces); double tolerance = double.NaN; if (!dataAccess.GetData(2, ref tolerance) || double.IsNaN(tolerance)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); dataAccess.SetData(2, false); return; } bool tryCellComplexByCells = false; if (!dataAccess.GetData(3, ref tryCellComplexByCells)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); dataAccess.SetData(2, false); return; } //string reportPath = null; //if (dataAccess.GetData(4, ref reportPath)) //{ // if (System.IO.File.Exists(reportPath)) // System.IO.File.Delete(reportPath); //} double minArea = Tolerance.MacroDistance; dataAccess.GetData(4, ref minArea); double silverSpacing = Tolerance.MacroDistance; dataAccess.GetData(5, ref silverSpacing); List <Topology> topologies = null; Log log = new Log(); List <Panel> panels_Redundant = null; AdjacencyCluster adjacencyCluster = Analytical.Topologic.Create.AdjacencyCluster(spaces, panels, out topologies, out panels_Redundant, minArea, true, tryCellComplexByCells, log, silverSpacing, tolerance); if (adjacencyCluster != null) { List <Space> spaces_Temp = adjacencyCluster.GetSpaces(); if (spaces_Temp == null || spaces_Temp.Count == 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No spaces have been detected"); } else { List <Point3D> locations = spaces_Temp.ConvertAll(x => x.Location); if (locations.RemoveAll(x => x == null) > 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "There are spaces without Location Points"); } List <Space> spaces_Unbounded = new List <Space>(); List <Space> spaces_Multiple = new List <Space>(); HashSet <int> indexes_Multiple = new HashSet <int>(); List <List <Space> > spacesList_Locations = adjacencyCluster.GetSpaces(locations); for (int i = 0; i < spacesList_Locations.Count; i++) { List <Space> spaces_Locations = spacesList_Locations[i]; Point3D point3D_Location = locations[i]; if (spaces_Locations == null) { spaces_Unbounded.Add(spaces_Temp.Find(x => point3D_Location.AlmostEquals(x.Location))); continue; } if (spacesList_Locations.Count > 2) { indexes_Multiple.Add(i); } } foreach (Space space in spaces_Unbounded) { string text = "There are unbounded spaces in topology model"; if (!string.IsNullOrWhiteSpace(space.Name)) { text += " " + space.Name; } text += " " + "Guid: " + space.Guid; AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, text); } foreach (Space space in spaces_Multiple) { string text = "There are multiple spaces in topology cell"; if (!string.IsNullOrWhiteSpace(space.Name)) { text += " " + space.Name; } text += " " + "Guid: " + space.Guid; AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, text); } } dataAccess.SetData(0, new GooAdjacencyCluster(adjacencyCluster)); } else { dataAccess.SetData(0, null); } dataAccess.SetDataList(1, topologies); dataAccess.SetDataList(2, adjacencyCluster?.GetPanels()); dataAccess.SetDataList(3, adjacencyCluster?.GetSpaces()); dataAccess.SetDataList(4, adjacencyCluster?.GetInternalPanels()); dataAccess.SetDataList(5, adjacencyCluster?.GetExternalPanels()); dataAccess.SetDataList(6, adjacencyCluster?.GetShadingPanels()); dataAccess.SetDataList(7, panels_Redundant); dataAccess.SetData(8, new GooLog(log)); dataAccess.SetData(9, adjacencyCluster != null); }