25#ifndef _MODELS_VERTEX_SOLVER_TFMESHSOLVER_H_
26#define _MODELS_VERTEX_SOLVER_TFMESHSOLVER_H_
33#include <tfSubEngine.h>
37namespace TissueForge::models::vertex {
64 static FVector3 VertexForce(
const Vertex *v) {
66 VertexForce(v, f.data());
103 double ms(
const Section §ion,
const bool &avg=
true)
const;
109 for(
size_t i = 0; i < Section::LAST; i++) timers[i] = 0;
120 ticks timers[Section::LAST];
150 const char *name =
"MeshSolver";
321 static std::vector<MeshLogEvent>
getLog() {
322 return MeshLogger::events();
333 static HRESULT log(
const MeshLogEventType &type,
const std::vector<int> &objIDs,
const std::vector<MeshObjTypeLabel> &objTypes,
const std::string &name=
"");
340 unsigned int _bufferSize;
341 unsigned int _surfaceVertices;
342 unsigned int _totalVertices;
344 std::mutex _engineLock;
345 std::vector<unsigned int> _surfaceVertexIndices;
347 std::vector<BodyType*> _bodyTypes;
348 std::vector<SurfaceType*> _surfaceTypes;
354 bool _isDirtyInst()
const;
357 HRESULT _setDirtyInst(
const bool &_isDirty);
360 Mesh *_newMeshInst();
375 SurfaceType *_findSurfaceFromNameInst(
const std::string &_name);
378 BodyType *_findBodyFromNameInst(
const std::string &_name);
381 BodyType *_getBodyTypeInst(
const unsigned int &typeId)
const;
384 SurfaceType *_getSurfaceTypeInst(
const unsigned int &typeId)
const;
387 HRESULT _positionChangedInst();
390 std::vector<unsigned int> _getSurfaceVertexIndicesInst()
const;
393 HRESULT _getSurfaceVertexIndicesAsyncStartInst();
396 std::vector<unsigned int> _getSurfaceVertexIndicesAsyncJoinInst();
399 HRESULT _logInst(
const MeshLogEventType &type,
const std::vector<int> &objIDs,
const std::vector<MeshObjTypeLabel> &objTypes,
const std::string &name=
"");
Contains all Vertex, Surface and Body instances.
Definition tfMesh.h:52
Convenience class to time mesh solver performance.
Definition tfMeshSolver.h:130
The mesh vertex is a volume of a mesh centered at a point in a space.
Definition tfVertex.h:71
A SubEngine is a singleton object that injects dynamics into the Tissue Forge engine....
Definition tfSubEngine.h:36
Mesh body type.
Definition tfBody.h:608
Definition tfMeshRenderer.h:35
Vertex model mesh solver.
Definition tfMeshSolver.h:148
static HRESULT getSurfaceVertexIndicesAsyncStart()
Start getting the starting vertex index for each surface.
static const int numBodyTypes()
Get the number of registered body types.
static HRESULT init()
Initialize the solver.
static bool is3D()
Test whether the mesh is 3D.
static unsigned int sizeBodies()
Get the size of the list of bodies.
static unsigned int numSurfaces()
Get the number of surfaces.
static HRESULT registerType(BodyType *_type)
Register a body type.
static Mesh * getMesh()
Get the mesh.
HRESULT preStepJoin() override
Last call before forces are calculated for a step.
static const int numSurfaceTypes()
Get the number of registered surface types.
static HRESULT log(const MeshLogEventType &type, const std::vector< int > &objIDs, const std::vector< MeshObjTypeLabel > &objTypes, const std::string &name="")
Log an event.
static unsigned int numBodies()
Get the number of bodies.
static HRESULT positionChanged()
Update internal data due to a change in position.
static HRESULT engineUnlock()
Unlocks the engine for thread-safe engine operations.
static HRESULT compact()
Reduce internal buffers and storage.
static HRESULT update(const bool &_force=false)
Update the solver if dirty.
MeshSolverTimers timers
Definition tfMeshSolver.h:155
HRESULT postStepStart() override
First call after forces are calculated, and before events are executed, for a step.
static std::vector< unsigned int > getSurfaceVertexIndicesAsyncJoin()
Finish getting the starting vertex index for each surface.
HRESULT postStepJoin() override
Last call after forces are calculated, and before events are executed, for a step.
static HRESULT registerType(SurfaceType *_type)
Register a surface type.
static std::vector< unsigned int > getSurfaceVertexIndices()
Get the starting vertex index for each surface.
static MeshSolver * get()
Get the solver singleton.
HRESULT preStepStart() override
First call before forces are calculated for a step.
static BodyType * findBodyFromName(const std::string &_name)
Find a registered body type by name.
static SurfaceType * findSurfaceFromName(const std::string &_name)
Find a registered surface type by name.
static SurfaceType * getSurfaceType(const unsigned int &typeId)
Get a surface type by id.
static std::vector< MeshLogEvent > getLog()
Get the current logger events.
Definition tfMeshSolver.h:321
static bool isDirty()
Test whether the current mesh state needs updated.
static unsigned int sizeSurfaces()
Get the size of the list of surfaces.
static HRESULT engineLock()
Locks the engine for thread-safe engine operations.
static unsigned int sizeVertices()
Get the size of the list of vertices.
static HRESULT setDirty(const bool &_isDirty)
static unsigned int numVertices()
Get the number of vertices.
static BodyType * getBodyType(const unsigned int &typeId)
Get a body type by id.
Mesh solver performance timers.
Definition tfMeshSolver.h:74
HRESULT reset()
Reset the timers.
Definition tfMeshSolver.h:108
HRESULT append(const Section §ion, const ticks _ticks)
Append time to a section.
Definition tfMeshSolver.h:94
std::string str() const
Get a string representation of the current timer average values.
Section
Solver routine sections.
Definition tfMeshSolver.h:79
double ms(const Section §ion, const bool &avg=true) const
Get the recorded runtime of a solver section, in ms.
Mesh surface type.
Definition tfSurface.h:1099
int32_t HRESULT
Definition tf_port.h:255
MeshLogEventType
Types of log events.
Definition tfMeshLogger.h:45
HRESULT VertexForce(const Vertex *v, FloatP_t *f)
Calculate the force on a vertex.