org.jcae.mesh.oemm
Class OEMM

java.lang.Object
  extended by org.jcae.mesh.oemm.OEMM
All Implemented Interfaces:
java.io.Serializable

public class OEMM
extends java.lang.Object
implements java.io.Serializable

This class represents an empty OEMM. An OEMM is a pointer-based octree, but cells do not contain any data. Only its spatial structure is considered, and it is assumed that the whole tree can reside in memory. This class defines the octree structure and how to traverse it. References: External Memory Management and Simplification of Huge Meshes, by P. Cignoni, C. Montani, C. Rocchini and R. Scopigno.

See Also:
Serialized Form

Nested Class Summary
static class OEMM.Node
          This class represents octants of an OEMM.
 
Field Summary
 OEMM.Node[] leaves
          Array of leaves.
static int MAXLEVEL
          Maximal tree depth.
protected  OEMM.Node root
          Root cell.
 double[] x0
          Double/integer conversion.
 
Constructor Summary
OEMM(int l)
          Create an empty OEMM with a given depth.
OEMM(java.lang.String dir)
          Create an empty OEMM.
 
Method Summary
 OEMM.Node build(int[] ijk)
          Builds an octant containing a given point if it does not already exist.
 int cellSizeByHeight(int h)
          Returns size of cells at a given height.
 boolean checkBoundingBox(double[] bbox)
          Checks whether a bounding box lies within current OEMM.
 void clearNodes()
          Remove all cells from a tree.
 void double2int(double[] p, int[] ijk)
          Converts from double coordinates to integer coordinates.
 double[] getCoords(boolean onlyLeaves)
          Returns coordinates of all cell corners.
 int getDepth()
           
 java.lang.String getDirectory()
          Returns top-level directory.
 java.lang.String getFileName()
          Returns file name containing OEMM data structure.
 int getNumberOfLeaves()
          Returns number of leaves.
protected static int indexSubOctree(int size, int[] ijk)
          Returns local index of cell containing a given point.
 void insert(OEMM.Node current)
          Inserts an octant into the tree structure if it does not already exist.
 void int2double(int[] ijk, double[] p)
          Converts from integer coordinates to double coordinates.
protected  void mergeChildren(OEMM.Node node)
          Merges all children of a given cell.
protected  int minCellSize()
          Returns size of deepest cell.
 void printInfos()
          Prints tree stats.
 OEMM.Node search(int[] ijk)
          Returns the octant of an OEMM structure containing a given point.
static OEMM.Node searchAdjacentNode(OEMM.Node fromNode, int[] ijk)
          Returns the adjacent node located at a given point with the same size.
 void setBoundingBox(double[] bbox)
          Sets object bounding box.
 void setDirectory(java.lang.String dir)
          Sets top-level directory.
 boolean walk(TraversalProcedure proc)
          Traverses the whole OEMM structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXLEVEL

public static final int MAXLEVEL
Maximal tree depth.

See Also:
Constant Field Values

x0

public double[] x0
Double/integer conversion. First three values contain coordinates of bottom-left corner, and the last one is a scale factor. Any coordinate can then been converted from double to integer by this formula:
  I[i] = (D[i] - x0[i]) * x0[3];
 
and inverse conversion is
  D[i] = x0[i] + I[i] / x0[3];
 


root

protected transient OEMM.Node root
Root cell.


leaves

public transient OEMM.Node[] leaves
Array of leaves.

Constructor Detail

OEMM

public OEMM(java.lang.String dir)
Create an empty OEMM.


OEMM

public OEMM(int l)
Create an empty OEMM with a given depth.

Method Detail

clearNodes

public final void clearNodes()
Remove all cells from a tree.


setBoundingBox

public final void setBoundingBox(double[] bbox)
Sets object bounding box. This method computes x0.

Parameters:
bbox - bounding box

checkBoundingBox

public final boolean checkBoundingBox(double[] bbox)
Checks whether a bounding box lies within current OEMM.

Parameters:
bbox - bounding box
Returns:
true if bounding box lies within current OEMM, false otherwise.

getDirectory

public final java.lang.String getDirectory()
Returns top-level directory.

Returns:
top-level directory

setDirectory

public final void setDirectory(java.lang.String dir)
Sets top-level directory.

Parameters:
dir - top-level directory

getFileName

public final java.lang.String getFileName()
Returns file name containing OEMM data structure.

Returns:
file name

getNumberOfLeaves

public final int getNumberOfLeaves()
Returns number of leaves.

Returns:
number of leaves

minCellSize

protected final int minCellSize()
Returns size of deepest cell.

Returns:
size of deepest cell

cellSizeByHeight

public final int cellSizeByHeight(int h)
Returns size of cells at a given height. By convention, height is set to 0 for bottom leaves.

Parameters:
h - cell height
Returns:
size of cells at given height

printInfos

public final void printInfos()
Prints tree stats.


double2int

public final void double2int(double[] p,
                             int[] ijk)
Converts from double coordinates to integer coordinates.

Parameters:
p - double coordinates.
ijk - integer coordinates.

int2double

public final void int2double(int[] ijk,
                             double[] p)
Converts from integer coordinates to double coordinates.

Parameters:
ijk - integer coordinates.
p - double coordinates.

walk

public final boolean walk(TraversalProcedure proc)
Traverses the whole OEMM structure.

Parameters:
proc - procedure called on each octant.
Returns:
true if the whole structure has been traversed, false if traversal aborted.

indexSubOctree

protected static final int indexSubOctree(int size,
                                          int[] ijk)
Returns local index of cell containing a given point.

Parameters:
size - size of child cells
ijk - integer coordinates of desired point

build

public final OEMM.Node build(int[] ijk)
Builds an octant containing a given point if it does not already exist.

Parameters:
ijk - integer coordinates of an interior node
Returns:
the octant of the smallest size containing this point. It is created if it does not exist.

insert

public final void insert(OEMM.Node current)
Inserts an octant into the tree structure if it does not already exist.

Parameters:
current - node being inserted.

search

public final OEMM.Node search(int[] ijk)
Returns the octant of an OEMM structure containing a given point.

Parameters:
ijk - integer coordinates of an interior node
Returns:
the octant of the smallest size containing this point.

mergeChildren

protected final void mergeChildren(OEMM.Node node)
Merges all children of a given cell.

Parameters:
node - cell to be merged

searchAdjacentNode

public static final OEMM.Node searchAdjacentNode(OEMM.Node fromNode,
                                                 int[] ijk)
Returns the adjacent node located at a given point with the same size.

Parameters:
fromNode - start node
ijk - integer coordinates of lower-left corner
Returns:
the octant of the desired size containing this point.

getCoords

public double[] getCoords(boolean onlyLeaves)
Returns coordinates of all cell corners.

Parameters:
onlyLeaves - if set to true, only leaf cells are considered, otherwise all cells are considered.
Returns:
an array containing corners coordinates

getDepth

public int getDepth()