// Pointcloud public Pointcloud PointcloudToSpeckle(RH.PointCloud pointcloud, string units = null) { var u = units ?? ModelUnits; var _pointcloud = new Pointcloud() { points = PointsToFlatArray(pointcloud.GetPoints().ToList()).ToList(), colors = pointcloud.GetColors().Select(o => o.ToArgb()).ToList(), bbox = BoxToSpeckle(new RH.Box(pointcloud.GetBoundingBox(true)), u), units = u }; return(_pointcloud); }
public RH.PointCloud PointcloudToNative(Pointcloud pointcloud) { var points = pointcloud.GetPoints().Select(o => PointToNative(o).Location).ToList(); var _pointcloud = new RH.PointCloud(points); if (pointcloud.colors.Count == points.Count) { for (int i = 0; i < points.Count; i++) { _pointcloud[i].Color = System.Drawing.Color.FromArgb(pointcloud.colors[i]); } } return(_pointcloud); }
public Pointcloud PointcloudToSpeckle(PointCloudInstance pointcloud, string units = null) { var u = units ?? ModelUnits; var boundingBox = pointcloud.get_BoundingBox(null); var filter = PointCloudFilterFactory.CreateMultiPlaneFilter(new List <DB.Plane>() { DB.Plane.CreateByNormalAndOrigin(XYZ.BasisZ, boundingBox.Min) }); var points = pointcloud.GetPoints(filter, 0.0001, 999999); // max limit is 1 mil but 1000000 throws error var _pointcloud = new Pointcloud(); _pointcloud.points = points.Select(o => PointToSpeckle(o, u)).SelectMany(o => new List <double>() { o.x, o.y, o.z }).ToList(); _pointcloud.colors = points.Select(o => o.Color).ToList(); _pointcloud.units = u; _pointcloud.bbox = BoxToSpeckle(boundingBox, u); return(_pointcloud); }