In addition to the standard RenderProps that control how the nodes and surfaces appear, finite element models and their sub-components have a few additional properties that affect rendering. Some of these are listed in Table 6.7.
|elementWidgetSize||size of element to render|
|directionRenderLen||relative length to draw fibre direction indicator|
|directionRenderType||where to draw directions: ELEMENT, INTEGRATION_POINT|
|surfaceRendering||how to render surface: None, Shaded, Stress, Strain, MAPStress, MAPStrain|
|stressPlotRange||range of values for stress/strain plot|
|stressPlotRanging||how to determine stress/strain plot range: Auto, Fixed|
|colorMap||delegate object controlling the map of stress/strain values to color|
The property elementWidgetSize applies only to FemModel3d and FemElement3d. It specifies the scale to draw each element volume. For instance, the blue beam in Figure 6.17 uses a widget size of 0.8, resulting in a mosaic-like pattern.
The next two properties in Table 6.7 apply to the muscle classes FemMuscleModel, MuscleBundle, and MuscleElementDesc. When directionRenderLen > 0, lines are drawn inside elements to indicate fibre directions. If directionRenderType = ELEMENT, then one line is drawn per element indicating the average contraction direction. If directionRenderType = INTEGRATION_POINT, a separate direction line is drawn per point.
The last four properties apply to
They control how the surface is colored. This can be used to enable stress/strain
visualizations. The property surfaceRendering sets what to draw:
None no surface Shaded the face color specified by the mesh’s RenderProps Stress the von Mises stress Strain the von Mises strain MAPStress Maximum absolute value principal stress MAPStrain Maximum absolute value principal strain
The stressPlotRange controls the range of values to use when plotting stress/strain. Values outside this range are truncated. The colorMap is a delegate object that converts those stress and strain values to colors. Various types of maps exist, including GreyscaleColorMap, HueColorMap, RainbowColorMap, and JetColorMap. These all implement the ColorMap interface.
To display values corresponding to colors, a ColorBar needs to be added to the RootModel. Color bars are general Renderable objects that are only used for visualizations. They are added to the display using the
method in RootModel. Color bars also have a ColorMap associated with it. The following functions are useful for controlling its visualization:
The normalized location specifies sizes relative to the screen size (1 = screen width/height). The location override, if values are non-zero, will override the normalized location, specifying values in absolute pixels. Negative values for position correspond to distances from the left/top. For instance,
will create a bar that is 10% up from the bottom of the screen, 40 pixels from the right edge, with a height occupying 80% of the screen, and width 20 pixels.
Note that the color bar is not associated with any mesh or finite element model. Any synchronization of colors and labels must be done manually by the developer. It is recommended to do this in the RootModel’s prerender(...) method, so that colors are updated every time the model’s rendering configuration changes.
The following model extends FemBeam to render stress, with an added color bar. The loaded model is shown in Figure 6.18.
As mentioned in Section 4.6.5, it is possible to render the contact pressure involved in the collision between two bodies, and this is often particularly desirable in the case of FEM models. A simple example is defined in
which sets the drawColorMap property of the collision behavior to CONTACT_PRESSURE in order to display a color map of the contact pressure. The example is similar to that of Section 4.6.7, which shows how to render penetration depth.
The caveats about color map rendering described in Section 4.6.5 apply. In particular, the resolution of the color map is limited by the resolution of the collision mesh for the collidable on which the map is drawn, and so the application should ensure that this is sufficiently fine. Also, to allow the map to blend properly with the rest of the collidable, the color corresponding to should match the default face color for the collidable.
The complete source code is shown below:
To begin, the demo creates two FEM models: a spherical ball (lines 52-56) and a rectangular sheet (lines 59-66), and then fixes the end nodes of the sheet (lines 69-74). Surface rendering is enabled for the sheet (line 65), but not for the ball, in order to improve the visibility of the color map.
Lines 77-81 create and set a collision behavior between the two models, with the drawColorMap property set to CONTACT_PRESSURE. Because for this example we want the color map to be drawn on the second collidable (the sheet), we set the setColorMapCollidable property to 1 (line 79); otherwise, the default value of 0 would cause the color map to be drawn on the first collidable (the ball). (Alternatively, we could have simply defined the collision behavior as being between the surface and the ball instead of the ball and the sheet.) The color map range is explicitly set to lie between (line 80); this is in contrast to the example in Section 4.6.7, where the range is auto-updated on each step. Other rendering properties are set for the collision manager at lines 83-97, including a custom color map that varies between CREAM (the color of the mesh) for no pressure and dark red for maximum pressure.
At line 100, a color bar is created and added to the scene, using the method createColorBar() (lines 36-45), to explicitly show the pressure that corresponds to the different colors. The color bar is given the same color map and value range used to render the pressure. Finally, default face and line colors for all components in the model are set at lines 105-106.
To run this example in ArtiSynth, select All demos > tutorial > ContactPressureRender from the Models menu. When run, the FEM models will collide and render the contact pressure on the sheet, as shown in Figure 6.19.