GeViewer package

Interactive viewer

class geviewer.viewer.GeViewer(plotter_widget=None)

Bases: object

The main interface for the GeViewer application, responsible for loading, processing, and visualizing data files. This class manages the creation and display of 3D visualizations based on the provided data files and offers various functionalities such as toggling display options and saving sessions.

clear_component_meshes(components)

Clears the meshes in the components.

Parameters:

components (list) – The components to clear the meshes from.

clear_meshes()

Clears the meshes and frees associated memory.

count_components(components, exclude_events=False, exclude_invisible=False)

Counts the number of components in the list of components.

Parameters:

components (list) – A list of components.

Returns:

The number of components in the list.

Return type:

int

create_plotter(progress_obj=None)

Creates the plotter and plots the meshes.

Parameters:

progress_obj (ProgressBar, optional) – The progress object to use for the plotter.

do_bounds_overlap(mesh1, mesh2)

Checks if the bounds of two meshes overlap in all three dimensions.

Parameters:
  • mesh1 (pyvista.PolyData) – The first mesh.

  • mesh2 (pyvista.PolyData) – The second mesh.

Returns:

True if the bounds overlap in all dimensions, False otherwise.

Return type:

bool

find_overlaps(tolerance=0.001, n_samples=100000, progress_obj=None)

Finds the overlaps between the meshes.

Parameters:
  • tolerance (float, optional) – The tolerance for the overlap.

  • n_samples (int, optional) – The number of samples to use.

Returns:

The ids of the meshes that overlap.

Return type:

list

get_overlap(mesh1, mesh2, tolerance=0.001, n_samples=100000, progress_obj=None)

Gets the overlap between two meshes.

Parameters:
  • mesh1 (pyvista.PolyData) – The first mesh.

  • mesh2 (pyvista.PolyData) – The second mesh.

  • tolerance (float, optional) – The tolerance for the overlap.

  • n_samples (int, optional) – The number of samples to use.

Returns:

The points of overlap and the fraction of points that survived.

Return type:

tuple

is_mesh_inside(mesh1, mesh2)

Checks if one mesh is inside another.

Parameters:
  • mesh1 (pyvista.PolyData) – The first mesh.

  • mesh2 (pyvista.PolyData) – The second mesh.

Returns:

True if mesh1 is inside mesh2, False otherwise.

Return type:

bool

load_file(filename, off_screen=False, progress_obj=None)

Loads the file into the components list.

Parameters:
  • filename (str) – The name of the file to load.

  • off_screen (bool, optional) – If True, the plotter is created without displaying it. Defaults to False.

  • progress_obj (ProgressBar, optional) – The progress bar object to use.

load_session(filename)

Loads the session from a .gev file.

Parameters:

filename (str) – The name of the file to load the session from.

plot_meshes(components, level=0, progress_obj=None)

Plots the meshes and saved the actors in a dictionary.

Parameters:
  • components (list) – The components to plot.

  • level (int, optional) – Keeps track of the recursion level.

  • progress_obj (ProgressBar, optional) – The progress object to use for the plotter.

save_session(filename)

Saves the session to a .gev file.

Parameters:

filename (str) – The name of the file to save the session to.

set_background_color()

Sets the background color.

toggle_background()

Toggles the gradient background on and off.

toggle_parallel_projection()

Toggles the parallel projection on and off.

toggle_transparent()

Toggles transparency on and off.

toggle_wireframe()

Toggles between solid and wireframe display modes. Disables depth peeling if wireframe mode is enabled to improve responsiveness.

User interface

class geviewer.gui.Application(*args, **kwargs)

Bases: QApplication

A custom application class for the GeViewer application.

notify(receiver, event)

Handles unhandled exceptions.

class geviewer.gui.ConsoleRedirect(console)

Bases: StringIO

Redirects stdout and stderr to a QTextEdit widget.

flush()

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

stylize_text(text)

Stylizes the text.

This method stylizes the text by adding a prompt to the beginning of the text, replacing newlines with HTML line breaks, and replacing warnings, errors, and successes with HTML formatted text.

Parameters:

text (str) – The text to stylize.

Returns:

The stylized text.

Return type:

str

write(text)

Writes to the console.

