open_viewmin.filter_tree_plot.filters.sample#
Utilities for sampling a mesh, either at regular intervals or randomly, e.g. for plotting glyphs
Functions#
|
Calculate an orthonormal basis for the plane perpendicular to a given |
|
Create callable that produces a filter formula probing a parent mesh at |
|
Create a callable that adds a filter formula probing a mesh along |
|
Create a callable that samples a mesh evenly or randomly |
|
Normalize a vector. |
|
Add a filter formula to a plotter to probe a mesh at calculated |
|
Add a filter formula probing a mesh along |
|
Calculate points on a small circuit at a given point, normal to a given |
|
Create a sampled mesh, either evenly or randomly sampled |
|
Workaround for PyVista's removal of probe filter |
Module Contents#
- _get_basis_for_normal_plane(normal_dir)#
Calculate an orthonormal basis for the plane perpendicular to a given direction.
- Parameters:
normal_dir (numpy.ndarray) – Normal to the plane.
- Returns:
Two basis vectors.
- Return type:
numpy.ndarray, numpy.ndarray
- _make_centroids_probe_filter_callable(plotter, find_centroids_of_mesh_name)#
Create callable that produces a filter formula probing a parent mesh at calculated centroids.
- Parameters:
plotter (open_viewmin.FilterTreePlot)
find_centroids_of_mesh_name (str) – Name of parent mesh
- Return type:
callable()
- _make_circuit_probe_filter_callable(plotter, mesh_of_circuit_centers_name, normals_name=None)#
Create a callable that adds a filter formula probing a mesh along a collection of small circuits around the points of a parent mesh.
- Parameters:
plotter (open_viewmin.FilterTreePlot)
mesh_of_circuit_centers_name (str) – Name of mesh whose points will be the centers of the circuits.
normals_name (str or None) – Name of vector dataset, defined on the mesh of circuit centers, to be used as normals to circuits. Pass None to default to name of active_vectors dataset of parent mesh.
- Return type:
callable()
- _make_mesh_pts_sampler(dims)#
Create a callable that samples a mesh evenly or randomly
- Parameters:
dims ((int, int, int)) – System dimensions
- Returns:
Function to sample a mesh.
- Return type:
callable()
- _unit_vector_along(vec)#
Normalize a vector.
- Parameters:
vec (numpy.ndarray)
- Returns:
Normalized vector.
- Return type:
numpy.ndarray
- add_centroids_probe_filter_formula(plotter, parent_mesh_name=None, num_centroids=10, ref_pt_idx=0, sampled_mesh_name=None, find_centroids_of_mesh_name=None)#
Add a filter formula to a plotter to probe a mesh at calculated centroids.
- Parameters:
plotter (open_viewmin.FilterTreePlot)
parent_mesh_name (str or None, optional) – Name of mesh to probe. Pass None to default to plotter.default_mesh_name. Note that this is not generally the same as find_centroids_of_mesh_name.
num_centroids (int, optional) – Number of centroids to calculate. Larger value means finer subdivisions.
ref_pt_idx (int, optional) – Index of point in parent mesh’s array of points to use as arbitrary starting point or centroids calculation.
sampled_mesh_name (str or None, optional) – Name of child (sampled) mesh. Pass None to use “_centroids” appended to parent_mesh_name.
find_centroids_of_mesh_name (str or None, optional) – Name of mesh from whose points the centroids will be calculated. Pass None to default to parent_mesh_name.
- Returns:
Name of sampled (child) mesh
- Return type:
str
- add_circuit_probe_filter_formula(plotter, mesh_of_circuit_centers_name, sampled_mesh_name=None, mesh_to_probe_name=None, normals_name=None, radius=3, n_samples=32, use_ints=False)#
Add a filter formula probing a mesh along a collection of small circuits around the points of a parent mesh.
- Parameters:
plotter (open_viewmin.FilterTreePlot)
mesh_to_probe_name (str or None, optional) – Name of mesh to probe. Note that this is not in general the same as mesh_of_circuit_centers_name.
sampled_mesh_name (str or None, optional) – Name of sampled (child) mesh. Pass None to default to “_circuit” appended to normals_name.
mesh_of_circuit_centers_name (str) – Name of mesh whose points will be the centers of the circuits.
normals_name (str or None, optional) – Name of vectors dataset defined on mesh_of_circuit_centers to be used as normal directions to circuits. Pass None to default to name of active_vectors dataset of parent mesh.
radius (float, optional) – Radius of each circuit.
n_samples (int, optional) – Number of circuits.
use_ints (bool, optional) – Whether to round coordinates of circuit points to integers.
- Returns:
Name of sampled (child) mesh, or None if no child mesh was created.
- Return type:
str or None
- get_circuit(plotter, point, normal_dir, radius=3, n_samples=32, use_ints=False)#
Calculate points on a small circuit at a given point, normal to a given direction.
- Parameters:
plotter (open_viewmin.FilterTreePlot)
point (numpy.ndarray) – Coordinates of the circuit center.
normal_dir (numpy.ndarray) – Normal vector to the circuit.
radius (float, optional) – Radius of the circuit.
n_samples (int, optional) – Number of points in the circuit.
use_ints (bool, optional) – Whether to round coordinates of circuit points to integers.
- Returns:
Array of circuit points.
- Return type:
numpy.ndarray
- make_sampled_mesh(plotter, parent_mesh_name, stride, sampled_mesh_name=None, random=False)#
Create a sampled mesh, either evenly or randomly sampled
- Parameters:
plotter (
FilterTreePlot
)parent_mesh_name (str) – Name of mesh to sample
stride (float) – Spacing (or, for random sampling, average spacing) between sampled points
sampled_mesh_name (str or None, optional) – Name of child (sampled) mesh. Pass None to append “_sampled” to parent_mesh_name.
random (bool) – Whether to use random sampling instead of evenly spaced sampling.
- Returns:
Name of sampled (child) mesh
- Return type:
str
- probe(mesh, sampled_points, **kwargs)#
Workaround for PyVista’s removal of probe filter
Essentially reverses the sample filter.
- Parameters:
mesh (pyvista.DataSet)
sampled_points (numpy.ndarray or pyvista.pyvista_ndarray)
**kwargs – Keyword arguments to pyvista.DataSet.sample