Description
Renderer of a force network as a set of segments between arbitrary points.
Each segment is given by its two end points and a value. The value is mapped to a color, through a colormap or a linear ramp between two colors, unless an explicit color is given for the segment. Segments are drawn as unlit lines one pixel wide, or as lit cylinders whose radius is constant, mapped from the segment value, or given per segment. All sizes are in world units.
This renderer is a component for VSG plugins. A plugin creates it, calls Initialize() from its OnBindAssets() function, and passes the segments to draw with SetSegments(), typically from its OnRender() function. The plugin extracts and filters the contact data; the renderer draws the segments it is given. The capacity (maximum number of segments) is fixed at construction: segments beyond the capacity are dropped and counted.
#include <ChForceNetworkVSG.h>
Public Types | |
| enum | Mode { Mode::LINES, Mode::CYLINDERS } |
| Rendering mode for network segments. More... | |
Public Member Functions | |
| ChForceNetworkVSG (unsigned int capacity) | |
| Create a force-network renderer for at most the specified number of segments. | |
| void | SetMode (Mode mode) |
| Set the rendering mode (default: CYLINDERS). | |
| Mode | GetMode () const |
| Get the current rendering mode. | |
| void | SetColormap (ChColormap::Type type) |
| Map segment values to colors with the specified colormap (default: JET). | |
| void | SetColorRamp (const ChColor &color_min, const ChColor &color_max) |
| Map segment values to colors with a linear ramp between two colors. | |
| bool | UsesColormap () const |
| Return true if segment values are mapped to colors with a colormap, false if with a two-color ramp. | |
| ChColormap::Type | GetColormapType () const |
| Get the type of the colormap used to map segment values to colors. | |
| void | SetValueRange (double vmin, double vmax) |
| Set the range of segment values mapped to colors and radii (default: [0, 1]). More... | |
| ChVector2d | GetValueRange () const |
| Get the range of segment values mapped to colors and radii. | |
| void | SetRadius (double radius) |
| Set a constant radius for segments drawn as cylinders (default: 0.001). | |
| void | SetRadiusRange (double rmin, double rmax) |
| Map segment values to cylinder radii, from rmin at the low end of the value range to rmax at the high end. | |
| void | SetResolution (int num_divs) |
| Set the number of divisions of the cylinder cross-section (default: 12). More... | |
| void | Initialize (ChVisualSystemVSG &vsys) |
| Create the VSG nodes and add them to the scene of the given visual system. More... | |
| void | SetSegments (unsigned int num_segments, const float *points1, const float *points2, const float *values, const float *colors=nullptr, const float *radii=nullptr) |
| Set the segments drawn from the next frame on. More... | |
| void | SetVisibility (bool visible) |
| Show or hide the force network (default: visible). | |
| bool | IsVisible () const |
| Return true if the force network is visible. | |
| unsigned int | GetCapacity () const |
| Get the maximum number of segments. | |
| unsigned int | GetNumSegments () const |
| Get the number of segments drawn, as set by the last call to SetSegments(). | |
| unsigned int | GetNumDropped () const |
| Get the number of segments dropped by the last call to SetSegments() because they exceeded the capacity. | |
| unsigned long long | GetTotalDropped () const |
| Get the total number of segments dropped because they exceeded the capacity, over all calls to SetSegments(). | |
Member Enumeration Documentation
◆ Mode
|
strong |
Member Function Documentation
◆ Initialize()
| void chrono::vsg3d::ChForceNetworkVSG::Initialize | ( | ChVisualSystemVSG & | vsys | ) |
Create the VSG nodes and add them to the scene of the given visual system.
The nodes must exist when the visual system compiles its scene. A plugin therefore calls this function from its OnBindAssets() function, before the visual system is initialized.
◆ SetResolution()
| void chrono::vsg3d::ChForceNetworkVSG::SetResolution | ( | int | num_divs | ) |
Set the number of divisions of the cylinder cross-section (default: 12).
This function must be called before Initialize().
◆ SetSegments()
| void chrono::vsg3d::ChForceNetworkVSG::SetSegments | ( | unsigned int | num_segments, |
| const float * | points1, | ||
| const float * | points2, | ||
| const float * | values, | ||
| const float * | colors = nullptr, |
||
| const float * | radii = nullptr |
||
| ) |
Set the segments drawn from the next frame on.
The arrays hold the data of num_segments segments: points1 and points2 the two end points (3 floats per segment), values one value per segment, colors (optional) an explicit RGB color per segment (3 floats per segment), and radii (optional) an explicit cylinder radius per segment. Explicit colors replace the colors mapped from the values and explicit radii replace the constant or mapped radii. The values array may be null if explicit colors are given and no radius range is set. Segments beyond the capacity are dropped and counted.
◆ SetValueRange()
| void chrono::vsg3d::ChForceNetworkVSG::SetValueRange | ( | double | vmin, |
| double | vmax | ||
| ) |
Set the range of segment values mapped to colors and radii (default: [0, 1]).
Values outside this range are clamped to it.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono_vsg/utils/ChForceNetworkVSG.h
- /builds/uwsbel/chrono/src/chrono_vsg/utils/ChForceNetworkVSG.cpp