Class MeshFunctions
public class MeshFunctions extends Utility
Policy: See ProgressUpdater
for details on how to incorporate progress
updaters into your methods. In general, if progress updating is desired, functions must be
able to handle null
updater arguments, and preferably provide a second method
with no updater which calls the first with a null
updater (thus allowing
stand-alone calls to blocking methods).
TODO: Remove all calls to Worker
in this class. All functions should block.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
- See Also:
ProgressUpdater
,InterfaceProgressBar
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MeshFunctions.IndexedPoint3f
-
Field Summary
Fields Modifier and Type Field Description static javax.swing.JProgressBar
progressBar
static double
tolerance
-
Constructor Summary
Constructors Constructor Description MeshFunctions()
-
Method Summary
Modifier and Type Method Description static void
addIndexedTriangleArray(Mesh3D mesh, org.jogamp.java3d.IndexedTriangleArray tris)
Adds an IndexedTriangleArray to the current mesh.static void
cleanMesh(Mesh3D mesh)
static Mesh3D
combine(Mesh3D mesh1, Mesh3D mesh2)
Combinesmesh1
andmesh2
and returns the result.static boolean
computeVertexWiseCurvature(Mesh3DInt mesh3D, java.lang.String target_column, ProgressUpdater progress)
Computes the curvature of a mesh at each of its nodes, as the magnitude of the sum of surface normals of the triangles of which it is a node.static Mesh3D
condenseMesh(Mesh3D mesh)
Condenses a mesh by removing all coincident nodes.static void
correctOrientation(Mesh3D mesh)
Orients all faces with each other, starting with the first facestatic void
correctOrientation(Mesh3D mesh, boolean reverse)
Orients all faces with each other (starting with face 0)static java.util.ArrayList<Mesh3D>
cutMeshWithPlane(Mesh3D mesh, Plane3D plane, InterfaceProgressBar progress_bar)
Cutsmesh
withplane
, creating new faces along the cut seam.static java.util.ArrayList<Mesh3D>
cutMeshWithPlane3(Mesh3D mesh, Plane3D plane)
Cutsmesh
withplane
, creating new faces along the cut seam.static void
decimateByDistance(Mesh3D mesh, Mesh3D newmesh, double threshold)
Decimates this mesh by merging multiple nodes into a single node if they are separated by less than. static org.jogamp.vecmath.Vector3f[]
flipNormals(org.jogamp.vecmath.Vector3f[] normals)
protected static java.util.ArrayList<MguiInteger>
getAllNeighbours(int n, NeighbourhoodMesh nmesh, boolean[] removed, int[] added, boolean[] processed)
Searches for all neighbours ofn
innmesh
.static double
getArea(Mesh3D mesh)
Returns the surface area of the given meshstatic double
getAverageEdgeLength(Mesh3D mesh)
Returns the average edge length keyin a mesh.static java.util.ArrayList<java.lang.Integer>
getBoundaryNodeIndices(Mesh3D mesh)
static boolean[]
getBoundaryNodes(Mesh3D mesh)
Determine which nodes are boundary nodes, return an array of booleans.static int
getClosestVertex(Mesh3D mesh, int idx, java.util.ArrayList<java.lang.Integer> search_vertices, MguiDouble distance)
Returns the closest vertex in a list of vertices, or from all vertices if the list is empty.static java.util.ArrayList<java.lang.Integer>
getClosestVertices(Mesh3D mesh)
Returns a list of sizemesh.n
integers, such that list(i) = the index of the closest vertex j from vertex i.static java.util.ArrayList<java.lang.Integer>
getClosestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances)
Returns a list of sizemesh.n
integers, such that list(i) = the index of the closest vertex j from vertex i.static Mesh3D
getConvexHull(Mesh3D mesh)
Returns a new mesh which is the convex hull of the given mesh.static Mesh3D
getConvexHull(Mesh3D mesh, java.lang.String method)
static Mesh3D
getConvexHull(Mesh3D mesh, java.lang.String method, ProgressUpdater progress)
Returns a new mesh which is the convex hull of the given mesh.static Mesh3D
getConvexHull(Mesh3D mesh, ProgressUpdater progress)
static java.util.ArrayList<java.lang.Boolean>
getDuplicateFaces(Mesh3D mesh)
Returns an array of booleans where true indicates a duplicate facestatic java.util.List<java.lang.Integer>
getDuplicateNodes(Mesh3D mesh)
Returns an array of booleans where true indicates a duplicate nodestatic java.util.ArrayList<MguiDouble>
getEdgeLengths(Mesh3D mesh, java.util.ArrayList<MeshEdge> edges)
Returns a list of edge lengths for the given set of edgesstatic java.util.ArrayList<java.lang.Integer>
getFarthestVertices(Mesh3D mesh)
Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.static java.util.ArrayList<java.lang.Integer>
getFarthestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances)
Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.static java.util.ArrayList<java.lang.Integer>
getFarthestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances, java.util.ArrayList<java.lang.Integer> vertices)
Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.static Mesh3D
getFractalSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int min_nodes)
static Mesh3D
getGlobeSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes)
static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>
getIntersectingFaces(Mesh3D mesh1, Mesh3D mesh2, float search_max)
Returns a list of face indices indicating which faces intersect betweenmesh1
andmesh2
.static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>
getIntersectingFaces(Mesh3D mesh_1, Mesh3D mesh_2, float search_max, ProgressUpdater progress)
Returns two lists of face indices indicating which faces intersect betweenmesh1
andmesh2
.static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>
getIntersectingFacesBlocking(Mesh3D mesh_1, Mesh3D mesh_2, float search_max, ProgressUpdater progress)
Returns two lists of face indices indicating which faces intersect betweenmesh1
andmesh2
.static org.jogamp.vecmath.Point3f
getIntersectionPoint(Mesh3D mesh, org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v)
Finds the point from the first face in the nodes list which intersects the line segment defined byp
and v.static java.util.ArrayList<Polygon3D>
getIntersectionSegments(Mesh3D mesh1, Mesh3D mesh2, InterfaceProgressBar progress_bar)
Return a set of line segments which represent the intersection of one mesh with another.static Mesh3D
getIsosurfaceFromVolume(Volume3DInt volume, java.lang.String column, double iso_level)
Constructs an isosurface fromvolume
; i.e., computes a mesh which represents the location where values in the 3D scalar field involume
are equal toiso_level
.static java.util.HashMap<java.lang.Integer,java.lang.Integer>
getJaggedEdgeNodes(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, int min_nbrs, int max_nbrs, boolean islands)
Detects nodes corresponding to "jagged" edges; a jagged edge node is defined as one which has onlymax_nbrs
neighbours with the same value as itself, and at leastmin_nbrs
neighbours which are the same value.static java.util.ArrayList<java.lang.Double>
getLaplacian(Mesh3D mesh)
Computes the discrete Laplacian for each vertex inmesh.
static java.util.ArrayList<MguiNumber>
getLargestContiguousRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int out_value)
Retains only the largest contiguous ROIs in the given set of values; all others are set toout_value
.static float
getMaximumEdgeLength(Mesh3D mesh)
Searches all edges and returns the maximum lengthstatic float
getMeanCurvature(Mesh3D mesh)
static Mesh3D
getMeanSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes, float stop_delta, long max_itrs)
static Mesh3D
getMeshExpandedAlongNormals(Mesh3D mesh, float expansion)
Expandsmesh
along its vertex normals by a distance ofexpansion
.static java.util.ArrayList<Mesh3D>
getMeshParts(Mesh3D mesh)
static java.util.ArrayList<Mesh3D>
getMeshParts(Mesh3D mesh, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> old_data, java.util.ArrayList<java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>>> parts_data)
static java.util.ArrayList<Mesh3D>
getMeshParts(Mesh3D mesh, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> old_data, java.util.ArrayList<java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>>> parts_data, ProgressUpdater updater)
Returns a set of non-contiguous meshes frommesh
.static float
getMinimumEdgeLength(Mesh3D mesh)
Searches all edges and returns the minimum lengthprotected static void
getNeighbourhoodPoints(java.util.TreeSet<org.jogamp.vecmath.Point3f> points, Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node, int levels)
static java.util.ArrayList<org.jogamp.vecmath.Point3f>
getNeighbourhoodPoints(Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node)
Returns a list of points corresponding to the immediate (1st level) neighbourhood of nodenode
.static java.util.ArrayList<org.jogamp.vecmath.Point3f>
getNeighbourhoodPoints(Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node, int levels)
Returns a list of points corresponding to the n-th level neighbourhood of nodenode
, where n is specified by the parameterlevels
static Mesh3D
getNeighbourhoodSubmesh(Mesh3D mesh, int i)
Gets a submesh frommesh
consisting of the neighbourhood of vertexi
.static Mesh3D
getOptimalSubmesh(Mesh3D mesh, java.util.ArrayList<MguiInteger> ring)
Returns the optimal submesh defined by the connect ringring
.static Mesh3D
getOptimizedSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes, double stop_value, long max_iter, float entropy)
static java.util.ArrayList<java.lang.Integer>
getRegionBoundaryNodeIndices(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, int value)
Returns a list of nodes which form the boundary of all regions defined byvalue
, specified by the vertex-wise listvalues
.static java.util.ArrayList<java.lang.Integer>
getRoiIndices(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int roi)
Returns a list of indices corresponding torois == roi
.static VertexSelection
getRoiSelection(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int roi)
Returns a vertex selection corresponding torois == roi
.static Mesh3D
getRoiSubmesh(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int roi)
Returns a submesh ofmesh
including all vertices corresponding torois == roi
.static java.util.ArrayList<java.lang.Integer>
getSelfIntersections(Mesh3D mesh, float search_max)
Returns a list of face indices indicating which faces intersect withinmesh
.static java.util.ArrayList<java.lang.Integer>
getSelfIntersections(Mesh3D mesh, float search_max, ProgressUpdater progress)
protected static java.util.ArrayList<java.lang.Integer>
getSelfIntersectionsBlocking(Mesh3D mesh, float search_max, ProgressUpdater progress)
Returns a list of face indices indicating which faces intersect withinmesh
.static Mesh3D
getSubMesh(Mesh3D mesh, java.util.ArrayList<java.lang.Integer> ring)
Returns a submesh defined by the connect ringring
.static Mesh3D
getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain)
Returns a submesh comprised of all unmasked (mask != 0) vertices and all faces whose vertices are retained.static Mesh3D
getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)
Returns a submesh based upon a mask.static Mesh3D
getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)
static Mesh3D
getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value_from, int value_to, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)
Returns a submesh comprised of all unmasked (mask != 0) vertices and all faces whose vertices are retained.static Mesh3D
getSubMesh(Mesh3D mesh_old, VertexSelection selection, boolean retain)
Returns a sub-mesh ofmesh_old
containing all vertices and associated faces inselection
.static Mesh3D
getSubMesh(Mesh3D mesh_old, VertexSelection selection, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)
Returns a sub-mesh ofmesh_old
containing all vertices and associated faces inselection
.static java.util.ArrayList<org.jogamp.vecmath.Vector3f>
getSurfaceNormals(Mesh3D mesh)
Returns surface normals for all vertices ofmesh
, determined as the average vector of all triangular face normals.static Mesh3D
getTriangulation(org.jogamp.vecmath.Point3f[] nodes)
Triangulates a set of nodes that form a ring.static java.util.ArrayList<MguiNumber>
getVertexWiseCurvature(Mesh3D mesh, ProgressUpdater progress)
Computes the mean curvature at each node in the mesh.static java.util.ArrayList<MguiNumber>
getVertexWiseCurvature_bak(Mesh3D mesh, ProgressUpdater progress)
Computes the mean curvature at each node in the mesh.static java.util.ArrayList<MguiFloat>
getVertexWiseCurvatureBak(Mesh3D mesh)
static double[]
getVolumeAndArea(Mesh3D mesh, java.util.ArrayList<MguiNumber> thickness, java.util.ArrayList<MguiNumber> filter, double cutoff)
Given a mesh and a set of thickness values, returns an area and a volume calculation (in that order).static Mesh3D
inflateMeshTRP(Mesh3DInt mesh3D, double lambda, double beta, long max_itr, ProgressUpdater progress)
Inflate this mesh using the TRP method.static boolean
intersects(Mesh3D mesh, org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v)
Determines whether a vector defined byp
andv
intersectsmesh
.static boolean
isBadFace(Mesh3D.MeshFace3D face)
static Volume3DInt
mapMeshToVolumeGaussian(Mesh3DInt mesh_int, Volume3DInt volume, java.lang.String mesh_column, java.lang.String grid_channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, boolean normalize, boolean is_discrete, ProgressUpdater progress)
static java.util.ArrayList<MguiNumber>
mapVolumeToMeshEV(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, float radius, int stat, ProgressUpdater progress)
Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel(s) approach.static java.util.ArrayList<MguiNumber>
mapVolumeToMeshEV(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, ProgressUpdater progress)
Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel approach.protected static java.util.ArrayList<MguiNumber>
mapVolumeToMeshEVBlocking(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, float radius, int stat, ProgressUpdater progress)
Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel(s) approach.static java.util.ArrayList<MguiNumber>
mapVolumeToMeshGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.String setSigmaT, boolean normalize)
static java.util.ArrayList<MguiNumber>
mapVolumeToMeshGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.String setSigmaT, boolean normalize, ProgressUpdater progress, boolean output_matrix, double normal_set_max_sigma, double tangent_set_max_sigma, java.lang.String matrix_file)
Maps values from aGrid3D
object to a mesh object by applying a Gaussian kernal to voxels in the vicinity of each mesh vertex.static java.util.ArrayList<MguiNumber>
maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val)
static java.util.ArrayList<MguiNumber>
maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val, double contained_val)
static java.util.ArrayList<MguiNumber>
maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val, double contained_val, VertexSelection selection)
Masks a mesh with a plane.static Mesh3D
mergeMeshes(java.util.ArrayList<Mesh3D> mesh_list)
Merges the mesh shapes inlist
and returns the resulting single mesh.static Mesh3D
mergeMeshes(java.util.ArrayList<Mesh3D> mesh_list, java.util.ArrayList<java.util.HashMap<java.lang.Integer,java.lang.Integer>> index_map)
Merges the mesh shapes inlist
and returns the resulting single mesh.protected void
orderNeighbours(java.util.ArrayList<MguiInteger> list, NeighbourhoodMesh nmesh)
protected static int
polygonizeCell(org.jogamp.vecmath.Point3f[] gridcell, double[] values, java.util.ArrayList<org.jogamp.vecmath.Point3f> triangles, double isolevel)
Uses the marching cubes lookup tables to find triangular faces intersecting the given grid cell at the given isolevelstatic boolean
removeBadFaces(Mesh3D mesh)
static boolean
removeDuplicateFaces(Mesh3D mesh)
static boolean
removeDuplicateNodes(Mesh3D mesh)
Removes all duplicate vertices frommesh
, and changesmesh
in place.static void
removeNodes(Mesh3D mesh, boolean[] removed)
Removes all nodes specified innodes
frommesh
, and retriangulates the remaining nodes.static void
removeNodes(Mesh3D mesh, boolean[] removed, NeighbourhoodMesh nmesh)
Removes all nodes specified innodes
frommesh
, and retriangulates the remaining nodes.static void
removeStrandedNodes(Mesh3D mesh)
Removes all nodes frommesh
which do not have a corresponding face.static void
selectFloodFill(Mesh3D mesh, VertexSelection selection, int seed_node, ProgressUpdater progress)
Selects all nodes surrounding a seed node in a region enclosed by selected nodes; if seed node is not fully enclosed, this will select the entire mesh.static void
smoothEM(Mesh3DInt mesh)
static void
smoothLR(Mesh3D mesh)
static java.util.ArrayList<MguiNumber>
smoothVertexValuesIsotropicGaussian(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, double sigma, double sigma_max, ProgressUpdater progress)
Smoothsvalues
with an isotropic Gaussian kernel, along the surface ofmesh
.static java.util.ArrayList<MguiNumber>
splitRoiWithPlane(Mesh3D mesh, Plane3D plane, java.util.ArrayList<MguiNumber> rois, int roi, int new_roi, ProgressUpdater progress)
Splits the ROI defined byroi
into two parts, on either side ofplane
.static void
subdivideMesh(Mesh3D mesh, int iter)
static void
subdivideMesh(Mesh3DInt mesh, int iter)
Subdividesiter times, for all triangle in mesh. static void
subdivideMesh(Mesh3DInt mesh, int iter, double edgeThreshold, double areaThreshold)
Subdividesiter times, for triangles which meet the criteria specified by and . static java.util.ArrayList<MguiNumber>
subdivideRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, int min_roi, int max_roi, ProgressUpdater progress)
Subdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
.static java.util.ArrayList<MguiNumber>
subdivideRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, ProgressUpdater progress)
Subdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
.static java.util.ArrayList<MguiNumber>
subdivideRoisBlocking(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, int min_roi, int max_roi, ProgressUpdater progress)
Subdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
.static Mesh3D
transformWithMatrix(Mesh3D mesh_in, org.jogamp.vecmath.Matrix4d matrix, InterfaceProgressBar progress_bar)
static void
triangulate(Mesh3D mesh, java.util.ArrayList<MguiInteger> neighbours)
Triangulates the given neighbourhood by adding faces using recursive loop splittingstatic boolean
validateSurface(Mesh3D mesh)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
tolerance
public static double tolerance -
progressBar
public static javax.swing.JProgressBar progressBar
-
-
Constructor Details
-
MeshFunctions
public MeshFunctions()
-
-
Method Details
-
getConvexHull
Returns a new mesh which is the convex hull of the given mesh. Defaults to the "Giftwrap" algorithm, by Tim Lambert:http://www.cse.unsw.edu.au/~lambert/java/3d/implementation.html
- Parameters:
mesh
- Mesh for which to compute a convex hull.method
- The method to use
-
getConvexHull
-
getConvexHull
-
combine
Combinesmesh1
andmesh2
and returns the result.- Parameters:
mesh1
-mesh2
-- Returns:
-
getConvexHull
Returns a new mesh which is the convex hull of the given mesh. Algorithms provided by Joseph O'Rourke et al:http://maven.smith.edu/~orourke/books/ftp.html
and Tim Lambert:
http://www.cse.unsw.edu.au/~lambert/java/3d/implementation.html
- Parameters:
mesh
- Mesh for which to compute a convex hullmethod
- The method to usebar
- Optional progress bar- Returns:
- the convex hull, or
null
if method failed or was cancelled.
-
getSubMesh
Returns a sub-mesh ofmesh_old
containing all vertices and associated faces inselection
.- Parameters:
mesh_old
- Mesh from which to obtain sub-meshselection
- Selected vertices for sub-meshretain
- Whether to retain the selection (otherwise it is removed)- Returns:
- Newly created sub-mesh
-
getSubMesh
public static Mesh3D getSubMesh(Mesh3D mesh_old, VertexSelection selection, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)Returns a sub-mesh ofmesh_old
containing all vertices and associated faces inselection
.- Parameters:
mesh_old
- Mesh from which to obtain sub-meshselection
- Selected vertices for sub-meshretain
- Whether to retain the selection (otherwise it is removed)any_in_face
- Include faces with any vertices in selection? Otherwise, requires all vertices to be in the selection.data_old
- Data frommesh_old
to transfer tomesh_new
(can benull
)data_new
- New data for the sub-mesh; this should be a reference to an emptyHashMap
- Returns:
- Newly created sub-mesh
-
getLargestContiguousRois
public static java.util.ArrayList<MguiNumber> getLargestContiguousRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int out_value)Retains only the largest contiguous ROIs in the given set of values; all others are set toout_value
.- Parameters:
mesh
-rois
-out_value
-- Returns:
-
splitRoiWithPlane
public static java.util.ArrayList<MguiNumber> splitRoiWithPlane(Mesh3D mesh, Plane3D plane, java.util.ArrayList<MguiNumber> rois, int roi, int new_roi, ProgressUpdater progress)Splits the ROI defined byroi
into two parts, on either side ofplane
.- Parameters:
mesh
-plane
-rois
-roi
-new_roi
-progress
-- Returns:
- The new ROIs; or
null
if the plane does not intersect the ROI
-
subdivideRois
public static java.util.ArrayList<MguiNumber> subdivideRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, ProgressUpdater progress) throws MeshFunctionExceptionSubdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
. Generation is constrained by the min/max parameters.A starting parcellation can be specified using the
old_rois
parameter; this can also benull
to start from a random seed.- Parameters:
mesh
-old_rois
-min_rois
-max_rois
-max_size
-min_size
-target_rois
-- Returns:
- Throws:
MeshFunctionException
-
subdivideRois
public static java.util.ArrayList<MguiNumber> subdivideRois(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, int min_roi, int max_roi, ProgressUpdater progress) throws MeshFunctionExceptionSubdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
. Generation is constrained by the min/max parameters.A starting parcellation can be specified using the
old_rois
parameter; this can also benull
to start from a random seed.- Parameters:
mesh
-old_rois
-min_rois
-max_rois
-max_size
-min_size
-target_rois
-min_roi
- Minimum roi value to includemax_roi
- Maximum roi value to include- Returns:
- Throws:
MeshFunctionException
-
subdivideRoisBlocking
public static java.util.ArrayList<MguiNumber> subdivideRoisBlocking(Mesh3D mesh, java.util.ArrayList<MguiNumber> old_rois, int min_size, int target_rois, int min_roi, int max_roi, ProgressUpdater progress) throws MeshFunctionExceptionSubdivides a mesh into (roughly) equally sized ROIs, with the final number equal or close totarget_rois
. Generation is constrained by the min/max parameters.A starting parcellation can be specified using the
old_rois
parameter; this can also benull
, in which case the mesh will first be split by the median x coordinate and then subdivided.- Parameters:
mesh
-old_rois
-min_rois
-max_rois
-max_size
-min_size
-target_rois
-min_roi
- Minimum roi value to includemax_roi
- Maximum roi value to include- Returns:
- Throws:
MeshFunctionException
-
getFarthestVertices
Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.- Parameters:
mesh
-- Returns:
-
getFarthestVertices
public static java.util.ArrayList<java.lang.Integer> getFarthestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances)Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.- Parameters:
mesh
-distances
- Stores the corresponding distances; can benull
.- Returns:
-
getFarthestVertices
public static java.util.ArrayList<java.lang.Integer> getFarthestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances, java.util.ArrayList<java.lang.Integer> vertices)Returns a list of sizemesh.n
integers, such that list(i) = the index of the farthest vertex j from vertex i.- Parameters:
mesh
-distances
- Stores the corresponding distances; can benull
.n_vertex
- Number of vertices to sample frommesh
. n_vertex <= 0 samples from entire mesh (default). This should be specified for very large graphs to avoid resource issues.- Returns:
-
getClosestVertices
Returns a list of sizemesh.n
integers, such that list(i) = the index of the closest vertex j from vertex i.- Parameters:
mesh
-- Returns:
-
getClosestVertices
public static java.util.ArrayList<java.lang.Integer> getClosestVertices(Mesh3D mesh, java.util.ArrayList<java.lang.Double> distances)Returns a list of sizemesh.n
integers, such that list(i) = the index of the closest vertex j from vertex i.- Parameters:
mesh
-distances
- Stores the corresponding distances; can benull
.- Returns:
-
getRoiSubmesh
Returns a submesh ofmesh
including all vertices corresponding torois == roi
.- Parameters:
mesh
-rois
-roi
-- Returns:
-
getRoiSelection
public static VertexSelection getRoiSelection(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int roi)Returns a vertex selection corresponding torois == roi
.- Parameters:
mesh
-rois
-roi
-- Returns:
-
getRoiIndices
public static java.util.ArrayList<java.lang.Integer> getRoiIndices(Mesh3D mesh, java.util.ArrayList<MguiNumber> rois, int roi)Returns a list of indices corresponding torois == roi
.- Parameters:
mesh
-rois
-roi
-- Returns:
-
getClosestVertex
public static int getClosestVertex(Mesh3D mesh, int idx, java.util.ArrayList<java.lang.Integer> search_vertices, MguiDouble distance)Returns the closest vertex in a list of vertices, or from all vertices if the list is empty. This searches links and accumulates distance along the links, rather than using Euclidean distance. If the vertex is unconnected to any of the target vertices, returnsnull
. Thedistance
parameter (if notnull
) stores the actual link-wise distance.- Parameters:
mesh
-idx
-search_vertices
-distance
-- Returns:
-
getRegionBoundaryNodeIndices
public static java.util.ArrayList<java.lang.Integer> getRegionBoundaryNodeIndices(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, int value)Returns a list of nodes which form the boundary of all regions defined byvalue
, specified by the vertex-wise listvalues
.- Parameters:
mesh
-values
-value
-- Returns:
-
selectFloodFill
public static void selectFloodFill(Mesh3D mesh, VertexSelection selection, int seed_node, ProgressUpdater progress)Selects all nodes surrounding a seed node in a region enclosed by selected nodes; if seed node is not fully enclosed, this will select the entire mesh.- Parameters:
mesh
-selection
-seed_node
-
-
getSubMesh
public static Mesh3D getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain)Returns a submesh comprised of all unmasked (mask != 0) vertices and all faces whose vertices are retained.- Parameters:
mesh
-mask
-value
-retain
-- Returns:
- submesh
-
getSubMesh
public static Mesh3D getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new) -
getSubMesh
public static Mesh3D getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)Returns a submesh based upon a mask. Ifretain
is true, retains all vertices wheremask == value
; otherwise retains the inverse. Removes all faces containing removed vertices. Ifdata_old
anddata_new
are non-null, populatesdata_new
with the retained values fromdata_old
.- Parameters:
mesh
-mask
-value
-retain
-any_in_face
- retains a face if any of its vertices are retaineddata
-- Returns:
- submesh
-
getSubMesh
public static Mesh3D getSubMesh(Mesh3D mesh_old, java.util.ArrayList<MguiNumber> mask, int value_from, int value_to, boolean retain, boolean any_in_face, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_old, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> data_new)Returns a submesh comprised of all unmasked (mask != 0) vertices and all faces whose vertices are retained.- Parameters:
mesh
-mask
-value_from
-value_to
-retain
-any_in_face
- retains a face if any of its vertices are retaineddata
-- Returns:
- submesh
-
removeStrandedNodes
Removes all nodes frommesh
which do not have a corresponding face.- Parameters:
mesh
-
-
validateSurface
-
removeDuplicateFaces
-
isBadFace
-
removeBadFaces
-
getDuplicateFaces
Returns an array of booleans where true indicates a duplicate face- Returns:
-
removeDuplicateNodes
Removes all duplicate vertices frommesh
, and changesmesh
in place.Duplicates are determined as
pt1.distance(pt2) < MeshFunctions.tolerance
.- Parameters:
mesh
-- Returns:
true
if successful
-
getDuplicateNodes
Returns an array of booleans where true indicates a duplicate node- Returns:
-
transformWithMatrix
public static Mesh3D transformWithMatrix(Mesh3D mesh_in, org.jogamp.vecmath.Matrix4d matrix, InterfaceProgressBar progress_bar) -
subdivideMesh
-
subdivideMesh
Subdividesiter times, for all triangle in mesh. Operates directly on mesh, so if user requires a retained original, he/she must make a copy before calling. - Parameters:
mesh
- Mesh object to subdivide.iter
- Number of times to subdivide this mesh. If<= 0, operation will do nothing.
-
subdivideMesh
public static void subdivideMesh(Mesh3DInt mesh, int iter, double edgeThreshold, double areaThreshold)Subdividesiter times, for triangles which meet the criteria specified by and . Operates directly on mesh, so if user requires a retained original, he/she must make a copy before calling. - Parameters:
mesh
- Mesh object to subdivideedgeThreshold
- Triangle will be subdivided if one edge is at least as long as. If edgeThreshold <= 0, edge length is not checked. areaThreshold
- Triangle will be subdivided if its area is at least. If <= 0, area is not checked. iter
- Number of times to subdivide this mesh. If<= 0, and either or > 0, operation will subdivide until no triangles satisfy criteria. Otherwise it will do nothing.
-
maskMeshWithPlane
public static java.util.ArrayList<MguiNumber> maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val) -
maskMeshWithPlane
public static java.util.ArrayList<MguiNumber> maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val, double contained_val) -
maskMeshWithPlane
public static java.util.ArrayList<MguiNumber> maskMeshWithPlane(Mesh3D mesh, Plane3D plane, double above_val, double below_val, double contained_val, VertexSelection selection)Masks a mesh with a plane. -
addIndexedTriangleArray
public static void addIndexedTriangleArray(Mesh3D mesh, org.jogamp.java3d.IndexedTriangleArray tris)Adds an IndexedTriangleArray to the current mesh. Coincident nodes from either object will be represented as two seperate nodes, however. To merge these nodes into a single node, call decimateByLength with a minimal length threshold.- Parameters:
mesh
- Mesh object to which nodes and faces will be added.tris
- IndexedTriangleArray object from which nodes and face indices will be extracted.
-
getTriangulation
Triangulates a set of nodes that form a ring.- Parameters:
mesh
-nodes
-- Returns:
-
mergeMeshes
public static Mesh3D mergeMeshes(java.util.ArrayList<Mesh3D> mesh_list) throws MeshFunctionExceptionMerges the mesh shapes inlist
and returns the resulting single mesh.- Parameters:
mesh_list
-- Throws:
MeshFunctionException
- If the merge failed
-
mergeMeshes
public static Mesh3D mergeMeshes(java.util.ArrayList<Mesh3D> mesh_list, java.util.ArrayList<java.util.HashMap<java.lang.Integer,java.lang.Integer>> index_map) throws MeshFunctionExceptionMerges the mesh shapes inlist
and returns the resulting single mesh. Ifindex_map
is not null, also provides a mapping of the original indices to the merged mesh indices.- Parameters:
mesh_list
-index_map
-- Throws:
MeshFunctionException
- If the merge failed
-
decimateByDistance
Decimates this mesh by merging multiple nodes into a single node if they are separated by less than. - Parameters:
mesh
- Mesh3D object to be decimatedthreshold
- Threshold separation length at which to merge two nodes
-
inflateMeshTRP
public static Mesh3D inflateMeshTRP(Mesh3DInt mesh3D, double lambda, double beta, long max_itr, ProgressUpdater progress)Inflate this mesh using the TRP method. TODO: Remove worker here- Parameters:
mesh3D
-lambda
-beta
-max_itr
-progress
-- Returns:
-
getMeshParts
-
getMeshParts
public static java.util.ArrayList<Mesh3D> getMeshParts(Mesh3D mesh, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> old_data, java.util.ArrayList<java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>>> parts_data) -
getMeshParts
public static java.util.ArrayList<Mesh3D> getMeshParts(Mesh3D mesh, java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>> old_data, java.util.ArrayList<java.util.HashMap<java.lang.String,java.util.ArrayList<MguiNumber>>> parts_data, ProgressUpdater updater)Returns a set of non-contiguous meshes frommesh
. Ifmesh
is a single contiguous surface, this method will return only that surface.- Parameters:
mesh
- Mesh from which to extract partsold_data
- Vertex data to be transferred to the new meshesnew_data
- Vertex data transferred to the new meshes. Should be an empty object.- Returns:
- List of created mesh parts
-
getSubMesh
Returns a submesh defined by the connect ringring
. Triangulation is performed by connecting n to n + 2, to n - 1, to n + 3, etc.- Returns:
- optimal submesh
-
getOptimalSubmesh
Returns the optimal submesh defined by the connect ringring
. Triangulation is optimized by minimizing the sum of angles for each permutation of possible edge configurations.- Returns:
- optimal submesh
-
correctOrientation
Orients all faces with each other, starting with the first face- Parameters:
mesh
-
-
correctOrientation
Orients all faces with each other (starting with face 0)- Parameters:
mesh
-seed
-reverse
-
-
flipNormals
public static org.jogamp.vecmath.Vector3f[] flipNormals(org.jogamp.vecmath.Vector3f[] normals) -
condenseMesh
Condenses a mesh by removing all coincident nodes.- Parameters:
mesh
- mesh to condense- Returns:
- condensed mesh
-
computeVertexWiseCurvature
public static boolean computeVertexWiseCurvature(Mesh3DInt mesh3D, java.lang.String target_column, ProgressUpdater progress)Computes the curvature of a mesh at each of its nodes, as the magnitude of the sum of surface normals of the triangles of which it is a node. Adds this information tomesh3D
as a variable namedname
.- Parameters:
mesh3D
- Mesh for which to compute curvaturename
- Name of resulting variable
-
getVertexWiseCurvature_bak
public static java.util.ArrayList<MguiNumber> getVertexWiseCurvature_bak(Mesh3D mesh, ProgressUpdater progress)Computes the mean curvature at each node in the mesh. See:Tosun D, Rettman ME, Prince JL (2004). Mapping techniques for aligning sulci across multiple brains. Medical Image Analysis 8:295-309.
Meyer M, Desbrun M, Schroeder P, Barr AH (2002). Discrete differential- geometry operators for triangulated 2-manifolds. http://citeseer.ist.psu.edu/meyer02discrete.html
- Parameters:
mesh
-- Returns:
-
getVertexWiseCurvature
public static java.util.ArrayList<MguiNumber> getVertexWiseCurvature(Mesh3D mesh, ProgressUpdater progress)Computes the mean curvature at each node in the mesh. See:Tosun D, Rettman ME, Prince JL (2004). Mapping techniques for aligning sulci across multiple brains. Medical Image Analysis 8:295-309.
Meyer M, Desbrun M, Schroeder P, Barr AH (2002). Discrete differential- geometry operators for triangulated 2-manifolds. http://citeseer.ist.psu.edu/meyer02discrete.html
- Parameters:
mesh
-- Returns:
-
getVertexWiseCurvatureBak
-
getMeanCurvature
-
smoothLR
-
smoothEM
-
smoothVertexValuesIsotropicGaussian
public static java.util.ArrayList<MguiNumber> smoothVertexValuesIsotropicGaussian(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, double sigma, double sigma_max, ProgressUpdater progress)Smoothsvalues
with an isotropic Gaussian kernel, along the surface ofmesh
.- Parameters:
mesh
-values
-sigma
-sigma_max
-progress
-- Returns:
-
getEdgeLengths
public static java.util.ArrayList<MguiDouble> getEdgeLengths(Mesh3D mesh, java.util.ArrayList<MeshEdge> edges)Returns a list of edge lengths for the given set of edges- Parameters:
mesh
-- Returns:
-
getArea
Returns the surface area of the given mesh- Parameters:
mesh
-- Returns:
-
getVolumeAndArea
public static double[] getVolumeAndArea(Mesh3D mesh, java.util.ArrayList<MguiNumber> thickness, java.util.ArrayList<MguiNumber> filter, double cutoff)Given a mesh and a set of thickness values, returns an area and a volume calculation (in that order). Simply sums triangle areas for area, and multiplies area by the average thickness for volume.- Parameters:
mesh
-thickness
-cutoff
- value below which the area and volume are not counted.- Returns:
- double array with area and volume, in that order
-
getNeighbourhoodPoints
public static java.util.ArrayList<org.jogamp.vecmath.Point3f> getNeighbourhoodPoints(Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node)Returns a list of points corresponding to the immediate (1st level) neighbourhood of nodenode
.- Parameters:
mesh
-neighbourhoods
-node
-- Returns:
-
getNeighbourhoodPoints
public static java.util.ArrayList<org.jogamp.vecmath.Point3f> getNeighbourhoodPoints(Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node, int levels)Returns a list of points corresponding to the n-th level neighbourhood of nodenode
, where n is specified by the parameterlevels
- Parameters:
mesh
-neighbourhoods
-node
-- Returns:
-
getNeighbourhoodPoints
protected static void getNeighbourhoodPoints(java.util.TreeSet<org.jogamp.vecmath.Point3f> points, Mesh3D mesh, NeighbourhoodMesh neighbourhoods, int node, int levels) -
removeNodes
Removes all nodes specified innodes
frommesh
, and retriangulates the remaining nodes.- Parameters:
mesh
-vertices
-
-
removeNodes
Removes all nodes specified innodes
frommesh
, and retriangulates the remaining nodes.- Parameters:
mesh
-vertices
-nmesh
- Neighbourhood mesh (in case one is already made)
-
getAllNeighbours
protected static java.util.ArrayList<MguiInteger> getAllNeighbours(int n, NeighbourhoodMesh nmesh, boolean[] removed, int[] added, boolean[] processed)Searches for all neighbours ofn
innmesh
. If a neighbour is removed and not yet processed, its neighbours will also be added to this list recursively, and its index in theprocessed
array will be set to true (to prevent its being reprocessed). This continues until alln
's neighbours have been processed. -
orderNeighbours
-
triangulate
Triangulates the given neighbourhood by adding faces using recursive loop splitting- Parameters:
mesh
-n
-
-
mapVolumeToMeshGaussian
public static java.util.ArrayList<MguiNumber> mapVolumeToMeshGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.String setSigmaT, boolean normalize) -
mapVolumeToMeshGaussian
public static java.util.ArrayList<MguiNumber> mapVolumeToMeshGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.String setSigmaT, boolean normalize, ProgressUpdater progress, boolean output_matrix, double normal_set_max_sigma, double tangent_set_max_sigma, java.lang.String matrix_file)Maps values from aGrid3D
object to a mesh object by applying a Gaussian kernal to voxels in the vicinity of each mesh vertex. The Gaussian is defined in the direction normal to the vertex, bysigma_normal
(one standard deviation) andsigma_max_normal
(the distance, in standard deviations, at which to stop considering voxels). It is defined in the plane tangent to the normal depending on the value ofsetSigmaT
:- "Parameter":
sigma_tangent
is set to the passed parameter - "From mean area": for each vertex,
sigma_tangent
is set to sqrt(A_tri_mean / Pi) - "From mean length": for each vertex,
sigma_tangent
is set to the mean length of all edges connecting the vertex
Grid3D.getDoubleValue
method, but can alternatively be normalized by setting thenormalized
flag.- Parameters:
mesh
- Mesh on which to project valuesgrid
- Input gridsigma_normal
- Sigma defining the Gaussian in the normal directionsigma_tangent
- Sigma defining the Gaussian in the tangent directionsigma_max_normal
- Maximum sigma at which to obtain values in the normal directionsigma_max_tangent
- Maximum sigma at which to obtain values in the tangent directionsetSigmaT
- How to determine the tangent sigma; one of "parameter", "area", or...normalize
- Whether to normalize the resulting valuesnormal_set_max_sigma
- From all values within this proximity along the normal, set value to the maximum rather than the weighted average; set to 0 to avoid this behaviour (default)tangent_set_max_sigma
- From all values within this proximity along the tangent, set value to the maximum rather than the weighted average; set to 0 to avoid this behaviour (default)- Returns:
- Vertex-wise mapped values, or
null
if process fails or was cancelled.
- "Parameter":
-
mapMeshToVolumeGaussian
public static Volume3DInt mapMeshToVolumeGaussian(Mesh3DInt mesh_int, Volume3DInt volume, java.lang.String mesh_column, java.lang.String grid_channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, boolean normalize, boolean is_discrete, ProgressUpdater progress)Projects vertex-wise data from a givenMesh3DInt
data column to aGrid3D
channel, normal and transverse (tangent) Gaussian functions.- Parameters:
mesh_int
- The mesh from which to projectgrid
- The target 3D gridmesh_column
- The column from which to obtain the projected datagrid_channel
- The target grid channelsigma_normal
- The sigma defining a Gaussian normal to the vertexsigma_tangent
- The sigma defining a Gaussian tangential to the vertexmax_normal
- The maximum distance to project data in the normal directionmax_tangent
- The maximum distance to project data in the tangential directionis_discrete
- Indicates whether data are to be treated as discrete; if so, the mapped value will be the value of the neighbour with the highest Gaussian weight. Otherwise, value is the weighted real-valued mean.progress
-- Returns:
- A new
Grid3D
containing the projected values
-
getAverageEdgeLength
Returns the average edge length keyin a mesh.- Parameters:
mesh
-- Returns:
-
getSurfaceNormals
Returns surface normals for all vertices ofmesh
, determined as the average vector of all triangular face normals.- Parameters:
mesh
-- Returns:
-
mapVolumeToMeshEV
public static java.util.ArrayList<MguiNumber> mapVolumeToMeshEV(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, ProgressUpdater progress)Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel approach. This method essentially maps the value of the containing voxel to the vertex, ignoring all neighbours. Size is single voxel.- Parameters:
mesh
- Mesh whose vertices are used to determine mappingvolume
- Volume to mapcolumn
- Column to mapno_value
- Value to use when no mapping is madeprogress
-- Returns:
- A list of size n, where n = number of vertices in
mesh
-
mapVolumeToMeshEV
public static java.util.ArrayList<MguiNumber> mapVolumeToMeshEV(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, float radius, int stat, ProgressUpdater progress)Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel(s) approach. This method essentially maps the value of the containing voxel to the vertex, ignoring all neighbours.- Parameters:
mesh
- Mesh whose vertices are used to determine mappingvolume
- Volume to mapcolumn
- Column to mapno_value
- Value to use when no mapping is madesize
- Radius of the search sphere, in voxels; <=0 is single voxel (default)stat
- Statistic to use for summarizing values in a search sphere; only used if radius > 0; one of: 1=max, 2=min, 3=abs max, 4=abs min, 0(or other)= meanprogress
-- Returns:
- A list of size n, where n = number of vertices in
mesh
-
mapVolumeToMeshEVBlocking
protected static java.util.ArrayList<MguiNumber> mapVolumeToMeshEVBlocking(Mesh3D mesh, Volume3DInt volume, java.lang.String column, double no_value, float radius, int stat, ProgressUpdater progress)Maps the values inchannel
ofgrid
, an instance ofGrid3D
, to the vertices ofmesh
, using a containing-voxel(s) approach. This method essentially maps the value of the containing voxel to the vertex, ignoring all neighbours.- Parameters:
mesh
- Mesh whose vertices are used to determine mappingvolume
- Volume to mapcolumn
- Column to mapno_value
- Value to use when no mapping is maderadius
- Radius of the search sphere, in voxels; <=0 is single voxel (default)stat
- Statistic to use for summarizing values in a search sphere; only used if radius > 0; one of: 1=max, 2=min, 3=abs max, 4=abs min, 5=mode, 6=median, 0(or other)= meanprogress
-- Returns:
- A list of size n, where n = number of vertices in
mesh
-
getNeighbourhoodSubmesh
Gets a submesh frommesh
consisting of the neighbourhood of vertexi
.- Parameters:
mesh
-i
-- Returns:
-
cleanMesh
-
getMeanSphereMesh
public static Mesh3D getMeanSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes, float stop_delta, long max_itrs) -
getFractalSphereMesh
public static Mesh3D getFractalSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int min_nodes) -
getOptimizedSphereMesh
public static Mesh3D getOptimizedSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes, double stop_value, long max_iter, float entropy) -
intersects
public static boolean intersects(Mesh3D mesh, org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v)Determines whether a vector defined byp
andv
intersectsmesh
.- Parameters:
mesh
-p
-v
-- Returns:
-
getIntersectingFaces
public static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getIntersectingFaces(Mesh3D mesh1, Mesh3D mesh2, float search_max)Returns a list of face indices indicating which faces intersect betweenmesh1
andmesh2
. If there are no such faces, returns an empty list.- Parameters:
mesh1
-mesh2
-search_max
- Maximum search radius; should be similar to largest face size; larger takes longer- Returns:
-
getIntersectingFaces
public static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getIntersectingFaces(Mesh3D mesh_1, Mesh3D mesh_2, float search_max, ProgressUpdater progress)Returns two lists of face indices indicating which faces intersect betweenmesh1
andmesh2
. If there are no such faces, returns an empty list.- Parameters:
mesh1
-mesh2
-search_max
- Maximum search radius; should be similar to largest face size; larger takes longerprogress
-- Returns:
-
getIntersectingFacesBlocking
public static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getIntersectingFacesBlocking(Mesh3D mesh_1, Mesh3D mesh_2, float search_max, ProgressUpdater progress)Returns two lists of face indices indicating which faces intersect betweenmesh1
andmesh2
. If there are no such faces, returns an empty list.- Parameters:
mesh1
-mesh2
-search_max
- Maximum search radius; should be similar to largest face size; larger takes longerprogress
-- Returns:
-
getSelfIntersections
public static java.util.ArrayList<java.lang.Integer> getSelfIntersections(Mesh3D mesh, float search_max)Returns a list of face indices indicating which faces intersect withinmesh
. If there are no such faces, returns an empty list.- Parameters:
mesh
-search_max
- Maximum search radius; should be similar to largest face size; larger takes longer- Returns:
-
getSelfIntersections
public static java.util.ArrayList<java.lang.Integer> getSelfIntersections(Mesh3D mesh, float search_max, ProgressUpdater progress) -
getSelfIntersectionsBlocking
protected static java.util.ArrayList<java.lang.Integer> getSelfIntersectionsBlocking(Mesh3D mesh, float search_max, ProgressUpdater progress)Returns a list of face indices indicating which faces intersect withinmesh
. If there are no such faces, returns an empty list.- Parameters:
mesh
-search_max
- Maximum search radius; should be similar to largest face size; larger takes longerprogress
-- Returns:
-
getMaximumEdgeLength
Searches all edges and returns the maximum length- Returns:
-
getMinimumEdgeLength
Searches all edges and returns the minimum length- Returns:
-
getIntersectionPoint
public static org.jogamp.vecmath.Point3f getIntersectionPoint(Mesh3D mesh, org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v)Finds the point from the first face in the nodes list which intersects the line segment defined byp
and v. Returnsnull
if no intersection exists.- Parameters:
mesh
-p
-v
-- Returns:
-
getLaplacian
Computes the discrete Laplacian for each vertex inmesh. Adapted from matlab script; see
Oostendorp, Oosterom & Huiskamp (1989), Interpolation on a triangulated 3D surface. Journal of Computational Physics, 80: 331-343
- Parameters:
mesh
-- Returns:
- vertex-wise Laplacian values
-
cutMeshWithPlane3
public static java.util.ArrayList<Mesh3D> cutMeshWithPlane3(Mesh3D mesh, Plane3D plane) throws MeshFunctionExceptionCutsmesh
withplane
, creating new faces along the cut seam. Returns two meshes (if they exist) for above and below, respectively.- Parameters:
mesh
-plane
-as_submeshes
-- Returns:
- Throws:
MeshFunctionException
-
cutMeshWithPlane
public static java.util.ArrayList<Mesh3D> cutMeshWithPlane(Mesh3D mesh, Plane3D plane, InterfaceProgressBar progress_bar) throws MeshFunctionExceptionCutsmesh
withplane
, creating new faces along the cut seam. Returns two meshes (if they exist) for above and below, respectively.- Parameters:
mesh
-plane
-as_submeshes
-- Returns:
- Throws:
MeshFunctionException
-
getIntersectionSegments
public static java.util.ArrayList<Polygon3D> getIntersectionSegments(Mesh3D mesh1, Mesh3D mesh2, InterfaceProgressBar progress_bar) throws MeshFunctionExceptionReturn a set of line segments which represent the intersection of one mesh with another.- Parameters:
mesh1
-mesh2
-progress_bar
-- Returns:
- Throws:
MeshFunctionException
-
getGlobeSphereMesh
public static Mesh3D getGlobeSphereMesh(org.jogamp.vecmath.Point3f center, float radius, int n_nodes) -
getBoundaryNodes
Determine which nodes are boundary nodes, return an array of booleans.- Parameters:
mesh
-- Returns:
-
getBoundaryNodeIndices
-
getJaggedEdgeNodes
public static java.util.HashMap<java.lang.Integer,java.lang.Integer> getJaggedEdgeNodes(Mesh3D mesh, java.util.ArrayList<MguiNumber> values, int min_nbrs, int max_nbrs, boolean islands)Detects nodes corresponding to "jagged" edges; a jagged edge node is defined as one which has onlymax_nbrs
neighbours with the same value as itself, and at leastmin_nbrs
neighbours which are the same value. Values are treated as integers. Such nodes are candidates for a value change.- Parameters:
mesh
- Mesh to searchregions
- Vertex-wise valuesmin_nbrs
- The minimum # of neighbours with the same value which is different from a node's valuemax_brs
- The maximum # of neighbours with the same value as a node's value- Returns:
- A list of indices for jagged edge vertices
-
getMeshExpandedAlongNormals
Expandsmesh
along its vertex normals by a distance ofexpansion
. This is suitable for a convex mesh; for a concave mesh there is no guarantee that the resulting mesh will be valid (i.e., faces may become crossed).- Parameters:
mesh
-expansion
-- Returns:
- the expanded mesh
-
getIsosurfaceFromVolume
public static Mesh3D getIsosurfaceFromVolume(Volume3DInt volume, java.lang.String column, double iso_level)Constructs an isosurface fromvolume
; i.e., computes a mesh which represents the location where values in the 3D scalar field involume
are equal toiso_level
.- Parameters:
volume
-iso_level
-- Returns:
-
polygonizeCell
protected static int polygonizeCell(org.jogamp.vecmath.Point3f[] gridcell, double[] values, java.util.ArrayList<org.jogamp.vecmath.Point3f> triangles, double isolevel)Uses the marching cubes lookup tables to find triangular faces intersecting the given grid cell at the given isolevel- Parameters:
grid
-values
-- Returns:
-