refactoredCPPNeuronMesher
|
Implementation of OpenGL rendering utilities for neuron visualization. More...
Functions | |
void | drawSimpleSphere (const SWCNode &node, double size) |
Renders a low-detail sphere at the specified node's position. More... | |
void | drawSimpleLine (const SWCNode &a, const SWCNode &b) |
Draws a straight line between two nodes. More... | |
void | drawSphere (const SWCNode &node, int slices, int stacks) |
Renders a detailed sphere at the specified node's position. More... | |
void | drawCylinder (const SWCNode &a, const SWCNode &b, int segments) |
Renders a tapered cylinder between two nodes. More... | |
void | drawBoundingBox (double minX, double maxX, double minY, double maxY, double minZ, double maxZ) |
Renders a wireframe bounding box in 3D space. More... | |
void | setColorByType (int type) |
Sets the OpenGL color based on SWC node type. More... | |
void | renderSWC (const std::vector< SWCNode > &nodes) |
Renders a collection of SWC nodes as a 3D neuron morphology. More... | |
Implementation of OpenGL rendering utilities for neuron visualization.
This file contains utility functions for rendering 3D neuron structures using OpenGL. It provides various primitives for drawing spheres, cylinders, and other geometric shapes used to represent neuron morphologies in 3D space.
Key features:
The implementation uses legacy OpenGL immediate mode (glBegin/glEnd) for simplicity and compatibility with the existing visualization pipeline.
void drawBoundingBox | ( | double | minX, |
double | maxX, | ||
double | minY, | ||
double | maxY, | ||
double | minZ, | ||
double | maxZ | ||
) |
Renders a wireframe bounding box in 3D space.
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.
Renders a tapered cylinder between two nodes.
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 straight line between two nodes.
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 | ||
) |
Renders a low-detail sphere at the specified node's position.
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 | ||
) |
Renders a detailed sphere at the specified node's position.
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 collection of SWC nodes as a 3D neuron morphology.
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.
[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.