Grid Functions
Functions:
MTK_Grid_Close
int MTK_Grid_Close(MTK_Grid* grid);
Description
Close grid and release any memory used. Note: this does not save any changes.
Parameters
grid
pointer to an MTK_Grid struct
Return Value
0
success
other
failure
MTK_Grid_GetExtent
int MTK_Grid_GetExtent( MTK_Grid* grid, double* lowerBoundX, double* lowerBoundY, double* upperBoundX, double* upperBoundY );
Description
Query the extent of a grid.
Parameters
grid
pointer to an MTK_Grid struct
lowerBoundX
X lower left corner (double)
lowerBoundY
Y lower left corner (double)
upperBoundX
Y upper right corner (double)
upperBoundY
Y upper right corner (double)
Return Value
0
success
other
failure
MTK_Grid_GetNodeValue
int MTK_Grid_GetNodeValue( MTK_Grid* grid, const int& i, const int& j, double* value, int* mask );
Description
Query the value of a grid node.
Parameters
grid
pointer to an MTK_Grid struct
i
x node index (0+) (int)
j
y node index (0+) (int)
value
node value (double*)
mask
node mask value (int*)
1
active (not masked)
0
inactive (masked)
Return Value
0
success
other
failure
MTK_Grid_GetSpacing
int MTK_Grid_GetSpacing(MTK_Grid* grid, double* cellSizeX, double* cellSizeY);
Description
Query the cellsizes of a grid.
Parameters
grid
pointer to an MTK_Grid struct
cellSizeX
cell size in the X direction (double)
cellSizeY
cell size in the Y direction (double)
Return Value
0
success
other
failure
MTK_Grid_IsValid
int MTK_Grid_IsValid(MTK_Grid* grid);
Description
Query the validity of a grid.
Parameters
grid
pointer to an MTK_Grid struct
Return Value
1
valid
0
invalid
-1
failed
MTK_Grid_New
MTK_Grid* MTK_Grid_New( const double& lowerBoundX, const double& lowerBoundY, const double& upperBoundX, const double& upperBoundY, const double& cellSizeX, const double& cellSizeY );
Description
Create a grid with the given structure, but with no data. Note: this does not create an actual file.
Parameters
lowerBoundX
X lower left corner (double)
lowerBoundY
Y lower left corner (double)
upperBoundX
Y upper right corner (double)
upperBoundY
Y upper right corner (double)
cellSizeX
grid cell size in X direction (double)
cellSizeY
grid cell size in Y direction (double)
Return Value
Pointer to a MTK_Grid struct
success
Null pointer
failure
MTK_Grid_NumNodes
int MTK_Grid_NumNodes(MTK_Grid* grid, int* numberInX, int* numberInY);
Description
Query the number of nodes in each direction of a grid.
Parameters
grid
pointer to an MTK_Grid struct
numberInX
number of cells in the X direction (int)
numberInY
number of cells in the Y direction (int)
Return Value
0
success
other
failure
MTK_Grid_Open
MTK_Grid* MTK_Grid_Open(const char* name);
Description
Open an existing grid file.
Parameters
name
grid filename (const char*)
Return Value
Pointer to a MTK_Grid struct
success
Null pointer
failure
MTK_Grid_Save
int MTK_Grid_Save(MTK_Grid* grid, const char* name);
Description
Save the grid to a file.
Parameters
grid
pointer to an MTK_Grid struct
name
grid name (const char*)
Return Value
0
success
other
failure
MTK_Grid_SetNodeValue
int MTK_Grid_SetNodeValue( MTK_Grid* grid, const int& i, const int& j, const double& value, const int& mask );
Description
Set the value of a grid node.
Parameters
grid
pointer to an MTK_Grid struct
i
x node index (0+) (int)
j
y node index (0+) (int)
value
node value (double)
mask
node mask value (int)
1
active (not masked)
0
inactive (masked)
Return Value
0
success
other
failure