Class Topography
A topographic mesh defined by an array of elevation values.
Examples
// Read topo elevations from a file.
var data = JsonConvert.DeserializeObject<Dictionary<string, double[]>>(File.ReadAllText("./elevations.json"));
var latitude = 45;
var elevations = data["points"];
var tileSize = WebMercatorProjection.GetTileSizeMeters(latitude, 15);
// Create a topography.
var topo = new Topography(Vector3.Origin, tileSize, elevations);
Inherited Members
Namespace: Elements
Assembly: Hypar.Elements.dll
Syntax
public class Topography : MeshElement, INotifyPropertyChanged, ITessellate
Constructors
Topography(Mesh, Material, Transform, Guid, String)
Create a topography from a custom mesh. It is assumed that the mesh is an open mesh that's roughly parallel to the XY plane.
Declaration
public Topography(Mesh mesh, Material material, Transform transform, Guid id, string name)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The mesh geometry of the topography. |
Material | material | The topography's material. |
Transform | transform | The topography's transform. |
System.Guid | id | The topography's id. |
System.String | name | The topography's name. |
Topography(Vector3, Double, Double[], Material, Transform, Guid, String)
Create a topography.
Declaration
public Topography(Vector3 origin, double width, double[] elevations, Material material = null, Transform transform = null, Guid id = default(Guid), string name = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | origin | The origin of the topography. |
System.Double | width | The width the topography. When constructed from a set of elevations, the width and the length of the topography will be the same. |
System.Double[] | elevations | An array of elevation samples which will be converted to a square array of width. |
Material | material | The topography's material. |
Transform | transform | The topography's transform. |
System.Guid | id | The topography's id. |
System.String | name | The topography's name. |
Topography(Topography)
Construct a new Topography by duplicating another one.
Declaration
public Topography(Topography topography)
Parameters
Type | Name | Description |
---|---|---|
Topography | topography |
Properties
AbsoluteMinimumElevation
The absolute minimum elevation of the topography's mass.
Declaration
public double? AbsoluteMinimumElevation { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> | If this value is not null, DepthBelowMinimumElevation will be ignored. |
CellHeight
The height of a cell.
Declaration
public double CellHeight { get; }
Property Value
Type | Description |
---|---|
System.Double |
CellWidth
The width of a cell.
Declaration
public double CellWidth { get; }
Property Value
Type | Description |
---|---|
System.Double |
DepthBelowMinimumElevation
The depth of the the topography's mass below the topography's minimum elevation.
Declaration
public double DepthBelowMinimumElevation { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Elevations
A flat list of elevation data which is used to generate the topographic mesh's vertices. The elevations will be used with the RowWidth property to convert the flat list into a square grid.
Declaration
public double[] Elevations { get; }
Property Value
Type | Description |
---|---|
System.Double[] |
MaxElevation
The maximum elevation of the topography.
Declaration
public double MaxElevation { get; }
Property Value
Type | Description |
---|---|
System.Double |
MinElevation
The minimum elevation of the topography.
Declaration
public double MinElevation { get; }
Property Value
Type | Description |
---|---|
System.Double |
Origin
The origin of the topography.
Declaration
public Vector3 Origin { get; }
Property Value
Type | Description |
---|---|
Vector3 |
RowWidth
The number of cells 'across' the topography.
Declaration
public int RowWidth { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AverageEdges(Topography, Units.CardinalDirection)
Average the vertex placement along the specified edge of this topography with the vertex placement along the corresponding edge of a target topography.
Declaration
public void AverageEdges(Topography target, Units.CardinalDirection edgeToAverage)
Parameters
Type | Name | Description |
---|---|---|
Topography | target | |
Units.CardinalDirection | edgeToAverage |
CutAndFill(IList<Polygon>, Double, out List<Mesh>, out List<Mesh>, Double)
Cut and or fill the topography with the specified perimeter to the specified elevation.
Declaration
public (double CutVolume, double FillVolume) CutAndFill(IList<Polygon> perimeters, double elevation, out List<Mesh> cuts, out List<Mesh> fills, double batterAngle = 45)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Polygon> | perimeters | The perimeters of the cut and fill areas. |
System.Double | elevation | The final elevation of the cut and fill. |
System.Collections.Generic.List<Mesh> | cuts | Meshes representing the cut volume in the topography. |
System.Collections.Generic.List<Mesh> | fills | Meshes representing the fill volume in the topography. |
System.Double | batterAngle | The angle of the battering surrounding the fill area in degrees. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Double, System.Double> | The sum of all cut and fill volumes. |
GetEdgeVertices(Units.CardinalDirection)
Get the vertices along the specified edge of a square topography.
Declaration
public Vertex[] GetEdgeVertices(Units.CardinalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
Units.CardinalDirection | direction | The edge of vertices to return. |
Returns
Type | Description |
---|---|
Vertex[] | A collection of vertices. |
TopMesh()
Returns a new mesh that represents the top surface of this topography.
Declaration
public Mesh TopMesh()
Returns
Type | Description |
---|---|
Mesh |
Trim(Profile)
Trim the topography with the specified perimeter.
Declaration
public void Trim(Profile perimeter)
Parameters
Type | Name | Description |
---|---|---|
Profile | perimeter | The perimeter of the trimmed topography. |
Trimmed(Profile)
Returns a new Topography that is a trimmed version of the current Topography.
Declaration
public Topography Trimmed(Profile perimeter)
Parameters
Type | Name | Description |
---|---|---|
Profile | perimeter | The perimeter of the trimmed topography. |
Returns
Type | Description |
---|---|
Topography |
Tunnel(BoundedCurve, Double)
Cut a tunnel through a topography.
Declaration
public void Tunnel(BoundedCurve path, double diameter)
Parameters
Type | Name | Description |
---|---|---|
BoundedCurve | path | The path of the tunnel. |
System.Double | diameter | The diameter of the tunnel. |
UpdateRepresentations()
Update the representations.
Declaration
public override void UpdateRepresentations()