Class PnMarchingCubes
- java.lang.Object
-
- vgp.volume.mc.PnMarchingCubes
-
public class PnMarchingCubes extends java.lang.ObjectImplementation 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()- Author:
- Matthias Nieser
- Version:
- 27.01.05, 1.00 created (mn) 15.02.05, 1.10 data producer replaced by PnFunction (mn) 18.02.05, 1.11 made some code beautification (mn)
-
-
Constructor Summary
Constructors Constructor and Description PnMarchingCubes()Construct a new MarchingCubes object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleangetOrientate()Return a flag, whether the alforithm should produce an oriented surface.booleangetWeighted()voidsetData(PdVector data)Set the data of the scalar field.voidsetFunction(PnFunction function, boolean bufferData)Set function to obtain the data of the scalar field.voidsetOrientate(boolean orientate)Set flag, whether the algorithm should produce an oriented surface.voidsetVectorGrid(int dimX, int dimY, int dimZ, PdVector origin, PdVector baseX, PdVector baseY, PdVector baseZ)Set the dimension and distortion of the bounding box.voidsetVectorGrid(PdVector corner1, PdVector corner2, int numX, int numY, int numZ)Set the dimension and bounding box of the vector grid.voidsetWeighted(boolean weighted)Set whether the position of new vertices should be weighted on the function values of the corners of the cube.PgElementSetstartAlgorithm(double threshold)Start the algorithm.
-
-
-
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 boxcorner2- opposite corner of the bounding boxnumX- number of sampled points in x directionnumY- number of sampled points in y directionnumZ- 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 directiondimY- number of sampled points in y directiondimZ- number of sampled points in z directionorigin- corner of the bounding boxbaseX- distance vector between two sample points in x directionbaseY- distance vector between two sample points in y directionbaseZ- 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 PnFunctionbufferData- 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
-
-
"