mymesh.implicit.TetMesh#

mymesh.implicit.TetMesh(func, bounds, h, threshold=0, threshold_direction=-1, interpolation='linear', args=(), kwargs={}, background=None, snap2surf=True)[source]#

Generate a tetrahedral mesh of an implicit function

Parameters:
  • func (function) – Implicit function that describes the geometry of the object to be meshed. The function should be of the form v = f(x,y,z,*args,**kwargs) where x, y, and z are 1D numpy arrays of x, y and z coordinates and v is a 1D numpy array of function values. For method=’mc’, x, y, and z will be 3D coordinate arrays and v must be 3D as well. Additional arguments and keyword arguments may be passed through args and kwargs.

  • bounds (array_like) – 6 element array, list, or tuple with the minimum and maximum bounds in each direction that the function will be evaluated. This should be formatted as: [xmin, xmax, ymin, ymax, zmin, zmax]

  • h (scalar, tuple) – Element side length. Can be specified as a single scalar value, or a three element tuple (or array_like).

  • threshold (scalar) – Isovalue threshold to use for keeping/removing elements, by default 0.

  • threshold_direction (signed integer) – If threshold_direction is negative (default), values less than or equal to the threshold will be considered “inside” the mesh and the opposite if threshold_direction is positive, by default -1.

  • interpolation (str, optional) – Method of interpolation used for placing the vertices on the approximated isosurface. This can be ‘midpoint’, ‘linear’, or ‘quadratic’, by default ‘linear’.

  • args (tuple, optional) – Tuple of additional positional arguments for func, by default ().

  • kwargs (dict, optional) – Dictionary of additional keyword arguments for func, by default {}.

  • background (None or mymesh.mesh, optional) – Background tetrahedral mesh to use for evaluating the function and performing marching tetrahedra. If a mesh is provide, bounds and h will be ignored. If None is provided, a uniform tetrahedral grid will be used, by default None.

  • snap2surf (bool or float, optional) – Option to use SnapGrid2Surf() which moves points of the background mesh to lie on the surface. If specified as a float in the range [0, 0.5], sets the snapping parameter which indicates the relative distance within which a point is snapped (0 = no snapping, 0.5 = all possible points are snapped). If True, default snapping parameter of 0.2 is used. By default, True.

Returns:

tet – Mesh object containing the tetrahedral mesh.

Note

Due to the ability to unpack the mesh object to NodeCoords and NodeConn, the NodeCoords and NodeConn array can be returned directly (instead of the mesh object) by running: NodeCoords, NodeConn = implicit.TetMesh(...)

Return type:

mymesh.mesh

Examples

tet = implicit.TetMesh(implicit.gyroid, [0,1,0,1,0,1], 0.05)
tet.plot(bgcolor='w')
../../_images/mymesh-implicit-TetMesh-1.png