/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Brep trimmed = null; bool shouhui = false; if (!DA.GetData(0, ref trimmed) || !DA.GetData(1, ref shouhui)) { return; } ////////////////////////////////////////////////// if (shouhui) { Rhino.Geometry.Collections.BrepFaceList bf = trimmed.Faces; bf.ShrinkFaces(); List <Surface> sfs = new List <Surface>(); for (int i = 0; i < bf.Count; i++) { BrepFace bb = bf[i]; Surface sf = bb.DuplicateSurface(); sfs.Add(sf); } DA.SetDataList(0, sfs); } else { trimmed.Faces.ShrinkFaces(); DA.SetData(0, trimmed); } }
/// <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) { //Create class instances ObjectModel.MultiFamily MFH = new ObjectModel.MultiFamily(); //Get Data if (!DA.GetData(0, ref MFH)) { return; } //Calculate (shapeFactor = envelopArea/Atemp). Only works for breps with the same floor geometry on every floor. double envelopArea = AreaMassProperties.Compute(MFH.HouseGeom).Area; Rhino.Geometry.Collections.BrepFaceList faces = MFH.HouseGeom.Faces; double floorArea = 0; foreach (var face in faces) { if (face.NormalAt(0.5, 0.5) == new Vector3d(0, 0, -1)) { floorArea = AreaMassProperties.Compute(face).Area; } ; } double shapefactor = envelopArea / (floorArea * MFH.Floors); //Should be the actual number of floors. //Set data DA.SetData(0, shapefactor); }
/* * private void ComputeHouseIds(List<Brep> ListOfBreps) * { * double threshold = 10.0; * Brep[] SortedBreps = Globals.SortedBreps; * List<Brep> newList = new List<Brep>(); * List<int> test = new List<int>(); * // here we see the test passed, the loop is adding the right amount of objects * // question is why is it when we int a brep to put in new list, it only adds one object. * // we first establish if the problem is with the global variables * List<int> listOfGroups = new List<int>(); * List<Brep> listOfBreps = new List<Brep>(SortedBreps); * // i think we need to add the first id to the list * int ID = 0; * listOfGroups.Add(0); * // First we need to find the center points * for (int i = 0; i < listOfBreps.Count; i++) * { * Brep brep = listOfBreps[i]; * BoundingBox bbox = brep.GetBoundingBox(true); * Point3d centerPoint = bbox.Center; * double x = centerPoint.X; * double y = centerPoint.Y; * for (int j = i + 1; j < listOfBreps.Count;) * { * Brep brep2 = listOfBreps[j]; * BoundingBox bbox2 = brep2.GetBoundingBox(true); * Point3d centerPoint2 = bbox2.Center; * double x2 = centerPoint2.X; * double y2 = centerPoint2.Y; * * double vectorX = x - x2; * double vectorY = y - y2; * * * double length = Math.Sqrt(Math.Pow(vectorX, 2) + Math.Pow(vectorY, 2)); * * if (length <= threshold) * { * listOfGroups.Add(ID); * listOfBreps.RemoveAt(j); * } * else * { * ID = ID + 1; * listOfGroups.Add(ID); * j += 1; * } * } * } * Globals.HouseIds = listOfGroups; * } */ //Getting Floor Breps private Tuple <BrepFace, Brep> ComputeFloorSurfaces(Brep brep) { List <BrepFace> faces = new List <BrepFace>(); List <Brep> trimmedSurfaces = new List <Brep>(); Rhino.Geometry.Collections.BrepFaceList Faces = brep.Faces; for (int i = 0; i < Faces.Count; i++) { Rhino.Geometry.BrepFace Face = Faces[i]; Vector3d normal = Face.NormalAt(0.5, 0.5); if (normal.Z == -1) { faces.Add(Face); Surface surface = Face.UnderlyingSurface(); Brep new_brep = Rhino.Geometry.Brep.CopyTrimCurves(Face, surface, 1e-6); trimmedSurfaces.Add(new_brep); } } BrepFace BottomFace = faces[0]; Brep BottomFaceTrimmed = trimmedSurfaces[0]; return(Tuple.Create(BottomFace, BottomFaceTrimmed)); }