This method writes to the console by inserting the text into the text edit widget and moving the cursor to the end.

Parameters:

text (str) – The text to write to the console.

class geviewer.gui.ProgressBar

Bases: QProgressBar

A custom progress bar class for the GeViewer application.

This class handles all interactions between the worker threads and the GUI, including updating the progress bar, sending text updates, and interrupting the worker threads if necessary.

finished

Signal emitted when the task is finished

increment_progress()

Increments the progress bar by 1%.

interrupt_worker()

Flags an interrupt to the worker.

maximum

Signal emitted to set the maximum value of the progress bar

Parameters:

int – The new maximum value

print_update(text)

Adds an update to the update buffer.

progress

Signal emitted to update the progress value

Parameters:

int – The new progress value

reset_progress()

Resets the progress bar to 0%.

run_timer

Signal emitted to start or stop the timer

Parameters:

bool – True to start the timer, False to stop

send_updates()

Flushes the update buffer.

set_maximum_value(value)

Sets the maximum value of the progress bar.

Parameters:

value (int) – The maximum value of the progress bar.

signal_finished()

Signals that the progress bar has finished.

start_or_stop_timer(start)

Starts or stops the timer in the main thread.

Parameters:

start (bool) – Whether to start the timer.

sync_status(update=None, increment=False)

Synchronizes the status of the worker with that of the user interface. This should be called in the following format:

pbar = ProgressBar()
if pbar.sync_status(update, increment): return

where update is a string and increment is a boolean. This will pass the status updates to the user interface and return True if the worker should be interrupted.

Parameters:
  • update (str, optional) – The update to send to the user interface.

  • increment (bool, optional) – Whether to increment the progress bar.

Returns:

Whether the worker should be interrupted.

Return type:

bool

update

Signal emitted to send status updates

Parameters:

str – The update text

class geviewer.gui.Window

Bases: MainWindow

A custom main window class for the GeViewer application.

abort_process()

Aborts a running process.

add_key_events()

Adds key events to the plotter.

This is the simplest way to have the buttons synchronize with whatever key inputs the user provides.

add_menu_bar()

Adds the menu bar to the main window.

This method creates and configures the main menu bar for the application. It adds the following menus: - File: Contains actions for opening files, saving, and closing the window. - Edit: Contains actions for clearing the console, copying console content, and clearing meshes. - View: Contains actions for toggling visibility of various panels and visual elements. - Window: Contains actions for closing the window. - Help: Contains actions for displaying the license information.

The menu bar provides easy access to key functionality and settings of the application.

add_options_tab()

Adds camera and figure options to the first tab.

add_toolbar()

Adds the toolbar to the main window.

This method creates a QToolBar and populates it with various actions for controlling the viewer’s display options and camera views. The toolbar includes actions for toggling wireframe mode, transparency, parallel projection, and setting different standard views (isometric, top, bottom, front, back).

add_tools_tab()

Adds view and geometry options to the second tab.

center_on_screen(screen_geometry)

Centers the window on the screen.

Parameters:

screen_geometry (QRect) – The geometry of the screen.

check_for_updates()

Checks for updates.

This method checks for updates by calling the check_for_updates function from the utils module and printing the result to the console.

check_geometry(tolerance, samples)

Checks the geometry.

This method checks the geometry by finding the overlaps between the components and updating the overlaps list.

Parameters:
  • tolerance (float) – The tolerance for the overlaps.

  • samples (int) – The number of samples to use for the overlaps.

clear_focal_error_state()

Clears the focal error state.

This method clears the focal error state by setting the palette of the camera focal text to the default palette.

clear_measurement(print_to_console=True)

Clears the measurement.

This method clears the measurement by clearing the measurement boxes.

clear_overlaps()

Clears the overlaps.

This method clears the overlaps by removing all actors from the plotter and clearing the overlaps list.

clear_position_error_state()

Clears the position error state.

This method clears the position error state by setting the palette of the camera position text to the default palette.

clear_up_error_state()

Clears the up error state.

This method clears the up error state by setting the palette of the camera up text to the default palette.

clear_viewer()

Clears the meshes.

This method clears the meshes by removing all actors from the plotter and clearing the checkbox mapping.

clear_window_error_state()

Clears the window error state.

