# Friday 16 March 2012

So the assignFieldValueForSingleKeypoint now works. But how to calculate the field value for all Keypoints for a given surface cube.

For any given Keypoint we have to start form that point moving along the x axis until we find a Surface Cube where the field value < Magic. But we need to calculate the field value for all keypoints at a given possible Surface cube vertex.

This means that you take the integer values of the 3 float points of a Keypoint (so as to have a starting point).

So for a keypoint:

20.5, 32.5, 48.5 you start at 20.0, 32.0, 48.0 and work along the X axis (20, 21, 22…) until you find a **small* cube that (must be definition) intersect the iso-surface.

But how to calculate the field value for a given small cube. Well, any small cube is contained in a big cube. If that big cube is with range of the keypoint then so **could** any given small cube within it be within range. If the containing big cube is not within range, then the smaller cubes within it **cannot* be within range. So to fins the field value of any small cube:

Find the corresponding big cube (divide all x,y,z values by 16 and take integer result).

Calculate the index of the big cube (calcCubeIndex)

Return corresponding Bcube table Bcube (done by getBcubelist)

This is all done by **getBcubeListFromBcubeTable4SmallCube**

Loop along the bCubeList getting the keypoint

Add the field value for every keypoint to a total field value for the given small cube and return that total field value. This is done by:

**assignFieldValueForAllKeypointsForSmallCube*

So where we have

**assignFieldValueForSingleKeypoint** we need: **assignFieldValueForAllKeypointsForSmallCube**

assignFieldValueForAllKeypointsForSurfaceCube:

parameters: 1) a Bcubelist 2) a Keypoint

public double assignFieldValueForAllKeypointsForSurfaceCube(LinkedList<Bcube> bcubeList, Keypoint Kp)