ru.sscc.spline.base
Class SimpleMesh

java.lang.Object
  |
  +--ru.sscc.spline.base.SimpleMesh
Direct Known Subclasses:
OrderedMesh

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
 double origin
          An affine transform origin.
 double scale
          An affine fransform scaling factor.
 int size
          A number of mesh nodes.
 
Constructor Summary
SimpleMesh()
           
 
Method Summary
abstract  double distance(int i, int j)
          Returns a distance between i-th and j-th nodes of transformed mesh, e.g.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origin

public double origin
An affine transform origin.

scale

public double scale
An affine fransform scaling factor.

size

public int size
A number of mesh nodes.
Constructor Detail

SimpleMesh

public SimpleMesh()
Method Detail

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.

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.

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