public Output Execute(Input input) { // Extract location data. // The GeoJSON may contain a number of features. Here we just // take the first one assuming it's a Polygon, and we use // its first point as the origin. var outline = (Hypar.GeoJSON.Polygon)input.Location[0].Geometry; var origin = outline.Coordinates[0][0]; var offset = origin.ToVectorMeters(); var plines = outline.ToPolygons(); var pline = plines[0]; var boundary = new Hypar.Geometry.Polygon(pline.Vertices.Select(v => new Vector3(v.X - offset.X, v.Y - offset.Y, v.Z)).ToList()); var mass = new Mass(boundary, 0, input.Height); // Add your mass element to a new Model. var model = new Model(); model.AddElement(mass); // Set the origin of the model to convey to Hypar // where to position the generated 3D model. model.Origin = origin; var output = new Output(model, mass.Profile.Perimeter.Area); return(output); }
/// <summary> /// Convert the coordinate array to a collection of polylines. /// The last position of the polygon is dropped. /// </summary> /// <returns></returns> public Hypar.Geometry.Polygon[] ToPolygons() { var plineArr = new Hypar.Geometry.Polygon[Coordinates.Length]; for (var i = 0; i < plineArr.Length; i++) { var coords = this.Coordinates[i]; var verts = new Vector3[coords.Length - 1]; // Drop the last position. for (var j = 0; j < coords.Length - 1; j++) { verts[j] = coords[j].ToVectorMeters(); } var pline = new Hypar.Geometry.Polygon(verts); plineArr[i] = pline; } return(plineArr); }
/// <summary> /// Construct a Profile. /// </summary> /// <param name="name">The name of the Profile.</param> /// <param name="perimeter">The perimeter of the Profile</param> public Profile(Polygon perimeter, string name = null) { this.Id = Guid.NewGuid().ToString(); this.Perimeter = perimeter; this.Name = name; }