VoxelSpace

References
public sealed class VoxelSpace
A sparse voxel volume.

Constructors

VoxelSpace

#
public VoxelSpace(double unitSize, ushort[,,] voxels, int offsetX, int offsetY, int offsetZ)
unitSize (double)
voxels (ushort[,,])
offsetX (int)
offsetY (int)
offsetZ (int)

Properties

All

#
public IEnumerable<(int x, int y, int z)> All { get; }
Iterate over all set voxel indices. This includes the voxels on the interior and the boundary of the mesh.

AllInterior

#
public IEnumerable<(int x, int y, int z)> AllInterior { get; }
Iterate over all interior voxel indices.

Count

#
public int Count { get; }
Total number of voxels in the grid, including the unset ones.

CountX

#
public int CountX { get; }
Total number of voxels in the grid X direction.

CountY

#
public int CountY { get; }
Total number of voxels in the grid Y direction.

CountZ

#
public int CountZ { get; }
Total number of voxels in the grid Z direction.

Unit

#
public double Unit { get; }
Unit size for voxels.

Methods

CreateFromMesh

#
public static VoxelSpace CreateFromMesh(Mesh mesh, double unit, CancellationToken token)
mesh (Mesh)
unit (double)
token (CancellationToken)

GradAt

#
public double GradAt(Point3d location, Vector3d normal)
Compute the magnitude of the normalised temperature gradient going into the volume.
location (Point3d)Sampling location.
normal (Vector3d)Normal at location (sampling will happen in the reverse direction). The normal ought to have unit length, although a scaled normal would also affect the depth at which sampling happens, exposing another level of control to the caller.

PointAt

#
public Point3d PointAt(int x, int y, int z)
Gets the real world coordinate at the voxel centre.
x (int)Voxel x index.
y (int)Voxel y index.
z (int)Voxel z index.
Point at voxel centre.

SolveHeatDispersion

#
public void SolveHeatDispersion(double targetTemperature, int maximumIterations, CancellationToken token)
Run a cooling simulation. All interior voxels are set to 1.0, all exterior ones to 0.0 and then an iterative smoothing is applied until the average temp drops below 'coolingLimit'.
targetTemperature (double)Use 0.5 when in doubt.
maximumIterations (int)Maximum number of iterations.
token (CancellationToken)Cancellation token.

TempAt

#
public double TempAt(int x, int y, int z)
Gets the temperature at the given voxel indices.
x (int)
y (int)
z (int)
Temp at voxel, or double.NaN if undefined.

TempAt

#
public double TempAt(Point3d location)
Measure the interpolated temperature at a location.
location (Point3d)