Class Geodesic_WM
- java.lang.Object
-
- gov.nih.mipav.view.renderer.WildMagic.Render.Geodesic_WM
-
public class Geodesic_WM extends java.lang.Object
- Author:
- Alexandra Bokinsky, Ph.D. Under contract from Magic Software.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean[]
m_abRemoveTris
List of triangles to remove.private int[]
m_aiEndIndex
The indices of the triangle containing the end of the new line.private int[]
m_aiFirstIndex
The indices of the triangle containing the first point on the new line.private int[]
m_aiIndex
vertices array.private int[]
m_aiIndexShift
For shifting the triangle indices after removing triangles from the mesh.private int[]
m_aiPreviousStartIndex
The indices of the triangle containing the previous start point.private int[]
m_aiStartIndex
The indices of the triangle containing the start of the new line.private java.util.LinkedList<java.lang.Integer>[]
m_akEdgeList
Data members used in Dijkstra's search.private boolean
m_bEnabled
Turned on when picking with the mouse is enabled:.private boolean
m_bEndpointChanged
Flag to indicates end point changes.private boolean
m_bFinished
Closing the Geodesic path:.private boolean
m_bFirstWire
private boolean
m_bGroupAdded
Flag for clearing the Geodesic curves, if it is false, no curves have been added to the GeodesicGroup.private boolean
m_bLastWire
Live wire last point.private boolean
m_bLivewire
Live wire or point and click mode.private boolean
m_bOpen
Close path or not.private boolean[]
m_bRelaxed
For Dijkstra search.private float
m_fDijkstraPathLength
Path length statistics for each type of path:.private float
m_fRadius
Radius of the sphere displayed to mark the points on the Geodesic.private float[]
m_fRemainingWeight
Weights, relaxed flags, and previous vertex index for Dijkstra's search:.private float
m_fSmoothedPathLength
Length of the smoothed geodesic pathprivate float[]
m_fWeight
For Dijkstra search.private int
m_iDijkstraGeodesicGroup
The number of line segments on the Dijkstra curve.private int
m_iEnd
The index of the vertex in the triangle mesh where the Geodesic curve is to end.private int
m_iEuclidianGeodesicGroup
The number of line segments on the Euclidian curve.private int
m_iIndexCount
index count.private int
m_iLineClosed
The index of the last node on a closed path.private int
m_iNumGeodesicVertices
Number of vertices in the geodesic curve.private int
m_iNumNewMeshes
Number of meshes.private int
m_iNumNotRemoved
Number of triangles not removed during a cut mesh operation.private int
m_iNumPicked
Keeps track of the of picking, so that when a pair of points has been picked the Geodesic is calculated:.private int
m_iNumRemoved
Number of triangles removed during a cut mesh operation.private int
m_iNumTriangles
Number of triangles in the mesh, after the new triangles are added:.private int
m_iNumWorking
number of vertices in the path.private int[]
m_iPrevious
For Dijkstra search.private int
m_iSmoothedGeodesicGroup
Root group for different path.private int
m_iStart
The start index value for the pair of points.private int
m_iVertexCount
Local copies of the Vertex and Index arrays: a local copy is kept so that when the start or end points fall inside a triangle, a new vertex is added to the vertex array, and three new triangles are added to the triangle index array, new normals are added to the Normal array:.private java.util.LinkedList<java.lang.Integer>
m_kBorder
Data member for Dijkstra's search.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kEndPoint
End point on the curve.private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kEndSurface
Surface the End point is on.private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kFinished
The finished TriMeshprivate WildMagic.LibFoundation.Mathematics.Vector3f
m_kFirstPoint
First point, for closing the Geodesic curve:.private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f>>
m_kGeodesic_Finished
For finished paths, either open or closed:.private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f>>
m_kGeodesic_Working
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics.private java.util.LinkedList<java.util.LinkedList<java.lang.Integer>>
m_kGeodesic_Working_Left
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics.private java.util.LinkedList<java.util.LinkedList<java.lang.Integer>>
m_kGeodesic_Working_Right
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics.private WildMagic.LibFoundation.Mathematics.Vector3f[]
m_kGeodesicVertices
The final list of points in the Geodesic curve.private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kLastCut
Previous cut meshprivate WildMagic.LibGraphics.SceneGraph.TriMesh
m_kLastFinished
Previous mesh with a finished curveprivate WildMagic.LibGraphics.SceneGraph.TriMesh
m_kModified
Current modified meshprivate java.util.LinkedList<WildMagic.LibFoundation.Mathematics.ColorRGBA>
m_kNewColors
New Colors link list.private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>
m_kNewNormals
New normal link list.private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>
m_kNewTexCoords
New texCoords link list.private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>
m_kNewTriangles
new triangle link list.private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>
m_kNewVerts
New vertices link list.private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kOriginal
Data members for the Geodesic Class: Triangle mesh:.(package private) JPanelGeodesic_WM
m_kPanel
Reference to the JPanelGeodesic:.private javax.swing.JProgressBar
m_kPBar
Volume renderer progress bar:.private WildMagic.LibFoundation.Mathematics.ColorRGB[]
m_kPickColors
Color of the first and successive points on the Geodesic curve:.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kPreviousStartPoint
Previous start point on the new line segment.private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>
m_kRemoveTriangles
Removed triangle link list.private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>>
m_kStartEndList
link list to hold the path.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kStartPoint
Start and End points -- pair of points for which a Geodesic is calculated, must be in TriangleMesh coordinates:.private WildMagic.LibGraphics.SceneGraph.TriMesh
m_kStartSurface
TriMesh containing the start point on the new line segmentprivate WildMagic.LibGraphics.SceneGraph.TriMesh
m_kSurface
Current TriMesh surfaceprivate WildMagic.LibGraphics.SceneGraph.TriMesh
m_kSurfaceBackup
Backup surface.
-
Constructor Summary
Constructors Constructor Description Geodesic_WM()
Instantiation without initializing the progress bar, pickCanvas, GeodesicGroup, triangle mesh or sphere radius, each of those can be set through individual member access functions:.Geodesic_WM(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, float fRadius)
Instantiation of the Geodesic object, with the objects necessary for the Geodesic to serve as a MouseListener that performs picking and with the Group kGeodesicGroup so that the Geodesic curve can be drawn directly on the TriMesh.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addEdge(int iEdgeIndex, int iNewEdge)
Add the edge to the EdgeList, check to make sure that edge has not already been added.private int
checkOnEdge(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kPoint, int[] aiTriIndex, WildMagic.LibFoundation.Mathematics.Vector3f kNormal, WildMagic.LibFoundation.Mathematics.Vector3f kTexCoord, WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
Given a point which is known to be inside a triangle, and that triangle, this function determines which edge, if any, that point falls on.private void
cleanUp()
cleanUp deletes the data stuctures used for the Dijkstra's search, but does not delete the array of points on the Geodesic curve.void
clear(boolean bAll)
Clear all geodesics curves drawn on the surface.private void
clearAllStartEnd()
clears the all the points added in livewire mode when clear all is called from the user interface.void
clearCut(boolean bAll)
Clear the current geodesics curve drawn on the surface.private void
clearLastStartEnd()
clears the last points added in livewire mode when clear last point is called from the user interface.boolean
computeGeodesic(float fPercentage, boolean bSmoothed)
Compute the Geodesic curve.private boolean
contains(java.util.LinkedList kTriList, WildMagic.LibFoundation.Mathematics.Vector3f kNewTri)
Contains determines if the linked list kTriList contains the input triangle, which is specified by three vertex indices.private int
containsVector(java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> kVecList, WildMagic.LibFoundation.Mathematics.Vector3f kNewTri)
Return index of the Vector3f in the list.private boolean
createEdgeLists(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
Create the edges list from the given surface triangle mesh.private WildMagic.LibGraphics.SceneGraph.TriMesh
createNewMesh(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iVertexCount, int iOldVertexCount)
creates a new mesh after triangulation or when a mesh is cut along the geodesic.boolean
createPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iStart, int iEnd)
createPath starts with the results of Dijkstra's minimum path algorithm.void
cut()
Cut the m_kModified mesh.void
dispose()
Deletes all member variables, clean memory.private float
distance(WildMagic.LibFoundation.Mathematics.Vector3f kPoint1, WildMagic.LibFoundation.Mathematics.Vector3f kPoint2)
Calculate the Euclidean distance between two points.void
drawDijkstraEuclidianPath(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibGraphics.SceneGraph.TriMesh kWorking, int iStart, int iEnd)
drawPath draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.private void
drawDijkstraEuclidianPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.void
drawGeodesicPath(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, int iStart, int iEnd)
drawPath draws the Geodesic path as a LineArray and adds it to the children of the m_kSmoothedGeodesicGroup object, it also draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.private void
drawGeodesicPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.void
drawPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iStart, int iEnd)
drawPath draws the Geodesic path as a LineArray and adds it to the children of the m_kSmoothedGeodesicGroup object, it also draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.private void
drawPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.private int
extractNewMesh(java.util.LinkedList kLoop)
Used in cutting closed paths and creating new meshes to export to the scene graph.private void
findEdges(int iIndex, boolean[] bFound)
Go through the edge list find the the edge specified.private float
findMin(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kStart, int iMiddle, int iSide, WildMagic.LibFoundation.Mathematics.Vector3f kEnd, WildMagic.LibFoundation.Mathematics.Vector4f kNewPoint4)
findMin finds the point (newpoint) along the edge that connects the points Side-Middle that minimizes the distance Start-newpoint-End.private int
findNewMeshes(WildMagic.LibGraphics.SceneGraph.TriMesh kSourceMesh, java.util.LinkedList kGeodesic_Closed_Loops)
Used in cutting closed paths and creating new meshes to export to the scene graph.private int
findSmallest()
The findSmallest function searches through the list of vertices that are not yet relaxed but that have been visited by the Dijkstra Search, so that the weight factor is not Float.MAX_VALUE, but also is not the minimum value for that node.private int
findTriPoints(int iNode1, int iNode2, java.util.LinkedList<java.lang.Integer> kEndPoints)
Find the next side triangle index.void
finish(boolean bOpen)
Closes the geodesic curve.private void
finishWorkingLists(boolean bOpen)
Adds the working paths to the finished path lists, combining the segments in the working paths into one path.private WildMagic.LibFoundation.Mathematics.ColorRGBA
getColor(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point color for a new starting point inside an existing triangle.private WildMagic.LibFoundation.Mathematics.ColorRGBA
getColor(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle color from the given triangle index.boolean
getEnable()
Access on when picking with the mouse is enabled.private WildMagic.LibFoundation.Mathematics.Vector3f
getNormal(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point normal for a new starting point inside an existing triangle.private WildMagic.LibFoundation.Mathematics.Vector3f
getNormal(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle normal from the given triangle index.int
getNumPathPoints()
Returns the number of points in the geodesic curve.private int
getPathIndex(java.util.LinkedList kPath, int iVertexCount, int iIndex, boolean bOpen)
getPathIndex returns what the new vertex index should be.void
getPathPoint(int iPoint, WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Access to the i-th point on the Geodesic curve.void
getPathPoints(WildMagic.LibFoundation.Mathematics.Vector3f[] akPoints)
Access to the all the points on the Geodesic curve.private void
getStartEnd(int iWhich)
In livewire mode the endpoints of each path segment along Dijkstra's curve -- between each of the user-selected points -- are stored so that the smoothed geodesic may be calculated and displayed later.private WildMagic.LibFoundation.Mathematics.Vector3f
getTexCoord(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point texture coordinate for a new starting point inside an existing triangle.private WildMagic.LibFoundation.Mathematics.Vector3f
getTexCoord(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle texture coordinate from the given triangle index.private void
initColors()
Initializes the colors for the first point on the curve, and the successive points.private void
initializeGeodesic(float fPercentage)
initializeGeodesic copies the triangle mesh and initializes the data structures for Dijkstra's Single-Source shortest path algorithm.private boolean
onRight(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iPrevIndex, int iIndex, int iSideIndex)
onRight determines if a given point on a triangle, kSide, is to the right of or to the left of the vector specified by the vertices kPrev - kPoint.private void
outputDeletedAsNew(WildMagic.LibGraphics.SceneGraph.TriMesh kSourceMesh)
creating new meshes to export to the scene graph.private void
relaxEdges(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iNode)
This function determines the shortest path from the start vertex through the input vertex to the vertices that neighbor the input vertex.private void
resetDrawGeodesic()
Remove all the geodesic lines and reset to draw the new geodesic lines.private void
saveStartEnd()
In livewire mode the endpoints of each path segment along Dijkstra's curve -- between each of the user-selected points -- are stored so that the smoothed geodesic may be calculated and displayed later.void
setEnable(boolean bEnable)
Enables picking with the mouse and drawing the curve on the mesh.void
setEndIndex(int iIndex)
Set the index of the vertex in the triangle mesh where the Geodesic curve is to end.void
setEndIndices(int[] iIndices)
Sets the indices of the triangle that the end point is located in.void
setEndPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Sets the end point of the geodesic curve on the mesh.private void
setEndSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
The start and end surfaces ensure that the points on the geodesic curve all fall on one mesh, and that the algorithm isn't trying to find a path between two unconnected meshes.void
setPanel(JPanelGeodesic_WM kPanel)
Access to the JPanelGeodesic interface object.void
setPickedPoint(WildMagic.LibGraphics.Collision.PickRecord kPickPoint, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
void
setPreviousStartIndices(int[] iIndices)
Sets the indices of the triangle that the previous start point is located in.private void
setPreviousStartPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Sets the previous start point of the geodesic curve on the mesh.void
setRadius(float fRadius)
Set the radius of the spheres used to mark the start and end points on the geodesic curve.void
setStartIndex(int iIndex)
Set the index of the vertex in the triangle mesh where the Geodesic curve is to start.void
setStartIndices(int[] iIndices, boolean bFirst)
Sets the indices of the triangle that the start point is located in.void
setStartPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint, boolean bFirst)
Sets the start point of the geodesic curve on the mesh.private void
setStartSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
The start and end surfaces ensure that the points on the geodesic curve all fall on one mesh, and that the algorithm isn't trying to find a path between two unconnected meshes.private void
setSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
Access function to set the triangle mesh that the geodesic curve is calculated on.private int
smoothPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iNode, java.util.LinkedList<java.lang.Integer> kLeft, java.util.LinkedList<java.lang.Integer> kMiddle, java.util.LinkedList<java.lang.Integer> kRight, java.util.LinkedList<java.lang.Integer> kLeftTemp, java.util.LinkedList<java.lang.Integer> kRightTemp, java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f> kNewVertTemp)
Smooth the path.private void
sortTriIndex(WildMagic.LibFoundation.Mathematics.Vector3f aiAddTri, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer)
Used when new triangles are added to the mesh, either when the mesh is triangulated along the smoothed geodesic curve, or when the mesh is cut. sortTriIndex sorts the triangle indices so that the triangle is always front-facing and that the normals are correct for renderingvoid
toggleLivewire()
Toggle between livewire mode and point & click mode.private int
triangleEdge(int i0, int i1, int i2, int iP0, int iP1)
if the two of the first three triangle indices equal the second two indices, then the third index is returned.private boolean
triangleEquals(int i0, int i1, int i2, int iP0, int iP1, int iP2)
Returns true if the first three triangle indices equal the second three indices.private boolean
triangleExists(WildMagic.LibFoundation.Mathematics.Vector3f kTri)
Check to see if the triangle specified in the triangle list.private int
triangulate(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, java.util.LinkedList kPath, java.util.LinkedList kLeftPath, java.util.LinkedList kRightPath, int iVertexCount)
triangulates the mesh along a single geodesic.private void
triangulateMeshPath()
re-triangulates the mesh along the Smoothed Geodesic.private int
unZip(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f> kPath, int iVertexCount, boolean bOpen, java.util.LinkedList<java.lang.Integer> kNewPath)
unZip cuts along the smoothed geodesic path by creating new vertices for each point on the path, and updating the triangles that are connected to the path and that fall on the right of the path to contain the new path vertices.
-
-
-
Field Detail
-
m_kPanel
JPanelGeodesic_WM m_kPanel
Reference to the JPanelGeodesic:.
-
m_abRemoveTris
private boolean[] m_abRemoveTris
List of triangles to remove.
-
m_aiEndIndex
private int[] m_aiEndIndex
The indices of the triangle containing the end of the new line.
-
m_aiFirstIndex
private int[] m_aiFirstIndex
The indices of the triangle containing the first point on the new line.
-
m_aiIndex
private int[] m_aiIndex
vertices array.
-
m_aiIndexShift
private int[] m_aiIndexShift
For shifting the triangle indices after removing triangles from the mesh.
-
m_aiPreviousStartIndex
private int[] m_aiPreviousStartIndex
The indices of the triangle containing the previous start point.
-
m_aiStartIndex
private int[] m_aiStartIndex
The indices of the triangle containing the start of the new line.
-
m_akEdgeList
private java.util.LinkedList<java.lang.Integer>[] m_akEdgeList
Data members used in Dijkstra's search. The Edgelist is a list for each vertex of all the vertices that it is connected to by one edge. The vertices are stored in the Edgelist as the vertex index.
-
m_bEnabled
private boolean m_bEnabled
Turned on when picking with the mouse is enabled:.
-
m_bEndpointChanged
private boolean m_bEndpointChanged
Flag to indicates end point changes.
-
m_bFinished
private boolean m_bFinished
Closing the Geodesic path:.
-
m_bFirstWire
private boolean m_bFirstWire
-
m_bGroupAdded
private boolean m_bGroupAdded
Flag for clearing the Geodesic curves, if it is false, no curves have been added to the GeodesicGroup.
-
m_bLastWire
private boolean m_bLastWire
Live wire last point.
-
m_bLivewire
private boolean m_bLivewire
Live wire or point and click mode.
-
m_bOpen
private boolean m_bOpen
Close path or not.
-
m_bRelaxed
private boolean[] m_bRelaxed
For Dijkstra search.
-
m_fDijkstraPathLength
private float m_fDijkstraPathLength
Path length statistics for each type of path:.
-
m_fRadius
private float m_fRadius
Radius of the sphere displayed to mark the points on the Geodesic. This can be set directly by the class using the Geodesic object.
-
m_fRemainingWeight
private float[] m_fRemainingWeight
Weights, relaxed flags, and previous vertex index for Dijkstra's search:.
-
m_fSmoothedPathLength
private float m_fSmoothedPathLength
Length of the smoothed geodesic path
-
m_fWeight
private float[] m_fWeight
For Dijkstra search.
-
m_iEnd
private int m_iEnd
The index of the vertex in the triangle mesh where the Geodesic curve is to end.
-
m_iIndexCount
private int m_iIndexCount
index count.
-
m_iLineClosed
private int m_iLineClosed
The index of the last node on a closed path.
-
m_iNumGeodesicVertices
private int m_iNumGeodesicVertices
Number of vertices in the geodesic curve.
-
m_iNumNewMeshes
private int m_iNumNewMeshes
Number of meshes.
-
m_iNumPicked
private int m_iNumPicked
Keeps track of the of picking, so that when a pair of points has been picked the Geodesic is calculated:.
-
m_iNumTriangles
private int m_iNumTriangles
Number of triangles in the mesh, after the new triangles are added:.
-
m_iNumWorking
private int m_iNumWorking
number of vertices in the path.
-
m_iPrevious
private int[] m_iPrevious
For Dijkstra search.
-
m_iStart
private int m_iStart
The start index value for the pair of points.
-
m_iVertexCount
private int m_iVertexCount
Local copies of the Vertex and Index arrays: a local copy is kept so that when the start or end points fall inside a triangle, a new vertex is added to the vertex array, and three new triangles are added to the triangle index array, new normals are added to the Normal array:.
-
m_kBorder
private java.util.LinkedList<java.lang.Integer> m_kBorder
Data member for Dijkstra's search. The m_kBorder list stores all the vertices that have been visited by Dijkstra's search, but that have not yet been relaxed. It is used to speed up the search for the non-relaxed vertex with the smallest path distance
-
m_iDijkstraGeodesicGroup
private int m_iDijkstraGeodesicGroup
The number of line segments on the Dijkstra curve.
-
m_kEndPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kEndPoint
End point on the curve.
-
m_kEndSurface
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kEndSurface
Surface the End point is on.
-
m_iEuclidianGeodesicGroup
private int m_iEuclidianGeodesicGroup
The number of line segments on the Euclidian curve.
-
m_kFinished
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kFinished
The finished TriMesh
-
m_kFirstPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kFirstPoint
First point, for closing the Geodesic curve:.
-
m_kGeodesic_Finished
private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f>> m_kGeodesic_Finished
For finished paths, either open or closed:.
-
m_kGeodesic_Working
private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f>> m_kGeodesic_Working
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics. These are used in the cutting operations: For paths that are not finished, points may still be added to these paths:
-
m_kGeodesic_Working_Left
private java.util.LinkedList<java.util.LinkedList<java.lang.Integer>> m_kGeodesic_Working_Left
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics. These are used in the cutting operations: For paths that are not finished, points may still be added to these paths:
-
m_kGeodesic_Working_Right
private java.util.LinkedList<java.util.LinkedList<java.lang.Integer>> m_kGeodesic_Working_Right
LinkedLists to contain the working paths in progress, and all finished paths, open and closed for the smoothed geodesics and dijkstra's geodesics. These are used in the cutting operations: For paths that are not finished, points may still be added to these paths:
-
m_kGeodesicVertices
private WildMagic.LibFoundation.Mathematics.Vector3f[] m_kGeodesicVertices
The final list of points in the Geodesic curve. All points are constrained to lie on the triangle mesh,
-
m_kLastCut
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kLastCut
Previous cut mesh
-
m_kLastFinished
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kLastFinished
Previous mesh with a finished curve
-
m_kModified
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kModified
Current modified mesh
-
m_kNewNormals
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> m_kNewNormals
New normal link list.
-
m_kNewTexCoords
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> m_kNewTexCoords
New texCoords link list.
-
m_kNewColors
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.ColorRGBA> m_kNewColors
New Colors link list.
-
m_kNewTriangles
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> m_kNewTriangles
new triangle link list.
-
m_kNewVerts
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> m_kNewVerts
New vertices link list.
-
m_kOriginal
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kOriginal
Data members for the Geodesic Class: Triangle mesh:.
-
m_kPBar
private javax.swing.JProgressBar m_kPBar
Volume renderer progress bar:.
-
m_kPickColors
private WildMagic.LibFoundation.Mathematics.ColorRGB[] m_kPickColors
Color of the first and successive points on the Geodesic curve:.
-
m_kPreviousStartPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kPreviousStartPoint
Previous start point on the new line segment.
-
m_kRemoveTriangles
private java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> m_kRemoveTriangles
Removed triangle link list.
-
m_iSmoothedGeodesicGroup
private int m_iSmoothedGeodesicGroup
Root group for different path.
-
m_kStartEndList
private java.util.LinkedList<java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f>> m_kStartEndList
link list to hold the path.
-
m_kStartPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kStartPoint
Start and End points -- pair of points for which a Geodesic is calculated, must be in TriangleMesh coordinates:.
-
m_kStartSurface
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kStartSurface
TriMesh containing the start point on the new line segment
-
m_kSurface
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kSurface
Current TriMesh surface
-
m_kSurfaceBackup
private WildMagic.LibGraphics.SceneGraph.TriMesh m_kSurfaceBackup
Backup surface.
-
m_iNumRemoved
private int m_iNumRemoved
Number of triangles removed during a cut mesh operation.
-
m_iNumNotRemoved
private int m_iNumNotRemoved
Number of triangles not removed during a cut mesh operation.
-
-
Constructor Detail
-
Geodesic_WM
public Geodesic_WM()
Instantiation without initializing the progress bar, pickCanvas, GeodesicGroup, triangle mesh or sphere radius, each of those can be set through individual member access functions:.
-
Geodesic_WM
public Geodesic_WM(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, float fRadius)
Instantiation of the Geodesic object, with the objects necessary for the Geodesic to serve as a MouseListener that performs picking and with the Group kGeodesicGroup so that the Geodesic curve can be drawn directly on the TriMesh.- Parameters:
kPickCanvas
- PickCanvaskGeodesicGroup
- GroupkMesh
- TriMesh surfacefRadius
- float marker sphere radius
-
-
Method Detail
-
clear
public void clear(boolean bAll)
Clear all geodesics curves drawn on the surface.- Parameters:
bAll
- bAll, when true clears all the geodesic curves, when false, clears the last point drawn:
-
clearCut
public void clearCut(boolean bAll)
Clear the current geodesics curve drawn on the surface.- Parameters:
bAll
- bAll, when true clears all the geodesic curves, when false, clears the last point drawn:
-
computeGeodesic
public boolean computeGeodesic(float fPercentage, boolean bSmoothed)
Compute the Geodesic curve. The triangle mesh, start, and end points, start and end indices must be defined before this function is called.- Parameters:
fPercentage
- float, the optimization parameter for Dijkstra's shortest-path search. Values between 0-100, (increasing optimization).bSmoothed
- flag to smoothes and stores the shortest path.- Returns:
- true on successful path creation.
-
createPath
public boolean createPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iStart, int iEnd)
createPath starts with the results of Dijkstra's minimum path algorithm. It smooths the path, and stores the resulting points in the m_kGeodesicPath data member.- Parameters:
iStart
- int given geodesic line starting pointiEnd
- int given geodesic line ending point- Returns:
- boolean success or not
-
cut
public void cut()
Cut the m_kModified mesh.
-
dispose
public void dispose()
Deletes all member variables, clean memory.
-
drawDijkstraEuclidianPath
public void drawDijkstraEuclidianPath(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibGraphics.SceneGraph.TriMesh kWorking, int iStart, int iEnd)
drawPath draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.- Parameters:
iStart
- int Dijkstra path starting pointiEnd
- int Dijkstra path ending point
-
drawGeodesicPath
public void drawGeodesicPath(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, int iStart, int iEnd)
drawPath draws the Geodesic path as a LineArray and adds it to the children of the m_kSmoothedGeodesicGroup object, it also draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.- Parameters:
iStart
- int Geodesic path starting pointiEnd
- int Geodesic path ending point
-
drawPath
public void drawPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iStart, int iEnd)
drawPath draws the Geodesic path as a LineArray and adds it to the children of the m_kSmoothedGeodesicGroup object, it also draws the Dijkstra path and Euclidian paths and adds them to the corresponding m_kDijkstraGeodesicGroup and m_kEuclidianGeodesicGroups.- Parameters:
iStart
- int Geodesic path starting pointiEnd
- int Geodesic path ending point
-
finish
public void finish(boolean bOpen)
Closes the geodesic curve.- Parameters:
bOpen
- bOpen: when true leaves the geodesic open, when false closes the geodesic by connecting to the first point on the polyline sequence.
-
getEnable
public boolean getEnable()
Access on when picking with the mouse is enabled.- Returns:
- boolean picking is enabled or not.
-
getNumPathPoints
public int getNumPathPoints()
Returns the number of points in the geodesic curve.- Returns:
- int, the number of points on the Geodesic.
-
getPathPoint
public void getPathPoint(int iPoint, WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Access to the i-th point on the Geodesic curve. All points on the geodesic curve lie on the triangle mesh.- Parameters:
iPoint
- i-th point indexkPoint
- Vector3f point's coordinate
-
getPathPoints
public void getPathPoints(WildMagic.LibFoundation.Mathematics.Vector3f[] akPoints)
Access to the all the points on the Geodesic curve. All points on the geodesic curve lie on the triangle mesh.- Parameters:
akPoints
- Vector3f[] points coordinates array
-
setEnable
public void setEnable(boolean bEnable)
Enables picking with the mouse and drawing the curve on the mesh.- Parameters:
bEnable
- set the mouse picking enabled or not.
-
setEndIndex
public void setEndIndex(int iIndex)
Set the index of the vertex in the triangle mesh where the Geodesic curve is to end. The index must be less than or equal to the number of vertices in the triangle mesh.- Parameters:
iIndex
- int the index of the vertex in the triangle mesh where the Geodesic curve is to end.
-
setEndIndices
public void setEndIndices(int[] iIndices)
Sets the indices of the triangle that the end point is located in. This is used when the end point falls on the inside of a triangle in the mesh, the indices parameter defines which triangle the end point falls in.- Parameters:
iIndices
- int[3] array of vertex indices defining the end triangle.
-
setEndPoint
public void setEndPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Sets the end point of the geodesic curve on the mesh. The point coordinates must be in local mesh coordinates.- Parameters:
kPoint
- the point on the triangle mesh where the geodesic curve is to end, in mesh coordinates.
-
setPanel
public void setPanel(JPanelGeodesic_WM kPanel)
Access to the JPanelGeodesic interface object.- Parameters:
kPanel
- JPanelGeodesic geodesic panel
-
setPickedPoint
public void setPickedPoint(WildMagic.LibGraphics.Collision.PickRecord kPickPoint, WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
-
setPreviousStartIndices
public void setPreviousStartIndices(int[] iIndices)
Sets the indices of the triangle that the previous start point is located in. This is used when the start point falls on the inside of a triangle in the mesh, the indices parameter defines which triangle the start point falls in.- Parameters:
iIndices
- index coordinate
-
setRadius
public void setRadius(float fRadius)
Set the radius of the spheres used to mark the start and end points on the geodesic curve.- Parameters:
fRadius
- the size of the marker sphere to be drawn on the mesh
-
setStartIndex
public void setStartIndex(int iIndex)
Set the index of the vertex in the triangle mesh where the Geodesic curve is to start. The index must be less than or equal to the number of vertices in the triangle mesh.- Parameters:
iIndex
- int the index of the vertex in the triangle mesh where the Geodesic curve is to start.
-
setStartIndices
public void setStartIndices(int[] iIndices, boolean bFirst)
Sets the indices of the triangle that the start point is located in. This is used when the start point falls on the inside of a triangle in the mesh, the indices parameter defines which triangle the start point falls in.- Parameters:
iIndices
- int[3] array of vertex indices defining the start triangle.bFirst
- flag indicate the first indices defining the start triangle.
-
setStartPoint
public void setStartPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint, boolean bFirst)
Sets the start point of the geodesic curve on the mesh. The point coordinates must be in local mesh coordinates.- Parameters:
kPoint
- the point on the triangle mesh where the geodesic curve is to start, in mesh coordinates.bFirst
- flag indicate the first indices defining the start triangle.
-
toggleLivewire
public void toggleLivewire()
Toggle between livewire mode and point & click mode.
-
addEdge
private void addEdge(int iEdgeIndex, int iNewEdge)
Add the edge to the EdgeList, check to make sure that edge has not already been added.- Parameters:
iEdgeIndex
- edge indexiNewEdge
- int added edge index
-
checkOnEdge
private int checkOnEdge(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kPoint, int[] aiTriIndex, WildMagic.LibFoundation.Mathematics.Vector3f kNormal, WildMagic.LibFoundation.Mathematics.Vector3f kTexCoord, WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
Given a point which is known to be inside a triangle, and that triangle, this function determines which edge, if any, that point falls on.- Parameters:
kMesh
- TriMesh surfacekPoint
- Vector3faiTriIndex
- int[]kNormal
- Vector3f- Returns:
- int
-
cleanUp
private void cleanUp()
cleanUp deletes the data stuctures used for the Dijkstra's search, but does not delete the array of points on the Geodesic curve.
-
clearAllStartEnd
private void clearAllStartEnd()
clears the all the points added in livewire mode when clear all is called from the user interface.
-
clearLastStartEnd
private void clearLastStartEnd()
clears the last points added in livewire mode when clear last point is called from the user interface.
-
contains
private boolean contains(java.util.LinkedList kTriList, WildMagic.LibFoundation.Mathematics.Vector3f kNewTri)
Contains determines if the linked list kTriList contains the input triangle, which is specified by three vertex indices. The LinkedList member function contains is not used because the indices may be in a different order, and the function must return true if any of the triangles in the list match the input triangle regardless of the order the vertices are specified- Parameters:
kTriList
- Link ListkNewTri
- Point3i input triangle vertex indices- Returns:
- boolean contains the triangle or not.
-
containsVector
private int containsVector(java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector3f> kVecList, WildMagic.LibFoundation.Mathematics.Vector3f kNewTri)
Return index of the Vector3f in the list.- Parameters:
kVecList
- list of Vector3fkNewTri
- Vector3f- Returns:
- index of the Vector in the list, -1 if it is not in the list.
-
createEdgeLists
private boolean createEdgeLists(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
Create the edges list from the given surface triangle mesh.- Parameters:
kMesh
- surface- Returns:
- boolean success or not
-
createNewMesh
private WildMagic.LibGraphics.SceneGraph.TriMesh createNewMesh(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iVertexCount, int iOldVertexCount)
creates a new mesh after triangulation or when a mesh is cut along the geodesic.- Parameters:
kMesh
- TriMesh surfaceiVertexCount
- int new vertex countiOldVertexCount
- int old vertex cunt- Returns:
- TriMesh surface
-
distance
private float distance(WildMagic.LibFoundation.Mathematics.Vector3f kPoint1, WildMagic.LibFoundation.Mathematics.Vector3f kPoint2)
Calculate the Euclidean distance between two points.- Parameters:
kPoint1
- Point3f starting pointkPoint2
- Point3f ending point- Returns:
- float distance
-
drawDijkstraEuclidianPoint
private void drawDijkstraEuclidianPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.- Parameters:
kStart
- Point3f starting pointkColor
- Color3f ending point
-
drawGeodesicPoint
private void drawGeodesicPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kParent, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.- Parameters:
kStart
- Point3f starting pointkColor
- Color3f ending point
-
drawPoint
private void drawPoint(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kStart, WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
Draw the user-selected point as a sphere on the triangle mesh, the sphere is added to all three drawing groups: m_kSmoothedGeodesicGroup, m_kDijkstraGeodesicGroup, and m_kEuclidianGeodesicGroup.- Parameters:
kStart
- Point3f point coordinatekColor
- Color3f point color
-
extractNewMesh
private int extractNewMesh(java.util.LinkedList kLoop)
Used in cutting closed paths and creating new meshes to export to the scene graph.- Parameters:
kLoop
- LinkedList surface mesh link list- Returns:
- int number of deleted vertices
-
findEdges
private void findEdges(int iIndex, boolean[] bFound)
Go through the edge list find the the edge specified.- Parameters:
iIndex
- int edge indexbFound
- boolean[] edge being found
-
findMin
private float findMin(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, WildMagic.LibFoundation.Mathematics.Vector3f kStart, int iMiddle, int iSide, WildMagic.LibFoundation.Mathematics.Vector3f kEnd, WildMagic.LibFoundation.Mathematics.Vector4f kNewPoint4)
findMin finds the point (newpoint) along the edge that connects the points Side-Middle that minimizes the distance Start-newpoint-End.- Parameters:
kStart
- Point3f starting pointiMiddle
- int middle pointiSide
- int side point indexkEnd
- Point3f end indexkNewPoint4
- Point4f new point- Returns:
- float find min point index
-
findNewMeshes
private int findNewMeshes(WildMagic.LibGraphics.SceneGraph.TriMesh kSourceMesh, java.util.LinkedList kGeodesic_Closed_Loops)
Used in cutting closed paths and creating new meshes to export to the scene graph.- Parameters:
kSourceMesh
- TriMesh surface meshkGeodesic_Closed_Loops
- LinkedList closed path- Returns:
- int
-
findSmallest
private int findSmallest()
The findSmallest function searches through the list of vertices that are not yet relaxed but that have been visited by the Dijkstra Search, so that the weight factor is not Float.MAX_VALUE, but also is not the minimum value for that node. In Dijkstra's search the vertex with the smallest weight is relaxed first, a greedy algorithm that chooses the locally closest vertex to add to the path. The final weight for the vertex is determined when it is relaxed.This function uses the data member m_kBorder -- the linked list of vertices that have been visited by Dijkstra's search, but which have not yet been relaxed.
- Returns:
- int index of the vertex with the smallest weight
-
findTriPoints
private int findTriPoints(int iNode1, int iNode2, java.util.LinkedList<java.lang.Integer> kEndPoints)
Find the next side triangle index.- Parameters:
iNode1
- int node 1 along the sideiNode2
- int node 2 along the sidekEndPoints
- end point Link List- Returns:
- int next side triangle index
-
finishWorkingLists
private void finishWorkingLists(boolean bOpen)
Adds the working paths to the finished path lists, combining the segments in the working paths into one path.- Parameters:
bOpen
- boolean close path or not
-
getColor
private WildMagic.LibFoundation.Mathematics.ColorRGBA getColor(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle color from the given triangle index.- Parameters:
kMesh
- TriMesh surface meshiIndex1
- int triangle point index 1iIndex2
- int triangle point index 2- Returns:
- interpolated color the triangle
-
getColor
private WildMagic.LibFoundation.Mathematics.ColorRGBA getColor(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point color for a new starting point inside an existing triangle. The new color is the average of the colors at each point in the triangle the starting point is inside- Parameters:
kMesh
- TriMesh surface meshaiIndex
- int[] 3 triangle points- Returns:
- Color4f Average color of the triangle.
-
getNormal
private WildMagic.LibFoundation.Mathematics.Vector3f getNormal(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle normal from the given triangle index.- Parameters:
kMesh
- TriMesh surface meshiIndex1
- int triangle point index 1iIndex2
- int triangle point index 2- Returns:
- Vector3f normal of the triangle
-
getNormal
private WildMagic.LibFoundation.Mathematics.Vector3f getNormal(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point normal for a new starting point inside an existing triangle. The new normal is the average of the normals at each point in the triangle the starting point is inside- Parameters:
kMesh
- TriMesh surface meshaiIndex
- int[] 3 triangle points- Returns:
- Vector3f Average normal of the triangle.
-
getPathIndex
private int getPathIndex(java.util.LinkedList kPath, int iVertexCount, int iIndex, boolean bOpen)
getPathIndex returns what the new vertex index should be. If the input index, iIndex, does fall on the cut path, kPath, then that point on the path is going to be duplicated to disconnect the triangles on either side of the cut path. Therefore the input index needs to be translated into a new vertex index, based on the current iVertexCount, the point's position along the path, and wehter or not the path is open or closed.- Parameters:
kPath
- LinkedList path link listiVertexCount
- int vertex countiIndex
- int path indexbOpen
- boolean close path or not- Returns:
- int the new vertex index
-
getStartEnd
private void getStartEnd(int iWhich)
In livewire mode the endpoints of each path segment along Dijkstra's curve -- between each of the user-selected points -- are stored so that the smoothed geodesic may be calculated and displayed later. This function retrieves the stored values when the livewire path is finished- Parameters:
iWhich
- int path index
-
getTexCoord
private WildMagic.LibFoundation.Mathematics.Vector3f getTexCoord(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iIndex1, int iIndex2)
Get the the triangle texture coordinate from the given triangle index.- Parameters:
kMesh
- TriMesh surface meshiIndex1
- int triangle point index 1iIndex2
- int triangle point index 2- Returns:
- interpolated texture coordinate the triangle
-
getTexCoord
private WildMagic.LibFoundation.Mathematics.Vector3f getTexCoord(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int[] aiIndex)
Calculates and returns the start point texture coordinate for a new starting point inside an existing triangle. The new texture coordinate is the average of the texture coordinates at each point in the triangle the starting point is inside- Parameters:
kMesh
- TriMesh surface meshaiIndex
- int[] 3 triangle points- Returns:
- Texture3f Average texture coordinate of the triangle.
-
initColors
private void initColors()
Initializes the colors for the first point on the curve, and the successive points.
-
initializeGeodesic
private void initializeGeodesic(float fPercentage)
initializeGeodesic copies the triangle mesh and initializes the data structures for Dijkstra's Single-Source shortest path algorithm.If the start and end vertices do not fall on a triangle vertex, then the triangle they fall inside split into three new triangles, by connecting the new vertex to each of the triangle vertices.
- Parameters:
fPercentage
- float the optimization parameter for Dijkstra's shortest-path search
-
onRight
private boolean onRight(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iPrevIndex, int iIndex, int iSideIndex)
onRight determines if a given point on a triangle, kSide, is to the right of or to the left of the vector specified by the vertices kPrev - kPoint.- Parameters:
kMesh
- TriMesh surface meshiPrevIndex
- int previous verticeiIndex
- int specified vertice indexiSideIndex
- int side vertice index- Returns:
- boolean a point on the right or triangle or not.
-
outputDeletedAsNew
private void outputDeletedAsNew(WildMagic.LibGraphics.SceneGraph.TriMesh kSourceMesh)
creating new meshes to export to the scene graph.
-
relaxEdges
private void relaxEdges(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iNode)
This function determines the shortest path from the start vertex through the input vertex to the vertices that neighbor the input vertex.The function relaxEdges looks at all the vertices connected by triangle edges to the input vertex and calculated the weight factors for each of those vertices, adding those vertices that are not yet "relaxed" to the list of vertices on the border.
Once the weight factors for each of the vertices connected to the input vertex are set, the input vertex is labeled "relaxed" and removed from the list of vertices on the border.
- Parameters:
iNode
- int input vertex index
-
resetDrawGeodesic
private void resetDrawGeodesic()
Remove all the geodesic lines and reset to draw the new geodesic lines.
-
saveStartEnd
private void saveStartEnd()
In livewire mode the endpoints of each path segment along Dijkstra's curve -- between each of the user-selected points -- are stored so that the smoothed geodesic may be calculated and displayed later.
-
setEndSurface
private void setEndSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
The start and end surfaces ensure that the points on the geodesic curve all fall on one mesh, and that the algorithm isn't trying to find a path between two unconnected meshes.- Parameters:
kMesh
- TriMesh surface mesh
-
setPreviousStartPoint
private void setPreviousStartPoint(WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
Sets the previous start point of the geodesic curve on the mesh. Used when the last point is deleted, the start point reverts to the previous start point. The point coordinates must be in local mesh coordinates.- Parameters:
kPoint
- the point on the triangle mesh where the geodesic curve is to start, in mesh coordinates.
-
setStartSurface
private void setStartSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
The start and end surfaces ensure that the points on the geodesic curve all fall on one mesh, and that the algorithm isn't trying to find a path between two unconnected meshes.- Parameters:
kMesh
- surface mesh
-
setSurface
private void setSurface(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh)
Access function to set the triangle mesh that the geodesic curve is calculated on.- Parameters:
kMesh
- the new triangle mesh
-
smoothPath
private int smoothPath(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, int iNode, java.util.LinkedList<java.lang.Integer> kLeft, java.util.LinkedList<java.lang.Integer> kMiddle, java.util.LinkedList<java.lang.Integer> kRight, java.util.LinkedList<java.lang.Integer> kLeftTemp, java.util.LinkedList<java.lang.Integer> kRightTemp, java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f> kNewVertTemp)
Smooth the path.- Parameters:
iNode
- int vertex indexkLeft
- LinkedList left pointkMiddle
- LinkedList middle pointkRight
- LinkedList right pointkLeftTemp
- LinkedList left point temporarykRightTemp
- LinkedList right point temporarykNewVertTemp
- LinkedList new point temporary- Returns:
- int success or not
-
sortTriIndex
private void sortTriIndex(WildMagic.LibFoundation.Mathematics.Vector3f aiAddTri, WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer)
Used when new triangles are added to the mesh, either when the mesh is triangulated along the smoothed geodesic curve, or when the mesh is cut. sortTriIndex sorts the triangle indices so that the triangle is always front-facing and that the normals are correct for rendering- Parameters:
aiAddTri
- Point3i added triangle vertices
-
triangleEdge
private int triangleEdge(int i0, int i1, int i2, int iP0, int iP1)
if the two of the first three triangle indices equal the second two indices, then the third index is returned.- Parameters:
i0
- int first triangle indice 1i1
- int first triangle indice 2i2
- int first triangle indice 3iP0
- int second triangle indice 1iP1
- int second triangle indice 2- Returns:
- int third index
-
triangleEquals
private boolean triangleEquals(int i0, int i1, int i2, int iP0, int iP1, int iP2)
Returns true if the first three triangle indices equal the second three indices.- Parameters:
i0
- first triangle indice 0i1
- first triangle indice 1i2
- first triangle indice 2iP0
- second triangle indice 0iP1
- second triangle indice 1iP2
- second triangle indice 2- Returns:
- boolean true equal, false not
-
triangleExists
private boolean triangleExists(WildMagic.LibFoundation.Mathematics.Vector3f kTri)
Check to see if the triangle specified in the triangle list.- Parameters:
kTri
- Point3i triangle specified- Returns:
- boolean true in the list, false not in the list
-
triangulate
private int triangulate(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, java.util.LinkedList kPath, java.util.LinkedList kLeftPath, java.util.LinkedList kRightPath, int iVertexCount)
triangulates the mesh along a single geodesic.- Parameters:
kMesh
- TriMesh surface meshkPath
- LinkedList path link listkLeftPath
- LinkedList left path link listkRightPath
- LinkedList right path link listiVertexCount
- int vertex count- Returns:
- int number of vertices
-
triangulateMeshPath
private void triangulateMeshPath()
re-triangulates the mesh along the Smoothed Geodesic.
-
unZip
private int unZip(WildMagic.LibGraphics.SceneGraph.TriMesh kMesh, java.util.LinkedList<WildMagic.LibFoundation.Mathematics.Vector4f> kPath, int iVertexCount, boolean bOpen, java.util.LinkedList<java.lang.Integer> kNewPath)
unZip cuts along the smoothed geodesic path by creating new vertices for each point on the path, and updating the triangles that are connected to the path and that fall on the right of the path to contain the new path vertices. This cuts the mesh by disconnecting the triangles that are on the left and right sides of the geodesic path.- Parameters:
kMesh
- TriMesh surface meshkPath
- LinkedList path link listiVertexCount
- int vertex countbOpen
- boolean closed path or notkNewPath
- LinkedList new path link list- Returns:
- int new number of vertices
-
-