//---------------------------------------------------------------------------------------------------- //Here Come the Methods private MassObject BrepToMassObject(Brep brep) { MassObject mass_object = new MassObject(brep); BoundingBox bbox = brep.GetBoundingBox(true); mass_object.CenterPoint = bbox.Center; mass_object.XComp = bbox.Center.X; mass_object.YComp = bbox.Center.Y; mass_object.ZComp = bbox.Center.Z; mass_object.Height = bbox.Diagonal.Z; mass_object.Area = ComputeFloorSurfaces(brep).Item2.GetArea(); return(mass_object); }
// looping through all givien breps and converting all to MassObjects adn giving each of them IDs private void ConvertBrepListToMassObjects(List <Brep> breps) { List <MassObject> massObjects = new List <MassObject>(); for (int i = 0; i < breps.Count; i++) { Brep brep = breps[i]; MassObject mObject = BrepToMassObject(brep); // Giving all massObjects an id with the iterator mObject.MassId = i; massObjects.Add(mObject); } Globals.MassObjects = massObjects; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> /// protected override void SolveInstance(IGH_DataAccess DA) { // First, we need to retrieve all data from the input parameters. // We'll start by declaring variables and assigning them starting values. List <Brep> breps = new List <Brep>(); double PanelWidth = 0.0; int massId = 0; List <Point3d> pnts = new List <Point3d>(); // Then we need to access the input parameters individually. // When data cannot be extracted from a parameter, we should abort this method. if (!DA.GetDataList(0, breps)) { return; } if (!DA.GetData(1, ref PanelWidth)) { return; } if (!DA.GetData(2, ref massId)) { return; } // We should now validate the data and warn the user if invalid data is supplied. if (breps.Count < 1) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Number of breps need to exceed 1"); return; } if (PanelWidth < 0.5) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Panel Width Should be larger than 0.5"); return; } // We're set to create the Mesh Facade now. To keep the size of the SolveInstance() method small, // The actual functionality will be in a different method: //Step 1 Sort breps //Brep[] sBreps = SortBrepByFloor(breps); //Step 2 Compute Sorted Floor Heights //double[] sHeights = ComputeFloorHeights(breps); //Step 3 Compute Order of House Ids //ComputeHouseIds(breps); ConvertBrepListToMassObjects(breps); ClusterMassesIntoBuildings(); MassObject massobject = Globals.MassObjects[massId]; int MyBuildingId = massobject.BuildingNumber; int MyMassId = massobject.MassId; double MyMassHeight = massobject.Height; int MyMassHouseNumber = massobject.HouseNumber; //Step 3 Make mesh //Mesh mesh = MakeMeshFaces(breps, PanelWidth, out pnts); //Step 4 Display BottomFaces //List<Brep> bottomFaces = DisplayAllBottomSurfaces(breps); //Step 5 Save data onto each face // for now we will just test this by sending teh data for the floor level, // later we will instead send over the window object as a whole // then create another compnenet that reads that data and does something with it. /* * WindowElement WindowInstance = new WindowElement(); * WindowElement window10 = WindowInstance.InitiateWindow(WindowId); * int floorNumber = window10.FloorNumber; * int windowNumber = window10.WindowId; * int EdgeNumber = window10.EdgeNumber; * int HouseNumber = window10.HouseNumber; */ // Finally assign the spiral to the output parameter. //DA.SetData(0, mesh); //DA.SetDataList(1, bottomFaces); //DA.SetDataList(2, pnts); DA.SetData(0, MyBuildingId); DA.SetData(1, MyMassId); DA.SetData(2, MyMassHeight); DA.SetData(3, MyMassHouseNumber); }