chrono::fea::ChElementDrawerDispatcher Class Reference

Description

This object takes care of invoking the proper ChDrawer methods, like UpdateBuffers(), depending on the type of the element.

The reason is that the UpdateBuffers() could be a virtual method from a ChFieldElement base class, but we prefer not to pollute the ChFieldElement base class with stuff that is related to drawing into a ChTriangleMeshConnected. So this ChElementDrawerDispatcher class works like an 'extension' of the polymorphism of finite elements, at the cost of a lookup into hash map that associates element type_index to the corresponding ChDrawerXXYY. [To do performance optimization: since this is invoked many times iterating on a stl container, and most likely elements are stored in sequences of same type_index, the hash lookup in drawers.find(..) could be shortcut by first testing if the last key-value can be reused.]

#include <ChDrawer.h>

Public Member Functions

template<typename T >
void RegisterDrawer (std::unique_ptr< ChDrawer > calc)
 
void IncrementBufferSizes (ChFieldElement &melement, size_t &num_vertexes, size_t &num_triangles, size_t &num_normals)
 This method takes a ChFieldElement and increments the counters of total used number of triangle vertexes, number of triangles, number of normals, used in a triangle mesh that shows the shape of the finite element. More...
 
void UpdateBuffers (ChFieldElement &melement, ChTriangleMeshConnected &mmesh, size_t &vert_offset, size_t &tri_offset, size_t &norm_offset)
 This method takes a ChFieldElement and, given a ChTriangleMeshConnected& mmesh, does this: 1) per each triangle from tri_offset sets the indexes in mmesh.GetIndicesVertexes() to 3 triangle vertexes; 2) per each triangle from tri_offset sets the indexes in mmesh.GetIndicesNormals() to 3 triangle normals; 3) per each normal from norm_offset sets its value in mmesh.GetCoordsNormals() (can be automated via ChDrawer::AutoComputeNormals()); Assumes there is no need to update the position of vertexes in mmesh.GetCoordsVertices() because already update by the caller, that sets the first N triangle vertices as the N finite element nodes - and same for N colors in mmesh.GetCoordsColors(), and N scalars/vectors/etc in myproperty.data of all properties in mmesh.GetPropertiesPerVertex(). More...
 

Member Function Documentation

◆ IncrementBufferSizes()

void chrono::fea::ChElementDrawerDispatcher::IncrementBufferSizes ( ChFieldElement melement,
size_t &  num_vertexes,
size_t &  num_triangles,
size_t &  num_normals 
)
inline

This method takes a ChFieldElement and increments the counters of total used number of triangle vertexes, number of triangles, number of normals, used in a triangle mesh that shows the shape of the finite element.

This function is called on all finite elements, to get the total amount of vertexes, triangles etc. in a ChTriangleMeshConnected that will be used to show finite elements on the screen.

◆ UpdateBuffers()

void chrono::fea::ChElementDrawerDispatcher::UpdateBuffers ( ChFieldElement melement,
ChTriangleMeshConnected mmesh,
size_t &  vert_offset,
size_t &  tri_offset,
size_t &  norm_offset 
)
inline

This method takes a ChFieldElement and, given a ChTriangleMeshConnected& mmesh, does this: 1) per each triangle from tri_offset sets the indexes in mmesh.GetIndicesVertexes() to 3 triangle vertexes; 2) per each triangle from tri_offset sets the indexes in mmesh.GetIndicesNormals() to 3 triangle normals; 3) per each normal from norm_offset sets its value in mmesh.GetCoordsNormals() (can be automated via ChDrawer::AutoComputeNormals()); Assumes there is no need to update the position of vertexes in mmesh.GetCoordsVertices() because already update by the caller, that sets the first N triangle vertices as the N finite element nodes - and same for N colors in mmesh.GetCoordsColors(), and N scalars/vectors/etc in myproperty.data of all properties in mmesh.GetPropertiesPerVertex().

However, if one has more triangle vertexes than N element nodes, there could be an additional task: 4) (optional) per each vertex beyond the N element nodes, interpolate position/color/properties by looking at values already updated in the position/color/properties of the first N vertexes of the mmesh, starting from vert_offset.


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