Description
VSG-based run-time visualization plugin for Chrono::Multicore systems.
The plugin draws the granular bodies of a Multicore system as GPU instances (see vsg3d::ChInstancedShapesVSG) and the contact force network (see vsg3d::ChForceNetworkVSG), writes images while the simulation runs, and shows a panel with Multicore timers, contact counts, and solver statistics.
The force network includes all rigid-rigid contacts with a positive normal force, contacts with walls included. Each contact is drawn as two half-segments, from each body center (or the center of the contact shape) to the contact point, midway between the two contact points of the shapes. A half-segment is not drawn if it starts at a large body (a body larger than the size limit of the automatic body selection, such as a wall) or if it is longer than a maximum length (by default, the median body size). The network is colored by the normal force, the Coulomb ratio (tangential force over its Coulomb limit), or the magnitude of the stored tangential displacement (SMC with the MultiStep tangential displacement model). A force threshold and a region filter (slab and box) select the contacts that are drawn; a slab gives section cuts.
The plugin must be attached to the VSG visual system before the visual system is initialized. It attaches the Multicore system to the visual system if that was not done already.
#include <ChMulticoreVisualizationVSG.h>


Public Types | |
| enum | NetworkColoring { NetworkColoring::NORMAL_FORCE, NetworkColoring::COULOMB_RATIO, NetworkColoring::TANGENTIAL_DISPLACEMENT } |
| Quantity used to color the force network. More... | |
| enum | NetworkAnchor { NetworkAnchor::BODY_CENTER, NetworkAnchor::SHAPE_CENTER } |
| Start point of the two half-segments of a contact. More... | |
Public Member Functions | |
| ChMulticoreVisualizationVSG (ChSystemMulticore *sys) | |
| void | EnableBodyInstancing (bool val) |
| Enable or disable drawing of granular bodies as GPU instances (default: true). More... | |
| void | SetBodySizeFactor (double factor) |
| Set the size factor for the automatic selection of granular bodies (default: 10). More... | |
| void | SetBodySelection (const std::vector< std::shared_ptr< ChBody >> &bodies) |
| Set an explicit list of bodies drawn as instances, replacing the automatic selection. More... | |
| void | SetBodySelector (std::function< bool(const ChBody &body)> selector) |
| Set a predicate selecting the bodies drawn as instances, replacing the automatic selection. More... | |
| void | SetBodyShapeSource (vsg3d::ChInstancedShapesVSG::ShapeSource source) |
| Set the source of the shapes drawn for each granular body (default: COLLISION). More... | |
| void | SetBodyResolution (int num_divs) |
| Set the number of divisions of a full circle used to tessellate round body shapes (default: 24). More... | |
| void | SetBodyDefaultColor (const ChColor &color) |
| Set the color of granular bodies whose visual model defines no color (default: [0.75, 0.75, 0.75]). More... | |
| void | SetBodyColorCallback (std::shared_ptr< vsg3d::ChInstancedShapesVSG::ColorCallback > callback) |
| Set a callback for the colors of granular bodies, replacing the colors from the visual models. | |
| void | SetBodyVisibilityCallback (std::shared_ptr< vsg3d::ChInstancedShapesVSG::VisibilityCallback > callback) |
| Set a callback for the visibility of granular bodies. | |
| void | SetInactiveBodyVisibility (bool visible) |
| Enable or disable drawing of inactive (fixed or sleeping) granular bodies (default: false). | |
| void | SetBodyVisibility (bool visible) |
| Show or hide the granular bodies (default: visible). | |
| void | SetNetworkVisibility (bool visible) |
| Show or hide the force network (default: hidden). | |
| void | SetNetworkMode (vsg3d::ChForceNetworkVSG::Mode mode) |
| Set the rendering mode of the force network (default: CYLINDERS). | |
| void | SetNetworkColoring (NetworkColoring quantity) |
| Set the quantity used to color the force network (default: NORMAL_FORCE). | |
| void | SetNetworkColoring (NetworkColoring quantity, double vmin, double vmax) |
| Set the quantity used to color the force network and the range of values mapped to colors. More... | |
| void | SetNetworkColormap (ChColormap::Type type) |
| Map network values to colors with the specified colormap (default: JET). | |
| void | SetNetworkColorRamp (const ChColor &color_min, const ChColor &color_max) |
| Map network values to colors with a linear ramp between two colors. | |
| void | SetNetworkRadius (double radius) |
| Set a constant radius for network segments drawn as cylinders (default: 0.1 times the median body size). | |
| void | SetNetworkRadius (double rmin, double rmax, double fmin, double fmax) |
| Scale the radius of network segments with the normal force, from rmin at fmin to rmax at fmax (clamped). | |
| void | SetNetworkForceThreshold (double threshold, bool relative=false) |
| Set the force threshold of the network (default: 0). More... | |
| void | SetNetworkMaxHalfLength (double length) |
| Set the maximum length of a network half-segment (default: the median body size). | |
| void | SetNetworkAnchor (NetworkAnchor anchor) |
| Set the start point of the network half-segments (default: BODY_CENTER). | |
| void | SetNetworkCapacity (unsigned int num_segments) |
| Set the maximum number of network half-segments (default: 12 times the number of bodies, at most 2e6). More... | |
| void | SetRegionSlab (const ChVector3d &point, const ChVector3d &normal, double half_thickness) |
| Restrict drawing to a slab of the specified half-thickness, centered at a point and normal to a direction. More... | |
| void | SetRegionBox (const ChAABB &box) |
| Restrict drawing to an axis-aligned box. More... | |
| void | ClearRegion () |
| Remove the slab and box region filters. | |
| void | SetRegionBodyFiltering (bool val) |
| Apply the region filter to granular bodies as well as to the force network (default: false). | |
| void | SetImageOutputDirectory (const std::string &dir) |
| Set the output directory for images (default: "."). More... | |
| void | SetImageOutput (bool val) |
| Enable or disable writing of images (default: false). More... | |
| void | SetImageOutputInterval (unsigned int interval) |
| Write the image of every n-th rendered frame (default: 1). | |
| void | SetImageOutputFormat (const std::string &extension) |
| Set the image format, given as a file extension (default: "bmp"). More... | |
| unsigned int | GetNumImages () const |
| Get the number of images written (requested) so far. | |
| unsigned int | GetNumNetworkSegments () const |
| Get the number of network half-segments drawn at the current frame. | |
| unsigned int | GetNumNetworkSegmentsDropped () const |
| Get the number of network half-segments dropped at the current frame because they exceeded the capacity. | |
| unsigned int | GetNumInstancedBodies () const |
| Get the number of bodies drawn as instances. | |
| double | GetMedianBodySize () const |
| Get the median body size, as computed at initialization. | |
| virtual void | OnAttach () override |
| Allow this plugin to perform any operations when it is attached to a VSG visual system. More... | |
| virtual void | OnInitialize () override |
| Allow this plugin to perform any pre-initialization operations. More... | |
| virtual void | OnBindAssets () override |
| Allow this plugin to perform any pre-binding operations. More... | |
| virtual void | OnRender () override |
| Allow this plugin to perform any pre-rendering operations. More... | |
Public Member Functions inherited from chrono::vsg3d::ChVisualSystemVSGPlugin | |
| void | AddEventHandler (std::shared_ptr< ChEventHandlerVSG > eh) |
| TODO - remove AddEventHandler? A plugin can call the VSG system's AddEventHandler in its OnAttach() function. More... | |
| ChVisualSystemVSG & | GetVisualSystemVSG () const |
| Get a reference to the VSG visual system to which the plugin was attached. | |
Friends | |
| class | MulticoreStatsVSG |
| class | MulticoreBodyVisibility |
Additional Inherited Members | |
Protected Attributes inherited from chrono::vsg3d::ChVisualSystemVSGPlugin | |
| std::vector< std::shared_ptr< ChEventHandlerVSG > > | m_evhandler |
| list of all additional event handlers | |
| ChVisualSystemVSG * | m_vsys |
| associated VSG visual system | |
Member Enumeration Documentation
◆ NetworkAnchor
◆ NetworkColoring
Member Function Documentation
◆ EnableBodyInstancing()
|
inline |
Enable or disable drawing of granular bodies as GPU instances (default: true).
If disabled, all bodies keep the default binding of the visual system. This function must be called before the visual system is initialized.
◆ OnAttach()
|
overridevirtual |
Allow this plugin to perform any operations when it is attached to a VSG visual system.
The pointer m_vsys to the associated VSG visual system is set before calling OnAttach.
Reimplemented from chrono::vsg3d::ChVisualSystemVSGPlugin.
◆ OnBindAssets()
|
overridevirtual |
Allow this plugin to perform any pre-binding operations.
This function is called during initialization of the associated VSG visual system, after the scene was created and before binding assets for the associated VSG visual system. A plugin can create and populate its own children in the VSG scene.
Reimplemented from chrono::vsg3d::ChVisualSystemVSGPlugin.
◆ OnInitialize()
|
overridevirtual |
Allow this plugin to perform any pre-initialization operations.
This function is called before the initialization of the associated VSG visual system.
Reimplemented from chrono::vsg3d::ChVisualSystemVSGPlugin.
◆ OnRender()
|
overridevirtual |
Allow this plugin to perform any pre-rendering operations.
This function is called before updating and rendering the associated VSG visual system.
Reimplemented from chrono::vsg3d::ChVisualSystemVSGPlugin.
◆ SetBodyDefaultColor()
|
inline |
Set the color of granular bodies whose visual model defines no color (default: [0.75, 0.75, 0.75]).
This function must be called before the visual system is initialized.
◆ SetBodyResolution()
|
inline |
Set the number of divisions of a full circle used to tessellate round body shapes (default: 24).
This function must be called before the visual system is initialized.
◆ SetBodySelection()
|
inline |
Set an explicit list of bodies drawn as instances, replacing the automatic selection.
This function must be called before the visual system is initialized.
◆ SetBodySelector()
|
inline |
Set a predicate selecting the bodies drawn as instances, replacing the automatic selection.
This function must be called before the visual system is initialized.
◆ SetBodyShapeSource()
| void chrono::ChMulticoreVisualizationVSG::SetBodyShapeSource | ( | vsg3d::ChInstancedShapesVSG::ShapeSource | source | ) |
Set the source of the shapes drawn for each granular body (default: COLLISION).
This function must be called before the visual system is initialized.
◆ SetBodySizeFactor()
| void chrono::ChMulticoreVisualizationVSG::SetBodySizeFactor | ( | double | factor | ) |
Set the size factor for the automatic selection of granular bodies (default: 10).
Bodies whose size is at most this factor times the median body size are drawn as instances. The resulting size limit also identifies large bodies for the force network. This function must be called before the visual system is initialized.
◆ SetImageOutput()
|
inline |
Enable or disable writing of images (default: false).
Images are written to the output directory as img_00000.bmp, img_00001.bmp, and so on (consecutive numbers). The image of a frame is written during the next call to Render(), so the last frame of a run is written only if Render() is called once more.
◆ SetImageOutputDirectory()
|
inline |
Set the output directory for images (default: ".").
The directory is created if it does not exist.
◆ SetImageOutputFormat()
|
inline |
Set the image format, given as a file extension (default: "bmp").
The supported formats are those of vsgXchange (e.g., bmp, png, jpg, tga). Writing a PNG image is much slower than writing a BMP image.
◆ SetNetworkCapacity()
|
inline |
Set the maximum number of network half-segments (default: 12 times the number of bodies, at most 2e6).
Half-segments beyond this capacity are dropped and counted. This function must be called before the visual system is initialized.
◆ SetNetworkColoring()
| void chrono::ChMulticoreVisualizationVSG::SetNetworkColoring | ( | NetworkColoring | quantity, |
| double | vmin, | ||
| double | vmax | ||
| ) |
Set the quantity used to color the force network and the range of values mapped to colors.
Without an explicit range, the range is [0, 1] for the Coulomb ratio and, for the other quantities, from 0 to the largest value at the current frame.
◆ SetNetworkForceThreshold()
| void chrono::ChMulticoreVisualizationVSG::SetNetworkForceThreshold | ( | double | threshold, |
| bool | relative = false |
||
| ) |
Set the force threshold of the network (default: 0).
Only contacts with a normal force larger than the threshold are drawn. If relative is true, the threshold is a multiple of the mean normal force over all contacts with a positive normal force.
◆ SetRegionBox()
| void chrono::ChMulticoreVisualizationVSG::SetRegionBox | ( | const ChAABB & | box | ) |
Restrict drawing to an axis-aligned box.
A contact is drawn if its contact point is in the box. With SetRegionBodyFiltering(true), a granular body is drawn if its center is in the box. A box and a slab can be combined.
◆ SetRegionSlab()
| void chrono::ChMulticoreVisualizationVSG::SetRegionSlab | ( | const ChVector3d & | point, |
| const ChVector3d & | normal, | ||
| double | half_thickness | ||
| ) |
Restrict drawing to a slab of the specified half-thickness, centered at a point and normal to a direction.
A contact is drawn if its contact point is in the slab. With SetRegionBodyFiltering(true), a granular body is drawn if its center is in the slab.
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono_multicore/visualization/ChMulticoreVisualizationVSG.h
- /builds/uwsbel/chrono/src/chrono_multicore/visualization/ChMulticoreVisualizationVSG.cpp
Public Member Functions inherited from