Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfSurface.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego and Tien Comlekoglu
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
24
25#ifndef _MODELS_VERTEX_SOLVER_TFSURFACE_H_
26#define _MODELS_VERTEX_SOLVER_TFSURFACE_H_
27
28#include <tf_port.h>
29
30#include <state/tfStateVector.h>
31#include <rendering/tfStyle.h>
32
33#include "tf_mesh.h"
34
35#include <io/tfThreeDFFaceData.h>
36
37#include <tuple>
38
39
40namespace TissueForge::models::vertex {
41
42
43 class Vertex;
44 struct VertexHandle;
45 class Body;
46 struct BodyHandle;
47 class Mesh;
48
49 struct SurfaceHandle;
50 struct SurfaceType;
51 struct BodyType;
52
53
65 class CAPI_EXPORT Surface {
66
68 int _objId;
69
70 public:
71
73 int typeId;
74
75 private:
76
78 Body *b1;
79
81 Body *b2;
82
84 std::vector<Vertex*> vertices;
85
87 FVector3 normal;
88
90 FVector3 centroid;
91
93 FVector3 velocity;
94
96 FloatP_t area;
97
99 FloatP_t perimeter;
100
102 FloatP_t _volumeContr;
103
105 FloatP_t density;
106
107 public:
108
110 std::vector<MeshObjActor*> actors;
111
114
117
120
121 Surface();
122 ~Surface();
123
129 static SurfaceHandle create(const std::vector<VertexHandle> &_vertices);
130
136 static SurfaceHandle create(TissueForge::io::ThreeDFFaceData *face);
137
143 static std::vector<SurfaceHandle> create(const std::vector<std::vector<VertexHandle> > &_vertices);
144
150 static std::vector<SurfaceHandle> create(const std::vector<TissueForge::io::ThreeDFFaceData*> &_faces);
151
152 MESHBOJ_DEFINES_DECL(Body);
153 MESHOBJ_DEFINEDBY_DECL(Vertex);
154 MESHOBJ_CLASSDEF(MeshObjTypeLabel::SURFACE)
155
156
159 std::string str() const;
160
164 std::string toString();
165
171 HRESULT add(Vertex *v);
172
179 HRESULT insert(Vertex *v, const int &idx);
180
187 HRESULT insert(Vertex *v, Vertex *before);
188
196 HRESULT insert(Vertex *toInsert, Vertex *v1, Vertex *v2);
197
203 HRESULT remove(Vertex *v);
204
211 HRESULT replace(Vertex *toInsert, const int &idx);
212
219 HRESULT replace(Vertex *toInsert, Vertex *toRemove);
220
226 HRESULT add(Body *b);
227
233 HRESULT remove(Body *b);
234
241 HRESULT replace(Body *toInsert, const int &idx);
242
249 HRESULT replace(Body *toInsert, Body *toRemove);
250
258 static HRESULT destroy(Surface *target);
259
267 static HRESULT destroy(SurfaceHandle &target);
268
276 static HRESULT destroy(const std::vector<Surface*>& target);
277
282
287
294
298 std::vector<Body*> getBodies() const;
299
303 const std::vector<Vertex*>& getVertices() const { return vertices; }
304
310 Vertex *findVertex(const FVector3 &dir) const;
311
317 Body *findBody(const FVector3 &dir) const;
318
324 std::tuple<Vertex*, Vertex*> neighborVertices(const Vertex *v) const;
325
329 std::vector<Surface*> neighborSurfaces() const;
330
336 std::vector<Surface*> connectedSurfaces(const std::vector<Vertex*> &verts) const;
337
341 std::vector<Surface*> connectedSurfaces() const;
342
348 std::vector<Vertex*> connectingVertices(const Surface *other) const;
349
355 std::vector<unsigned int> contiguousVertexLabels(const Surface *other) const;
356
362 unsigned int numSharedContiguousVertexSets(const Surface *other) const;
363
374 std::vector<Vertex*> sharedContiguousVertices(const Surface *other, const unsigned int &edgeLabel) const;
375
379 FVector3 getNormal() const;
380
384 const FVector3& getUnnormalizedNormal() const { return normal; }
385
389 const FVector3& getCentroid() const { return centroid; }
390
394 const FVector3& getVelocity() const { return velocity; }
395
399 const FloatP_t& getArea() const { return area; }
400
404 const FloatP_t& getPerimeter() const { return perimeter; }
405
409 const FloatP_t& getDensity() const { return density; }
410
416 void setDensity(const FloatP_t &_density) { density = _density; }
417
421 FloatP_t getMass() const { return area * density; }
422
428 FloatP_t volumeSense(const Body *body) const;
429
435 FloatP_t getVolumeContr(const Body *body) const { return _volumeContr * volumeSense(body); }
436
442 FVector3 getOutwardNormal(const Body *body) const;
443
449 FloatP_t getVertexArea(const Vertex *v) const;
450
456 FloatP_t getVertexMass(const Vertex *v) const { return getVertexArea(v) * density; }
457
463 FVector3 triangleNormal(const unsigned int &idx) const;
464
472 FloatP_t normalDistance(const FVector3 &pos) const;
473
480 bool isOutside(const FVector3 &pos) const;
481
489 bool contains(const FVector3 &pos, Vertex **v0, Vertex **v1) const;
490
496 bool contains(const FVector3 &pos) const;
497
506 static bool testSew(Surface* s1, Surface* s2, const FloatP_t& distCf, std::vector<int>& indicesMatched);
507
519 static HRESULT sew(Surface *s1, Surface *s2, const FloatP_t &distCf=0.01);
520
532 static HRESULT sew(const SurfaceHandle &s1, const SurfaceHandle &s2, const FloatP_t &distCf=0.01);
533
544 static HRESULT sew(const std::vector<Surface*>& _surfaces, const FloatP_t &distCf=0.01);
545
557 static HRESULT sew(const std::vector<SurfaceHandle>& _surfaces, const FloatP_t &distCf=0.01);
558
567 HRESULT merge(Surface *toRemove, const std::vector<FloatP_t> &lenCfs);
568
575 Surface *extend(const unsigned int &vertIdxStart, const FVector3 &pos);
576
585 Surface *extrude(const unsigned int &vertIdxStart, const FloatP_t &normLen);
586
600 Surface *split(Vertex *v1, Vertex *v2);
601
610 Surface *split(const FVector3 &cp_pos, const FVector3 &cp_norm);
611
612
613 friend SurfaceHandle;
614 friend Vertex;
615 friend Body;
616 friend BodyType;
617 friend Mesh;
618
619 };
620
621
630 struct CAPI_EXPORT SurfaceHandle {
631
632 int id;
633
634 SurfaceHandle(const int &_id=-1);
635
639 Surface *surface() const;
640
647 bool defines(const BodyHandle &b) const;
648
655 bool definedBy(const VertexHandle &v) const;
656
660 MeshObjTypeLabel objType() const { return MeshObjTypeLabel::SURFACE; }
661
666
672 bool validate();
673
678
682 std::string str() const;
683
687 std::string toString();
688
694 static SurfaceHandle fromString(const std::string &s);
695
702
709 HRESULT insert(const VertexHandle &v, const int &idx);
710
717 HRESULT insert(const VertexHandle &v, const VertexHandle &before);
718
726 HRESULT insert(const VertexHandle &toInsert, const VertexHandle &v1, const VertexHandle &v2);
727
734
741 HRESULT replace(const VertexHandle &toInsert, const int &idx);
742
749 HRESULT replace(const VertexHandle &toInsert, const VertexHandle &toRemove);
750
757
764
771 HRESULT replace(const BodyHandle &toInsert, const int &idx);
772
779 HRESULT replace(const BodyHandle &toInsert, const BodyHandle &toRemove);
780
785
790
797
801 std::vector<BodyHandle> getBodies() const;
802
806 std::vector<VertexHandle> getVertices() const;
807
813 VertexHandle findVertex(const FVector3 &dir) const;
814
820 BodyHandle findBody(const FVector3 &dir) const;
821
827 std::tuple<VertexHandle, VertexHandle> neighborVertices(const VertexHandle &v) const;
828
832 std::vector<SurfaceHandle> neighborSurfaces() const;
833
839 std::vector<SurfaceHandle> connectedSurfaces(const std::vector<VertexHandle> &verts) const;
840
844 std::vector<SurfaceHandle> connectedSurfaces() const;
845
851 std::vector<VertexHandle> connectingVertices(const SurfaceHandle &other) const;
852
858 std::vector<unsigned int> contiguousVertexLabels(const SurfaceHandle &other) const;
859
865 unsigned int numSharedContiguousVertexSets(const SurfaceHandle &other) const;
866
877 std::vector<VertexHandle> sharedContiguousVertices(const SurfaceHandle &other, const unsigned int &edgeLabel) const;
878
882 FVector3 getNormal() const;
883
887 FVector3 getUnnormalizedNormal() const;
888
892 FVector3 getCentroid() const;
893
897 FVector3 getVelocity() const;
898
902 FloatP_t getArea() const;
903
907 FloatP_t getPerimeter() const;
908
912 FloatP_t getDensity() const;
913
919 void setDensity(const FloatP_t &_density) const;
920
924 FloatP_t getMass() const;
925
931 FloatP_t volumeSense(const BodyHandle &body) const;
932
938 FloatP_t getVolumeContr(const BodyHandle &body) const;
939
945 FVector3 getOutwardNormal(const BodyHandle &body) const;
946
952 FloatP_t getVertexArea(const VertexHandle &v) const;
953
959 FloatP_t getVertexMass(const VertexHandle &v) const;
960
965
972
977
984
989
996
1002 FVector3 triangleNormal(const unsigned int &idx) const;
1003
1011 FloatP_t normalDistance(const FVector3 &pos) const;
1012
1019 bool isOutside(const FVector3 &pos) const;
1020
1028 bool contains(const FVector3 &pos, VertexHandle &v0, VertexHandle &v1) const;
1029
1035 bool contains(const FVector3 &pos) const;
1036
1045 HRESULT merge(SurfaceHandle &toRemove, const std::vector<FloatP_t> &lenCfs);
1046
1053 SurfaceHandle extend(const unsigned int &vertIdxStart, const FVector3 &pos);
1054
1063 SurfaceHandle extrude(const unsigned int &vertIdxStart, const FloatP_t &normLen);
1064
1077 SurfaceHandle split(const VertexHandle &v1, const VertexHandle &v2);
1078
1087 SurfaceHandle split(const FVector3 &cp_pos, const FVector3 &cp_norm);
1088
1089 operator bool() const { return id >= 0; }
1090 };
1091
1092
1099 struct CAPI_EXPORT SurfaceType : MeshObjType {
1100
1102 std::string name;
1103
1106
1108 FloatP_t density;
1109
1116 SurfaceType(const FloatP_t &flatLam, const FloatP_t &convexLam, const bool &noReg=false);
1117
1119 SurfaceType(const bool &noReg=false) : SurfaceType(0.1, 0.1, noReg) {};
1120
1124 MeshObjTypeLabel objType() const override { return MeshObjTypeLabel::SURFACE; }
1125
1129 virtual std::string str() const override;
1130
1134 std::string toString();
1135
1143 static SurfaceType *fromString(const std::string &str);
1144
1150 static SurfaceType *findFromName(const std::string &_name);
1151
1158
1162 virtual void on_register() {}
1163
1170
1174 virtual SurfaceType *get();
1175
1182
1188 HRESULT add(const std::vector<SurfaceHandle>& i);
1189
1196
1202 HRESULT remove(const std::vector<SurfaceHandle>& i);
1203
1207 std::vector<SurfaceHandle> getInstances();
1208
1212 std::vector<int> getInstanceIds() { return _instanceIds; }
1213
1217 unsigned int getNumInstances();
1218
1224 SurfaceHandle operator() (const std::vector<VertexHandle> &_vertices);
1225
1231 SurfaceHandle operator() (const std::vector<FVector3> &_positions);
1232
1239
1245 std::vector<SurfaceHandle> operator() (const std::vector<std::vector<VertexHandle> >& _vertices);
1246
1252 std::vector<SurfaceHandle> operator() (const std::vector<std::vector<FVector3> > &_positions);
1253
1260 std::vector<SurfaceHandle> operator() (const std::vector<TissueForge::io::ThreeDFFaceData*>& faces, const bool& safe=true);
1261
1271 SurfaceHandle nPolygon(const unsigned int &n, const FVector3 &center, const FloatP_t &radius, const FVector3 &ax1, const FVector3 &ax2);
1272
1281 SurfaceHandle replace(VertexHandle &toReplace, std::vector<FloatP_t> lenCfs);
1282
1283 private:
1284
1285 std::vector<int> _instanceIds;
1286
1287 };
1288
1289 inline bool operator< (const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return lhs.objectId() < rhs.objectId(); }
1290 inline bool operator> (const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return rhs < lhs; }
1291 inline bool operator<=(const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return !(lhs > rhs); }
1292 inline bool operator>=(const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return !(lhs < rhs); }
1293 inline bool operator==(const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return lhs.objectId() == rhs.objectId(); }
1294 inline bool operator!=(const TissueForge::models::vertex::Surface& lhs, const TissueForge::models::vertex::Surface& rhs) { return !(lhs == rhs); }
1295
1296 inline bool operator< (const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return lhs.id < rhs.id; }
1297 inline bool operator> (const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return rhs < lhs; }
1298 inline bool operator<=(const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return !(lhs > rhs); }
1299 inline bool operator>=(const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return !(lhs < rhs); }
1300 inline bool operator==(const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return lhs.id == rhs.id; }
1301 inline bool operator!=(const TissueForge::models::vertex::SurfaceHandle& lhs, const TissueForge::models::vertex::SurfaceHandle& rhs) { return !(lhs == rhs); }
1302
1303 inline bool operator< (const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return lhs.id < rhs.id; }
1304 inline bool operator> (const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return rhs < lhs; }
1305 inline bool operator<=(const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return !(lhs > rhs); }
1306 inline bool operator>=(const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return !(lhs < rhs); }
1307 inline bool operator==(const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return lhs.id == rhs.id; }
1308 inline bool operator!=(const TissueForge::models::vertex::SurfaceType& lhs, const TissueForge::models::vertex::SurfaceType& rhs) { return !(lhs == rhs); }
1309
1310}
1311
1312
1313inline std::ostream &operator<<(std::ostream& os, const TissueForge::models::vertex::Surface &o)
1314{
1315 os << o.str().c_str();
1316 return os;
1317}
1318
1319inline std::ostream &operator<<(std::ostream& os, const TissueForge::models::vertex::SurfaceType &o)
1320{
1321 os << o.str().c_str();
1322 return os;
1323}
1324
1325namespace std {
1326
1327 template <>
1328 struct hash<TissueForge::models::vertex::SurfaceHandle> {
1329 size_t operator() (const TissueForge::models::vertex::SurfaceHandle& h) const {
1330 return hash<int>()(h.id);
1331 }
1332 };
1333}
1334
1335#endif // _MODELS_VERTEX_SOLVER_TFSURFACE_H_
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
HRESULT refreshBodies()
Refresh internal ordering of defined bodies.
HRESULT replace(Vertex *toInsert, const int &idx)
Replace a vertex at a location in the list of vertices.
Vertex * findVertex(const FVector3 &dir) const
Find a vertex that defines this surface.
state::StateVector * species1
Definition tfSurface.h:113
std::vector< Body * > getBodies() const
Get the bodies defined by the surface.
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.
SurfaceType * type() const
Get the surface type.
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.
std::string toString()
Get a JSON string representation.
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.
HRESULT add(Vertex *v)
Add a vertex.
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
HRESULT remove(Vertex *v)
Remove a vertex.
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.
HRESULT become(SurfaceType *stype)
Become a different type.
static SurfaceHandle create(const std::vector< VertexHandle > &_vertices)
Construct a surface from a set of vertices.
const std::vector< Vertex * > & getVertices() const
Get the vertices that define the surface.
Definition tfSurface.h:303
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
HRESULT insert(Vertex *v, const int &idx)
Insert a vertex at a location in the list of vertices.
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 &center, 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