Description

Attach this visual asset to a ChPhysicsItem (ex.a ChDomain) in order to provide an automatic visualization of finite elements of a ChDomain, as 3D triangle meshes that can be rendered.

If the visualization system supports ChVisualShapeTriangleMesh, this will be rendered (ex. in Irrlicht 3d view, but also in Blender postprocessing etc.) The system is modular and expandable, so that you can visualize properties such as stress, strain, speed, acceleration, temperature etc., by adding ChVisualDataExtractor objects to this visual asset. Note that conversion of finite elements into triangle meshes is obtained through a modular expandable system based on ChDrawer objects, registered into a ChElementDrawerDispatcher; if the user defines a new finite element "Foo", then he also needs to implement the corresponding ChDrawerFoo class that generates its triangle mesh representation, and he also needs to register ChDrawerFoo into ChElementDrawerDispatcher, otherwise the element will be invisible.

#include <ChDrawer.h>

Inheritance diagram for chrono::fea::ChVisualDomainMesh:
Collaboration diagram for chrono::fea::ChVisualDomainMesh:

Public Member Functions

 ChVisualDomainMesh (std::shared_ptr< ChDomain > adomain)
 
void AddPropertyExtractor (const ChVisualDataExtractorScalarBase &mextractor, double min=0, double max=1, std::string mname="Scalar")
 Attach a scalar property extractor. More...
 
void AddPropertyExtractor (const ChVisualDataExtractorVectorBase &mextractor, double min=0, double max=1, std::string mname="Vect")
 Attach a vector property extractor. More...
 
void AddPositionExtractor (const ChVisualDataExtractorVectorBase &mextractor)
 
void SetColormap (const ChColormap &mcmap)
 Set the colormap for rendering the property via falsecolor.

 
void SetColormap (const ChColor &col)
 Set the color for rendering the glyphs as constant uniform color. More...
 
void SetShrinkElements (bool shrink, double factor)
 Set shrinkage of elements during drawing.
 
ChElementDrawerDispatcherGetElementDispatcher ()
 
- Public Member Functions inherited from chrono::ChVisualShapeTriangleMesh
 ChVisualShapeTriangleMesh (std::shared_ptr< ChTriangleMeshConnected > mesh, bool load_materials=true)
 
void SetMesh (std::shared_ptr< ChTriangleMeshConnected > mesh, bool load_materials=true)
 Associate the mesh asset with a triangle mesh geometry. More...
 
std::shared_ptr< ChTriangleMeshConnectedGetMesh () const
 Get triangle mesh geometry associated to visual shape.
 
bool IsWireframe () const
 
void SetWireframe (bool mw)
 
bool IsBackfaceCull () const
 
void SetBackfaceCull (bool mbc)
 
const std::string & GetName () const
 
void SetName (const std::string &mname)
 
const ChVector3dGetScale () const
 
void SetScale (const ChVector3d &mscale)
 
bool IsFixedConnectivity () const
 
void SetFixedConnectivity ()
 
const std::vector< int > & GetModifiedVertices () const
 
void SetModifiedVertices (const std::vector< int > &vertices)
 
virtual ChAABB GetBoundingBox () const override
 Get the shape bounding box.
 
virtual void ArchiveOut (ChArchiveOut &archive_out) override
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIn (ChArchiveIn &archive_in) override
 Method to allow de-serialization of transient data from archives.
 
- Public Member Functions inherited from chrono::ChVisualShape
void SetVisible (bool mv)
 Set this visualization asset as visible.
 
bool IsVisible () const
 Return true if the asset is set as visible.
 
void SetColor (const ChColor &col)
 Set the diffuse color for this shape. More...
 
ChColor GetColor () const
 Return the diffuse color of the first material in the list of materials for this shape. More...
 
void SetOpacity (float val)
 Set opacity for this shape (0: fully transparent; 1: fully opaque). More...
 
float GetOpacity () const
 Get opacity of the first material in the list of materials for this shape. More...
 
void SetTexture (const std::string &filename, float scale_x=1, float scale_y=1)
 Set the diffuse texture map for this shape. More...
 
