This PR adds a RasterMesh class to create pixel/voxel meshes from a PolyMesh. It addresses #44.
Approach
A raster grid is created, then the centers of the pixels are computed. For each region in the PolyMesh, pixels within the region are determined by creating a bounding box as a cheap screen, then testing which of the remaining points are within the region.
The array of element attributes is created by converting the lower-left corner of each pixel into a matrix coordinate, then populating the array with the attributes.
For meshes with holes or non-box domains, pixels will have an attribute of -1 if there is no element associated with them.
PR Summary
Purpose
This PR adds a RasterMesh class to create pixel/voxel meshes from a PolyMesh. It addresses #44.
Approach
A raster grid is created, then the centers of the pixels are computed. For each region in the PolyMesh, pixels within the region are determined by creating a bounding box as a cheap screen, then testing which of the remaining points are within the region.
The array of element attributes is created by converting the lower-left corner of each pixel into a matrix coordinate, then populating the array with the attributes.
For meshes with holes or non-box domains, pixels will have an attribute of -1 if there is no element associated with them.
Example
Adjusting the first example input to:
Creates an output raster mesh that looks like this:
Opening this mesh and calling the
RasterMesh.as_array()
function yields the following output:PR Checklist
tox
commands succeedClosing Issues
Fixes #44