Discrete2d — Root class of all 2d discrete spaces.
Description
A Discrete2d is basically a 2d array of ids. Subclasses add particular space semantics onto this. Currently Discrete2d grids are accessed by integer pairs of X and Y coordinates.
- setSizeX: (unsigned)xY: (unsigned)y Set the world size.
- (id *)allocLattice Allocate memory for the lattice.
- makeOffsets Given an array size, compute the offsets array that caches the multiplication by ysize. See the discrete2dSiteAt macro.
- createEnd Create the lattice, precompute the offsets based on Y coordinate.
Phase: Using
- (unsigned)getSizeX Get the size of the lattice in the X dimension.
- (unsigned)getSizeY Get the size of the lattice in the Y dimension.
- getObjectAtX: (unsigned)xY: (unsigned)y Return the pointer stored at (x,y).
- (long)getValueAtX: (unsigned)xY: (unsigned)y Return the integer stored at (x,y).
- putObject:anObjectatX: (unsigned)xY: (unsigned)y Put the given pointer to (x,y) overwriting whatever was there.
- putValue: (long)vatX: (unsigned)xY: (unsigned)y Put the given integer to (x,y) overwriting whatever was there.
- fastFillWithValue: (long)aValue Directly fills the lattice with a value.
- fastFillWithObject:anObj Directly fills the lattice with an object.
- fillWithValue: (long)aValue Fills the space using putValue.
- fillWithObject:anObj Fills the space using putObject.
- (id *)getLattice Returns the lattice pointer - use this for fast access.
- (int)setDiscrete2d:atoFile: (const char *)filename This method reads a PGM formatted file and pipes the data into a Discrete2d object.
- copyDiscrete2d:atoDiscrete2d:b This method copies the data in one Discrete2d object to another Discrete2d object. It assumes that both objects already exist.