Class SurfaceMask
- java.lang.Object
-
- gov.nih.mipav.view.renderer.J3D.surfaceview.SurfaceMask
-
public class SurfaceMask extends java.lang.Object
SurfaceMask. Calculates the surface volume mask (BitSet) for a triangle mesh surface displayed in the SurfaceRender class. Both boundary masks and filled-volume masks are calculated by the maskInsideVoxels() function.The boundary-mask is stored in the ModelStorageBase class and is used to display the triangle mesh intersection with the 2D plane in the PlaneRender class. The volume-mask is stored in the SurfaceAttributes class and is accessed through the SurfaceAttributes.getMask() member function. The volume mask is used in the BurnBaseView.calcTotalVolume() function.
- See Also:
JPanelSurface.java
,SurfaceRender.java
,SurfaceAttributes.java
,ModelStorageBase.java
,BurnBaseView.java
-
-
Field Summary
Fields Modifier and Type Field Description private float
m_fX0
The plane coordinate x,y dimensions:private float
m_fX1
The plane coordinate x,y dimensions:private float
m_fY0
The plane coordinate x,y dimensions:private float
m_fY1
The plane coordinate x,y dimensions:private float
m_fZ0
The plane coordinate x,y dimensions:private float
m_fZ1
The plane coordinate x,y dimensions:private int
m_iQuantity
Product of the image dimensions.private int
m_iXBound
Dimensions of imageA.private int
m_iYBound
Dimensions of imageA.private int
m_iZBound
Dimensions of imageA.private ModelLUT
m_kLUT
ModelLUT for getModelImageColor w/LUT changes:private ModelRGB
m_kRGBT
ModelRGB for getModelImageColor w/RGB LUT changes:private java.util.BitSet
mVolumeMask
Volume-Filled TriangleMesh mask.private int
xDim
ModelImage image array dimensions:private int
yDim
ModelImage image array dimensions:private int
zDim
ModelImage image array dimensions:
-
Constructor Summary
Constructors Constructor Description SurfaceMask()
Default Constructor:
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private float
calcMaxNormColors(ModelImage kImage, javax.vecmath.Color3f kOffset)
calculates the color normalization factorsprivate void
floodFill(int iX, int iY, int iZ)
Identify voxels enclosed by the brain surface by using a flood fill.private void
getColorMapped(int[] RGBIndexBuffer, javax.vecmath.Color3f kOffset, float fNorm, javax.vecmath.Color4f currentColor)
Get the color from the RGB lookup table:private int
getIndex(int iX, int iY, int iZ)
A convenience function for mapping the 3D voxel position (iX,iY,iZ) to a 1D array index.private float
getIntersectX(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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 float
getIntersectY(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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 float
getIntersectZ(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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.javax.vecmath.Color4f
getModelImageColor(ModelImage imageA, float fTransparency, javax.vecmath.Point3f kModelPoint)
Given a triangle vertex point from a ModelTriangleMesh, determines the corresponding ModelImage index point, and recreates the color that would have originally been assigned to the vertex.javax.vecmath.Point3f
getModelImagePoint(javax.vecmath.Point3f kTrianglePoint)
Given a triangle vertex point from a ModelTriangleMesh, determines the corresponding ModelImage index point.java.util.BitSet
getVolumeMask()
Get the current added surface bit mask.void
maskInsideVoxels(int index, ModelImage imageA, ModelTriangleMesh[] kMesh, boolean bHasVertexColor, boolean bCreateVertexColors, boolean bUseImageMask, float fOpacity, WildMagic.LibFoundation.Mathematics.ColorRGBA surColor)
Mask the mesh surface volume in voxels.void
setLUT(ModelLUT kLUT)
void
setRGBT(ModelRGB kRGBT)
-
-
-
Field Detail
-
mVolumeMask
private java.util.BitSet mVolumeMask
Volume-Filled TriangleMesh mask.
-
m_iXBound
private int m_iXBound
Dimensions of imageA.
-
m_iYBound
private int m_iYBound
Dimensions of imageA.
-
m_iZBound
private int m_iZBound
Dimensions of imageA.
-
m_iQuantity
private int m_iQuantity
Product of the image dimensions.
-
m_fX0
private float m_fX0
The plane coordinate x,y dimensions:
-
m_fY0
private float m_fY0
The plane coordinate x,y dimensions:
-
m_fZ0
private float m_fZ0
The plane coordinate x,y dimensions:
-
m_fX1
private float m_fX1
The plane coordinate x,y dimensions:
-
m_fY1
private float m_fY1
The plane coordinate x,y dimensions:
-
m_fZ1
private float m_fZ1
The plane coordinate x,y dimensions:
-
xDim
private int xDim
ModelImage image array dimensions:
-
yDim
private int yDim
ModelImage image array dimensions:
-
zDim
private int zDim
ModelImage image array dimensions:
-
m_kLUT
private ModelLUT m_kLUT
ModelLUT for getModelImageColor w/LUT changes:
-
m_kRGBT
private ModelRGB m_kRGBT
ModelRGB for getModelImageColor w/RGB LUT changes:
-
-
Method Detail
-
maskInsideVoxels
public void maskInsideVoxels(int index, ModelImage imageA, ModelTriangleMesh[] kMesh, boolean bHasVertexColor, boolean bCreateVertexColors, boolean bUseImageMask, float fOpacity, WildMagic.LibFoundation.Mathematics.ColorRGBA surColor)
Mask the mesh surface volume in voxels.- Parameters:
index
- Mask index in the ModelImage imageAimageA
- ModelImage for storing the surface-maskkMesh
- ModelTriangleMesh[] surfacesbHasVertexColor
- use per-vertex color from the ModelTriangleMesh, otherwise use the surColor parameterbCreateVertexColor
- create the per-vertex color from the imageA ModleImage,bUseImageMask
- create the per-vertex color from the imageA ModleImage, with the ModelImage maskfOpacity
- Mask opacitysurColor
- default Mask color
-
getModelImagePoint
public javax.vecmath.Point3f getModelImagePoint(javax.vecmath.Point3f kTrianglePoint)
Given a triangle vertex point from a ModelTriangleMesh, determines the corresponding ModelImage index point.- Parameters:
kTrianglePoint
- ModelTriangleMesh point in mesh coordinates- Returns:
- ModelImage index point.
-
setRGBT
public void setRGBT(ModelRGB kRGBT)
-
setLUT
public void setLUT(ModelLUT kLUT)
-
getColorMapped
private void getColorMapped(int[] RGBIndexBuffer, javax.vecmath.Color3f kOffset, float fNorm, javax.vecmath.Color4f currentColor)
Get the color from the RGB lookup table:- Parameters:
RGBIndexBuffer
- the color lookup table index bufferkOffset
- the color offsetfNorm
- the color normalizationcurrentColor
- the current color (changed)
-
calcMaxNormColors
private float calcMaxNormColors(ModelImage kImage, javax.vecmath.Color3f kOffset)
calculates the color normalization factors- Parameters:
kImage
- the model image from which the normalization factors are calculatedkOffset
- the calculated color offset- Returns:
- the color normalization factor.
-
getModelImageColor
public javax.vecmath.Color4f getModelImageColor(ModelImage imageA, float fTransparency, javax.vecmath.Point3f kModelPoint)
Given a triangle vertex point from a ModelTriangleMesh, determines the corresponding ModelImage index point, and recreates the color that would have originally been assigned to the vertex.- Parameters:
kTrianglePoint
- ModelTriangleMesh point in ModelImage coordinates- Returns:
- original color of the triangle point.
-
getVolumeMask
public java.util.BitSet getVolumeMask()
Get the current added surface bit mask.- Returns:
- BitSet surface volume bit set mask.
-
floodFill
private void floodFill(int iX, int iY, int iZ)
Identify voxels enclosed by the brain surface by using a flood fill. The flood fill is nonrecursive to avoid overflowing the program stack.- Parameters:
iX
- the x-value of the seed point for the filliY
- the y-value of the seed point for the filliZ
- the z-value of the seed point for the fill
-
getIndex
private final int getIndex(int iX, int iY, int iZ)
A convenience function for mapping the 3D voxel position (iX,iY,iZ) to a 1D array index. The images are stored as 1D arrays, so this function is used frequently.- Parameters:
iX
- the x-value of the voxel positioniY
- the y-value of the voxel positioniZ
- the z-value of the voxel position- Returns:
- the 1D array index corresponding to (iX,iY,iZ)
-
getIntersectX
private float getIntersectX(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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 float getIntersectY(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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 float getIntersectZ(javax.vecmath.Point3f kV0, javax.vecmath.Point3f kV1, javax.vecmath.Point3f 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
-
-