25#ifndef _MODELS_VERTEX_SOLVER_TFSURFACE_H_
26#define _MODELS_VERTEX_SOLVER_TFSURFACE_H_
31#include <rendering/tfStyle.h>
35#include <io/tfThreeDFFaceData.h>
40namespace TissueForge::models::vertex {
84 std::vector<Vertex*> vertices;
102 FloatP_t _volumeContr;
143 static std::vector<SurfaceHandle>
create(
const std::vector<std::vector<VertexHandle> > &_vertices);
150 static std::vector<SurfaceHandle>
create(
const std::vector<TissueForge::io::ThreeDFFaceData*> &_faces);
152 MESHBOJ_DEFINES_DECL(
Body);
153 MESHOBJ_DEFINEDBY_DECL(
Vertex);
154 MESHOBJ_CLASSDEF(MeshObjTypeLabel::SURFACE)
159 std::
string str() const;
164 std::
string toString();
298 std::vector<
Body*> getBodies() const;
303 const std::vector<
Vertex*>& getVertices()
const {
return vertices; }
399 const FloatP_t&
getArea()
const {
return area; }
416 void setDensity(
const FloatP_t &_density) { density = _density; }
421 FloatP_t
getMass()
const {
return area * density; }
544 static HRESULT sew(
const std::vector<Surface*>& _surfaces,
const FloatP_t &distCf=0.01);
557 static HRESULT sew(
const std::vector<SurfaceHandle>& _surfaces,
const FloatP_t &distCf=0.01);
1089 operator bool()
const {
return id >= 0; }
1116 SurfaceType(
const FloatP_t &flatLam,
const FloatP_t &convexLam,
const bool &noReg=
false);
1129 virtual std::string
str()
const override;
1245 std::vector<SurfaceHandle> operator() (
const std::vector<std::vector<VertexHandle> >& _vertices);
1252 std::vector<SurfaceHandle> operator() (
const std::vector<std::vector<FVector3> > &_positions);
1260 std::vector<SurfaceHandle> operator() (
const std::vector<TissueForge::io::ThreeDFFaceData*>& faces,
const bool& safe=
true);
1285 std::vector<int> _instanceIds;
1315 os << o.
str().c_str();
1321 os << o.
str().c_str();
1330 return hash<int>()(h.id);
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
const FloatP_t & getPerimeter() const
Get the perimeter.
Definition tfSurface.h:404
std::vector< Surface * > neighborSurfaces() const
Connected surfaces on the same body.
static HRESULT sew(const SurfaceHandle &s1, const SurfaceHandle &s2, const FloatP_t &distCf=0.01)
Sew two surfaces.
Surface * extend(const unsigned int &vertIdxStart, const FVector3 &pos)
Create a surface from two vertices and a position.
FloatP_t getVertexMass(const Vertex *v) const
Get the mass contribution of a vertex to this surface; only used in 2D simulation.
Definition tfSurface.h:456
Vertex * findVertex(const FVector3 &dir) const
Find a vertex that defines this surface.
state::StateVector * species1
Definition tfSurface.h:113
FVector3 getNormal() const
Get the surface normal.
const FVector3 & getVelocity() const
Get the velocity, calculated as the velocity of the centroid.
Definition tfSurface.h:394
int typeId
Definition tfSurface.h:73
std::vector< unsigned int > contiguousVertexLabels(const Surface *other) const
Get the integer labels of the contiguous vertices that this surface shares with another surface.
static HRESULT sew(const std::vector< SurfaceHandle > &_surfaces, const FloatP_t &distCf=0.01)
Sew a set of surfaces.
static std::vector< SurfaceHandle > create(const std::vector< TissueForge::io::ThreeDFFaceData * > &_faces)
Construct surfaces from faces.
Body * findBody(const FVector3 &dir) const
Find a body that this surface defines.
FloatP_t normalDistance(const FVector3 &pos) const
Get the normal distance to a point.
std::vector< Surface * > connectedSurfaces() const
Surfaces that share at least one vertex.
static std::vector< SurfaceHandle > create(const std::vector< std::vector< VertexHandle > > &_vertices)
Construct surfaces from sets of vertices.
static SurfaceHandle create(TissueForge::io::ThreeDFFaceData *face)
Construct a surface from a face.
unsigned int numSharedContiguousVertexSets(const Surface *other) const
Get the number of contiguous vertex sets that this surface shares with another surface.
void setDensity(const FloatP_t &_density)
Set the mass density; only used in 2D simulation.
Definition tfSurface.h:416
HRESULT merge(Surface *toRemove, const std::vector< FloatP_t > &lenCfs)
Merge with a surface. The passed surface is destroyed.
FloatP_t volumeSense(const Body *body) const
Get the sign of the volume contribution to a body that this surface contributes.
bool contains(const FVector3 &pos) const
Test whether the surface contains a point.
Surface * split(Vertex *v1, Vertex *v2)
Split into two surfaces.
const FloatP_t & getArea() const
Get the area.
Definition tfSurface.h:399
std::vector< Vertex * > sharedContiguousVertices(const Surface *other, const unsigned int &edgeLabel) const
Get the vertices of a contiguous shared vertex set with another surface.
FloatP_t getMass() const
Get the mass; only used in 2D simulation.
Definition tfSurface.h:421
bool isOutside(const FVector3 &pos) const
Test whether a point is on the outer side.
rendering::Style * style
Definition tfSurface.h:119
static HRESULT sew(Surface *s1, Surface *s2, const FloatP_t &distCf=0.01)
Sew two surfaces.
bool contains(const FVector3 &pos, Vertex **v0, Vertex **v1) const
Test whether the surface contains a point.
const FVector3 & getCentroid() const
Get the centroid.
Definition tfSurface.h:389
Surface * split(const FVector3 &cp_pos, const FVector3 &cp_norm)
Split into two surfaces.
std::vector< MeshObjActor * > actors
Definition tfSurface.h:110
std::vector< Vertex * > connectingVertices(const Surface *other) const
Vertices defining this and another surface.
FVector3 triangleNormal(const unsigned int &idx) const
Get the normal of a triangle.
FVector3 getOutwardNormal(const Body *body) const
Get the outward facing normal w.r.t. a body.
state::StateVector * species2
Definition tfSurface.h:116
std::vector< Surface * > connectedSurfaces(const std::vector< Vertex * > &verts) const
Surfaces that share at least one vertex in a set of vertices.
static SurfaceHandle create(const std::vector< VertexHandle > &_vertices)
Construct a surface from a set of vertices.
const FVector3 & getUnnormalizedNormal() const
Get the surface unnormalized normal.
Definition tfSurface.h:384
std::tuple< Vertex *, Vertex * > neighborVertices(const Vertex *v) const
Connected vertices on the same surface.
Surface * extrude(const unsigned int &vertIdxStart, const FloatP_t &normLen)
Create a surface from two vertices of a surface in a mesh by extruding along the normal of the surfac...
std::string str() const
Get a summary string.
const FloatP_t & getDensity() const
Get the mass density; only used in 2D simulation.
Definition tfSurface.h:409
static HRESULT sew(const std::vector< Surface * > &_surfaces, const FloatP_t &distCf=0.01)
Sew a set of surfaces.
FloatP_t getVolumeContr(const Body *body) const
Get the volume that this surface contributes to a body.
Definition tfSurface.h:435
FloatP_t getVertexArea(const Vertex *v) const
Get the area that a vertex contributes to this surface.
static bool testSew(Surface *s1, Surface *s2, const FloatP_t &distCf, std::vector< int > &indicesMatched)
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 face data
Definition tfThreeDFFaceData.h:41
A handle to a Body.
Definition tfBody.h:345
Mesh body type.
Definition tfBody.h:608
Base mesh object type definition.
Definition tfMeshObj.h:176
int id
Definition tfMeshObj.h:179
A handle to a Surface.
Definition tfSurface.h:630
Surface * surface() const
Get the underlying object, if any.
void setDensity(const FloatP_t &_density) const
Set the mass density; only used in 2D simulation.
std::tuple< VertexHandle, VertexHandle > neighborVertices(const VertexHandle &v) const
Connected vertices on the same surface.
state::StateVector * getSpeciesOutward() const
Get the species on outward-facing side of the surface, if any.
static SurfaceHandle fromString(const std::string &s)
Create an instance from a JSON string representation.
FloatP_t getPerimeter() const
Get the perimeter.
state::StateVector * getSpeciesInward() const
Get the species on inward-facing side of the surface, if any.
std::vector< SurfaceHandle > neighborSurfaces() const
Connected surfaces on the same body.
HRESULT setStyle(rendering::Style *s) const
Set the surface style.
FloatP_t normalDistance(const FVector3 &pos) const
Get the normal distance to a point.
bool isOutside(const FVector3 &pos) const
Test whether a point is on the outer side.
BodyHandle findBody(const FVector3 &dir) const
Find a body that this surface defines.
std::string toString()
Get a JSON string representation.
HRESULT replace(const BodyHandle &toInsert, const BodyHandle &toRemove)
Replace a body with another body.
std::string str() const
Get a summary string.
SurfaceHandle split(const VertexHandle &v1, const VertexHandle &v2)
Split into two surfaces.
FloatP_t getArea() const
Get the area.
VertexHandle findVertex(const FVector3 &dir) const
Find a vertex that defines this surface.
unsigned int numSharedContiguousVertexSets(const SurfaceHandle &other) const
Get the number of contiguous edges that this surface shares with another surface.
FloatP_t getVertexArea(const VertexHandle &v) const
Get the area that a vertex contributes to this surface.
FVector3 getVelocity() const
Get the velocity, calculated as the velocity of the centroid.
FloatP_t getVertexMass(const VertexHandle &v) const
Get the mass contribution of a vertex to this surface; only used in 2D simulation.
bool validate()
Validate the surface.
FloatP_t getMass() const
Get the mass; only used in 2D simulation.
HRESULT positionChanged()
Update internal data due to a change in position.
bool defines(const BodyHandle &b) const
Test whether defines a body.
bool contains(const FVector3 &pos) const
Test whether the surface contains a point.
FVector3 triangleNormal(const unsigned int &idx) const
Get the normal of a triangle.
HRESULT add(const BodyHandle &b)
Add a body.
std::vector< SurfaceHandle > connectedSurfaces(const std::vector< VertexHandle > &verts) const
Surfaces that share at least one vertex in a set of vertices.
HRESULT remove(const VertexHandle &v)
Remove a vertex.
HRESULT replace(const VertexHandle &toInsert, const int &idx)
Replace a vertex at a location in the list of vertices.
SurfaceType * type() const
Get the surface type.
HRESULT replace(const BodyHandle &toInsert, const int &idx)
Replace a body at a location in the list of bodies.
FloatP_t getVolumeContr(const BodyHandle &body) const
Get the volume that this surface contributes to a body.
HRESULT setSpeciesInward(state::StateVector *s) const
Set the species on inward-facing side of the surface.
HRESULT setSpeciesOutward(state::StateVector *s) const
Set the species on outward-facing side of the surface.
std::vector< SurfaceHandle > connectedSurfaces() const
Surfaces that share at least one vertex.
bool contains(const FVector3 &pos, VertexHandle &v0, VertexHandle &v1) const
Test whether the surface contains a point.
FloatP_t volumeSense(const BodyHandle &body) const
Get the sign of the volume contribution to a body that this surface contributes.
std::vector< BodyHandle > getBodies() const
Get the bodies defined by the surface.
SurfaceHandle split(const FVector3 &cp_pos, const FVector3 &cp_norm)
Split into two surfaces.
HRESULT become(SurfaceType *stype)
Become a different type.
HRESULT insert(const VertexHandle &v, const VertexHandle &before)
Insert a vertex before another vertex.
HRESULT remove(const BodyHandle &b)
Remove a body.
FVector3 getCentroid() const
Get the centroid.
FVector3 getUnnormalizedNormal() const
Get the surface unnormalized normal.
bool definedBy(const VertexHandle &v) const
Test whether defined by a vertex.
rendering::Style * getStyle() const
Get the surface style, if any.
std::vector< VertexHandle > connectingVertices(const SurfaceHandle &other) const
Vertices defining this and another surface.
HRESULT insert(const VertexHandle &v, const int &idx)
Insert a vertex at a location in the list of vertices.
std::vector< unsigned int > contiguousVertexLabels(const SurfaceHandle &other) const
Get the integer labels of the contiguous edges that this surface shares with another surface.
SurfaceHandle extend(const unsigned int &vertIdxStart, const FVector3 &pos)
Create a surface from two vertices and a position.
HRESULT destroy()
Destroy the surface.
MeshObjTypeLabel objType() const
Get the mesh object type.
Definition tfSurface.h:660
FloatP_t getDensity() const
Get the mass density; only used in 2D simulation.
std::vector< VertexHandle > getVertices() const
Get the vertices that define the surface.
std::vector< VertexHandle > sharedContiguousVertices(const SurfaceHandle &other, const unsigned int &edgeLabel) const
Get the vertices of a contiguous shared edge with another surface.
FVector3 getOutwardNormal(const BodyHandle &body) const
Get the outward facing normal w.r.t. a body.
HRESULT add(const VertexHandle &v)
Add a vertex.
HRESULT refreshBodies()
Refresh internal ordering of defined bodies.
FVector3 getNormal() const
Get the normal.
HRESULT merge(SurfaceHandle &toRemove, const std::vector< FloatP_t > &lenCfs)
Merge with a surface. The passed surface is destroyed.
HRESULT replace(const VertexHandle &toInsert, const VertexHandle &toRemove)
Replace a vertex with another vertex.
SurfaceHandle extrude(const unsigned int &vertIdxStart, const FloatP_t &normLen)
Create a surface from two vertices of a surface in a mesh by extruding along the normal of the surfac...
HRESULT insert(const VertexHandle &toInsert, const VertexHandle &v1, const VertexHandle &v2)
Insert a vertex between two vertices.
Mesh surface type.
Definition tfSurface.h:1099
virtual HRESULT registerType()
Registers a type with the engine.
MeshObjTypeLabel objType() const override
Get the mesh object type.
Definition tfSurface.h:1124
virtual SurfaceType * get()
Get the type engine instance.
HRESULT remove(const std::vector< SurfaceHandle > &i)
Remove instances.
HRESULT add(const std::vector< SurfaceHandle > &i)
Add instances.
std::string name
Definition tfSurface.h:1102
SurfaceHandle replace(VertexHandle &toReplace, std::vector< FloatP_t > lenCfs)
Replace a vertex with a surface.
rendering::Style * style
Definition tfSurface.h:1105
static SurfaceType * fromString(const std::string &str)
Create from a JSON string representation.
virtual std::string str() const override
Get a summary string.
FloatP_t density
Definition tfSurface.h:1108
unsigned int getNumInstances()
number of instances that belong to this type
HRESULT add(const SurfaceHandle &i)
Add an instance.
SurfaceType(const bool &noReg=false)
Definition tfSurface.h:1119
bool isRegistered()
Tests whether this type is registered.
std::vector< int > getInstanceIds()
list of instances ids that belong to this type
Definition tfSurface.h:1212
SurfaceHandle nPolygon(const unsigned int &n, const FVector3 ¢er, const FloatP_t &radius, const FVector3 &ax1, const FVector3 &ax2)
Construct a polygon with n vertices circumscribed on a circle.
std::string toString()
Get a JSON string representation.
SurfaceType(const FloatP_t &flatLam, const FloatP_t &convexLam, const bool &noReg=false)
Construct a new surface type.
virtual void on_register()
A callback for when a type is registered.
Definition tfSurface.h:1162
HRESULT remove(const SurfaceHandle &i)
Remove an instance.
static SurfaceType * findFromName(const std::string &_name)
Get a registered type by name.
std::vector< SurfaceHandle > getInstances()
list of instances that belong to this type
A handle to a Vertex.
Definition tfVertex.h:493
The Tissue Forge style type.
Definition tfStyle.h:46
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