This method clears the window error state by setting the palette of the figure size text to the default palette.

create_components_panel()

Adds the components panel to the main window.

create_control_panel()

Adds the control panel to the main window.

create_viewer_panel()

Adds the viewer panel to the main window.

display_measurement(point1, point2, distance)

Displays the measurement.

This method displays the measurement by setting the measurement box to the distance between the two points.

Parameters:
  • point1 (list) – The first point.

  • point2 (list) – The second point.

  • distance (float) – The distance between the two points.

export_figure(file_name, width, height)

Saves the figure.

This method saves the figure by creating an off-screen plotter with the desired size and copying the mesh and camera settings to the off-screen plotter.

Parameters:
  • file_name (str) – The file name to save the figure to.

  • width (int) – The width of the figure.

  • height (int) – The height of the figure.

export_figure_dialog()

Saves the file dialog.

This method saves the file dialog by getting the save file name and emitting the save figure event.

file_loaded

Signal emitted when a file is loaded

file_name_changed

Signal emitted when the file name changes

Parameters:

str – The new file name

generate_checkboxes(components, level)

Generates checkboxes for the components in the current file.

This method generates checkboxes for the components in the current file. It also sets up the connections for toggling visibility and updating the event selection box.

Parameters:
  • components (list) – The components to generate checkboxes for.

  • level (int) – The level of the components to generate checkboxes for.

global_exception_hook(exctype, value, traceback_obj)

Global method to catch unhandled exceptions.

handle_camera_focal_change()

Handles the change in camera focal point.

This method handles the change in camera focal point by validating the new focal point and setting the camera focal point in the viewer.

handle_camera_position_change()

Handles the change in camera position.

This method handles the change in camera position by validating the new position and setting the camera position in the viewer.

handle_camera_up_change()

Handles the change in camera up vector.

This method handles the change in camera up vector by validating the new up vector and setting the camera up vector in the viewer.

handle_figure_size_change()

Handles the change in figure size.

This method handles the change in figure size by validating the new size and setting the figure size in the viewer.

load_and_plot(progress_obj, filename)

The function to call when a file is loaded.

Parameters:
  • progress_obj (ProgressBar) – The progress object to use.

  • filename (str) – The path to the file to load.

load_file(file_path)

Loads the file.

Parameters:

file_path (str) – The path to the file to load.

load_initial_files(files)

Loads initial files after the window has been shown.

Parameters:

files (list of str) – List of file paths to load

measure_distance()

Measures the distance.

This method measures the distance by adding a measurement widget to the plotter and clearing the measurement box.

monitor_camera_position()

Monitors the camera position.

This method monitors the camera position by checking if it has changed from the last position and updating the timer if it has.

number_of_events

Signal emitted when the number of events changes

Parameters:

int – The new number of events

on_file_loaded(start_time=None)

Method to call when a file is loaded.

Parameters:

start_time (float, optional) – The start time of the file loading.

open_color_picker(button)

Opens the color picker.

This method opens the color picker by getting the color from the color dialog and setting the background color of the viewer.

Parameters:

button (int) – The button to open the color picker for.

open_file_dialog()

Opens the file dialog.

This method opens the file dialog by getting the open file name and emitting the file name changed event.

print_to_console(text)

Prints to the console.

This method prints text to the console with the GeViewer prompt.

Parameters:

text (str) – The text to print to the console.

resize_window()

Resizes the window to fit the screen.

save_file_dialog()

Saves the file.

This method saves the file by getting the save file name and emitting the save file event.

set_camera_focal(focal_point)

Sets the camera focal point in the viewer.

This method sets the camera focal point in the viewer by updating the camera’s focal point attribute and triggering an update of the plotter.

Parameters:

focal_point (str) – The new camera focal point.

set_camera_position(position)

Sets the camera position in the viewer.

This method sets the camera position in the viewer by updating the camera’s position attribute and triggering an update of the plotter.

Parameters:

position (str) – The new camera position.

set_camera_up(up_vector)

Sets the camera up vector in the viewer.

This method sets the camera up vector in the viewer by updating the camera’s up vector attribute and triggering an update of the plotter.

Parameters:

up_vector (str) – The new camera up vector.

set_figure_size(figure_size)

Sets the figure size in the viewer.

