refactoredCPPNeuronMesher
|
OpenGL drawing utilities for neuron visualization. More...
#include <array>
#include <vector>
#include <GLFW/glfw3.h>
#include <GL/glu.h>
Go to the source code of this file.
Functions | |
void | drawSimpleSphere (const SWCNode &node, double size=0.5f) |
Draws a simple low-polygon sphere at a node's position. More... | |
void | drawSimpleLine (const SWCNode &a, const SWCNode &b) |
Draws a simple line between two nodes. More... | |
void | drawSphere (const SWCNode &node, int slices=6, int stacks=6) |
Draws a sphere with specified geometric detail. More... | |
void | drawCylinder (const SWCNode &a, const SWCNode &b, int segments=6) |
Draws a cylinder connecting two nodes. More... | |
void | drawBoundingBox (double minX, double maxX, double minY, double maxY, double minZ, double maxZ) |
Draws an axis-aligned bounding box. More... | |
void | setColorByType (int type) |
Sets the OpenGL color based on SWC node type. More... | |
void | renderSWC (const std::vector< SWCNode > &nodes) |
Renders a complete SWC neuron morphology. More... | |
OpenGL drawing utilities for neuron visualization.
This header provides functions for rendering 3D neuron morphologies using OpenGL. It includes utilities for drawing spheres, cylinders, and other geometric primitives that make up neuron visualizations.
void drawBoundingBox | ( | double | minX, |
double | maxX, | ||
double | minY, | ||
double | maxY, | ||
double | minZ, | ||
double | maxZ | ||
) |
Draws an axis-aligned bounding box.
minX | Minimum x-coordinate |
maxX | Maximum x-coordinate |
minY | Minimum y-coordinate |
maxY | Maximum y-coordinate |
minZ | Minimum z-coordinate |
maxZ | Maximum z-coordinate |
Renders a wireframe box representing the spatial bounds of the neuron. Uses immediate mode OpenGL line drawing.
Draws an axis-aligned bounding box.
[in] | minX | The minimum X coordinate of the bounding box |
[in] | maxX | The maximum X coordinate of the bounding box |
[in] | minY | The minimum Y coordinate of the bounding box |
[in] | maxY | The maximum Y coordinate of the bounding box |
[in] | minZ | The minimum Z coordinate of the bounding box |
[in] | maxZ | The maximum Z coordinate of the bounding box |
This function draws a white wireframe box representing the spatial bounds of the neuron morphology. The box is drawn using OpenGL line primitives, with each edge of the box represented by a single line segment.
The function sets the current OpenGL color to white before rendering and uses immediate mode rendering (glBegin/glEnd). The box is axis-aligned and defined by the provided min/max coordinates in each dimension.
Draws a cylinder connecting two nodes.
a | First node (start of cylinder) |
b | Second node (end of cylinder) |
segments | Number of radial segments for the cylinder [default: 6] |
Renders a tapered cylinder that connects two nodes, with the radius at each end determined by the nodes' radii. The cylinder is colored according to the first node's type.
Draws a cylinder connecting two nodes.
[in] | a | The starting node of the cylinder |
[in] | b | The ending node of the cylinder |
[in] | segments | The number of sides around the cylinder |
This function draws a tapered cylinder connecting two nodes in 3D space. The cylinder's radius at each end is determined by the radius property of the corresponding node, allowing for smooth tapering of neurites.
The function handles the necessary coordinate system transformations to orient the cylinder correctly between the two points in 3D space. It uses OpenGL's matrix stack to ensure the transformations don't affect subsequent rendering operations.
Draws a simple line between two nodes.
a | First node (start point) |
b | Second node (end point) |
Renders a line in 3D space between two nodes using immediate mode OpenGL. The line width is determined by the nodes' radii.
Draws a simple line between two nodes.
[in] | a | The starting node of the line |
[in] | b | The ending node of the line |
This function renders a simple line segment between two nodes in 3D space using OpenGL's immediate mode line rendering. The line is drawn with the current OpenGL color and line width settings.
The function is typically used for wireframe representations of neuron morphologies or for debug visualization.
void drawSimpleSphere | ( | const SWCNode & | node, |
double | size | ||
) |
Draws a simple low-polygon sphere at a node's position.
node | The SWC node containing position and radius information |
size | Scale factor for the sphere radius (default: 0.5) |
This function renders a sphere using immediate mode OpenGL with minimal geometric detail, making it suitable for large numbers of nodes.
Draws a simple low-polygon sphere at a node's position.
[in] | node | The SWCNode containing the position for the sphere |
[in] | size | The radius of the sphere |
This function draws a simple sphere using OpenGL's GLU quadric primitives. It's optimized for speed rather than visual quality, using a low number of slices and stacks (8x8) for the sphere approximation.
The function handles the OpenGL matrix stack appropriately, pushing the current matrix before translation and popping it afterward to avoid affecting subsequent rendering operations.
void drawSphere | ( | const SWCNode & | node, |
int | slices, | ||
int | stacks | ||
) |
Draws a sphere with specified geometric detail.
node | The SWC node to draw |
slices | Number of subdivisions around the z-axis (longitude) [default: 6] |
stacks | Number of subdivisions along the z-axis (latitude) [default: 6] |
Uses GLU quadric objects to render a sphere with the specified level of detail. The sphere is colored according to the node's type.
Draws a sphere with specified geometric detail.
[in] | node | The SWCNode containing the position and radius for the sphere |
[in] | slices | The number of subdivisions around the Z axis (longitude) |
[in] | stacks | The number of subdivisions along the Z axis (latitude) |
This function draws a sphere using OpenGL's GLU quadric primitives with smooth normal vectors for proper lighting calculations. The sphere's radius is taken from the node's radius property, and its position is set to the node's coordinates.
The function handles the OpenGL matrix stack appropriately and uses the current OpenGL color for rendering. The resolution of the sphere can be controlled through the slices and stacks parameters.
void renderSWC | ( | const std::vector< SWCNode > & | nodes | ) |
Renders a complete SWC neuron morphology.
nodes | Vector of SWC nodes to render |
This is the main rendering function that draws an entire neuron morphology. It handles the display of all nodes and connections between them, with appropriate coloring based on node types. The function respects the current rendering mode and visualization settings from globals.h.
Renders a complete SWC neuron morphology.
[in] | nodes | A vector of SWCNode objects representing the neuron morphology |
This function renders a complete neuron morphology from SWC node data using different rendering modes controlled by the global renderMode
variable. The function handles both the rendering of nodes (soma, branch points, etc.) and the connections between them (dendrites, axons).
Supported render modes:
The function first renders all nodes according to the current render mode, then renders the connections between nodes. Node colors are determined by their SWC type using the setColorByType() function.
renderMode
variable to determine rendering style void setColorByType | ( | int | type | ) |
Sets the OpenGL color based on SWC node type.
type | SWC node type identifier (1-7) |
Maps standard SWC node types to distinct colors for visualization. The color mapping follows the standard SWC color scheme:
[in] | type | The SWC node type identifier |
This function maps standard SWC node types to specific colors for visualization. The color mapping is as follows:
The function uses a static map for efficient type-to-color lookup and modifies the current OpenGL color state.