Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfParticleList.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
25#ifndef _MDCORE_INCLUDE_TFPARTICLELIST_H_
26#define _MDCORE_INCLUDE_TFPARTICLELIST_H_
27
28#include <mdcore_config.h>
29#include <io/tf_io.h>
30#include <types/tf_types.h>
31
32#include <vector>
33
34
35namespace TissueForge {
36
37
38 enum ParticleListFlags {
39 // list owns the data the ParticleList::parts
40 PARTICLELIST_OWNDATA = 1 << 0,
41
42 // list supports insertion / deletion
43 PARTICLELIST_MUTABLE = 1 << 1
44 };
45
46 struct ParticleHandle;
47
52 struct CAPI_EXPORT ParticleList {
53 int32_t *parts;
54 int32_t nr_parts;
55 int32_t size_parts;
56 uint16_t flags;
57
58 // frees the memory associated with the parts list.
59 void free();
60
67 HRESULT reserve(size_t _nr_parts);
68
69 // inserts the given id into the list, returns the index of the item.
70 uint16_t insert(int32_t item);
71
78 uint16_t insert(const ParticleHandle *particle);
79
86 uint16_t remove(int32_t id);
87
93 uint16_t extend(const ParticleList &other);
94
96 bool has(const int32_t &pid);
97
99 bool has(ParticleHandle *part);
100
107 ParticleHandle *item(const int32_t &i);
108
110 int32_t operator[](const size_t &i);
111
113 std::vector<int32_t> vector();
114
121
122 FMatrix3 getVirial();
123 FPTYPE getRadiusOfGyration();
124 FVector3 getCenterOfMass();
125 FVector3 getCentroid();
126 FMatrix3 getMomentOfInertia();
127 std::vector<FVector3> getPositions();
128 std::vector<FVector3> getVelocities();
129 std::vector<FVector3> getForces();
130
137 std::vector<FVector3> sphericalPositions(FVector3 *origin=NULL);
138
142 bool getOwnsData() const;
143
149 void setOwnsData(const bool &_flag);
150
154 bool getMutable() const;
155
161 void setMutable(const bool &_flag);
162
163 ParticleList();
164 ParticleList(uint16_t init_size, uint16_t flags = PARTICLELIST_OWNDATA | PARTICLELIST_MUTABLE);
166 ParticleList(std::vector<ParticleHandle> particles);
167 ParticleList(std::vector<ParticleHandle*> particles);
168 ParticleList(uint16_t nr_parts, int32_t *parts);
169 ParticleList(const ParticleList &other);
170 ParticleList(const std::vector<int32_t> &pids);
172
178 std::string toString();
179
186 static ParticleList *fromString(const std::string &str);
187
188 };
189
190
191};
192
193#endif // _MDCORE_INCLUDE_TFPARTICLELIST_H_
Definition tfMatrix3.h:35
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
A handle to a particle.
Definition tfParticle.h:313
A special list with convenience methods for working with sets of particles.
Definition tfParticleList.h:52
ParticleHandle * item(const int32_t &i)
looks for the item at the given index and returns it if found, otherwise returns NULL
std::vector< int32_t > vector()
bool getOwnsData() const
Get whether the list owns its data.
void setOwnsData(const bool &_flag)
Set whether the list owns its data.
bool has(ParticleHandle *part)
HRESULT reserve(size_t _nr_parts)
Reserve enough storage for a given number of items.
static ParticleList * fromString(const std::string &str)
Create from a JSON string representation.
uint16_t insert(const ParticleHandle *particle)
Inserts the given particle into the list, returns the index of the item.
uint16_t extend(const ParticleList &other)
inserts the contents of another list
int32_t operator[](const size_t &i)
bool has(const int32_t &pid)
static ParticleList all()
returns an instance populated with all current particles
std::vector< FVector3 > sphericalPositions(FVector3 *origin=NULL)
Get the spherical coordinates of each particle.
bool getMutable() const
Get whether the list is mutable.
uint16_t remove(int32_t id)
looks for the item with the given id and deletes it form the list
void setMutable(const bool &_flag)
Set whether the list is mutable.
std::string toString()
Get a JSON string representation.
int32_t HRESULT
Definition tf_port.h:255