pygmi.pfmod.mvis3d#
Code for the 3d model creation.
Classes#
Widget class to call the main interface. |
|
OpenGL Widget. |
|
Canvas for the sunshading tool. |
Functions#
|
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.ContextModule
Widget class to call the main interface.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- setupui()#
Set up UI.
- Return type:
None.
- save()#
Save a jpg.
- Return type:
None.
- update_for_kmz()#
Update for the kmz file.
- Return type:
None.
- change_defs()#
List box routine.
- Return type:
None.
- data_init()#
Initialise data.
- Return type:
None.
- set_selected_liths()#
Set the selected lithologies.
- Return type:
None.
- mod3d_vs()#
Vertical slider used to scale 3d view.
- resetlight()#
Reset light to the current model position.
- Return type:
None.
- sunclick(event)#
Sunclick event is used to track changes to the sunshading.
- Parameters:
event (event - matplotlib button press) – event returned by matplotlib when a button is pressed
- update_color()#
Update colour only.
- Return type:
None.
- 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.
- Return type:
None.
- update_model(issmooth=None)#
Update the 3d model.
Faces, nodes and face normals are calculated here, from the voxel model.
- Parameters:
issmooth (bool, optional) – Flag to indicate a smooth model. The default is None.
- Return type:
None.
- update_model2()#
Update the 3d model part 2.
- Return type:
None.
- class pygmi.pfmod.mvis3d.GLWidget(parent=None)#
Bases:
PyQt6.QtOpenGLWidgets.QOpenGLWidget
OpenGL Widget.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- minimumSizeHint()#
Minimum size hint.
- Returns:
Returns a size of (50, 50)
- Return type:
QtCore.QSize
- sizeHint()#
Size hint.
- Returns:
Returns a size of (400, 400)
- Return type:
QtCore.QSize
- setXRotation(angle)#
Set X rotation.
- Parameters:
angle (float) – X angle of rotation.
- Return type:
None.
- setYRotation(angle)#
Set Y Rotation.
- Parameters:
angle (float) – Y angle of rotation.
- Return type:
None.
- setZRotation(angle)#
Set Z rotation.
- Parameters:
angle (float) – Z angle of rotation.
- Return type:
None.
- initializeGL()#
Initialise OpenGL.
- Return type:
None.
- setlightdir(x, y, z)#
Set light direction.
- Parameters:
x (float) – X light position.
y (float) – Y light position.
z (float) – Z light position.
- Return type:
None.
- initGeometry()#
Initialise geometry.
- Return type:
None.
- init_object()#
Initialise VBO.
- Return type:
None.
- paintGL()#
Paint OpenGL.
- Return type:
None.
- draw_with_axis()#
Draw with a set of axes.
- Return type:
None.
- print_string(x, y, z, text)#
Print a 2D text string.
- Parameters:
x (float) – X coordinate.
y (float) – Y coordinate.
z (float) – Z coordinate.
text (str) – Text string.
- Return type:
None.
- resizeGL(width, height)#
Resize OpenGL.
- Parameters:
width (float) – Width of side.
height (float) – Height of side.
- Return type:
None.
- init_projection()#
Initialise the projection.
- Return type:
None.
- readPixels()#
Read pixels from the window.
- Returns:
data – Returned pixel data.
- Return type:
numpy array
- mousePressEvent(event)#
Mouse press event.
- Parameters:
event (QMouseEvent) – Mouse event.
- Return type:
None.
- mouseMoveEvent(event)#
Mouse move event.
- Parameters:
event (QMouseEvent) – Mouse event.
- Return type:
None.
- wheelEvent(event)#
Mouse wheel event.
- Parameters:
event (QWheelEvent) – Mouse wheel event.
- Return type:
None.
- normalizeAngle(angle)#
Corrects an angle to between 0 and 360*16.
- Parameters:
angle (float) – Input angle.
- Returns:
angle – Output angle.
- Return type:
float
- class pygmi.pfmod.mvis3d.MySunCanvas(parent=None)#
Bases:
matplotlib.backends.backend_qtagg.FigureCanvasQTAgg
Canvas for the sunshading tool.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- sun#
plot of a circle ‘o’ showing where the sun is
- Type:
matplotlib plot instance
- axes#
axes on which the sun is drawn
- Type:
matplotlib axes instance
- init_graph()#
Initialise graph.
- Return type:
None.
- pygmi.pfmod.mvis3d.calc_norms(faces, vtx)#
Calculate normals.
- Parameters:
faces (numpy array) – Array of faces.
vtx (numpy array.) – Array of vertices.
- Return type:
None.
- pygmi.pfmod.mvis3d.normalize_v3(arr)#
Normalize a numpy array of 3 component vectors shape=(n,3).
- Parameters:
arr (numpy array) – Array of 3 component vectors.
- Returns:
arr – Output array of 3 component vectors.
- Return type:
numpy array
- 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 array) – X coordinates.
y (numpy array) – Y coordinates.
z (numpy array) – Z coordinates.
c (numpy array) – Data.
iso (float) – Isosurface level.
showlog (function, optional) – Display information. The default is print.
- Returns:
F (numpy array) – Face list.
V (numpy array) – Vertex list.
- pygmi.pfmod.mvis3d.InterpolateVertices(isolevel, p1x, p1y, p1z, p2x, p2y, p2z, valp1, valp2)#
Interpolate vertices.
- Parameters:
isolevel (float) – ISO level.
p1x (numpy array) – p1 x coordinate.
p1y (numpy array) – p1 y coordinate.
p1z (numpy array) – p1 z coordinate.
p2x (numpy array) – p2 x coordinate.
p2y (numpy array) – p2 y coordinate.
p2z (numpy array) – p2 z coordinate.
valp1 (numpy array) – p1 value.
valp2 (numpy array) – p2 value.
- Returns:
p – Interpolated vertices.
- Return type:
numpy array
- pygmi.pfmod.mvis3d.fancyindex(out, var1, ii, jj, kk)#
Fancy index.
- Parameters:
out (numpy array) – Input data.
var1 (numpy array) – Input data.
ii (numpy array) – i indices.
jj (numpy array) – j indices.
kk (numpy array) – k indices.
- Returns:
out – Output data with new values.
- Return type:
numpy array
- 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) – Tuple with number of rows and columns as first two elements.
row (int) – Row.
col (int) – Column.
layer (numpy array) – Layer.
- Returns:
tmp – Index returned.
- Return type:
numpy array
- pygmi.pfmod.mvis3d.ind2sub(msize, idx)#
Index to sub.
- Parameters:
msize (tuple) – Tuple with number of rows and columns as first two elements.
idx (numpy array) – Array of indices.
- Returns:
row (int) – Row.
col (int) – Column.
layer (numpy array) – Layer.
- pygmi.pfmod.mvis3d.GetTables()#
Get tables.
- Returns:
A list with edgetable and tritable.
- Return type:
list