Show / Hide Table of Contents

    Class Grid2d

    Represents a 2-dimensional grid which can be subdivided

    Examples
    // Create a 2d grid that's 40 x 30 in size
    var grid = new Grid2d(40, 30);
    
    // Access the U and V axes directly and use 1d subdivision methods on them
    grid.U.DivideByFixedLength(7, FixedDivisionMode.RemainderAtBothEnds);
    grid.V.DivideByPattern(new[] { 2.0, 5.0 });
    
    // Get a row by index
    var fifthRow = grid.GetRowAtIndex(4);
    // Divide U axis of all cells in row into panels of approximate width 1
    fifthRow.ForEach(c => c.U.DivideByApproximateLength(1));
    
    // Get a cell by u, v indices
    var cell = grid[1, 1];
    // Divide the cell in the V direction
    cell.V.DivideByCount(4);
    
    // Create a floor from the entire grid's boundary
    var floor = new Floor(new Profile((Polygon)grid.GetCellGeometry()), 0.5, new Transform(0, 0, -0.51));
    
    // Create model curves from all subdivided cells of the grid
    var modelCurves = grid.ToModelCurves();
    
    Inheritance
    System.Object
    Grid2d
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Spatial
    Assembly: Hypar.Elements.dll
    Syntax
    [JsonConverter(typeof(JsonInheritanceConverter), new object[]{"discriminator"})]
    public class Grid2d

    Constructors

    Grid2d()

    Construct a Grid2d with default domain (0,0) to (1,1)

    Declaration
    public Grid2d()

    Grid2d(Polygon, Transform)

    Create a Grid2d from a polygon and optional Transform. If the plane is null or not supplied, the identity transform will be used for the grid origin and orientation. Currently only transforms parallel to the supplied polygons are supported. The polygon's bounding box parallel to the supplied transform will be used as the grid extents.

    Declaration
    public Grid2d(Polygon boundary, Transform transform = null)
    Parameters
    Type Name Description
    Polygon boundary

    The external boundary of this grid system.

    Transform transform

    A transform representing the alignment of the grid.

    Grid2d(Polygon, Vector3, Vector3, Vector3)

    Create a grid from a single boundary, an origin, and its U and V directions

    Declaration
    public Grid2d(Polygon boundary, Vector3 origin, Vector3 uDirection, Vector3 vDirection)
    Parameters
    Type Name Description
    Polygon boundary
    Vector3 origin
    Vector3 uDirection
    Vector3 vDirection

    Grid2d(Polygon, Grid1d, Grid1d)

    Create a grid from a boundary and custom U and V grids

    Declaration
    public Grid2d(Polygon boundary, Grid1d u, Grid1d v)
    Parameters
    Type Name Description
    Polygon boundary
    Grid1d u
    Grid1d v

    Grid2d(Grid1d, Grid1d)

    Construct a Grid2d from two Grid1ds in the U and V directions

    Declaration
    public Grid2d(Grid1d u, Grid1d v)
    Parameters
    Type Name Description
    Grid1d u
    Grid1d v

    Grid2d(Grid2d)

    Construct a Grid2d from another Grid2d

    Declaration
    public Grid2d(Grid2d other)
    Parameters
    Type Name Description
    Grid2d other

    Grid2d(Grid2d, Grid1d, Grid1d)

    Construct a Grid2d using another Grid2d as the base, but with different Grid1ds as its axes.

    Declaration
    public Grid2d(Grid2d other, Grid1d u, Grid1d v)
    Parameters
    Type Name Description
    Grid2d other

    The Grid2d to base this one on.

    Grid1d u

    The Grid1d representing the U Axis.

    Grid1d v

    The Grid1d representing the V Axis.

    Grid2d(IList<Polygon>, Transform)

    Create a Grid2d from a list of boundary polygons and an optional transform. If the transform is null or not supplied, a transform will be generated automatically from the boundaries' normal. Currently only transforms parallel to the supplied polygons are supported. The polygons' bounding box parallel to the supplied transform will be used as the grid extents.

    Declaration
    public Grid2d(IList<Polygon> boundaries, Transform transform = null)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Polygon> boundaries

    The external boundaries of this grid system.

    Transform transform

    A transform representing the alignment of the grid.

    Grid2d(IList<Polygon>, Vector3, Vector3, Vector3)

    Create a grid from a list of boundaries, an origin, and its U and V directions

    Declaration
    public Grid2d(IList<Polygon> boundaries, Vector3 origin, Vector3 uDirection, Vector3 vDirection)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Polygon> boundaries
    Vector3 origin
    Vector3 uDirection
    Vector3 vDirection

    Grid2d(IList<Polygon>, Grid1d, Grid1d)

    Create a grid from a list of boundaries and custom U and V grids

    Declaration
    public Grid2d(IList<Polygon> boundaries, Grid1d u, Grid1d v)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Polygon> boundaries
    Grid1d u
    Grid1d v

    Grid2d(Double, Double)

    Construct a Grid2d with specified dimensions for the U and V direction.

    Declaration
    public Grid2d(double uDimension, double vDimension)
    Parameters
    Type Name Description
    System.Double uDimension

    The size along the U axis

    System.Double vDimension

    The size along the V axis

    Properties

    Cells

    Child cells of this Grid. If null, this Grid is a complete cell with no subdivisions.

    Declaration
    [JsonIgnore]
    public List<List<Grid2d>> Cells { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.Collections.Generic.List<Grid2d>>

    CellsFlat

    A flat list of all the top-level cells in this grid. To get child cells as well, use Grid2d.GetCells() instead.

    Declaration
    [JsonIgnore]
    public List<Grid2d> CellsFlat { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<Grid2d>

    IsSingleCell

    Returns true if this 2D Grid has no subdivisions / sub-grids.

    Declaration
    [JsonIgnore]
    public bool IsSingleCell { get; }
    Property Value
    Type Description
    System.Boolean

    Item[Int32, Int32]

    Retrieve a single top-level cell at the specified [u,v] indices.

    Declaration
    [JsonIgnore]
    public Grid2d this[int u, int v] { get; }
    Parameters
    Type Name Description
    System.Int32 u

    The U index

    System.Int32 v

    The V index

    Property Value
    Type Description
    Grid2d

    The cell at these indices

    Type

    An optional type designation for this cell.

    Declaration
    public string Type { get; set; }
    Property Value
    Type Description
    System.String

    U

    The 1d Grid along the U dimension

    Declaration
    public Grid1d U { get; }
    Property Value
    Type Description
    Grid1d

    V

    The 1d grid along the V dimension

    Declaration
    public Grid1d V { get; }
    Property Value
    Type Description
    Grid1d

    Methods

    FindCellAtPosition(Double, Double)

    Retrieve the grid cell (as a Grid1d) at a length along the U and V domains.

    Declaration
    public Grid2d FindCellAtPosition(double uPosition, double vPosition)
    Parameters
    Type Name Description
    System.Double uPosition

    U Position

    System.Double vPosition

    V Position

    Returns
    Type Description
    Grid2d

    GetCellAtIndices(Int32, Int32)

    Retrieve a single top-level cell at the specified [u,v] indices.

    Declaration
    public Grid2d GetCellAtIndices(int u, int v)
    Parameters
    Type Name Description
    System.Int32 u

    The U index

    System.Int32 v

    The V index

    Returns
    Type Description
    Grid2d

    The cell at these indices

    GetCellGeometry()

    Get a rectangular polygon representing this untrimmed cell boundary.

    Declaration
    public BoundedCurve GetCellGeometry()
    Returns
    Type Description
    BoundedCurve

    A rectangle representing this cell in world coordinates.

    GetCellNodes()

    Get the points at the corners of all grid cells. ///

    Declaration
    public List<Vector3> GetCellNodes()
    Returns
    Type Description
    System.Collections.Generic.List<Vector3>

    GetCells()

    Recursively retrieve all bottom-level cells from this grid.

    Declaration
    public List<Grid2d> GetCells()
    Returns
    Type Description
    System.Collections.Generic.List<Grid2d>

    A list of all bottom-level cells in the grid.

    GetCellSeparators(GridDirection, Boolean)

    Get the top-level lines separating cells from one another.

    Declaration
    public List<ICurve> GetCellSeparators(GridDirection direction, bool trim = false)
    Parameters
    Type Name Description
    GridDirection direction

    The grid direction in which you want to get separators.

    System.Boolean trim

    Whether or not to trim cell separators with the trimmed cell boundary

    Returns
    Type Description
    System.Collections.Generic.List<ICurve>

    The lines between cells, running parallel to the grid direction selected.

    GetColumnAtIndex(Int32)

    Get a list of all the top-level cells at a given u index.

    Declaration
    public List<Grid2d> GetColumnAtIndex(int u)
    Parameters
    Type Name Description
    System.Int32 u

    The u index

    Returns
    Type Description
    System.Collections.Generic.List<Grid2d>

    A list of the column of all cells with this u index.

    GetRowAtIndex(Int32)

    Get a list of all the top-level cells at a given v index.

    Declaration
    public List<Grid2d> GetRowAtIndex(int v)
    Parameters
    Type Name Description
    System.Int32 v

    The v index

    Returns
    Type Description
    System.Collections.Generic.List<Grid2d>

    A list of the row of all cells with this v index.

    GetTrimmedCellGeometry()

    Get a list of polygons representing this cell boundary, trimmed by any polygon boundary. If the cell falls completely outside of the boundary, an empty array will be returned.

    Declaration
    public BoundedCurve[] GetTrimmedCellGeometry()
    Returns
    Type Description
    BoundedCurve[]

    Curves representing this cell in world coordinates.

    GetTrimmedCellProfiles()

    Get a list of profiles representing this cell boundary, trimmed by any polygon boundary. Internal polygons that are completely inside the cell and are clockwise, will be added as profile voids. If the cell falls completely outside of the boundary, an empty array will be returned.

    Declaration
    public IEnumerable<Profile> GetTrimmedCellProfiles()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Profile>

    Curves representing this cell in world coordinates.

    IsOutside()

    Test if the cell is fully outside the boundary.

    Declaration
    public bool IsOutside()
    Returns
    Type Description
    System.Boolean

    True if the grid cell is totally outside the boundary.

    IsTrimmed(Boolean)

    Test if the cell is trimmed by a boundary.

    Declaration
    public bool IsTrimmed(bool treatFullyOutsideAsTrimmed = true)
    Parameters
    Type Name Description
    System.Boolean treatFullyOutsideAsTrimmed

    Should cells that fall entirely outside of the boundary be treated as trimmed? True by default.

    Returns
    Type Description
    System.Boolean

    True if the cell is trimmed by the grid boundary.

    SplitAtPoint(Vector3)

    Split the grid at a point in world space

    Declaration
    public void SplitAtPoint(Vector3 point)
    Parameters
    Type Name Description
    Vector3 point

    The point at which to split.

    SplitAtPoints(IEnumerable<Vector3>)

    Split the grid at points in world space

    Declaration
    public void SplitAtPoints(IEnumerable<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vector3> points

    The points at which to split

    SplitAtPosition(Vector3)

    Split the grid at a position in the grid's coordinate system

    Declaration
    public void SplitAtPosition(Vector3 position)
    Parameters
    Type Name Description
    Vector3 position

    The position at which to split, with X = U and Y = V.

    SplitAtPosition(Double, Double)

    Split the grid at a position in the grid's coordinate system

    Declaration
    public void SplitAtPosition(double uPosition, double vPosition)
    Parameters
    Type Name Description
    System.Double uPosition

    The U position

    System.Double vPosition

    The V position

    SplitAtPositions(IEnumerable<Vector3>)

    Split the grid at positions in the grid's coordinate system

    Declaration
    public void SplitAtPositions(IEnumerable<Vector3> positions)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vector3> positions

    The positions at which to split, with X = U and Y = V.

    Extension Methods

    ModelCurveExtensions.ToModelCurves(Grid2d, Transform, Material)