Cells
A cell is a primitive containing four points. The SDK represents a cell as an array containing the indices of four points.
Accessing an object’s cells
Cells are point-based objects. Therefore, the cells of any object are set and accessed using the points property. We define points for a cell to be an array of n*4 points, where n is the number of cells. Below is an example of points for a cell:
You can only access the cells of an object via the cells property. The cells property is a read-only property. Because most cell-based objects contain multiple cells, the cells property is represented as a NumPy array. Each element of the array represents a cell, which in turn is an array of the four point indices defining the cell.
A GridSurface is the simplest cell-based spatial object. We can use it to illustrate how to create cells with the example below.
from mapteksdk.project import Project
from mapteksdk.data import GridSurface
project = Project()
points = [[1.1, 1.15, 1.11], [1.98, 1.17, 1.08], [3.02, 1.13, 1.07],
[1.08, 1.99, 1.07], [2.01, 2.03, 1.37], [3.00, 2.11, 1.33],
[1.13, 3.08, 1.08], [2.00, 3.01, 0.99], [3.18, 3.07, 1.34]]
with project.new("surfaces/grid_surface", GridSurface(
major_dimension_count=3, minor_dimension_count=3
)) as new_grid:
new_grid: GridSurface # Added to enable IntelliSense
new_grid.points = points
# Accessing cells requires PointStudio 2021.1 or higher,
# SDK version 1.2 (from Extend Plugins 2021.1).
print(new_grid.cells)
Manipulating an object’s cells
Use the following properties and methods to manipulate the cells of an object:
| Name | Description |
major_dimension_count
|
Use this property to define the number of rows of cells in a cell-based object. |
minor_dimension_count
|
Use this property to define the number of columns of cells in a cell-based object. |
cell_count
|
Use this property to return the total number of cells in an object. |
cell_point_count
|
Use this property to return the number of cell points in a cell-based object. This is usually equal to the major_dimension_count multiplied by the minor_dimension count properties, but may be less if the object contains invalid points. |
cell_visibility
|
Use this property to set the visibility of each cell. This is represented by an array of boolean values, where a False value indicates that the cell is invisible and a True value indicates that the cell is visible. |
cell_attributes
|
Use this method to save or return custom cell attributes in an object. To set a particular cell attribute, you can use the notation cell_attributes[attribute_name] = data. |
save_cell_attribute(attribute_name, data)
|
Use this method to save a cell attribute and allocate data to it. |
delete_cell_attribute(attribute_name)
|
Use this method to delete a cell attribute. |
You can read more about the Cell primitive class in the class references.