org.jcae.mesh.oemm
Class RawStorage

java.lang.Object
  extended by org.jcae.mesh.oemm.RawStorage

public class RawStorage
extends java.lang.Object

Convert a triangle soup into an OEMM data structure. The different steps can be found in MeshOEMMIndex, here is a summary:

  1. Initialize an OEMM instance with desired depth.
  2. Read triangle soup and count triangle in each OEMM cell.
  3. Merge adjacent cells when they contain few triangles.
  4. Copy triangle soup into a dispatched file in which triangles are sorted by octants.
  5. In each octant, write an indexed OEMM data structure.


Nested Class Summary
static interface RawStorage.SoupReaderInterface
           
 
Constructor Summary
RawStorage()
           
 
Method Summary
static boolean countTriangles(OEMM tree, java.lang.String soupFile)
          Builds an OEMM and counts the number of triangles which have to be assigned to each leaf.
static boolean countTriangles(OEMM tree, java.lang.String soupFile, boolean build)
          Counts the number of triangles which have to be assigned to each leaf.
static void dispatch(OEMM tree, java.lang.String soupFile, java.lang.String structFile, java.lang.String dataFile)
          Reads a triangle soup and dispatches triangles into an intermediate OEMM data structure.
static void indexOEMM(java.lang.String structFile, java.lang.String outDir)
          Transforms dispatched file into an OEMM.
static void readSoup(java.lang.String file, RawStorage.SoupReaderInterface proc)
          Reads a triangle soup and executes a procedure on all triangles and vertices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawStorage

public RawStorage()
Method Detail

readSoup

public static void readSoup(java.lang.String file,
                            RawStorage.SoupReaderInterface proc)
Reads a triangle soup and executes a procedure on all triangles and vertices.

Parameters:
file - triangle soup file name
proc - a RawStorage.SoupReaderInterface instance, its RawStorage.SoupReaderInterface.processVertex(int, double[]) method is called for each vertex, and RawStorage.SoupReaderInterface.processTriangle(int) is called for each triangle.

countTriangles

public static boolean countTriangles(OEMM tree,
                                     java.lang.String soupFile)
Builds an OEMM and counts the number of triangles which have to be assigned to each leaf. A triangle soup is read from the file associated with an OEMM, deepest cells for triangle vertices are created if needed, and triangle counters are updated. When this routine returns, all leaf nodes have been created and each node knowa how many triangles will be assigned to it in later stages.

Parameters:
tree - an OEMM
soupFile - triangle soup file name
Returns:
false if a vertex was found outside of octree bounds, true otherwise.

countTriangles

public static boolean countTriangles(OEMM tree,
                                     java.lang.String soupFile,
                                     boolean build)
Counts the number of triangles which have to be assigned to each leaf. A triangle soup is read from the file associated with an OEMM, deepest cells for triangle vertices are created if needed, and triangle counters are updated. When this routine returns, all leaf nodes have been created and each node know how many triangles will be assigned to it in later stages.

Parameters:
tree - an OEMM
soupFile - triangle soup file name
build - if true, OEMM instance is built. Otherwise, it is supposed to have already been built.
Returns:
false if a vertex was found outside of octree bounds, true otherwise.

dispatch

public static final void dispatch(OEMM tree,
                                  java.lang.String soupFile,
                                  java.lang.String structFile,
                                  java.lang.String dataFile)
Reads a triangle soup and dispatches triangles into an intermediate OEMM data structure. The data structure has been setup in countTriangles(org.jcae.mesh.oemm.OEMM, java.lang.String), and will now be written onto disk as a linear octree. Each block is composed of a header containing:
  1. Block size.
  2. Cell size (in integer coordinates).
  3. Integer coordinates of its lower-left corner.
  4. Exact number of triangles stored in this leaf.
It is followed by the integer coordinates of triangle vertices.

Parameters:
tree - an OEMM
soupFile - triangle soup file name
structFile - output file containing dispatched data structure
dataFile - dispatched data file

indexOEMM

public static void indexOEMM(java.lang.String structFile,
                             java.lang.String outDir)
Transforms dispatched file into an OEMM.

Parameters:
structFile - dispatched file.
outDir - directory in which OEMM structure will be stored.