refactoredCPPNeuronMesher
opgl_utils.cpp File Reference

OpenGL utility functions for neuron visualization. More...

#include "opgl_utils.h"
#include "globals.h"
Include dependency graph for opgl_utils.cpp:

Functions

void printHelpText ()
 Prints the help text to the standard output. More...
 
std::vector< SWCNodeloadSWC (const std::string &filename)
 Loads a neuron morphology from an SWC or UGX file. More...
 
void computeBounds (const std::vector< SWCNode > &nodes, double &minX, double &maxX, double &minY, double &maxY, double &minZ, double &maxZ, double &centerX, double &centerY, double &centerZ, double &radius)
 Computes the bounding box and center of a set of nodes. More...
 
void openNeuronFile (std::vector< SWCNode > &nodes, double &minX, double &maxX, double &minY, double &maxY, double &minZ, double &maxZ, double &centerX, double &centerY, double &centerZ, double &radius)
 Opens a file dialog and loads a neuron morphology file. More...
 

Variables

std::string currentLoadedFile = "."
 Path to the currently loaded neuron file. More...
 

Detailed Description

OpenGL utility functions for neuron visualization.

This file contains utility functions for handling OpenGL-related operations in the neuron visualization application. It provides functionality for loading neuron data from files, computing spatial bounds, and managing the visualization state.

Key features:

  • Loading and parsing SWC/UGX neuron files
  • Computing spatial bounds and center of neuron morphologies
  • Managing file I/O for neuron data
  • Integration with the main visualization pipeline

The implementation handles various neuron file formats and provides utility functions to support the OpenGL rendering pipeline.

Author
CPPNeuronMesher Team
Date
2025-07-27
Version
1.0
See also
globals.h for shared state variables
opgl_utils.h for function declarations

Function Documentation

◆ computeBounds()

void computeBounds ( const std::vector< SWCNode > &  nodes,
double &  minX,
double &  maxX,
double &  minY,
double &  maxY,
double &  minZ,
double &  maxZ,
double &  centerX,
double &  centerY,
double &  centerZ,
double &  radius 
)

Computes the bounding box and center of a set of nodes.

Computes the spatial bounds and center of a set of nodes.

Parameters
[in]nodesVector of SWC nodes to compute bounds for
[out]minXMinimum X coordinate of the bounding box
[out]maxXMaximum X coordinate of the bounding box
[out]minYMinimum Y coordinate of the bounding box
[out]maxYMaximum Y coordinate of the bounding box
[out]minZMinimum Z coordinate of the bounding box
[out]maxZMaximum Z coordinate of the bounding box
[out]centerXX coordinate of the bounding box center
[out]centerYY coordinate of the bounding box center
[out]centerZZ coordinate of the bounding box center
[out]radiusRadius of the bounding sphere (half the maximum dimension)

This function calculates the axis-aligned bounding box, center point, and bounding sphere radius for a set of 3D points represented by SWC nodes. The results are returned through reference parameters.

The function also prints the computed bounds and center to the console for debugging purposes.

Note
If the input vector is empty, the function returns immediately
The radius is defined as half the maximum dimension of the bounding box
See also
openNeuronFile() for a typical usage example
Here is the caller graph for this function:

◆ loadSWC()

std::vector<SWCNode> loadSWC ( const std::string &  filename)

Loads a neuron morphology from an SWC or UGX file.

Loads neuron data from an SWC file.

Parameters
[in]filenamePath to the SWC or UGX file to load
Returns
std::vector<SWCNode> Vector of SWC nodes representing the neuron

This function loads a neuron morphology from the specified file and returns its nodes as a vector of SWCNode objects. It supports both SWC and UGX file formats and performs preprocessing on the loaded data.

The function:

  1. Reads the neuron data using NeuronGraph's readFromFileUGXorSWC()
  2. Applies preprocessing to the loaded nodes
  3. Converts the node map to a vector for rendering
Note
The function modifies the global graph object
Preprocessing includes validation and cleanup of the neuron structure
Exceptions
std::runtime_errorif the file cannot be read or parsed
See also
NeuronGraph::readFromFileUGXorSWC()
NeuronGraph::preprocess()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openNeuronFile()

void openNeuronFile ( std::vector< SWCNode > &  nodes,
double &  minX,
double &  maxX,
double &  minY,
double &  maxY,
double &  minZ,
double &  maxZ,
double &  centerX,
double &  centerY,
double &  centerZ,
double &  radius 
)

Opens a file dialog and loads a neuron morphology file.

Opens a file dialog to load a neuron file and updates the view.

Parameters
[out]nodesVector to store the loaded SWC nodes
[out]minXMinimum X coordinate of the bounding box
[out]maxXMaximum X coordinate of the bounding box
[out]minYMinimum Y coordinate of the bounding box
[out]maxYMaximum Y coordinate of the bounding box
[out]minZMinimum Z coordinate of the bounding box
[out]maxZMaximum Z coordinate of the bounding box
[out]centerXX coordinate of the bounding box center
[out]centerYY coordinate of the bounding box center
[out]centerZZ coordinate of the bounding box center
[out]radiusRadius of the bounding sphere

This function opens a file dialog for the user to select an SWC or UGX file, loads the selected file, and computes the spatial bounds of the neuron. The function updates both the provided output parameters and the global state.

The function performs the following steps:

  1. Shows a file dialog for selecting SWC or UGX files
  2. Loads the selected file using loadSWC()
  3. Updates the global currentNodes and currentLoadedFile variables
  4. Computes the spatial bounds and center of the loaded neuron
  5. Resets the refinement delta to its default value
Note
Uses tinyfiledialogs for the file dialog
Prints diagnostic information to the console
See also
loadSWC() for the actual file loading implementation
computeBounds() for the bounds calculation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printHelpText()

void printHelpText ( )

Prints the help text to the standard output.

Prints keyboard and mouse controls to the console.

Displays the application's keyboard and mouse controls to the console. The help text is defined as a global string constant in globals.h.

Note
The help text includes controls for view manipulation, file operations, and rendering modes.
See also
globals.h for the help text definition
Here is the caller graph for this function:

Variable Documentation

◆ currentLoadedFile

std::string currentLoadedFile = "."

Path to the currently loaded neuron file.

Path to the currently loaded SWC file.