25#ifndef _MODELS_VERTEX_SOLVER_TFBODY_H_
26#define _MODELS_VERTEX_SOLVER_TFBODY_H_
34#include <io/tfThreeDFMeshData.h>
37namespace TissueForge::models::vertex {
59 class CAPI_EXPORT Body {
72 std::vector<Surface*> surfaces;
98 static BodyHandle
create(
const std::vector<SurfaceHandle> &_surfaces);
103 MESHOBJ_DEFINEDBY_DECL(Vertex);
104 MESHOBJ_DEFINEDBY_DECL(
Surface);
105 MESHOBJ_CLASSDEF(MeshObjTypeLabel::BODY)
242 void setDensity(
const FloatP_t &_density) { density = _density; }
257 const FloatP_t&
getArea()
const {
return area; }
267 FloatP_t
getMass()
const {
return volume * density; }
345 struct CAPI_EXPORT BodyHandle {
349 BodyHandle(
const int &_id=-1);
596 BodyHandle
split(
const FVector3 &cp_pos,
const FVector3 &cp_norm,
SurfaceType *stype=NULL);
598 operator bool()
const {
return id >= 0; }
616 BodyType(
const bool &noReg=
false);
626 virtual std::string
str()
const override;
708 BodyHandle operator() (
const std::vector<SurfaceHandle> &surfaces);
735 std::vector<int> _instanceIds;
743 inline bool operator==(
const TissueForge::models::vertex::Body& lhs,
const TissueForge::models::vertex::Body& rhs) {
return lhs.objectId() == rhs.objectId(); }
744 inline bool operator!=(
const TissueForge::models::vertex::Body& lhs,
const TissueForge::models::vertex::Body& rhs) {
return !(lhs == rhs); }
746 inline bool operator< (
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return lhs.id < rhs.id; }
747 inline bool operator> (
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return rhs < lhs; }
748 inline bool operator<=(
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return !(lhs > rhs); }
749 inline bool operator>=(
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return !(lhs < rhs); }
750 inline bool operator==(
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return lhs.id == rhs.id; }
751 inline bool operator!=(
const TissueForge::models::vertex::BodyHandle& lhs,
const TissueForge::models::vertex::BodyHandle& rhs) {
return !(lhs == rhs); }
753 inline bool operator< (
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return lhs.
id < rhs.
id; }
754 inline bool operator> (
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return rhs < lhs; }
755 inline bool operator<=(
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return !(lhs > rhs); }
756 inline bool operator>=(
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return !(lhs < rhs); }
757 inline bool operator==(
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return lhs.
id == rhs.
id; }
758 inline bool operator!=(
const TissueForge::models::vertex::BodyType& lhs,
const TissueForge::models::vertex::BodyType& rhs) {
return !(lhs == rhs); }
765 os << o.
str().c_str();
771 os << o.
str().c_str();
780 return hash<int>()(h.id);
The mesh body is a volume-enclosing object of mesh surfaces.
Definition tfBody.h:59
const FloatP_t & getVolume() const
Get the volume.
Definition tfBody.h:262
bool isOutside(const FVector3 &pos) const
Test whether a point is outside. Test is performed using the nearest surface.
std::string toString()
Get a JSON string representation.
FloatP_t getVertexMass(const Vertex *v) const
Get the mass contribution of a vertex to this body.
Definition tfBody.h:288
const FloatP_t & getDensity() const
Get the mass density.
Definition tfBody.h:235
HRESULT add(Surface *s)
Add a surface.
BodyType * type() const
Get the body type.
HRESULT remove(Surface *s)
Remove a surface.
std::vector< Body * > adjacentBodies() const
Get the adjacent bodies.
Surface * findSurface(const FVector3 &dir) const
Find a surface that defines this body.
std::vector< MeshObjActor * > actors
Definition tfBody.h:89
std::vector< Surface * > neighborSurfaces(const Surface *s) const
Get the neighboring surfaces of a surface on this body.
std::vector< Body * > connectedBodies() const
Get the connected bodies.
state::StateVector * species
Definition tfBody.h:92
static BodyHandle create(const std::vector< SurfaceHandle > &_surfaces)
const FloatP_t & getArea() const
Get the surface area.
Definition tfBody.h:257
FloatP_t getVertexArea(const Vertex *v) const
Get the surface area contribution of a vertex to this body.
const std::vector< Surface * > & getSurfaces() const
Get the surfaces that define the body.
Definition tfBody.h:188
void updateInternals()
Update all internal data and parents.
std::vector< Surface * > findInterface(const Body *b) const
Get the surfaces that define the interface between this body and another body.
std::string str() const
Get a summary string.
static BodyHandle create(TissueForge::io::ThreeDFMeshData *ioMesh)
HRESULT replace(Surface *toInsert, Surface *toRemove)
Replace a surface with a surface.
FloatP_t getVertexVolume(const Vertex *v) const
Get the volume contribution of a vertex to this body.
FloatP_t getMass() const
Get the mass.
Definition tfBody.h:267
const FVector3 & getCentroid() const
Get the centroid.
Definition tfBody.h:247
int typeId
Definition tfBody.h:67
std::vector< Vertex * > getVertices() const
Get the vertices that define the body.
Vertex * findVertex(const FVector3 &dir) const
Find a vertex that defines this body.
void setDensity(const FloatP_t &_density)
Set the mass density.
Definition tfBody.h:242
std::vector< Vertex * > sharedVertices(const Body *other) const
Get the vertices that define both this body and another body.
FloatP_t contactArea(const Body *other) const
Get the contacting surface area of this body with another body.
Body * split(const FVector3 &cp_pos, const FVector3 &cp_norm, SurfaceType *stype=NULL)
Split into two bodies. The split is defined by a cut plane.
FVector3 getVelocity() const
Get the velocity, calculated as the velocity of the centroid.
HRESULT become(BodyType *btype)
Become a different type.
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
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
3D data file mesh data
Definition tfThreeDFMeshData.h:43
A handle to a Body.
Definition tfBody.h:345
bool definedBy(const VertexHandle &v) const
Test whether defined by a vertex.
std::string toString()
Get a JSON string representation.
BodyHandle split(const FVector3 &cp_pos, const FVector3 &cp_norm, SurfaceType *stype=NULL)
Split into two bodies. The split is defined by a cut plane.
VertexHandle findVertex(const FVector3 &dir) const
Find a vertex that defines this body.
BodyType * type() const
Get the body type.
HRESULT add(const SurfaceHandle &s)
Add a surface.
FVector3 getVelocity() const
Get the velocity, calculated as the velocity of the centroid.
FloatP_t getVertexVolume(const VertexHandle &v) const
Get the volume contribution of a vertex to this body.
MeshObjTypeLabel objType() const
Get the mesh object type.
Definition tfBody.h:375
FloatP_t getDensity() const
Get the mass density.
std::vector< SurfaceHandle > getSurfaces() const
Get the surfaces that define the body.
std::vector< BodyHandle > connectedBodies() const
Get the connected bodies.
std::vector< BodyHandle > adjacentBodies() const
Get the adjacent bodies.
FVector3 getCentroid() const
Get the centroid.
std::vector< SurfaceHandle > neighborSurfaces(const SurfaceHandle &s) const
Get the neighboring surfaces of a surface on this body.
std::string str() const
Get a summary string.
FloatP_t getVertexArea(const VertexHandle &v) const
Get the surface area contribution of a vertex to this body.
std::vector< VertexHandle > sharedVertices(const BodyHandle &other) const
Get the vertices that define both this body and another body.
HRESULT positionChanged()
Update internal data due to a change in position.
state::StateVector * getSpecies() const
Get the amount of species in the enclosed volume, if any.
HRESULT become(BodyType *btype)
Become a different type.
bool validate()
Validate the body.
std::vector< VertexHandle > getVertices() const
Get the vertices that define the body.
FloatP_t getMass() const
Get the mass.
FloatP_t getVolume() const
Get the volume.
bool isOutside(const FVector3 &pos) const
Test whether a point is outside. Test is performed using the nearest surface.
std::vector< SurfaceHandle > findInterface(const BodyHandle &b) const
Get the surfaces that define the interface between this body and another body.
static BodyHandle fromString(const std::string &s)
Create an instance from a JSON string representation.
HRESULT destroy()
Destroy the body.
void setDensity(const FloatP_t &_density)
Set the mass density.
HRESULT replace(const SurfaceHandle &toInsert, const SurfaceHandle &toRemove)
Replace a surface with a surface.
HRESULT setSpecies(state::StateVector *s) const
Set the amount of species in the enclosed volume.
FloatP_t contactArea(const BodyHandle &other) const
Get the contacting surface area of this body with another body.
HRESULT remove(const SurfaceHandle &s)
Remove a surface.
bool definedBy(const SurfaceHandle &s) const
Test whether defined by a surface.
FloatP_t getArea() const
Get the surface area.
SurfaceHandle findSurface(const FVector3 &dir) const
Find a surface that defines this body.
Body * body() const
Get the underlying object, if any.
FloatP_t getVertexMass(const VertexHandle &v) const
Get the mass contribution of a vertex to this body.
Mesh body type.
Definition tfBody.h:608
std::vector< int > getInstanceIds()
list of instances ids that belong to this type
Definition tfBody.h:698
std::vector< BodyHandle > getInstances()
list of instances that belong to this type
BodyHandle extrude(const SurfaceHandle &base, const FloatP_t &normLen)
Create a body from a surface in a mesh by extruding along the outward-facing normal of the surface.
virtual BodyType * get()
Get the type engine instance.
bool isRegistered()
Tests whether this type is registered.
unsigned int getNumInstances()
number of instances that belong to this type
virtual std::string str() const override
Get a summary string.
HRESULT remove(const BodyHandle &i)
Remove an instance.
std::string name
Definition tfBody.h:611
static BodyType * findFromName(const std::string &_name)
static BodyType * fromString(const std::string &str)
Create from a JSON string representation.
virtual void on_register()
A callback for when a type is registered.
Definition tfBody.h:655
HRESULT remove(const std::vector< BodyHandle > &i)
Remove instances.
std::string toString()
Get a JSON string representation.
FloatP_t density
Definition tfBody.h:614
MeshObjTypeLabel objType() const override
Get the mesh object type.
Definition tfBody.h:621
virtual HRESULT registerType()
Registers a type with the engine.
HRESULT add(const BodyHandle &i)
Add an instance.
BodyHandle extend(const SurfaceHandle &base, const FVector3 &pos)
Create a body from a surface in the mesh and a position.
Base mesh object type definition.
Definition tfMeshObj.h:176
int id
Definition tfMeshObj.h:179
A handle to a Surface.
Definition tfSurface.h:630
Mesh surface type.
Definition tfSurface.h:1099
A handle to a Vertex.
Definition tfVertex.h:493
A state vector of an object.
Definition tfStateVector.h:50
int32_t HRESULT
Definition tf_port.h:255
MeshObjTypeLabel
Mesh object type enum.
Definition tfMeshObj.h:48