Description
Generic finite element drawing interface.
The idea is that, after you implement some element inherited from ChFieldElement, you can (optionally) implement a concrete class inherited from this ChDrawer, where you take care of how the element is drawn on the screen. Note that methods of this class will be most often called indirectly, through the ChElementDrawerDispatcher that takes care of invoking the proper drawing functions depending on the type of the element; for this reason your ChDrawer classes must be registered in such dispatcher via RegisterDrawer(..) for the element to appear on the screen.
#include <ChDrawer.h>

Public Member Functions | |
| virtual void | IncrementBufferSizes (ChFieldElement &melement, size_t &num_vertexes, size_t &num_triangles, size_t &num_normals) const =0 |
| 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... | |
| virtual void | UpdateBuffers (ChFieldElement &melement, ChTriangleMeshConnected &mmesh, size_t &vert_offset, size_t &tri_offset, size_t &norm_offset) const =0 |
| 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... | |
Protected Member Functions | |
| void | AutoComputeNormals (ChTriangleMeshConnected &mmesh, const size_t tri_offset, const size_t norm_offset, const size_t num_triangles, const size_t num_normals) const |
| This is a helper function that can be called at the end of each element's UpdateBuffers(), to avoid setting all normals with ad-hoc formulas. More... | |
Member Function Documentation
◆ AutoComputeNormals()
|
inlineprotected |
This is a helper function that can be called at the end of each element's UpdateBuffers(), to avoid setting all normals with ad-hoc formulas.
The ratio is that AutoComputeNormals() just iterates through all triangles, compute a auxiliary triangle normal, then average those auxiliary triangle normals to get the normals at vertexes - if vertexes share normals. In most cases this gives a good result and auto-smoothes curved surfaces avoiding the faceted look. Note that if you do not want triangle edges tobe 'smoothed', as in the case of hexahedrons where the square edges must be sharp and the edges inside the eight faces must be smoothed, in IncrementBufferSizes() and UpdateBuffers() you must
setup normal indices so that triangles joined at a sharp edge do NOT share normals at the two edge vertices; that's why ChDrawerHexahedron_8 assumes 24 independent normals, as 4 per face x 6 faces, not 1 per the 8 vertices.
◆ IncrementBufferSizes()
|
pure virtual |
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.
Implemented in chrono::fea::ChDrawerHexahedron_8, and chrono::fea::ChDrawerTetrahedron_4.
◆ UpdateBuffers()
|
pure virtual |
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.
Implemented in chrono::fea::ChDrawerHexahedron_8, and chrono::fea::ChDrawerTetrahedron_4.
The documentation for this class was generated from the following file:
- /builds/uwsbel/chrono/src/chrono/fea/ChDrawer.h