Package net.imglib2.mesh
Class Meshes
- java.lang.Object
-
- net.imglib2.mesh.Meshes
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RealIntervalboundingBox(Mesh mesh)Computes and returns an oriented bounding boxRealIntervalstatic MeshboundingBoxMesh(Mesh input)Computes and returns an oriented bounding boxMeshstatic voidcalculateNormals(Mesh src, Mesh dest)Calculates the normals for a mesh.static RealPointcenter(Mesh m)Finds the center of a mesh using vertices.static Iterable<BufferMesh>connectedComponents(Mesh mesh)Returns an iterable over the connected components of the specified mesh.static voidcopy(Mesh src, Mesh dest)Copies a mesh into another mesh.static <T extends BooleanType<T>>
MeshmarchingCubes(RandomAccessibleInterval<T> source)Creates mesh e.g.static <T extends RealType<T>>
MeshmarchingCubes(RandomAccessibleInterval<T> source, double isoLevel)Creates mesh e.g.static BufferMeshmerge(Iterable<Mesh> meshes)static intnConnectedComponents(Mesh mesh)Returns the number of connected components in the specified mesh.static BufferMeshremoveDuplicateVertices(Mesh mesh, int precision)Creates a new mesh from a given mesh without any duplicate vertices.static voidscale(Mesh mesh, double[] scale)Scales the vertices position by the amount specified by the array.static Meshsimplify(Mesh mesh, float target_percent, float agressiveness)Simplifies a given mesh.static voidtranslate(Mesh mesh, double[] translate)Translates the vertices position by the amount specified by the array.static voidtranslateScale(Mesh mesh, double[] translate, double[] scale)Translates the vertices position by the amount specified by the array, then scales the coordinates.
-
-
-
Method Detail
-
center
public static RealPoint center(Mesh m)
Finds the center of a mesh using vertices.- Returns:
- a RealPoint representing the mesh's center
-
boundingBox
public static RealInterval boundingBox(Mesh mesh)
Computes and returns an oriented bounding boxRealInterval- Parameters:
mesh-- Returns:
- the output
Mesh - Implementation Note:
- op names="geom.boundingBox"
-
boundingBoxMesh
public static Mesh boundingBoxMesh(Mesh input)
Computes and returns an oriented bounding boxMesh- Parameters:
input-- Returns:
- the output
Mesh - Implementation Note:
- op names="geom.boundingBox"
-
copy
public static void copy(Mesh src, Mesh dest)
Copies a mesh into another mesh.- Parameters:
src- Source mesh, from which data will be copied.dest- Destination mesh, into which source will be copied. (container)- Implementation Note:
- op names="engine.copy, copy.mesh"
-
calculateNormals
public static void calculateNormals(Mesh src, Mesh dest)
Calculates the normals for a mesh. Creates a new mesh with the calculated normals. Assumes CCW winding order.- Parameters:
src- Source mesh, used for vertex and triangle infodest- Destination mesh, will be populated with src's info plus the calculated normals
-
simplify
public static Mesh simplify(Mesh mesh, float target_percent, float agressiveness)
Simplifies a given mesh. Normals and uv coordinates will be ignored and not added to the output mesh.- Parameters:
mesh- Source meshtarget_percent- the amount in percent to attempt to achieve. For example: 0.25f would result in creating a mesh with 25% of triangles contained in the original.agressiveness- sharpness to increase the threshold. 5..8 are good numbers. more iterations yield higher quality. Minimum 4 and maximum 20 are recommended.- Returns:
- the simplified mesh The result will not include normals or uv coordinates.
-
removeDuplicateVertices
public static BufferMesh removeDuplicateVertices(Mesh mesh, int precision)
Creates a new mesh from a given mesh without any duplicate vertices. Normals and uv coordinates will be ignored and not added to the output mesh.- Parameters:
mesh- Source meshprecision- decimal digits to take into account when comparing mesh vertices- Returns:
- new mesh without duplicate vertices. The result will not include normals or uv coordinates.
-
marchingCubes
public static <T extends BooleanType<T>> Mesh marchingCubes(RandomAccessibleInterval<T> source)
Creates mesh e.g. from IterableRegion by using the marching cubes algorithm.- Parameters:
source- The binary input image for the marching cubes algorithm.- Returns:
- The result mesh of the marching cubes algorithm.
-
marchingCubes
public static <T extends RealType<T>> Mesh marchingCubes(RandomAccessibleInterval<T> source, double isoLevel)
Creates mesh e.g. from IterableRegion by using the marching cubes algorithm.- Parameters:
source- The input image for the marching cubes algorithm.isoLevel- The threshold to distinguish between foreground and background values.- Returns:
- The result mesh of the marching cubes algorithm.
-
nConnectedComponents
public static int nConnectedComponents(Mesh mesh)
Returns the number of connected components in the specified mesh.- Parameters:
mesh- the mesh.- Returns:
- the number of connected components.
-
connectedComponents
public static Iterable<BufferMesh> connectedComponents(Mesh mesh)
Returns an iterable over the connected components of the specified mesh.- Parameters:
mesh- the mesh.- Returns:
- an iterable.
-
scale
public static void scale(Mesh mesh, double[] scale)
Scales the vertices position by the amount specified by the array.Note that the position are simply multiplied by the specified scale, so they are scaled with respect to (0,0,0) which makes this method useful mainly to have a mesh generated by marching-cube algorithm have coordinates in physical units.
- Parameters:
mesh- the mesh to scale.scale- adoublearray of at least 3 elements.
-
translate
public static void translate(Mesh mesh, double[] translate)
Translates the vertices position by the amount specified by the array.The positions are equal to
new_pos[d] = old_pos[d] + translate[d].- Parameters:
mesh- the mesh to translate.translate- adoublearray of at least 3 elements.
-
translateScale
public static void translateScale(Mesh mesh, double[] translate, double[] scale)
Translates the vertices position by the amount specified by the array, then scales the coordinates.The positions are equal to
new_pos[d] = (old_pos[d] + translate[d]) * scale[d].- Parameters:
mesh- the mesh to translate.translate- adoublearray of at least 3 elements.scale- adoublearray of at least 3 elements.
-
merge
public static BufferMesh merge(Iterable<Mesh> meshes)
-
-