Class GridD<P>
A data structure that represents a three dimensional grid.
Inheritance
Inherited Members
Namespace: Fusee.Structures
Assembly: Fusee.Structures.dll
Syntax
public abstract class GridD<P>
Type Parameters
Name | Description |
---|---|
P | The type of the payload. |
Constructors
GridD(double3, double3, Int32, Int32, Int32)
Creates a new instance of type GridD.
Declaration
public GridD(double3 center, double3 size, int noOfCellsX, int noOfCellsY, int noOfCellsZ)
Parameters
Type | Name | Description |
---|---|---|
double3 | center | The center of the grid. |
double3 | size | The size of the grid. |
System.Int32 | noOfCellsX | Number of cells in x direction. |
System.Int32 | noOfCellsY | Number of cells in y direction. |
System.Int32 | noOfCellsZ | Number of cells in z direction. |
Fields
CellSize
The size of a grid cell.
Declaration
public readonly double3 CellSize
Field Value
Type | Description |
---|---|
double3 |
Center
The center of the grid.
Declaration
public readonly double3 Center
Field Value
Type | Description |
---|---|
double3 |
NumberOfGridCells
The number of grid cells in each dimension.
Declaration
public readonly int3 NumberOfGridCells
Field Value
Type | Description |
---|---|
int3 |
Properties
GridCellsDict
All grid cells as Dictionary, using the three dimensional index as key.
Declaration
public Dictionary<int3, GridCellD<P>> GridCellsDict { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<int3, GridCellD<P>> |
Size
The size of the grid.
Declaration
public double3 Size { get; }
Property Value
Type | Description |
---|---|
double3 |
Methods
CreateCell(int3)
Creates the cell for a given index with default(P) as Payload.
Declaration
public void CreateCell(int3 idx)
Parameters
Type | Name | Description |
---|---|---|
int3 | idx | The index. |
CreateCellForItem(Func<P, double3>, P)
Sorts a payload item into a grid cell. This method needs to determine if the respective cell already exists and create it if that's not the case.
Declaration
public abstract void CreateCellForItem(Func<P, double3> GetPositionOfPayloadItem, P payloadItem)
Parameters
Type | Name | Description |
---|---|---|
System.Func<P, double3> | GetPositionOfPayloadItem | Method that returns the position of a payload item. |
P | payloadItem | The payload item. |
CreateCells()
Creates all cells for this grid without any payload.
Declaration
public void CreateCells()
CreateCells(IEnumerable<P>)
Creates cells for this grid by calling CreateCellForItem(Func<P, double3>, P) for each payload item.
Declaration
public void CreateCells(IEnumerable<P> payload)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<P> | payload | The payload that shall be read to this grid. |
GetGridNeighbourIndices(int3, Int32)
Gets the indices of the direct or indirect neighbor.
Declaration
protected static List<int3> GetGridNeighbourIndices(int3 startIdx, int dist = 1)
Parameters
Type | Name | Description |
---|---|---|
int3 | startIdx | The index of the cell we want to get the neighbors for. |
System.Int32 | dist | The distance to the neighbors. Default is 1 - this will get the direct neighbors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<int3> |
GetPositionOfPayloadItem(P)
Returns the (x,y,z) coordinates of a payload item.
Declaration
public abstract double3 GetPositionOfPayloadItem(P item)
Parameters
Type | Name | Description |
---|---|---|
P | item | The payload item. |
Returns
Type | Description |
---|---|
double3 |
TryGetCellForPos(double3, double3, double3, out int3)
Gets the GridCell and its index for a given position. The GridCell can be null if it hasn't been created yet. See https://math.stackexchange.com/questions/528501/how-to-determine-which-cell-in-a-grid-a-point-belongs-to
Declaration
public GridCellD<P> TryGetCellForPos(double3 gridSize, double3 gridCenter, double3 pos, out int3 cellIdx)
Parameters
Type | Name | Description |
---|---|---|
double3 | gridSize | The size of the whole grid. |
double3 | gridCenter | The center of the grid. |
double3 | pos | The position to get the cell for. |
int3 | cellIdx | The index of the GridCell this point falls into. |
Returns
Type | Description |
---|---|
GridCellD<P> |