ru.sscc.spline.mesh
Class SimpleMesh

java.lang.Object
  |
  +--ru.sscc.spline.mesh.SimpleMesh
Direct Known Subclasses:
NonuniformMesh, StrictNonuniformMesh, UniformMesh

public abstract class SimpleMesh
extends java.lang.Object
implements java.io.Serializable

The description of the simple 1D mesh. The user's mesh nodes are usually affain transformed while construction of an internal mesh by the formula x'=(x-x0)*s, where x0 is a new origin point (usually the first point in the mesh) and s is a scale factor. The class provides testing of a point to find a mesh cell it belongs to.

See Also:
Serialized Form

Field Summary
protected  double origin
          An affine transform origin.
protected  double scale
          An affine fransform scaling factor.
 int size
          A number of mesh nodes.
 
Constructor Summary
protected SimpleMesh(int size)
          Constructor: sets the mesh size attribute.
 
Method Summary
abstract  double averageStep()
          Returns an average mesh step.
abstract  double distance(int i, int j)
          Returns a distance between i-th and j-th nodes of transformed mesh, e.g.
 double extendedMeshDistance(int i, int j)
          Returns a distance between i-th and j-th nodes of the extended mesh.
abstract  void findCell(SimpleMeshWorkspace workspace, double x)
          Finds a mesh cell to which a point belongs.
static void findCell(SimpleMeshWorkspace workspace, double t, double[] nodes, int firstIndex, int lastIndex)
          Finds a mesh cell to which a point belongs.
static void findCell(SimpleMeshWorkspace workspace, double t, float[] nodes, int firstIndex, int lastIndex)
          Finds a mesh cell to which a point belongs.
abstract  double get(int i)
          Returns a value of i-th mesh node in the original coordinate system.
abstract  boolean isUniform()
          Returns a mesh uniformness tag.
 double origin()
          Returns the new origin point.
 double scale()
          Returns the scale factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

public final int size
A number of mesh nodes.

origin

protected double origin
An affine transform origin.

scale

protected double scale
An affine fransform scaling factor.
Constructor Detail

SimpleMesh

protected SimpleMesh(int size)
Constructor: sets the mesh size attribute.
Method Detail

origin

public final double origin()
Returns the new origin point.

scale

public final double scale()
Returns the scale factor.

averageStep

public abstract double averageStep()
Returns an average mesh step.

findCell

public abstract void findCell(SimpleMeshWorkspace workspace,
                              double x)
Finds a mesh cell to which a point belongs. Writes the cell index and a position within the cell (a distance in new coordinates from the left cell bound) into workspace's attributes cellIndex and cellPoint.
Parameters:
workspace - a mesh workspace
x - a point (in original coordinates) to search

get

public abstract double get(int i)
Returns a value of i-th mesh node in the original coordinate system.

isUniform

public abstract boolean isUniform()
Returns a mesh uniformness tag.

distance

public abstract double distance(int i,
                                int j)
Returns a distance between i-th and j-th nodes of transformed mesh, e.g. the value ti-tj.

extendedMeshDistance

public double extendedMeshDistance(int i,
                                   int j)
Returns a distance between i-th and j-th nodes of the extended mesh. The transformed mesh is extended in both directions by a number of virtual nodes. The additional notes are usually placed with the same distance between each other. The left virtual nodes indices are -1, -2, ... and the right virtual nodes indices are size, size+1, ...

findCell

public static void findCell(SimpleMeshWorkspace workspace,
                            double t,
                            double[] nodes,
                            int firstIndex,
                            int lastIndex)
Finds a mesh cell to which a point belongs. Writes the cell index and a position within the cell (a distance in new coordinates from the left cell bound) into workspace's attributes cellIndex and cellPoint. The algorithm is adaptive (at first it tests cells neighbouring to the cell found before).

The nodes[firstIndex],...,nodes[lastIndex-1] entries are used in the algorithm. The resulting cell index is an integer value belonging to the range [firstIndex..lastIndex]. If cellIndex==firstIndex, the point is to the left from the nodes[firstIndex]. In this case, the position will be negative and equal to (t-nodes[firstIndex]). In other cases, the point position is equal to (t-nodes[cellIndex-1]).

Parameters:
workspace - the mesh workspace
t - the point (in mesh coordinates) to search
nodes - the array containing mesh nodes
firstIndex - the first index in the array to search
lastIndex - the index after the last array's entry

findCell

public static void findCell(SimpleMeshWorkspace workspace,
                            double t,
                            float[] nodes,
                            int firstIndex,
                            int lastIndex)
Finds a mesh cell to which a point belongs. Writes the cell index and a position within the cell (a distance in new coordinates from the left cell bound) into workspace's attributes cellIndex and cellPoint. The algorithm is adaptive (at first it tests cells neighbouring to the cell found before).

The nodes[firstIndex],...,nodes[lastIndex-1] entries are used in the algorithm. The resulting cell index is an integer value belonging to the range [firstIndex..lastIndex]. If cellIndex==firstIndex, the point is to the left from the nodes[firstIndex]. In this case, the position will be negative and equal to (t-nodes[firstIndex]). In other cases, the point position is equal to (t-nodes[cellIndex-1]).

Parameters:
workspace - the mesh workspace
t - the point (in mesh coordinates) to search
nodes - the array containing mesh nodes
firstIndex - the first index in the array to search
lastIndex - the index after the last array's entry