This method sets the figure size in the viewer by updating the figure size attribute and triggering an update of the plotter.

Parameters:

figure_size (str) – The new figure size.

set_focal_error_state()

Sets the focal error state.

This method sets the focal error state by setting the palette of the camera focal text to a light red color.

set_position_error_state()

Sets the position error state.

This method sets the position error state by setting the palette of the camera position text to a light red color.

set_up_error_state()

Sets the up error state.

This method sets the up error state by setting the palette of the camera up text to a light red color.

set_visibility_recursive(comp, visibility)

Sets the visibility of a component and all its children recursively.

This method sets the visibility of a component and all its children recursively by checking the corresponding checkbox and updating the visibility of the associated actors.

Parameters:
  • comp (dict) – The component to set visibility for.

  • visibility (bool) – The visibility to set for the component.

set_window_error_state()

Sets the window error state.

This method sets the window error state by setting the palette of the figure size text to a light red color.

show_documentation()

Shows the documentation.

This method shows the documentation by opening the documentation in the default web browser.

show_license()

Shows the license.

This method shows the license by reading the license file and printing it to the console.

show_overlaps()

Shows the overlaps.

This method shows the overlaps by setting the checkboxes to checked for the overlapping meshes and toggling the transparency if it is not already enabled.

show_single_event(event_index)

Shows a single event in the viewer.

This method shows a single event in the viewer by checking the corresponding checkbox and updating the visibility of the associated actors.

Parameters:

event_index (int) – The index of the event to show.

synchronize_toolbar(wireframe=True)

Synchronizes the toolbar.

This method synchronizes the toolbar by setting the wireframe attribute of the viewer to the opposite of its current value and updating the wireframe button.

Parameters:

wireframe (bool) – The wireframe state to synchronize.

toggle_background()

Toggles the background.

This method toggles the background by setting the background attribute of the viewer to the opposite of its current value and updating the background button.

toggle_components_panel()

Toggles the components panel.

This method toggles the components panel by showing or hiding it depending on its current state.

toggle_control_panel()

Toggles the control panel.

This method toggles the control panel by showing or hiding it depending on its current state.

toggle_depth_peeling(on=False)

Toggles depth peeling.

This method turns on or off depth peeling for the plotter.

toggle_gradient()

Toggles the gradient.

This method toggles the gradient by setting the gradient attribute of the viewer to the opposite of its current value and updating the background color of the viewer.

toggle_parallel()

Toggles the parallel projection.

This method toggles the parallel projection by setting the parallel attribute of the viewer to the opposite of its current value and updating the parallel button.

toggle_transparent(print=True)

Toggles the transparency.

This method toggles the transparency by setting the transparent attribute of the viewer to the opposite of its current value and updating the transparency button.

toggle_visibility(state, comp)

Toggles the visibility of a component in the viewer.

This method toggles the visibility of a component in the viewer by checking the corresponding checkbox and updating the visibility of the associated actors.

Parameters:
  • state (int) – The state of the checkbox to toggle.

  • comp (dict) – The component to toggle visibility for.

toggle_wireframe()

Toggles the wireframe.

This method toggles the wireframe by setting the wireframe attribute of the viewer to the opposite of its current value and updating the wireframe button.

update_event_total(total)

Updates the event selection box to reflect the total number of events.

This method updates the range of the event selection box to reflect the total number of events in the current file.

Parameters:

total (int) – The total number of events in the current file.

update_menu_action(visible)

Updates the menu action.

This method updates the menu action by setting the check state to checked if visible, otherwise unchecked.

Parameters:

visible (bool) – The visibility of the menu action.

update_title(filename)

Updates the title text to reflect the current file being viewed.

This method updates the text of the window title to indicate the current file being viewed. If multiple files are being viewed, it will also show the number of additional files being viewed.

Parameters:

filename (str) – The name of the file being viewed.

update_view_params()

Updates the view parameters.

This method updates the view parameters by setting the camera position, focal point, and up vector in the viewer.

update_wireframe_action()

Updates the wireframe button.

This method updates the wireframe button by setting the text to ‘Solid’ if the wireframe is enabled, otherwise ‘Wireframe’.

validate_camera_focal(focal_point)

Validates the camera focal point.

