Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfCluster.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Copyright (c) 2022-2024 T.J. Sego
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 _MDCORE_INCLUDE_TFCLUSTER_H_
26#define _MDCORE_INCLUDE_TFCLUSTER_H_
27
28#include "tfParticle.h"
29
30#include <vector>
31
32
33namespace TissueForge {
34
35
40 struct CAPI_EXPORT Cluster : Particle {};
41
43
48 struct CAPI_EXPORT ClusterParticleType : ParticleType {
49
50 ClusterParticleType(const bool &noReg=false);
51 virtual ~ClusterParticleType();
52
53 std::string str() const override;
54
63 bool hasType(const ParticleType *type);
64
66 bool has(const int32_t &pid);
67
69 bool has(ParticleType *ptype);
70
72 bool has(ParticleHandle *part);
73
85
91 virtual ClusterParticleType *get() override;
92
93 };
94
102 struct CAPI_EXPORT ClusterParticleHandle : ParticleHandle {
103 ClusterParticleHandle();
104 ClusterParticleHandle(const int &id);
105
106 std::string str() const override;
107
114
127 ParticleHandle *operator()(
128 ParticleType *partType,
129 FVector3 *position=NULL,
130 FVector3 *velocity=NULL
131 );
132
144 ParticleHandle *operator()(ParticleType *partType, const std::string &str);
145
147 bool has(const int32_t &pid);
148
150 bool has(ParticleHandle *part);
151
152 ParticleHandle* fission(
153 FVector3 *axis=NULL,
154 bool *random=NULL,
155 FPTYPE *time=NULL,
156 FVector3 *normal=NULL,
157 FVector3 *point=NULL
158 );
159
170 ParticleHandle* split(
171 FVector3 *axis=NULL,
172 bool *random=NULL,
173 FPTYPE *time=NULL,
174 FVector3 *normal=NULL,
175 FVector3 *point=NULL
176 );
177
184
187
189 FVector3 getCenterOfMass();
190
192 FVector3 getCentroid();
193
196
198 uint16_t getNumParts();
199
201 std::vector<int32_t> getPartIds();
202 };
203
207 CAPI_FUNC(HRESULT) Cluster_AddParticle(struct Cluster *cluster, struct Particle *part);
208
209
215
220 Cluster *cluster,
221 ParticleType* particleType,
222 FVector3 *position=NULL,
223 FVector3 *velocity=NULL
224 );
225
233
238
239
246 Cluster *Cluster_fromString(const std::string &str);
247
255
256};
257
258
259inline std::ostream &operator<<(std::ostream& os, const TissueForge::ClusterParticleHandle &p)
260{
261 os << p.str().c_str();
262 return os;
263}
264
265inline std::ostream &operator<<(std::ostream& os, const TissueForge::ClusterParticleType &p)
266{
267 os << p.str().c_str();
268 return os;
269}
270
271#endif // _MDCORE_INCLUDE_TFCLUSTER_H_
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
HRESULT _Cluster_init()
HRESULT Cluster_AddParticle(struct Cluster *cluster, struct Particle *part)
ClusterParticleType * ClusterParticleType_fromString(const std::string &str)
Create a cluster type from a JSON string representation.
Particle * Cluster_CreateParticle(Cluster *cluster, ParticleType *particleType, FVector3 *position=NULL, FVector3 *velocity=NULL)
ClusterParticleType * ClusterParticleType_FindFromName(const char *name)
Get a registered cluster type by type name.
Cluster * Cluster_fromString(const std::string &str)
Create a cluster from a JSON string representation.
HRESULT Cluster_ComputeAggregateQuantities(struct Cluster *cluster)
The cluster analogue to :class:Particle.
Definition tfCluster.h:40
The cluster analogue to :class:ParticleHandle.
Definition tfCluster.h:102
ParticleHandle * operator()(ParticleType *partType, const std::string &str)
Constituent particle constructor.
Cluster * cluster()
Gets the actual cluster of this handle.
ParticleHandle * operator()(ParticleType *partType, FVector3 *position=NULL, FVector3 *velocity=NULL)
Constituent particle constructor.
bool has(ParticleHandle *part)
bool has(const int32_t &pid)
ParticleHandle * split(FVector3 *axis=NULL, bool *random=NULL, FPTYPE *time=NULL, FVector3 *normal=NULL, FVector3 *point=NULL)
Split the cluster.
ParticleList items()
Get all particles of this cluster.
std::vector< int32_t > getPartIds()
The cluster analogue to :class:ParticleType.
Definition tfCluster.h:48
HRESULT registerType() override
Registers a type with the engine.
virtual ClusterParticleType * get() override
Get the type engine instance.
bool hasType(const ParticleType *type)
Tests where this cluster has a particle type.
bool has(ParticleType *ptype)
bool has(const int32_t &pid)
bool has(ParticleHandle *part)
A handle to a particle.
Definition tfParticle.h:313
Particle * part()
Gets the actual particle of this handle.
Definition tfEngine.h:1414
Definition tfParticle.h:101
A special list with convenience methods for working with sets of particles.
Definition tfParticleList.h:52
Structure containing information on each particle type.
Definition tfParticle.h:768
int32_t HRESULT
Definition tf_port.h:255