magritte.mesher module
- class magritte.mesher.Mesh
Bases:
objectMagritte custom mesh class (that ignores unconnected points).
- magritte.mesher.get_recursive_remesh(positions: array, data: array, depth: int, max_depth: int, threshold: float, remesh_points: array, remesh_nb_points: int)
Helper function for the point cloud remeshing method. Uses recursion to remesh a given point cloud (uses all data to determine whether to recurse on a smaller scale), by evaluating the total variation in the data (compared against the threshold).
- Parameters:
positions (numpy array of float) – 3D positions of the points (dimension of array N by 3)
data (numpy array of float) – Corresponding data for the points, in order to determine the variation. Must be non-zero
depth (int) – Current recursion depth
max_depth (int) – Maximal recursion depth. Determines the miminal scale in the remeshed point cloud. Must be positive
threshold (float) – The threshold to use when deciding the variation to be small enough in order to approximate a region with a single point. Must be positive
remesh_points (numpy array (in/out)) – Array holding the remeshed point positions. Must be large enough to contain all remeshed points, Must have at least dimensions N by 3.
remesh_nb_points (int (in/out)) – The number of point in the remeshed point cloud. Must be initialized to 0
- magritte.mesher.point_cloud_add_spherical_inner_boundary(remeshed_positions, nb_boundary, radius, healpy_order=5, origin=array([0., 0., 0.]))
Function for specifying a spherical inner boundary in a remeshed point cloud. First clears the inner region of points and then constructs a spherical boundary using healpy.
- Parameters:
remeshed_positions (numpy array of float) – Positions of the points in the point cloud. Assumes the boundary points to lie in front.
nb_boundary (unsigned int) – The number of boundary points in the point cloud.
radius (positive float) – Radius of the spherical inner boundary
healpy_order (unsigned int) – The number of points on the inner boundary is defined as: 12*(healpy_order**2), as the healpy discretization of the sphere is used.
origin (1 by 3 numpy vector of float) – Contains x,y,z coordinates of center point of the sphere (by default [0.0,0.0,0.0]^T)
- Returns:
remeshed_positions (numpy array of float) – The positions of the points in the remeshed point cloud. The boundary points lie in front.
number of boundary points (unsigned int) – The number of boundary points in the remeshed point cloud.
- magritte.mesher.point_cloud_add_spherical_outer_boundary(remeshed_positions, nb_boundary, radius, healpy_order=10, origin=array([0., 0., 0.]))
Function for specifying a spherical outer boundary in a remeshed point cloud. First clears the region outside the sphere and then constructs a spherical boundary using healpy.
- Parameters:
remeshed_positions (numpy array of float) – Positions of the points in the point cloud. Assumes the boundary points to lie in front.
nb_boundary (unsigned int) – The number of boundary points in the point cloud.
radius (positive float) – Radius of the spherical outer boundary
healpy_order (unsigned int) – The number of points on the outer boundary is defined as: 12*(healpy_order**2), as the healpy discretization of the sphere is used.
origin (1 by 3 numpy vector of float) – Contains x,y,z coordinates of center point of the sphere (by default [0.0,0.0,0.0]^T)
- Returns:
remeshed_positions (numpy array of float) – The positions of the points in the remeshed point cloud. The boundary points lie in front.
number of boundary points (unsigned int) – The number of boundary points in the remeshed point cloud.
- magritte.mesher.point_cloud_clear_inner_boundary_generic(remeshed_positions, nb_boundary, numpy_friendly_function, threshold)
General function for consistently clearing an inner boundary region in a remeshed point cloud.
- Parameters:
remeshed_positions (numpy array of float) – Positions of the points in the point cloud. Assumes the boundary points to lie in front.
nb_boundary (unsigned int) – The number of boundary points in the point cloud.
numpy_friendly_function (lambda function which operates on numpy array) – Function which acts on location for determining the shape of the inner boundary condition region
threshold (float) – Cutoff value associate to numpy_friendly_function in order to constrain the shape of the inner boundary region
- Returns:
remeshed_positions (numpy array of float) – The positions of the points in the remeshed point cloud. The boundary points lie in front.
number of boundary points (unsigned int) – The number of boundary points in the remeshed point cloud.
- magritte.mesher.point_cloud_clear_outer_boundary_generic(remeshed_positions, nb_boundary, numpy_friendly_function, threshold)
General function for consistently clearing all points outside a given region in a remeshed point cloud.
- Parameters:
remeshed_positions (numpy array of float) – Positions of the points in the point cloud. Assumes the boundary points to lie in front.
nb_boundary (unsigned int) – The number of boundary points in the point cloud.
numpy_friendly_function (lambda function which operates on numpy array) – Function which acts on location for determining the shape of the inner boundary condition region
threshold (float) – Cutoff value associate to numpy_friendly_function in order to constrain the shape of the inner boundary region
- Returns:
remeshed_positions (numpy array of float) – The positions of the points in the remeshed point cloud. The boundary points lie in front.
number of boundary points (unsigned int) – The number of boundary points in the remeshed point cloud.
- magritte.mesher.remesh_point_cloud(positions, data, max_depth=9, threshold=0.05, hullorder=3)
Remeshing method by comparing the maximal variation of the data against the threshold. Uses a recursive method with maximal depth max_depth. The hullorder specifies the density of the generated uniform boundary.
- Parameters:
positions (numpy array of float) – 3D positions of the points (dimension of array N by 3)
data (numpy array of float) – Corresponding data for the points, in order to determine the variation. Must be non-zero
max_depth (int) – Maximal recursion depth. Determines the miminal scale in the remeshed point cloud. Must be positive
threshold (float) – The threshold to use when deciding the variation to be small enough in order to approximate a region with a single point. Must be positive
hullorder (int) – Determines the amount of boundary points generated in the hull around the remeshed point cloud. Increasing this by 1 results in a 4 times increase in number of boundary points. Must be positive
- Returns:
remeshed_positions (numpy array of float) – The positions of the points in the remeshed point cloud. The boundary points lie in front.
number of boundary points (unsigned int) – The number of boundary points in the remeshed point cloud.