This method validates the camera focal point by checking if it is a comma-separated list of three floats. If not, it will print an error message and return False.

Parameters:

focal_point (str) – The camera focal point to validate.

Returns:

True if the camera focal point is valid, False otherwise.

Return type:

bool

validate_camera_position(position)

Validates the camera position.

This method validates the camera position by checking if it is a comma-separated list of three floats. If not, it will print an error message and return False.

Parameters:

position (str) – The camera position to validate.

Returns:

True if the camera position is valid, False otherwise.

Return type:

bool

validate_camera_up(up_vector)

Validates the camera up vector.

This method validates the camera up vector by checking if it is a comma-separated list of three floats. If not, it will print an error message and return False.

Parameters:

up_vector (str) – The camera up vector to validate.

Returns:

True if the camera up vector is valid, False otherwise.

Return type:

bool

validate_figure_size(figure_size)

Validates the figure size.

This method validates the figure size by checking if it is a comma-separated list of two integers. If not, it will print an error message and return False.

Parameters:

figure_size (str) – The figure size to validate.

Returns:

True if the figure size is valid, False otherwise.

Return type:

bool

class geviewer.gui.Worker(task, progress_bar, **kwargs)

Bases: QThread

A custom worker class for the GeViewer application.

cleanup()

Cleans up the resources used by the worker.

deleteLater()

Overrides the deleteLater method to clean up the resources used by the worker.

error_signal

Signal emitted when an error occurs during the worker’s task

Parameters:
  • type – The type of the exception

  • Exception – The exception instance

  • object – The traceback object

finished

Signal emitted when the worker has finished its task

get_result()

Returns the result of the worker.

on_finished(func)

Connects a function to the finished signal.

Parameters:

func (function) – The function to connect to the finished signal.

run()

Runs the worker.

geviewer.gui.launch_app(files_to_load=None)

Launches the app.

Application launcher

geviewer.geviewer.main()

The main command-line entry point for GeViewer.

File parsers

class geviewer.parsers.HepRepParser(filename)

Bases: Parser

Parser for HepRep files.

build_mesh_objects(components)

Draws the meshes for the given components.

Parameters:

components (list) – The list of components to draw meshes for.

combine_dicts(dicts)

Combines the given dictionaries into a single dictionary.

Parameters:

dicts (list) – The list of dictionaries to combine.

copy_parent_attvalues(parent, child)

Copies the parent attributes to the child.

Parameters:
  • parent (dict) – The parent component.

  • child (dict) – The child component.

create_meshes(components, progress_obj=None)

Creates the meshes for the given components.

Parameters:

components (list) – The list of components to create meshes for.

parse_file(progress_obj=None)

Parses the HepRep file and creates the meshes.

Parameters:

progress_obj (ProgressBar, optional) – The progress object to use for the progress bar.

parse_xml(xml_file)

Parses the HepRep file and returns the root element.

populate_meshes(element, component, level=-1, progress_obj=None)

Populates the meshes for the given element.

Parameters:
  • element (xml.etree.ElementTree.Element) – The element to populate.

  • component (dict) – The component to populate.

  • level (int) – The recursion level.

  • progress_obj (ProgressBar, optional) – The progress object to use for the progress bar.

process_attvalue(child, component)

Processes the attvalue to set the attributes of the component.

Parameters:
  • child (xml.etree.ElementTree.Element) – The attvalue to process.

  • component (dict) – The component to set the attributes for.

reduce_components(components)

Reduces the components by combining duplicate children.

Parameters:

components (list) – The list of components to reduce.

repair_mesh(mesh)

Attempts to repair the given mesh.

Parameters:

mesh (pv.PolyData) – The mesh to repair.

Returns:

A tuple containing the repaired mesh and a boolean indicating whether the mesh was repaired.

Return type:

tuple

class geviewer.parsers.Parser(filename)

Bases: object

Base class for all parsers.

combine_mesh_arrays(points, cells, colors)

Combines multiple mesh arrays into a single mesh.

This function takes lists of points, indices of faces or line segments (called cells), and colors, and combines them into a single set of points, cells, and colors, adjusting indices appropriately.

Parameters:
  • points (list of numpy.ndarray) – A list of arrays containing point coordinates.

  • cells (list of list) – A list of lists containing cell indices.

  • colors (list of numpy.ndarray) – A list of arrays containing color data.

