MeshVisualization

The MeshVisualization provides the class definition for the mesh visualization of a Gmsh model. It is based on the pyvista and vtk libraries und implements additional features for the mesh visualization.

Class Definition

class gmshModel.Visualization.MeshVisualization.MeshVisualization(model=None)[source]

Bases: object

Class for Gmsh model mesh visualization

This class visualizes the mesh of a given GmshModel using the pyvista and vtk libraries. It provides a simple method to visualize the model geometry by storing the mesh into a temporary “.vtu” file which is read by pyvista. With additional slider widgets for a threshold algorithm based on physical groups of the Gmsh model and a box widget to facilitate an extraction of areas within the mesh, the visualization tool allows to get an impression of the generated mesh.

Attributes:

model: GmshModel object instance

model instance for which the geometry has to be displayed

defaultSettings: dict

dictionary holding the default widget visualization options to allow restoring those options

currentSettings: dict

dictionary holding the current widget visualization options

plotterObj: pyvista plotter object instance

current plotter/renderer object

mesh: mesh object instance

object holding the current mesh information

thresholdAlgorithm: vtk Threshold Algorithm instance

object instance with information for the applied vtkThreshold algorithm

thresholdAlgorithm: vtk Extraction Algorithm instance

object instance with information for the applied vtkExtractGeometry algorithm

extractionBox: vtkBox object instance

object instance storing information of the extraction box

extractionBoxBounds: pyvista PolyData object instance

object instance storing information about the extraction box boundaries

active widgets: list

list of active widgets within the rendering object

addBoxWidget()[source]

Method to configure a box widget and add it to the rendering scene

addKeyPressEvents()[source]

Method to add all user-defined key-press events

addSliderWidgets()[source]

Method to configure a slider widget and add it to the rendering scene

filterPipeline()[source]

Filter pipeline method for mesh visualization

For every confirmed change of the widget settings, the mesh has to be updated. To this end, the filter pipeline consisting of the implemented threshold and extraction algorithms has to be executed. It is done within this method.

restoreDefaultSettings()[source]

Method to restore default visualization options

setupExtractionAlgorithm()[source]

Extraction algorithm method for mesh visualization

This method implements the extraction algorithm used within the filter pipeline. Based on the settings of the box widget, the mesh elements within the extraction box bounds are extracted.

setupThresholdAlgorithm()[source]

Threshold algorithm method for mesh visualization

This method implements the threshold algorithm used within the filter pipeline. Based on the settings of the slider widgets, the visibility of physical groups is enabled oder disabled.

showCommandLineHelp()[source]

Internal method to show command line help after the rendering window is displayed

toggleEdgeRepresentation()[source]

Method to toggle the edge mesh visibility

toggleMenu()[source]

Method to toggle the menu/widget visibility

toggleSurfaceRepresentation()[source]

Method to toggle the surface mesh visibility

visualizeMesh()[source]

Main method for the mesh visualization

Within this method, the mesh data of the model is stored into a temporary “.vtu”-file which is read pyvista. After setting up widgets and additional key-press-events, the mesh is visualized.