org.jcae.mesh.oemm
Class Storage

java.lang.Object
  extended by org.jcae.mesh.oemm.Storage
Direct Known Subclasses:
MeshReader

public class Storage
extends java.lang.Object

This class converts between disk and memory formats. MeshOEMMIndex is an example to show how to convert a triangle soup into an out-of-core mesh data structure. When an OEMM is generated on disk, octants can be loaded and unloaded on demand. An OEMM instance is first created by calling readOEMMStructure(java.lang.String). Then MeshReader.buildMesh(TIntHashSet) can be called to select which octants are loaded into memory. As can be seen in readOEMMStructure(java.lang.String), OEMM instances are serialized on disk. But this is different with partial mesh data structure. Each child octant has a local number between 0 and 7 depending on its spatial localization. A similar structure is kept on disk, each child octant is put into a seperate directory named after its number. Octant leaves contain vertex and triangle data. A file with a "v" suffix contains coordinates of vertices stored as 3 double values. A file with a "a" suffix contains for each vertex the list of leaves which are connected to this vertex. This allows setting readable and writable attributes, as explained in original paper. A file with a "t" suffix contains for each triangle 6 int values, the first 3 are leaf numbers for its 3 vertices, and last 3 are local vertex number in their respective leaf.


Field Summary
protected static int TRIANGLE_SIZE
          Number of bytes per triangle.
protected static int VERTEX_SIZE
          Number of bytes per vertex.
 
Constructor Summary
Storage()
           
 
Method Summary
protected static java.io.File getAdjacencyFile(OEMM oemm, OEMM.Node node)
           
protected static java.io.File getTrianglesFile(OEMM oemm, OEMM.Node node)
           
protected static java.io.File getVerticesFile(OEMM oemm, OEMM.Node current)
           
protected static java.util.List<TIntArrayList> readAdjacencyFile(OEMM oemm, OEMM.Node node, TIntHashSet storedLeaves)
          Read adjacency file and returns List of adjacent nodes without nodes that are loaded.
static OEMM readOEMMStructure(java.lang.String dir)
          Creates an OEMM instance from its disk representation.
static void saveNodes(OEMM oemm, Mesh mesh, TIntHashSet storedLeaves)
          Saves mesh on the disk into octree structure.
static void storeOEMMStructure(OEMM oemm)
          Stores an OEMM instance to its disk representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRIANGLE_SIZE

protected static final int TRIANGLE_SIZE
Number of bytes per triangle. On disk a triangle is represented by

See Also:
Constant Field Values

VERTEX_SIZE

protected static final int VERTEX_SIZE
Number of bytes per vertex. On disk a vertex is represented by 3 double (coordinates).

See Also:
Constant Field Values
Constructor Detail

Storage

public Storage()
Method Detail

readOEMMStructure

public static OEMM readOEMMStructure(java.lang.String dir)
Creates an OEMM instance from its disk representation.

Parameters:
dir - directory containing disk representation
Returns:
an OEMM instance

storeOEMMStructure

public static void storeOEMMStructure(OEMM oemm)
Stores an OEMM instance to its disk representation.

Parameters:
oemm - stored object

saveNodes

public static void saveNodes(OEMM oemm,
                             Mesh mesh,
                             TIntHashSet storedLeaves)
Saves mesh on the disk into octree structure. The o-nodes, that will be saved, are deduced from mesh (from position of vertices).

Parameters:
oemm - OEMM instance
mesh - mesh to be stored onto disk
storedLeaves - set of leaves to store TODO There is no support for moving vertices into another octree node.

getAdjacencyFile

protected static java.io.File getAdjacencyFile(OEMM oemm,
                                               OEMM.Node node)

getTrianglesFile

protected static java.io.File getTrianglesFile(OEMM oemm,
                                               OEMM.Node node)

getVerticesFile

protected static java.io.File getVerticesFile(OEMM oemm,
                                              OEMM.Node current)

readAdjacencyFile

protected static java.util.List<TIntArrayList> readAdjacencyFile(OEMM oemm,
                                                                 OEMM.Node node,
                                                                 TIntHashSet storedLeaves)
Read adjacency file and returns List of adjacent nodes without nodes that are loaded.

Parameters:
oemm - OEMM instance
node - OEMM node
storedLeaves - set of node indices being loaded
Returns:
a List instance; for each vertex, returns indices of adjacent and non-loaded nodes