Returns:

The combined points, cells, and colors.

Return type:

tuple

initialize_template(name)

Initializes a template for a component.

Parameters:

name (str) – The name of the component.

Returns:

The initialized template.

Return type:

dict

class geviewer.parsers.VRMLParser(filename)

Bases: Parser

Parser for VRML files.

build_markers(blocks, progress_obj=None)

Builds a mesh for the given blocks.

This function processes blocks of data for markers, creating a mesh for each.

Parameters:
  • blocks (list) – List of blocks containing data.

  • progress_obj (geviewer.gui.GeProgressBar, optional) – The progress object to use.

Returns:

The created mesh.

Return type:

pyvista.PolyData

build_mesh(blocks, which, progress_obj=None)

Builds a mesh for the given blocks.

This function processes blocks of data for polylines, markers, and solids, building corresponding meshes for each.

Parameters:
  • blocks (list) – List of blocks containing data.

  • which (str) – The type of mesh to build.

  • progress_obj (geviewer.gui.GeProgressBar, optional) – The progress object to use.

Returns:

The created mesh.

Return type:

pyvista.PolyData

create_meshes(polyline_blocks, marker_blocks, solid_blocks, progress_obj=None)

Creates and returns meshes for polylines, markers, and solids.

This function processes blocks of data for polylines, markers, and solids, building corresponding meshes for each.

Parameters:
  • polyline_blocks (list) – List of blocks containing polyline data.

  • marker_blocks (list) – List of blocks containing marker data.

  • solid_blocks (list) – List of blocks containing solid data.

  • progress_obj (geviewer.gui.GeProgressBar, optional) – The progress object to use.

Returns:

The created meshes.

Return type:

tuple

extract_blocks(file_content, progress_obj=None)

Extracts polyline, marker, and solid blocks from the given file content.

This function processes the provided file content, which is expected to be in a text format, and extracts blocks of different types based on specific keywords. It separates the blocks into categories: polyline, marker, and solid blocks, and also identifies the viewpoint block.

Parameters:
  • file_content (str) – The content of the file as a single string.

  • progress_obj (geviewer.gui.GeProgressBar, optional) – The progress object to use.

Returns:

A tuple containing four elements: - The viewpoint block (if found) as a string or None if not found. - A list of polyline blocks as strings. - A list of marker blocks as strings. - A list of solid blocks as strings.

Return type:

tuple

parse_file(progress_obj=None)

Parses the VRML file and creates the meshes.

Parameters:

progress_obj (geviewer.gui.GeProgressBar, optional) – The progress object to use.

parse_marker_block(block)

Parses a marker block to extract the position, radius, and color of a marker.

This function processes a block of text representing a marker in a 3D scene description. It extracts the position of the marker, the radius of the marker (typically a sphere), and the color of the marker. It also accounts for transparency and adjusts the alpha value of the color accordingly.

Parameters:

block (str) – The marker block content as a string.

Returns:

A tuple containing: - coords: An array of shape (3,) representing the position of the marker in 3D space. - radius: A float representing the radius of the marker. - color: An array of four floats representing the RGBA color of the marker, where alpha is adjusted for transparency.

Return type:

tuple

parse_polyline_block(block)

Parses a polyline block to extract particle track information, including coordinates, indices, and color.

This function processes a block of text representing a polyline in a 3D scene description. It extracts the coordinates of the points that define the polyline, the indices that describe the lines between these points, and the color associated with the polyline.

Parameters:

block (str) – The polyline block content as a string.

Returns:

A tuple containing: - coords: An array of shape (N, 3) representing the coordinates of the polyline points. - indices: An array of integers representing the indices that define the polyline segments. - color: An array of four floats representing the RGBA color of the polyline, where the alpha is set to 1.

Return type:

tuple

parse_solid_block(block)

Parses a solid block to extract geometry information for a 3D solid object.

This function processes a block of text representing a solid object in a 3D scene description. It extracts the vertex coordinates, the face indices that define the geometry of the solid, and the color of the solid. The function also handles transparency by adjusting the alpha value in the color array.

Parameters:

block (str) – The solid block content as a string.

Returns:

