pygmi.pfmod.mvis3d#

Code for the 3d model creation.

Classes#

Mod3dDisplay

Widget class to call the main interface.

MySunCanvas

Canvas for the sunshading tool.

Functions#

updatemod(gdat2, cindx, cloc)

Update model without smooothing.

MarchingCubes(x, y, z, c, iso, *[, showlog])

Marching cubes.

InterpolateVertices(isolevel, p1x, p1y, p1z, p2x, p2y, ...)

Interpolate vertices.

fancyindex(out, var1, ii, jj, kk)

Fancy index.

bitget(byteval, idx)

Bit get.

bitset(byteval, idx)

Bit set.

sub2ind(msize, row, col, layer)

Sub to index.

ind2sub(msize, idx)

Index to sub.

GetTables()

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.

closeEvent(QCloseEvent)#

Close event.

Parameters:

QCloseEvent (TYPE) – Close event.

Return type:

None.

save()#

Save a jpg.

Return type:

None.

update_for_kmz()#

Update for the kmz file.

Return type:

None.

change_defs()#

List widget 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.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.updatemod(gdat2, cindx, cloc)#

Update model without smooothing.

Parameters:
  • gdat2 (numpy array) – Model values.

  • cindx (numpy array) – Corner index.

  • cloc (numpy array) – Corner location.

Returns:

  • newcorners (numpy array) – New corner coordinates.

  • newfaces (numpy array) – New face indices.

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