JavaView© v3.95.000

vgp.volume.mc
Class PnMarchingCubes

java.lang.Object
  extended byvgp.volume.mc.PnMarchingCubes

public class PnMarchingCubes
extends java.lang.Object

Implementation of the marching cubes algorithm. This class will generate an isosurface to a given scalar field.

You may pass the scalar field as an dimX*dimY*dimZ sized array of double values. Because of the limited memory of a machine, it is also possible to specify a function which is called repeatedly from the algorithm to obtain the data of the scalar field. However, if the evaluation of the function costs much time, you may want to enable buffering, which reduces the number of callback calls for the same point in space from 8 to 1. The memory used for buffering is O(dimX*dimY).

Usage:
Construct new MarchingCube object
call setVectorGrid()
call setData() or setFunction()
call startAlgorithm()


Constructor Summary
PnMarchingCubes()
          Construct a new MarchingCubes object.
 
Method Summary
 boolean getOrientate()
          Return a flag, whether the alforithm should produce an oriented surface.
 boolean getWeighted()
           
 void setData(PdVector data)
          Set the data of the scalar field.
 void setFunction(PnFunction function, boolean bufferData)
          Set function to obtain the data of the scalar field.
 void setOrientate(boolean orientate)
          Set flag, whether the algorithm should produce an oriented surface.
 void setVectorGrid(int dimX, int dimY, int dimZ, PdVector origin, PdVector baseX, PdVector baseY, PdVector baseZ)
          Set the dimension and distortion of the bounding box.
 void setVectorGrid(PdVector corner1, PdVector corner2, int numX, int numY, int numZ)
          Set the dimension and bounding box of the vector grid.
 void setWeighted(boolean weighted)
          Set whether the position of new vertices should be weighted on the function values of the corners of the cube.
 PgElementSet startAlgorithm(double threshold)
          Start the algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PnMarchingCubes

public PnMarchingCubes()
Construct a new MarchingCubes object.

Method Detail

setVectorGrid

public void setVectorGrid(PdVector corner1,
                          PdVector corner2,
                          int numX,
                          int numY,
                          int numZ)
Set the dimension and bounding box of the vector grid. The bounding box is assumed to be a box with faces in the (x,y), (x,z) and (x,z) planes.

Parameters:
corner1 - on corner of the bounding box
corner2 - opposite corner of the bounding box
numX - number of sampled points in x direction
numY - number of sampled points in y direction
numZ - number of sampled points in z direction

setVectorGrid

public void setVectorGrid(int dimX,
                          int dimY,
                          int dimZ,
                          PdVector origin,
                          PdVector baseX,
                          PdVector baseY,
                          PdVector baseZ)
Set the dimension and distortion of the bounding box. All points of the form origin + k*baseX + l*baseY + m*baseZ will be sampled.

This method should be called before setData() or setDataProducer().

Parameters:
dimX - number of sampled points in x direction
dimY - number of sampled points in y direction
dimZ - number of sampled points in z direction
origin - corner of the bounding box
baseX - distance vector between two sample points in x direction
baseY - distance vector between two sample points in y direction
baseZ - distance vector between two sample points in z direction

setData

public void setData(PdVector data)
Set the data of the scalar field. The argument should be a vector of size dimX*dimY*dimZ. The value of the scalar field at position (x,y,z) should be stored in this vector at position [z*dimX*dimY + y*dimX + x].

Parameters:
data - function values of the sample points

setFunction

public void setFunction(PnFunction function,
                        boolean bufferData)
Set function to obtain the data of the scalar field.

Parameters:
function - instance of PnFunction
bufferData - whether the obtained data from the function should be buffered

setWeighted

public void setWeighted(boolean weighted)
Set whether the position of new vertices should be weighted on the function values of the corners of the cube. If this is enabled, the generated shape will be smoother, but there may occur more thin triangles (default: enabled).


getWeighted

public boolean getWeighted()
Returns:
boolean true if the position of new vertices is weighted on the function values at the corners of the cube.

setOrientate

public void setOrientate(boolean orientate)
Set flag, whether the algorithm should produce an oriented surface. When orientate is enabled, the algorithm will be a bit slower.

Parameters:
orientate - whether to produce an oriented surface (default: true)

getOrientate

public boolean getOrientate()
Return a flag, whether the alforithm should produce an oriented surface.


startAlgorithm

public PgElementSet startAlgorithm(double threshold)
Start the algorithm. The returned isosurface is not cleaned. You may want to call identifyVertices() and makeElementNormals() on the element set.

Parameters:
threshold - iso value for evaluation
Returns:
PgElementSet the generated isosurface

JavaView© v3.95.000

The software JavaView© is copyright protected. All Rights Reserved.