25#ifndef _MODELS_VERTEX_SOLVER_TFMESHOBJ_H_
26#define _MODELS_VERTEX_SOLVER_TFMESHOBJ_H_
28#include <tf_platform.h>
32#include <unordered_set>
33#include <unordered_map>
37namespace TissueForge::models::vertex {
55 #define MESHOBJ_CLASSDEF(oType) \
57 const int objectId() const { return _objId; } \
60 MeshObjTypeLabel objType() const { return oType; } \
69 HRESULT positionChanged();
71 #define MESHOBJ_INITOBJ \
74 #define MESHOBJ_DELOBJ
76 #define MESHBOJ_DEFINES_DECL(childType) \
77 bool defines(const childType *obj) const; \
79 #define MESHBOJ_DEFINES_DEF(parentAccessor) \
82 for(auto &p : obj->parentAccessor()) \
83 if(p->objectId() == this->objectId()) \
87 #define MESHOBJ_DEFINEDBY_DECL(parentType) \
88 bool definedBy(const parentType *obj) const;
90 #define MESHOBJ_DEFINEDBY_DEF \
91 return obj && obj->defines(this);
102 virtual std::string
name()
const {
return "MeshObjActor"; }
107 static std::string
actorName() {
return "MeshObjActor"; }
116 template <
typename T,
typename O>
117 static std::vector<T*>
get(O *obj) {
118 std::vector<T*> result;
121 for(
auto &a : obj->actors)
122 if(strcmp(a->name().c_str(), T::actorName().c_str()) == 0)
123 result.push_back((T*)a);
166 virtual FVector3
force(
const Body *source,
const Vertex *target) {
return FVector3(0); }
192 virtual std::string
str()
const = 0;
206 virtual std::string
name() {
return "MeshObjTypePairActor"; }
211 static std::string
actorName() {
return "MeshObjTypePairActor"; }
236 bool hasPair(
const int &type1,
const int &type2);
250 std::unordered_map<int, std::unordered_set<int> >
getTypePairs() {
return typePairs; };
254 std::unordered_map<int, std::unordered_set<int> > typePairs;
The mesh body is a volume-enclosing object of mesh surfaces.
Definition tfBody.h:59
Contains all Vertex, Surface and Body instances.
Definition tfMesh.h:52
The mesh surface is an area-enclosed object of implicit mesh edges defined by mesh vertices.
Definition tfSurface.h:65
The mesh vertex is a volume of a mesh centered at a point in a space.
Definition tfVertex.h:71
Base definition of how a mesh object acts on another mesh object.
Definition tfMeshObj.h:97
static std::vector< T * > get(O *obj)
Get a list of actors bound to a mesh object.
Definition tfMeshObj.h:117
virtual FloatP_t energy(const Body *source, const Vertex *target)
Calculate the energy of a source object acting on a target object.
Definition tfMeshObj.h:157
virtual std::string name() const
Name of the actor.
Definition tfMeshObj.h:102
virtual FVector3 force(const Surface *source, const Vertex *target)
Calculate the force that a source object exerts on a target object.
Definition tfMeshObj.h:148
virtual std::string toString()
Get a JSON string representation.
virtual FloatP_t energy(const Surface *source, const Vertex *target)
Calculate the energy of a source object acting on a target object.
Definition tfMeshObj.h:139
static std::string actorName()
Unique name of the actor.
Definition tfMeshObj.h:107
virtual FVector3 force(const Body *source, const Vertex *target)
Calculate the force that a source object exerts on a target object.
Definition tfMeshObj.h:166
Base mesh object type definition.
Definition tfMeshObj.h:176
std::vector< MeshObjActor * > actors
Definition tfMeshObj.h:182
virtual std::string str() const =0
Get a summary string.
virtual MeshObjTypeLabel objType() const =0
Get the mesh object type.
Base definition of how a mesh object of a type acts on another mesh object through interactions with ...
Definition tfMeshObj.h:201
virtual std::string name()
Name of the actor.
Definition tfMeshObj.h:206
bool hasPair(MeshObjType *type1, MeshObjType *type2)
Test whether a pair of types is registered with this actor.
HRESULT registerPair(MeshObjType *type1, MeshObjType *type2)
Register a pair of types for this actor.
HRESULT registerPair(const int &type1, const int &type2)
Register a pair of types for this actor.
bool hasPair(const int &type1, const int &type2)
Test whether a pair of types is registered with this actor.
std::unordered_map< int, std::unordered_set< int > > getTypePairs()
Get the type pair data.
Definition tfMeshObj.h:250
static std::string actorName()
Unique name of the actor.
Definition tfMeshObj.h:211
int32_t HRESULT
Definition tf_port.h:255
MeshObjTypeLabel
Mesh object type enum.
Definition tfMeshObj.h:48