std::string GetTexture () const
 Return the diffuse texture map of the first material in the list of materials for this shape. More...
 
void SetMutable (bool val)
 Set this visualization shape as modifiable (default: false). More...
 
bool IsMutable () const
 Return true if the visualization shape is marked as modifiable.
 
void SetDoubleFaced (bool val)
 Set shape rendering as double-faced (default: false).
 
bool IsDoubleFaced () const
 Return true if the visualization shape must be rendered double-faced.
 
int AddMaterial (std::shared_ptr< ChVisualMaterial > material)
 Add a visualization material and return its index in the list of materials.
 
void SetMaterial (int i, std::shared_ptr< ChVisualMaterial > material)
 Replace the material with specified index. More...
 
std::vector< std::shared_ptr< ChVisualMaterial > > & GetMaterials ()
 Get the list of visualization materials.
 
std::shared_ptr< ChVisualMaterialGetMaterial (int i) const
 Get the specified material in the list.
 
unsigned int GetNumMaterials () const
 Get the number of visualization materials.
 

Protected Member Functions

virtual void Update (ChObj *updater, const ChFrame<> &frame) override
 This Update() is called automatically by the parent ChPhysicsItem all time that the system needs to update the visual assets. More...
 

Protected Attributes

std::shared_ptr< ChVisualDataExtractorVectorBaseextractor_position
 
std::vector< std::pair< std::shared_ptr< ChVisualDataExtractorScalarBase >, ChPropertyScalar * > > extractors_scalar_properties
 
std::vector< std::pair< std::shared_ptr< ChVisualDataExtractorVectorBase >, ChPropertyVector * > > extractors_vector_properties
 
std::shared_ptr< ChDomainmdomain
 
ChElementDrawerDispatcher elem_dispatcher
 
ChColormap colormap
 
bool use_colormap
 
int i_scalar_prop_colorized
 
int i_vector_prop_colorized
 
bool shrink_elements
 
double shrink_factor
 
- Protected Attributes inherited from chrono::ChVisualShape
bool is_visible
 shape visibility flag
 
bool is_mutable
 flag indicating whether the shape is rigid or deformable
 
bool is_double_faced
 flag indicating that the shape should be rendered double-faced
 
std::vector< std::shared_ptr< ChVisualMaterial > > material_list
 list of visualization materials
 

Member Function Documentation

◆ AddPropertyExtractor() [1/2]

void chrono::fea::ChVisualDomainMesh::AddPropertyExtractor ( const ChVisualDataExtractorScalarBase mextractor,
double  min = 0,
double  max = 1,
std::string  mname = "Scalar" 
)
inline

Attach a scalar property extractor.

Every time step, the scalar values from the extractor will be fetched and stored in the corresponding ChProperty attached to the triangle mesh, with proper interpolation. If you added more than one property via AddPropertyExtractor(), by default the last one will be used for the falsecolor rendering.

◆ AddPropertyExtractor() [2/2]

void chrono::fea::ChVisualDomainMesh::AddPropertyExtractor ( const ChVisualDataExtractorVectorBase mextractor,
double  min = 0,
double  max = 1,
std::string  mname = "Vect" 
)
inline

Attach a vector property extractor.

Every time step, the vector values from the extractor will be fetched and stored in the corresponding ChProperty attached to the triangle mesh, with proper interpolation. If you added more than one property via AddPropertyExtractor(), by default the last one will be used for the falsecolor rendering.

◆ SetColormap()

void chrono::fea::ChVisualDomainMesh::SetColormap ( const ChColor col)
inline

Set the color for rendering the glyphs as constant uniform color.

This disables the colormap falsecolor rendering.

◆ Update()

virtual void chrono::fea::ChVisualDomainMesh::Update ( ChObj updater,
const ChFrame<> &  frame 
)
inlineoverrideprotectedvirtual

This Update() is called automatically by the parent ChPhysicsItem all time that the system needs to update the visual assets.

The main task of this Update is to generate/update the triangle mesh that represents the visualization of the finite elements of the domain.

Reimplemented from chrono::ChVisualShape.


The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono/fea/ChDrawer.h