Class VolumeSurface
- java.lang.Object
-
- gov.nih.mipav.view.renderer.WildMagic.Render.VolumeObject
-
- gov.nih.mipav.view.renderer.WildMagic.Render.VolumeSurface
-
public class VolumeSurface extends VolumeObject
-
-
Field Summary
Fields Modifier and Type Field Description private WildMagic.LibFoundation.Mathematics.ColorRGBA[]
m_akBackupColor
Backup of the per-vertex colors.private WildMagic.LibGraphics.SceneGraph.Node[]
m_akGeodesicNodes
Contains geodesic display components.private java.lang.String[]
m_akUnitsLabel
private boolean
m_bFirstRender
private boolean
m_bPainted
Set to true when the surface has been painted.private boolean
m_bTextureOn
Set to true when texture mapping is on.private float
m_fBlend
private float
m_fSurfaceArea
Surface area.private float
m_fVolume
Surface volume.private int
m_iCurrentGeodesic
Current displayed geodesic component.private WildMagic.LibGraphics.SceneGraph.BoxBV
m_kBoundingBox
private WildMagic.LibFoundation.Mathematics.Vector3f
m_kCenter
Center of surface.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kCenterScanner
private SurfaceLightingEffect
m_kLightShader
Surface shader effect.private SurfaceLightingEffect
m_kLightShaderTransparent
private WildMagic.LibGraphics.Rendering.MaterialState
m_kMaterial
Surface material properties.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kMaxBB
private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kMesh
TriMeshprivate WildMagic.LibFoundation.Mathematics.Vector3f
m_kMinBB
private float
m_kOpacity
Surface opacity value.private java.util.BitSet
m_kSurfaceMask
private SurfaceState
m_kSurfaceState
private java.util.BitSet
m_kVolumeMask
private VolumePreRenderEffect
m_kVolumePreShader
ShaderEffect for the plane bounding-boxes.private VolumePreRenderEffect
m_kVolumePreShaderTransparent
-
Fields inherited from class gov.nih.mipav.view.renderer.WildMagic.Render.VolumeObject
m_bDisplay, m_bPickable, m_bTransparent, m_fVolumeDiv, m_fVolumeMult, m_fX, m_fY, m_fZ, m_kAlpha, m_kAlphaTransparency, m_kCull, m_kDeleteList, m_kLocalScale, m_kPolygonOffset, m_kResolutions, m_kScene, m_kTranslate, m_kVolumeImageA, m_kVolumeImageB, m_kVolumeScale, m_kVolumeTrans, m_kWireframe, m_kZBuffer, m_kZBufferTransparency
-
-
Constructor Summary
Constructors Constructor Description VolumeSurface(VolumeImage[] images, WildMagic.LibGraphics.Rendering.Texture colormap, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean bComputeSurfaceMask, boolean isFileCoords)
VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface)
Create a new VolumeSurface with the VolumeImage parameter.VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean isFileCoords)
VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean bComputeSurfaceMask, boolean isFileCoords)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
AddGeodesic(WildMagic.LibGraphics.SceneGraph.Geometry kMesh, int iGroup)
Add a new geodesic component to the surface.void
Blend(float fValue)
Set object blend value.private java.util.HashSet[]
buildConnections()
Builds a list of cross-references, so that connections[i] contains all the vertices that are connected to vertex at i.private void
calcVolumeMask(java.util.BitSet mask, ModelImage kOutputImage, WildMagic.LibFoundation.Mathematics.Vector3f[] directions, int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, int iDimX, int iDimY)
private void
ComputeCenter()
Compute the center of the surface.private float
computeMeanEdgeLength(java.util.HashMap kEMap)
Compute the average length of all the edges in the triangle mesh.float
ComputeSurfaceArea()
Calculate the surface mesh area.static ModelImage
computeSurfaceImage(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image)
private static ModelImage
computeSurfaceImage(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale)
java.util.BitSet
computeSurfaceMask()
Computes a volume mask of the triangle mesh surface.private static void
computeSurfaceMask(java.util.BitSet mask, WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale, int start, int stop)
static java.util.BitSet
computeSurfaceMask(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image)
private static java.util.BitSet
computeSurfaceMask(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale)
private void
computeVertexInformation(float[] afParams, float fMeanEdgeLength, WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal, WildMagic.LibFoundation.Mathematics.Vector3f[] akVMean, WildMagic.LibFoundation.System.UnorderedSetInt[] akAdjacent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSTangent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSNormal, float[] afCurvature)
Let V[i] be a vertex in the triangle mesh.private void
computeVertexNormals(WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal)
Compute the vertex normals of the triangle mesh.float
ComputeVolume()
Calculates volume of triangle mesh.private void
CreateScene()
Creates the scene graph.java.util.BitSet
createVolumeMask()
Creates a BitSet mask that is the volume enclosed by the triangle mesh.void
dispose(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
Delete local memory.void
Dropper(WildMagic.LibGraphics.Collision.PickRecord kRecord, WildMagic.LibFoundation.Mathematics.ColorRGBA rkDropperColor, WildMagic.LibFoundation.Mathematics.Vector3f rkPickPoint)
Paint can support.void
Erase(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.Collision.PickRecord kRecord, int iBrushSize)
Erase paint.void
EraseAllPaint(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
Erase all paint.WildMagic.LibFoundation.Mathematics.Vector3f
GetCenter()
Return center of the surface.WildMagic.LibFoundation.Mathematics.ColorRGB
GetColor()
private static float
getIntersectX(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iY, float iZ)
Compute the point of intersection between a line (0,iY,iZ)+t(1,0,0) and the triangle defined by the three input points.private static float
getIntersectY(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iX, float iZ)
Compute the point of intersection between a line (iX,0,iZ)+t(0,1,0) and the triangle defined by the three input points.private static float
getIntersectZ(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iX, float iY)
Compute the point of intersection between a line (iX,iY,0)+t(0,0,1) and the triangle defined by the three input points.WildMagic.LibGraphics.Rendering.MaterialState
GetMaterial()
Return the surface material properties.WildMagic.LibGraphics.SceneGraph.TriMesh
GetMesh()
Return the TriMesh object (if, any) associated with this object.WildMagic.LibFoundation.Mathematics.Vector3f[]
getMinMax()
Returns the min/max bounding box coordinates for the mesh in volume-index coordinates.java.lang.String
GetName()
Return the name of this object.float
GetOpacity()
Return the surface opacity value.float
GetSurfaceArea()
Return the surface area.java.lang.String
GetSurfaceAreaString()
Return the surface area.float
GetVolume()
Return the volume of this surface.java.lang.String
GetVolumeString()
Return the volume of this surface.private void
initBoundingBox()
Initializes the bounding box for the mesh.void
Paint(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.Collision.PickRecord kRecord, WildMagic.LibFoundation.Mathematics.ColorRGBA kPaintColor, int iBrushSize)
Painting support.void
RemoveAllGeodesic()
Removes all geodesic components from the given surface.void
RemoveGeodesic(int iNode, int iGroup)
Removes the specific geodesic component from the given surface.void
Render(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller, boolean bPreRender, boolean bSolid)
Render the object.void
Render(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller, SurfaceClipEffect[] kEffect, int index, float fClipM1, float fClipP1)
Render the object.void
ReplaceGeodesic(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
When the Geodesic object cuts the mesh along an open curve, the old mesh changes, but does not need to be deleted and no new mesh needs to be added.private void
scaleMesh(float fValue, java.util.HashSet[] connections)
void
SetClip(int iWhich, float data, boolean bEnable)
Sets axis-aligned clipping for the VolumeShaderEffect.void
SetClipArb(float[] afEquation, boolean bEnable)
Sets arbitrary clipping for the VolumeShaderEffect.void
SetClipArbInv(float[] afEquation, boolean bEnable)
Sets arbitrary clipping for the VolumeShaderEffect.void
SetClipEye(float[] afEquation, boolean bEnable)
Sets eye clipping for the VolumeShaderEffect.void
SetClipEyeInv(float[] afEquation, boolean bEnable)
Sets inverse-eye clipping for the VolumeShaderEffect.void
SetClipping(boolean bClip)
Enables/disables surface clipping for the per-pixel shader.void
SetColor(WildMagic.LibFoundation.Mathematics.ColorRGB kColor, boolean bUpdate)
Set the object color.void
SetImageNew(ModelImage kImage)
Sets the ModelImage to use as an alternative to the volume ModelImage for surface texturing.void
SetLight(java.lang.String kLightType, float[] afType)
Sets the light for the EllipsoidsShader.void
SetLUTNew(ModelStorageBase kLUT)
Sets the LUT to use as an alternative to the volume lut for surface texturing.void
SetMaterial(WildMagic.LibGraphics.Rendering.MaterialState kMaterial, boolean bUpdate)
Set the surface material propertiesvoid
SetOpacity(float opacity)
Set the surface opacity propertiesvoid
SetPerPixelLighting(WildMagic.LibGraphics.Rendering.Renderer kRenderer, boolean bOn)
Sets the lighting shader to be per-pixel or per-vertex.void
SetSurfaceTexture(boolean bOn, boolean bUseNewImage, boolean bUseNewLUT)
Sets the surface texture on/off.void
SetTranslateVolumeCoords(WildMagic.LibFoundation.Mathematics.Vector3f position)
void
SetTranslateVolumeCoords(WildMagic.LibFoundation.Mathematics.Vector3f position, boolean compute)
void
smoothMesh(int iteration, float alpha, boolean volumeLimit, float volumePercent)
Smooth mesh.void
smoothThree(int iteration, float lambda, float mu)
Smooth mesh.void
smoothTwo(int iterations, float fStiffness, boolean volumeLimit, float volumePercent)
Derived from the first 2 of the 3 components of AlgorithmBrainExtraction Note that m_fStiffness does not increase and then decrease as in AlgorithmBrainExtraction but instead remains constant.boolean
testIntersection(WildMagic.LibFoundation.Mathematics.Vector3f kP0, boolean bUseMask)
Test if the input point is inside the triangle mesh.boolean
testIntersection(WildMagic.LibFoundation.Mathematics.Vector3f kP0, WildMagic.LibFoundation.Mathematics.Vector3f kP1, boolean bUseMask, boolean bPrint)
Tests if the line segment specified by the two input points intersects the mesh.private boolean
testIntersectionMask(WildMagic.LibFoundation.Mathematics.Vector3f kPos)
private boolean
testIntersections(WildMagic.LibFoundation.Mathematics.Vector3f kP0, WildMagic.LibFoundation.Mathematics.Vector3f kP1)
Tests if the line segment determined by the two input end-points intersects the mesh.static boolean
testIntersections(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, WildMagic.LibFoundation.Mathematics.Vector3f origin, WildMagic.LibFoundation.Mathematics.Line3f[] akLines)
Test if the input point is inside the mesh.void
ToggleGeodesicPathDisplay(int iWhich)
Switches between different ways of displaying the geodesic path (Euclidean, Geodesic, or Mesh).private float
update2(int i, float[] afCurvature, float fStiffness, float[] afParam)
Compute the coefficient of the surface normal for the update of the mesh vertex V[i] in the SNormal[i] direction.private void
updateMesh(java.util.HashMap kEMap, WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal, WildMagic.LibFoundation.Mathematics.Vector3f[] akVMean, WildMagic.LibFoundation.System.UnorderedSetInt[] akAdjacent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSTangent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSNormal, float[] afCurvature, float fStiffness)
The heart of the segmentation.-
Methods inherited from class gov.nih.mipav.view.renderer.WildMagic.Render.VolumeObject
GetBackface, getDepth, GetDisplay, GetPickable, GetPolygonMode, GetScene, getTexCoord, GetTranslate, localToScannerCoords, localToVolumeCoords, PostRender, scale, SetBackface, SetDisplay, SetFrontface, setImageB, SetPickable, SetPolygonMode, SetTranslate, Translate, volumeToLocalCoords
-
-
-
-
Field Detail
-
m_kVolumePreShader
private VolumePreRenderEffect m_kVolumePreShader
ShaderEffect for the plane bounding-boxes.
-
m_kVolumePreShaderTransparent
private VolumePreRenderEffect m_kVolumePreShaderTransparent
-
m_kMesh
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kMesh
TriMesh
-
m_kMaterial
private WildMagic.LibGraphics.Rendering.MaterialState m_kMaterial
Surface material properties.
-
m_kOpacity
private float m_kOpacity
Surface opacity value.
-
m_kLightShader
private SurfaceLightingEffect m_kLightShader
Surface shader effect.
-
m_kLightShaderTransparent
private SurfaceLightingEffect m_kLightShaderTransparent
-
m_fVolume
private float m_fVolume
Surface volume.
-
m_fSurfaceArea
private float m_fSurfaceArea
Surface area.
-
m_kCenter
private WildMagic.LibFoundation.Mathematics.Vector3f m_kCenter
Center of surface.
-
m_kCenterScanner
private WildMagic.LibFoundation.Mathematics.Vector3f m_kCenterScanner
-
m_akBackupColor
private WildMagic.LibFoundation.Mathematics.ColorRGBA[] m_akBackupColor
Backup of the per-vertex colors.
-
m_bPainted
private boolean m_bPainted
Set to true when the surface has been painted.
-
m_bTextureOn
private boolean m_bTextureOn
Set to true when texture mapping is on.
-
m_akGeodesicNodes
private WildMagic.LibGraphics.SceneGraph.Node[] m_akGeodesicNodes
Contains geodesic display components.
-
m_iCurrentGeodesic
private int m_iCurrentGeodesic
Current displayed geodesic component.
-
m_fBlend
private float m_fBlend
-
m_kSurfaceState
private SurfaceState m_kSurfaceState
-
m_akUnitsLabel
private java.lang.String[] m_akUnitsLabel
-
m_kBoundingBox
private WildMagic.LibGraphics.SceneGraph.BoxBV m_kBoundingBox
-
m_kMinBB
private WildMagic.LibFoundation.Mathematics.Vector3f m_kMinBB
-
m_kMaxBB
private WildMagic.LibFoundation.Mathematics.Vector3f m_kMaxBB
-
m_bFirstRender
private boolean m_bFirstRender
-
m_kVolumeMask
private java.util.BitSet m_kVolumeMask
-
m_kSurfaceMask
private java.util.BitSet m_kSurfaceMask
-
-
Constructor Detail
-
VolumeSurface
public VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface)
Create a new VolumeSurface with the VolumeImage parameter.- Parameters:
kImageA
- the VolumeImage containing shared data and textures for rendering.kVolumeImageB
- second VolumeImage.kTranslate
- translation in the scene-graph for this object.fX
- the size of the volume in the x-dimension (extent * resolutions)fY
- the size of the volume in the y-dimension (extent * resolutions)fZ
- the size of the volume in the z-dimension (extent * resolutions)
-
VolumeSurface
public VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean bComputeSurfaceMask, boolean isFileCoords)
-
VolumeSurface
public VolumeSurface(VolumeImage[] images, WildMagic.LibGraphics.Rendering.Texture colormap, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean bComputeSurfaceMask, boolean isFileCoords)
-
VolumeSurface
public VolumeSurface(VolumeImage kImageA, VolumeImage kImageB, WildMagic.LibFoundation.Mathematics.Vector3f kTranslate, float fX, float fY, float fZ, SurfaceState kSurface, boolean isFileCoords)
-
-
Method Detail
-
AddGeodesic
public void AddGeodesic(WildMagic.LibGraphics.SceneGraph.Geometry kMesh, int iGroup)
Add a new geodesic component to the surface.- Parameters:
kNew
- the new geodesic component.iGroup
- the display group to add to.
-
Blend
public void Blend(float fValue)
Description copied from class:VolumeObject
Set object blend value.- Overrides:
Blend
in classVolumeObject
- Parameters:
fValue
- blend value.
-
ComputeSurfaceArea
public float ComputeSurfaceArea()
Calculate the surface mesh area. Each surface mesh is composed of triangles. Calculate the surface area from the summation of the each triangle area. Based on the Area by Stokes' Theorem. Area(S) = 1/2 * Normal dot ( Sum from i = 0 to n-1 of ( V1 cross V2) ) ==> Area(S) = 1/2 * ( Sum from i = 0 to n-1 of ( Normal dot ( V1 cross V2) ) )- Returns:
- float
-
ComputeVolume
public float ComputeVolume()
Calculates volume of triangle mesh. The mesh consists of triangle faces and encloses a bounded region. Face j, 0 <= j <= n-1 has verticies P0, P1, and P2. The order of the verticies is counterclockwise as you view the face from outside the bounded region. The mesh is closed and manifold in the sense that each edge is shared by exactly two triangles. The volume of the bounded region is:
V = 1/6 (Sum from j=0 to n-1 of {P0 dot P1 cross P2})
The terms of the summation can be positive, negative, or zero. The term is positive if the face is counterclockwise when viewed from the zero vector, or zero if the face appears to be a line segment when viewed from the zero vector. NOTICE THAT THERE ARE 2 DIFFERENT DEFINITIONS OF COUNTERCLOCKWISE, COUNTERCLOCKWISE AS VIEWED FROM OUTSIDE THE BOUNDED REGION AND COUNTERCLOCKWISE AS VIEWED FROM THE ZERO VECTOR.A 3D image on a rectangular lattice contains points (i0, i1, i2) where 0 <= ik < Bk for specified dimension bounds Bk. These are just indicies. The actual physical measurements are provided by scaling factors Dk > 0. For example, a 256x256x256 MRI has B0 = B1 = B2 = 256. If each voxel is 1 mm in x, 1 mm in y, and 5 mm in z, then D0 = D1 = 1 and D2 = 5. The 3D image encloses a rectangular region [0,C0] x [0,C1] x [0,C2] in physical space where Ck = Dk*Bk. In the example, C0 = D0*B0 = 256 mm in x, C1 = D1*B1 = 256 mm in y, and C2 = D2*B2 = 1280 mm in z. Volume calculations are required to use physical measurements. In the example, volume will be in cubic millimeters.
The surface extraction is performed by mapping [0,C0] x [0,C1] x [0,C2] into [-1,1] x [-1,1] x [-1,1] using uniform scaling. This is done to keep the floating point values within order 1 to avoid the floating point errors that occur if you were to use the index values themselves. The topology of a level surface is invariant under any scaling (not just uniform), but the continuous level of detail algorithm for triangle decimation does edge collapses based on various geometric measurements of the mesh representing the level surface. The geometric measurements are not invariant under nonuniform scaling. Map the image into a cube using uniform scaling so that the triangle collapse order is invariant. The uniform scaling is done so that the largest image dimension [0,M] is mapped to [-1,1]. The other ranges are mapped to intervals of the form [-L,L) where L < 1. If (i0,i1,i2) is in [0,B0) x [0,B1) x [0,B2), the corresponding (x0,x1,x2) in [-1,1) is:
2*Dk*ik - Ck xk = ------------ max{C0,C1,C2}
However, we want to map from [0,Bk) to an inclusive interval [-Rk,Rk], where 0 < Rk < 1 and Rk = 1 - Dk/max{C0,C1,C2}. This ensures that surfaces begin in the center of a voxel rather than at the (0,0,0) corner of the voxel. The problem is easiest to see in the Z direction: a surface that should cover the full Z range will end before the last slice. Therefore, the formula should be:
2*Dk*ik - Ck + Dk xk = ----------------- max{C0,C1,C2}
Once a closed manifold triangle mesh is extracted, the problem is now to compute its volume in physical space. Note that ik are indicies in the original image, but the true physical length that is measured (relative to other index locations) is yk = Dk*ik. Any triangle mesh (x0,x1,x2) must be mapped to (y0,y1,y2) before the volume calculation. The mapping is:
max{C0,C1,C2}*xk + Ck - Dk yk = -------------------------- 2
The volume calculations use the previously mentioned formula where the P points are the (y0,y1,y2) values.
- Returns:
- The volume of the surface.
-
dispose
public void dispose(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
Delete local memory.- Overrides:
dispose
in classVolumeObject
-
Dropper
public void Dropper(WildMagic.LibGraphics.Collision.PickRecord kRecord, WildMagic.LibFoundation.Mathematics.ColorRGBA rkDropperColor, WildMagic.LibFoundation.Mathematics.Vector3f rkPickPoint)
Description copied from class:VolumeObject
Paint can support.- Overrides:
Dropper
in classVolumeObject
- Parameters:
kRecord
- pick record.rkPickPoint
- , picked point.
-
Erase
public void Erase(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.Collision.PickRecord kRecord, int iBrushSize)
Description copied from class:VolumeObject
Erase paint.- Overrides:
Erase
in classVolumeObject
- Parameters:
kRenderer
- Renderer.kRecord
- pick record.iBrushSize
- brush size.
-
EraseAllPaint
public void EraseAllPaint(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
Erase all paint.- Parameters:
kRenderer
- renderer.
-
GetCenter
public WildMagic.LibFoundation.Mathematics.Vector3f GetCenter()
Return center of the surface.- Returns:
- center of the surface.
-
GetMaterial
public WildMagic.LibGraphics.Rendering.MaterialState GetMaterial()
Return the surface material properties.- Returns:
- surface material properties.
-
GetMesh
public WildMagic.LibGraphics.SceneGraph.TriMesh GetMesh()
Description copied from class:VolumeObject
Return the TriMesh object (if, any) associated with this object.- Overrides:
GetMesh
in classVolumeObject
- Returns:
- the TriMesh object (if, any) associated with this object.
-
GetName
public java.lang.String GetName()
Description copied from class:VolumeObject
Return the name of this object.- Overrides:
GetName
in classVolumeObject
- Returns:
- name of this object.
-
GetOpacity
public float GetOpacity()
Return the surface opacity value.- Returns:
- surface opacity value.
-
GetSurfaceArea
public float GetSurfaceArea()
Return the surface area.- Returns:
- surface area.
-
GetSurfaceAreaString
public java.lang.String GetSurfaceAreaString()
Return the surface area.- Returns:
- surface area.
-
GetVolume
public float GetVolume()
Return the volume of this surface.- Returns:
- volume of this surface.
-
GetVolumeString
public java.lang.String GetVolumeString()
Return the volume of this surface.- Returns:
- volume of this surface.
-
Paint
public void Paint(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.Collision.PickRecord kRecord, WildMagic.LibFoundation.Mathematics.ColorRGBA kPaintColor, int iBrushSize)
Description copied from class:VolumeObject
Painting support.- Overrides:
Paint
in classVolumeObject
- Parameters:
kRenderer
- Renderer.kRecord
- pick record.kPaintColor
- paint color.iBrushSize
- brush size.
-
RemoveAllGeodesic
public void RemoveAllGeodesic()
Removes all geodesic components from the given surface.
-
RemoveGeodesic
public void RemoveGeodesic(int iNode, int iGroup)
Removes the specific geodesic component from the given surface.- Parameters:
iNode
-iGroup
-
-
Render
public void Render(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller, boolean bPreRender, boolean bSolid)
Description copied from class:VolumeObject
Render the object.- Specified by:
Render
in classVolumeObject
- Parameters:
kRenderer
- the OpenGLRenderer object.kCuller
- the Culler object.
-
Render
public void Render(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller, SurfaceClipEffect[] kEffect, int index, float fClipM1, float fClipP1)
Render the object.- Parameters:
kRenderer
- the OpenGLRenderer object.kCuller
- the Culler object.
-
ReplaceGeodesic
public void ReplaceGeodesic(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
When the Geodesic object cuts the mesh along an open curve, the old mesh changes, but does not need to be deleted and no new mesh needs to be added. This function allows the Geodesic object to replace the original mesh with the sliced mesh in the surface renderer. ReplaceMesh is also used to undo cutting operations.- Parameters:
kNew
- TriMesh new surface mesh
-
SetClip
public void SetClip(int iWhich, float data, boolean bEnable)
Sets axis-aligned clipping for the VolumeShaderEffect.- Parameters:
afClip
- the clipping parameters for axis-aligned clipping.
-
SetClipArb
public void SetClipArb(float[] afEquation, boolean bEnable)
Sets arbitrary clipping for the VolumeShaderEffect.- Parameters:
afEquation
- the arbitrary-clip plane equation.
-
SetClipArbInv
public void SetClipArbInv(float[] afEquation, boolean bEnable)
Sets arbitrary clipping for the VolumeShaderEffect.- Parameters:
afEquation
- the arbitrary-clip plane equation.
-
SetClipEye
public void SetClipEye(float[] afEquation, boolean bEnable)
Sets eye clipping for the VolumeShaderEffect.- Parameters:
afEquation
- the eye clipping equation.
-
SetClipEyeInv
public void SetClipEyeInv(float[] afEquation, boolean bEnable)
Sets inverse-eye clipping for the VolumeShaderEffect.- Parameters:
afEquation
- the inverse-eye clipping equation.
-
SetClipping
public void SetClipping(boolean bClip)
Enables/disables surface clipping for the per-pixel shader.- Parameters:
bClip
- surface clipping on/off.
-
SetColor
public void SetColor(WildMagic.LibFoundation.Mathematics.ColorRGB kColor, boolean bUpdate)
Description copied from class:VolumeObject
Set the object color.- Overrides:
SetColor
in classVolumeObject
- Parameters:
kColor
- new color.
-
GetColor
public WildMagic.LibFoundation.Mathematics.ColorRGB GetColor()
-
SetImageNew
public void SetImageNew(ModelImage kImage)
Sets the ModelImage to use as an alternative to the volume ModelImage for surface texturing.- Parameters:
kImage
- the alternate ModelImage to use for the surface texture.
-
SetLight
public void SetLight(java.lang.String kLightType, float[] afType)
Description copied from class:VolumeObject
Sets the light for the EllipsoidsShader.- Overrides:
SetLight
in classVolumeObject
- Parameters:
kLightType
- the name of the light to set (Light0, Light1, etc.)afType
- the type of light (Ambient = 0, Directional = 1, Point = 2, Spot = 3).
-
SetLUTNew
public void SetLUTNew(ModelStorageBase kLUT)
Sets the LUT to use as an alternative to the volume lut for surface texturing.- Parameters:
kLUT
- the new LUT.kRGBT
- the new ModelRGB (for color images).
-
SetMaterial
public void SetMaterial(WildMagic.LibGraphics.Rendering.MaterialState kMaterial, boolean bUpdate)
Set the surface material properties- Parameters:
kMaterial
- surface material properties.
-
SetOpacity
public void SetOpacity(float opacity)
Set the surface opacity properties- Parameters:
kMaterial
- surface opacity value.
-
SetPerPixelLighting
public void SetPerPixelLighting(WildMagic.LibGraphics.Rendering.Renderer kRenderer, boolean bOn)
Sets the lighting shader to be per-pixel or per-vertex.- Parameters:
kRenderer
- OpenGL renderer.bOn
- turns per-pixel lighting on/off.
-
SetSurfaceTexture
public void SetSurfaceTexture(boolean bOn, boolean bUseNewImage, boolean bUseNewLUT)
Sets the surface texture on/off.- Parameters:
bTextureOn
- texture on/offbUseNewImage
- indicates which volume to use as the texture.bUseNewLUT
- indicates which LUT to use.
-
SetTranslateVolumeCoords
public void SetTranslateVolumeCoords(WildMagic.LibFoundation.Mathematics.Vector3f position)
-
SetTranslateVolumeCoords
public void SetTranslateVolumeCoords(WildMagic.LibFoundation.Mathematics.Vector3f position, boolean compute)
-
smoothMesh
public void smoothMesh(int iteration, float alpha, boolean volumeLimit, float volumePercent)
Smooth mesh. The formula can be found in "The Visualization Toolkit" by Will Schoeder, Ken Martin, and Bill Lorensen, p. 389. Mesh smoothing moves the verticies of the mesh closer to an average of the points. Each point is moved so that it is the average of the points around it. The formula is:xi+1 = xi + (alpha * (Sum from j=0 to n of {xj - xi}))
where xi+1 is the new point, xi is the orginal point, and the xjs are points that are connected to xi. Alpha is some smoothing factor between .01 and .10. This formula is run for a number of iterations to obtain a smooth mesh. Usually the iterations will be between 50 and 100.- Parameters:
iteration
- Number of times to run smoothing formula on data set.alpha
- Smoothing factor.volumeLimit
- if true stop iterations when the present volume is volumePercent or more different from the initialvolumePercent
- percentage from initial volume for stopping iterations
-
smoothThree
public void smoothThree(int iteration, float lambda, float mu)
Smooth mesh. This method smoothes without shrinking by 2 Gaussian smoothing steps. First, a Gaussian smoothing is performed with a positive scale factor lambda. Second, a Gaussian smoothing is performed with a negative scale factor mu, which is greater in magnitude than lambda. To produce a significant smoothing, these steps must be repeated a number of times. 3 references for this smoothing: 1.) Curve and Surface Smoothing Without Shrinkage by Gabriel Taubin, Technical Report RC-19536, IBM Research, April, 1994. (also in Proceedings, Fifth International Conference on Computer Vision, pages 852-857, June, 1995). 2.) A Signal Processing Approach to Fair Surface Design by Gabriel Taubin, Computer Graphics, pages 351-358, August, 1995 (Proceedings SIGGRAPH '95). 3.) Optimal Surface Smoothing as Filter Design by Gabriel Taubin, Tong Zhang, and Gene Golub, IBM Research Report RC-20404 (#90237). Usually the iterations will be between 30 and 100.- Parameters:
iteration
- Number of times to run smoothing formula on data set.lambda
- positive scale factormu
- negative scale factorpVisible
- if true display progress bar Require: 0 < lambda < -mu (1/lambda) + (1/mu) < 2
-
smoothTwo
public void smoothTwo(int iterations, float fStiffness, boolean volumeLimit, float volumePercent)
Derived from the first 2 of the 3 components of AlgorithmBrainExtraction Note that m_fStiffness does not increase and then decrease as in AlgorithmBrainExtraction but instead remains constant. This is because the change in m_fStiffness only applies to the third component of AlgorithmBrainExtraction which uses image intensities.- Parameters:
iterations
- DOCUMENT ME!m_fStiffness
- DOCUMENT ME!volumeLimit
- if true stop iterations when the present volume is volumePercent or more different from the initialvolumePercent
- percentage from initial volume for stopping iterations
-
ToggleGeodesicPathDisplay
public void ToggleGeodesicPathDisplay(int iWhich)
Switches between different ways of displaying the geodesic path (Euclidean, Geodesic, or Mesh).- Parameters:
iWhich
- the type of display.
-
createVolumeMask
public java.util.BitSet createVolumeMask()
Creates a BitSet mask that is the volume enclosed by the triangle mesh. This function is not accurate if the mesh is not closed, however it will still return a mask.- Returns:
-
calcVolumeMask
private void calcVolumeMask(java.util.BitSet mask, ModelImage kOutputImage, WildMagic.LibFoundation.Mathematics.Vector3f[] directions, int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, int iDimX, int iDimY)
-
initBoundingBox
private void initBoundingBox()
Initializes the bounding box for the mesh. The volume bounding box is in volume-index coordinats.
-
getMinMax
public WildMagic.LibFoundation.Mathematics.Vector3f[] getMinMax()
Returns the min/max bounding box coordinates for the mesh in volume-index coordinates.- Returns:
- the min/max bounding box coordinates for the mesh in volume-index coordinates.
-
testIntersection
public boolean testIntersection(WildMagic.LibFoundation.Mathematics.Vector3f kP0, boolean bUseMask)
Test if the input point is inside the triangle mesh.- Parameters:
kP0
- input point.- Returns:
- true if the point is inside the mesh, false otherwise.
-
testIntersection
public boolean testIntersection(WildMagic.LibFoundation.Mathematics.Vector3f kP0, WildMagic.LibFoundation.Mathematics.Vector3f kP1, boolean bUseMask, boolean bPrint)
Tests if the line segment specified by the two input points intersects the mesh.- Parameters:
kP0
- first end-point of the line sement in volume-index coordinates.kP1
- second end-point of the line sement in volume-index coordinates.bPrint
- flag to print debugging printouts.- Returns:
- true if the line segment intersects the mesh, false otherwise.
-
testIntersectionMask
private boolean testIntersectionMask(WildMagic.LibFoundation.Mathematics.Vector3f kPos)
-
buildConnections
private java.util.HashSet[] buildConnections()
Builds a list of cross-references, so that connections[i] contains all the vertices that are connected to vertex at i.
-
ComputeCenter
private void ComputeCenter()
Compute the center of the surface.
-
computeMeanEdgeLength
private float computeMeanEdgeLength(java.util.HashMap kEMap)
Compute the average length of all the edges in the triangle mesh.
-
computeVertexInformation
private void computeVertexInformation(float[] afParams, float fMeanEdgeLength, WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal, WildMagic.LibFoundation.Mathematics.Vector3f[] akVMean, WildMagic.LibFoundation.System.UnorderedSetInt[] akAdjacent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSTangent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSNormal, float[] afCurvature)
Let V[i] be a vertex in the triangle mesh. This function computes VMean[i], the average of the immediate neighbors of V[i]. Define S[i] = VMean[i] - V[i]. The function also computes a surface normal SNormal[i], the component of S[i] in the vertex normal direction. STangent[i] = S[i] - SNormal[i] is computed as an approximation to a tangent to the surface. Finally, Curvature[i] is an approximation of the surface curvature at V[i].
-
computeVertexNormals
private void computeVertexNormals(WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal)
Compute the vertex normals of the triangle mesh. Each vertex normal is the unitized average of the non-unit triangle normals for those triangles sharing the vertex.
-
CreateScene
private void CreateScene()
Creates the scene graph.
-
scaleMesh
private void scaleMesh(float fValue, java.util.HashSet[] connections)
-
update2
private float update2(int i, float[] afCurvature, float fStiffness, float[] afParam)
Compute the coefficient of the surface normal for the update of the mesh vertex V[i] in the SNormal[i] direction. See BrainExtraction.pdf for a description of the update.- Parameters:
i
- the index of the vertex to update- Returns:
- the coefficient of SNormal[i] for the update
-
updateMesh
private void updateMesh(java.util.HashMap kEMap, WildMagic.LibFoundation.Mathematics.Vector3f[] akVNormal, WildMagic.LibFoundation.Mathematics.Vector3f[] akVMean, WildMagic.LibFoundation.System.UnorderedSetInt[] akAdjacent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSTangent, WildMagic.LibFoundation.Mathematics.Vector3f[] akSNormal, float[] afCurvature, float fStiffness)
The heart of the segmentation. This function is responsible for the evolution of the triangle mesh that approximates the brain surface. The update has a tangential component, a surface normal component, and a vertex normal component for each vertex in the mesh. The first two components control the geometry of the mesh. The last component is based on the MRI data itself. See BrainExtraction.pdf for a detailed description of the update terms.
-
testIntersections
public static boolean testIntersections(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, WildMagic.LibFoundation.Mathematics.Vector3f origin, WildMagic.LibFoundation.Mathematics.Line3f[] akLines)
Test if the input point is inside the mesh.- Parameters:
origin
- point to test for inside/outside mesh.directions
- set of randomised directions for counting mesh-intersections (odd = inside, even = outside).- Returns:
- true when the point is inside the mesh, false otherwise.
-
testIntersections
private boolean testIntersections(WildMagic.LibFoundation.Mathematics.Vector3f kP0, WildMagic.LibFoundation.Mathematics.Vector3f kP1)
Tests if the line segment determined by the two input end-points intersects the mesh.- Parameters:
kP0
- end-point of the line segment.kP1
- end-point of the line segment.- Returns:
- true if the line segment intersects the mesh.
-
computeSurfaceMask
public java.util.BitSet computeSurfaceMask()
Computes a volume mask of the triangle mesh surface. The BitSet mask volume has the same volume dimensions as the current image. The mask is used to show the surface-plane intersections in the slice views.- Parameters:
mesh
- triangle mesh to convert to a volume mask representation.- Returns:
- BitSet mask, which is set to true wherever the triangle mesh intersects the volume voxel.
-
computeSurfaceMask
public static java.util.BitSet computeSurfaceMask(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image)
-
computeSurfaceMask
private static java.util.BitSet computeSurfaceMask(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale)
-
computeSurfaceMask
private static void computeSurfaceMask(java.util.BitSet mask, WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale, int start, int stop)
-
computeSurfaceImage
public static ModelImage computeSurfaceImage(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image)
-
computeSurfaceImage
private static ModelImage computeSurfaceImage(WildMagic.LibGraphics.SceneGraph.TriMesh mesh, ModelImage image, float volume, WildMagic.LibFoundation.Mathematics.Vector3f trans, WildMagic.LibFoundation.Mathematics.Vector3f scale)
-
getIntersectX
private static float getIntersectX(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iY, float iZ)
Compute the point of intersection between a line (0,iY,iZ)+t(1,0,0) and the triangle defined by the three input points. All calculations are in voxel coordinates and the x-value of the intersection point is truncated to an integer.- Parameters:
kV0
- a 3D vertex of the trianglekV1
- a 3D vertex of the trianglekV2
- a 3D vertex of the triangleiY
- the y-value of the origin of the lineiZ
- the z-value of the origin of the line- Returns:
- the x-value of the intersection
-
getIntersectY
private static float getIntersectY(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iX, float iZ)
Compute the point of intersection between a line (iX,0,iZ)+t(0,1,0) and the triangle defined by the three input points. All calculations are in voxel coordinates and the y-value of the intersection point is truncated to an integer.- Parameters:
kV0
- a 3D vertex of the trianglekV1
- a 3D vertex of the trianglekV2
- a 3D vertex of the triangleiX
- the x-value of the origin of the lineiZ
- the z-value of the origin of the line- Returns:
- the y-value of the intersection
-
getIntersectZ
private static float getIntersectZ(WildMagic.LibFoundation.Mathematics.Vector3f kV0, WildMagic.LibFoundation.Mathematics.Vector3f kV1, WildMagic.LibFoundation.Mathematics.Vector3f kV2, float iX, float iY)
Compute the point of intersection between a line (iX,iY,0)+t(0,0,1) and the triangle defined by the three input points. All calculations are in voxel coordinates and the z-value of the intersection point is truncated to an integer.- Parameters:
kV0
- a 3D vertex of the trianglekV1
- a 3D vertex of the trianglekV2
- a 3D vertex of the triangleiX
- the x-value of the origin of the lineiY
- the y-value of the origin of the line- Returns:
- the z-value of the intersection
-
-