A tuple containing: - coords: An array of shape (N, 3) where N is the number of vertices, representing the vertex coordinates. - coord_inds: An array of shape (M,) where M is the number of indices, representing the indices defining the faces of the solid. - color: An array of four floats representing the RGBA color of the solid, where the alpha value is adjusted for transparency.

Return type:

tuple

parse_viewpoint_block(block)

Parses the viewpoint block to extract the field of view, position, and orientation.

This function extracts the field of view (FOV), position, and orientation from a given viewpoint block in a 3D scene description. The FOV is converted from radians to degrees.

Parameters:

block (str) – The viewpoint block content as a string.

Returns:

A tuple containing: - The field of view in degrees as a float (or None if not found). - The position as a list of three floats [x, y, z] (or None if not found). - The orientation as a list of four floats [x, y, z, angle] in radians (or None if not found).

Return type:

tuple

process_marker_block(block)

Processes a marker block to create a marker mesh.

This function takes a block of marker data and creates a spherical marker mesh using PyVista. It also extracts the color information associated with the marker.

Parameters:

block (str) – The marker block content as a string.

Returns:

A tuple containing: - A pv.Sphere object representing the marker mesh. - The color associated with the marker mesh as a list or array.

Return type:

tuple

process_polyline_block(block)

Processes a polyline block to create a polyline mesh.

This function takes a block of polyline data and converts it into a PyVista`PolyData` object representing the polyline mesh. It also extracts the color information associated with the mesh.

Parameters:

block (str) – The polyline block content as a string.

Returns:

A tuple containing: - A pv.PolyData object representing the polyline mesh. - The color associated with the polyline mesh as a list or array.

Return type:

tuple

process_solid_block(block)

Processes a solid block to create a solid mesh.

This function takes a block of solid data and creates a mesh for a solid object using PyVista. It also extracts the color information associated with the solid.

Parameters:

block (str) – The solid block content as a string.

Returns:

A tuple containing: - A pv.PolyData object representing the solid mesh. - The color associated with the solid mesh as a list or array.

Return type:

tuple

read_file(filename)

Reads the content of a file.

Parameters:

filename (str) – The path to the file to read.

Returns:

A single string containing the content of the file.

Return type:

str

File converter

class geviewer.converter.ProgressBar

Bases: object

A progress bar for the converter utility.

increment_progress()

Increments the progress bar.

print_update(text)

Prints text sent to the progress bar.

reset_progress()

Resets the progress bar.

set_maximum_value(value)

Sets the maximum value of the progress bar.

signal_finished()

Signals that the progress bar is finished.

sync_status(update=None, increment=False)

Synchronizes the status of the task with the progress bar.

Parameters:
  • update (str) – The update to be printed

  • increment (bool) – Whether to increment the progress bar

geviewer.converter.main()

Converts the file to .gev format and saves it to the specified destination.

Utilities

geviewer.utils.check_files(files)

Checks if the file paths are valid.

geviewer.utils.check_for_updates()

Determines whether the user is using the latest version of GeViewer. If not, prints a message to the console to inform the user.

geviewer.utils.get_license()

Gets the LICENSE file from the distribution.

geviewer.utils.print_banner()

Prints the banner to the terminal.

Geometry

geviewer.geometry.create_annular_cylinder_mesh(p1, p2, r1_outer, r2_outer, r1_inner, r2_inner, num_segments=50)

Creates a mesh for an annular cylinder.

Parameters:
  • p1 (tuple) – The first endpoint.

  • p2 (tuple) – The second endpoint.

  • r1_outer (float) – The outer radius at the first endpoint.

  • r2_outer (float) – The outer radius at the second endpoint.

  • r1_inner (float) – The inner radius at the first endpoint.

  • r2_inner (float) – The inner radius at the second endpoint.

  • num_segments (int) – The number of segments to use.

geviewer.geometry.create_cylinder_mesh(p1, p2, r1, r2, num_segments=50)

Creates a mesh for a cylinder.

Parameters:
  • p1 (tuple) – The first endpoint.

  • p2 (tuple) – The second endpoint.

  • r1 (float) – The radius at the first endpoint.

  • r2 (float) – The radius at the second endpoint.

  • num_segments (int) – The number of segments to use.