pygmi.pfmod.mvis3d#
Code for the 3D potential field model visualisation.
Classes#
Widget class to call the main interface. |
|
Canvas for the sunshading tool. |
Functions#
|
Update model without smoothing. |
|
Calculate normals. |
|
Normalize a numpy array of 3 component vectors shape=(n,3). |
|
Marching cubes. |
|
Interpolate vertices. |
|
Fancy index. |
|
Bit get. |
|
Bit set. |
|
Sub to index. |
|
Index to sub. |
Get tables. |
Module Contents#
- class pygmi.pfmod.mvis3d.Mod3dDisplay(parent=None)#
Bases:
pygmi.misc.ContextModuleWidget class to call the main interface.
- Parameters:
parent – Reference to the parent routine. The default is None.
- setupui()#
Set up UI.
- closeEvent(QCloseEvent)#
Close event.
- Parameters:
QCloseEvent – Close event.
- change_light()#
Change light type.
- save()#
Save a JPG or PNG.
- update_for_kmz()#
Update for the kmz file.
- change_defs()#
List widget routine.
- data_init()#
Initialise data.
- set_selected_liths()#
Set the selected lithologies.
- mod3d_vs()#
Vertical slider used to scale 3D view.
- resetlight()#
Reset light to the current model position.
- sunclick(event)#
Sunclick event is used to track changes to the sunshading.
- Parameters:
event (matplotlib.backend_bases.MouseEvent) – event returned by matplotlib when a button is pressed
- update_color()#
Update colour only.
- run()#
Entry point into the routine, used to run context menu item.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- update_plot()#
Update 3D model.
- update_model(issmooth=None)#
Update the 3D model.
Faces, nodes and face normals are calculated here, from the voxel model.
- Parameters:
issmooth (bool | None) – Flag to indicate a smooth model. The default is None.
- update_model2()#
Update the 3D model part 2.
- class pygmi.pfmod.mvis3d.MySunCanvas(parent=None)#
Bases:
matplotlib.backends.backend_qtagg.FigureCanvasQTAggCanvas for the sunshading tool.
- Parameters:
parent – Reference to the parent routine. The default is None.
- init_graph()#
Initialise graph.
- pygmi.pfmod.mvis3d.updatemod(gdat2, cindx, cloc)#
Update model without smoothing.
- Parameters:
gdat2 (numpy.typing.NDArray) – Model values.
cindx (numpy.typing.NDArray) – Corner index.
cloc (numpy.typing.NDArray) – Corner location.
- Returns:
newcorners (
ndarray) – New corner coordinates.newfaces (
ndarray) – New face indices.
- Return type:
tuple[numpy.typing.NDArray, numpy.typing.NDArray]
- pygmi.pfmod.mvis3d.calc_norms(faces, vtx)#
Calculate normals.
- Parameters:
faces (numpy.typing.NDArray) – Array of faces.
vtx (numpy.typing.NDArray) – Array of vertices.
- Returns:
output normals.
- Return type:
ndarray
- pygmi.pfmod.mvis3d.normalize_v3(arr)#
Normalize a numpy array of 3 component vectors shape=(n,3).
- Parameters:
arr (numpy.typing.NDArray) – Array of 3 component vectors.
- Returns:
Output array of 3 component vectors.
- Return type:
ndarray
- pygmi.pfmod.mvis3d.MarchingCubes(x, y, z, c, iso, *, showlog=print)#
Marching cubes.
Use marching cubes algorithm to compute a triangulated mesh of the isosurface within the 3D matrix of scalar values C at isosurface value ISO. The 3D matrices (X,Y,Z) represent a Cartesian, axis-aligned grid specifying the points at which the data C is given. These coordinate arrays must be in the format produced by Matlab’s meshgrid function. Output arguments F and V are the face list and vertex list of the resulting triangulated mesh. The orientation of the triangles is chosen such that the normals point from the higher values to the lower values. Optional arguments COLORS ans COLS can be used to produce interpolated mesh face colours. For usage, see Matlab’s isosurface.m. To avoid Out of Memory errors when matrix C is large, convert matrices X,Y,Z and C from doubles (Matlab default) to singles (32-bit floats).
Originally Adapted for Matlab by Peter Hammer in 2011 based on an Octave function written by Martin Helm <martin@mhelm.de> in 2009 http://www.mhelm.de/octave/m/marching_cube.m
Revised 30 September, 2011 to add code by Oliver Woodford for removing duplicate vertices.
- Parameters:
x (numpy.typing.NDArray) – X coordinates.
y (numpy.typing.NDArray) – Y coordinates.
z (numpy.typing.NDArray) – Z coordinates.
c (numpy.typing.NDArray) – Data.
iso (float) – Isosurface level.
showlog (collections.abc.Callable[..., None]) – Display information. The default is print.
- Returns:
F (
ndarray) – Face list.V (
ndarray) – Vertex list.
- Return type:
tuple[numpy.typing.NDArray, numpy.typing.NDArray]
- pygmi.pfmod.mvis3d.InterpolateVertices(isolevel, p1x, p1y, p1z, p2x, p2y, p2z, valp1, valp2)#
Interpolate vertices.
- Parameters:
isolevel (float) – ISO level.
p1x (numpy.typing.NDArray) – p1 x coordinate.
p1y (numpy.typing.NDArray) – p1 y coordinate.
p1z (numpy.typing.NDArray) – p1 z coordinate.
p2x (numpy.typing.NDArray) – p2 x coordinate.
p2y (numpy.typing.NDArray) – p2 y coordinate.
p2z (numpy.typing.NDArray) – p2 z coordinate.
valp1 (numpy.typing.NDArray) – p1 value.
valp2 (numpy.typing.NDArray) – p2 value.
- Returns:
Interpolated vertices.
- Return type:
ndarray
- pygmi.pfmod.mvis3d.fancyindex(out, var1, ii, jj, kk)#
Fancy index.
- Parameters:
out (numpy.typing.NDArray) – Input data.
var1 (numpy.typing.NDArray) – Input data.
ii (numpy.typing.NDArray) – i indices.
jj (numpy.typing.NDArray) – j indices.
kk (numpy.typing.NDArray) – k indices.
- Returns:
Output data with new values.
- Return type:
ndarray
- pygmi.pfmod.mvis3d.bitget(byteval, idx)#
Bit get.
- Parameters:
byteval (int) – Input value to get bit from.
idx (int) – Position of bit to get.
- Returns:
True if not 0, False otherwise.
- Return type:
bool
- pygmi.pfmod.mvis3d.bitset(byteval, idx)#
Bit set.
- Parameters:
byteval (int) – Input value to get bit from.
idx (int) – Position of bit to get.
- Returns:
Output value with bit set.
- Return type:
int
- pygmi.pfmod.mvis3d.sub2ind(msize, row, col, layer)#
Sub to index.
- Parameters:
msize – Tuple with number of rows and columns as first two elements.
row (numpy.typing.NDArray) – array of rows.
col (numpy.typing.NDArray) – array of columns
layer (numpy.typing.NDArray) – array of layers
- Returns:
Indices returned.
- Return type:
ndarray
- pygmi.pfmod.mvis3d.ind2sub(msize, idx)#
Index to sub.
- Parameters:
msize (tuple[int, int, int]) – Tuple with number of rows and columns as first two elements.
idx (numpy.typing.NDArray) – Array of indices.
- Returns:
row (
ndarray) – Row.col (
ndarray) – Column.layer (
ndarray) – Layer.
- Return type:
tuple[numpy.typing.NDArray, numpy.typing.NDArray, numpy.typing.NDArray]
- pygmi.pfmod.mvis3d.GetTables()#
Get tables.
- Returns:
A list with edgetable and tritable.
- Return type:
list