Adun  0.83
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Static Public Member Functions
AdGrid Class Reference

#import <AdunGrid.h>

Inheritance diagram for AdGrid:
Inheritance graph
[legend]
Collaboration diagram for AdGrid:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(id) - initWithDensity:cavity:
(id) - initWithDivisions:cavity:
(id) - init
(id) - initWithSpacing:
(id) - initWithSpacing:cavity:
(void) - resetCavity
(void) - cavityDidMove
(void) - setCavity:
(id) - cavity
(AdMatrix *) - grid
(NSArray *) - spacing
(void) - setSpacing:
(NSArray *) - divisions
(int) - numberOfPoints
(NSString *) - openDXRepresentationWithData:
(int) - indexOfGridPointNearestToPoint:
(int) - indexOfGridPointNearestToNSPoint:
(int) - indexOfGridPointNearestToPoint:indexes:
(NSIndexSet *) - indexesOfGridPointsLessThan:fromNSPoint:
(void) - setSearchCutoff:
(double) - searchCutoff

Static Public Member Functions

(id) + gridWithDensity:cavity:
(id) + gridWithDivisions:cavity:
(id) + gridWithSpacing:cavity:

Detailed Description

AdGrid instances represent a three dimensional cartesian grid in a volume defined by the grids cavity delegate which must conform to the AdGridDelegate protocol. The spacing of the grid points is determined when the object is initialised. The units used by the object are dimensionless.

AdGrid implements the NSCoding protocol. It only supports keyed coding.

Todo:
Missing Functionality - Update resetCavity (AdGrid) or implement a cavityVolumeDidChange method that keeps current points that are still in the cavity while adding new ones and removing old ones. Such a method is required if you need the grid points not to change during a volume change i.e. the grid spacing and centre is fixed after creation. Using resetCavity as it currently is implemented will result in a new grid being created which may not have the same characterisitics.

Member Function Documentation

- (id) cavity

Returns the grid delegate.

- (void) cavityDidMove

Should be sent on a change of cavity poisition. The grid object compares the old and new centers and moves translates grid accordingly. If the volume defined by the cavity also changes you should use resetCavity instead. This method does not affect the grid matrix references i.e. the pointer to grid matrix remains the same.

- (NSArray *) divisions

Returns the number of divisions (ticks) on each axis.

- (AdMatrix*) grid

Returns the grid as an AdMatrix structure. The returned pointer will be invalidated when the AdGrid instance is released, when a new cavity is set using setCavity:, when resetCavity is called or when setSpacing is called.

+ (id) gridWithDensity: (double)  density
cavity: (id)  aCavity 

Returns an autoreleased AdGrid object containing a grid with the given density of points in the volume defined by cavity.

+ (id) gridWithDivisions: (NSArray*)  divisions
cavity: (id)  aCavity 

Returns an autoreleased AdGrid object containing a grid with the given number of ticks on each axis.

+ (id) gridWithSpacing: (NSArray*)  spacing
cavity: (id)  aCavity 

Returns an autoreleased AdGrid object containing a a grid with the given spacing between ticks on each axis.

- (NSIndexSet *) indexesOfGridPointsLessThan: (double)  cutoff
fromNSPoint: (NSArray*)  point 

Returns the indexes of all grid points within cutoff of point

- (int) indexOfGridPointNearestToNSPoint: (NSArray*)  point

As indexOfGridPointNearestToPoint: except taking an NSArray

- (int) indexOfGridPointNearestToPoint: (Vector3D*)  point

Returns the index of the row in the grid matrix that is nearest to point. However if point isn't within the searchCutoff of any grid point i.e. its more than this value away on every axis from the nearest grid point, this method returns -1. Effectively this only returns a value if the point is within the volume covered by the grid.

- (int) indexOfGridPointNearestToPoint: (Vector3D*)  point
indexes: (int*)  array 

As indexOfGridPointNearestToPoint: but on return array contains the x, y and z indexes of the grid point. That is the index of the x, y, z tick nearest to the point. array must have space for three ints.

- (id) init

As initWithSpacing: passing [1.0, 1.0, 1.0] for spacing.

- (id) initWithDensity: (double)  density
cavity: (id)  cavity 

Creates a grid with the given density of points in the volume defined by the delegate.

Todo:
Not implemented
- (id) initWithDivisions: (NSArray*)  divisions
cavity: (id)  cavity 

Creates a grid with the given number of ticks on each axis. The tick spacing is defined by the cavity extremes.

Parameters:
AnNSArray on integers specfying the ticks for each axis in the order x,y,z
cavityAn object implementing the AdGridDelegate protocol
Todo:
Not implemented
- (id) initWithSpacing: (NSArray*)  spacing

As initWithSpacing:cavity: passing nil for cavity.

Note:
No grid will be created until a cavity is supplied
- (id) initWithSpacing: (NSArray*)  spacing
cavity: (id)  cavity 

Designated initialiser. Creates a grid in the volume defined by cavity with the given spacing between ticks on each axis.

Parameters:
AnNSArray of double specifying the spacing for each axis in the order x,y,z. If nil the spacing defaults to one in each direction.
cavityAn object implementing the AdGridDelegate protocol. If nil the grid is not created. It will be created at the next call to setCavity: with a valid argument.
- (int) numberOfPoints

Returns the total number of grid points.

- (NSString *) openDXRepresentationWithData: (NSArray*)  data

Writes an opendx representation of the grid which involves associating each grid point with a value given by the elements of data. Often the value is the result of evaluating some function at each grid-point e.g. the value of a potential. The result opendx file can be read by many viewers used to generate a volume map of the function in the space defined by the grid.

- (void) resetCavity

If the space defined by the cavity changes this message should be sent in order to update the grid. Any objects that retain references to the grid matrix should acquire a new reference. The method can also be used if the cavity centre was changed. However in this case cavityDidMove is more efficent. If no cavity has been set this method does nothing.

- (double) searchCutoff

Returns the cutoff. Points outside the grid volume but within this cutoff will be be assigned to a grid point by indexOfGridPointNearestToPoint:.

- (void) setCavity: (id)  anObject

Changes the grids cavity delegate to anObject which must conform to the AdGridDelegate protocol. If it does not an NSInvalidArgumentException is raised. The old grid is freed (if it exists) and a new one is created.

- (void) setSearchCutoff: (double)  value

Sets the cutoff. Points outside the grid volume but within this cutoff will be be assigned to a grid point by indexOfGridPointNearestToPoint:.

- (void) setSpacing: (NSArray*)  anArray

Sets the grid spacing. If a cavity is set a grid is created with the supplied spacing. Any previous grids are destroyed.

- (NSArray *) spacing

Retuns the spacing between the point on each axis (dimensionless)