Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfThreeDFStructure.h
1/*******************************************************************************
2 * This file is part of Tissue Forge.
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
20// todo: implement a sewing method on ThreeDFStructure to join same vertices but in different meshes
21// Currently, vertices are allocated by mesh; if a vertex is shared by meshes, they will show up as separate entities in each mesh.
22// This method should detect such occurrences and make one shared vertex among many meshes
23
24#ifndef _SOURCE_IO_TFTHREEDFSTRUCTURE_H_
25#define _SOURCE_IO_TFTHREEDFSTRUCTURE_H_
26
27#include <tf_port.h>
28
29#include "tfThreeDFVertexData.h"
30#include "tfThreeDFEdgeData.h"
31#include "tfThreeDFFaceData.h"
32#include "tfThreeDFMeshData.h"
33
34#include <unordered_map>
35
36
37namespace TissueForge::io {
38
39
40 struct CAPI_EXPORT ThreeDFComponentContainer {
41 std::vector<ThreeDFVertexData*> vertices;
42 std::vector<ThreeDFEdgeData*> edges;
43 std::vector<ThreeDFFaceData*> faces;
44 std::vector<ThreeDFMeshData*> meshes;
45 };
46
47
61 struct CAPI_EXPORT ThreeDFStructure {
62
65
68
70 FloatP_t vRadiusDef = 0.1;
71
73
74 // Structure management
75
82 HRESULT fromFile(const std::string &filePath);
83
91 HRESULT toFile(const std::string &format, const std::string &filePath);
92
98
99 // Inventory management
100
107
114
120 std::vector<ThreeDFVertexData*> getVertices();
121
127 std::vector<ThreeDFEdgeData*> getEdges();
128
134 std::vector<ThreeDFFaceData*> getFaces();
135
141 std::vector<ThreeDFMeshData*> getMeshes();
142
148 unsigned int getNumVertices();
149
155 unsigned int getNumEdges();
156
162 unsigned int getNumFaces();
163
169 unsigned int getNumMeshes();
170
179
188
197
206
213
220
227
234
241
248
255
262
263 void onRemoved(ThreeDFVertexData *v);
264 void onRemoved(ThreeDFEdgeData *e);
265 void onRemoved(ThreeDFFaceData *f);
266
267 // Transformations
268
274 FVector3 getCentroid();
275
282 HRESULT translate(const FVector3 &displacement);
283
290 HRESULT translateTo(const FVector3 &position);
291
299 HRESULT rotateAt(const FMatrix3 &rotMat, const FVector3 &rotPt);
300
307 HRESULT rotate(const FMatrix3 &rotMat);
308
316 HRESULT scaleFrom(const FVector3 &scales, const FVector3 &scalePt);
317
325 HRESULT scaleFrom(const FloatP_t &scale, const FVector3 &scalePt);
326
333 HRESULT scale(const FVector3 &scales);
334
341 HRESULT scale(const FloatP_t &scale);
342
343 private:
344
345 int id_vertex = 0;
346 int id_edge = 0;
347 int id_face = 0;
348 int id_mesh = 0;
349
350 };
351
352};
353
354#endif // _SOURCE_IO_TFTHREEDFSTRUCTURE_H_
Tissue Forge I/O.
Definition tfThreeDFAngleMeshGenerator.h:28
Definition tfThreeDFStructure.h:40
3D data file edge data
Definition tfThreeDFEdgeData.h:41
3D data file face data
Definition tfThreeDFFaceData.h:41
3D data file mesh data
Definition tfThreeDFMeshData.h:43
Container for relevant data found in a 3D data file.
Definition tfThreeDFStructure.h:61
HRESULT clear()
Clear all data of the structure.
std::vector< ThreeDFEdgeData * > getEdges()
Get all constituent edges.
void remove(ThreeDFEdgeData *e)
Remove a edge and all constituent data.
unsigned int getNumVertices()
Get the number of constituent vertices.
void add(ThreeDFMeshData *m)
Add a mesh and all constituent data.
FloatP_t vRadiusDef
Definition tfThreeDFStructure.h:70
unsigned int getNumMeshes()
Get the number of constituent meshes.
ThreeDFComponentContainer inventory
Definition tfThreeDFStructure.h:64
bool has(ThreeDFVertexData *v)
Test whether a vertex is a constituent.
HRESULT rotateAt(const FMatrix3 &rotMat, const FVector3 &rotPt)
Rotate the structure about a point.
HRESULT translate(const FVector3 &displacement)
Translate the structure by a displacement.
void remove(ThreeDFMeshData *m)
Remove a mesh and all constituent data.
unsigned int getNumEdges()
Get the number of constituent edges.
void add(ThreeDFEdgeData *e)
Add an edge and all constituent data.
HRESULT scaleFrom(const FVector3 &scales, const FVector3 &scalePt)
Scale the structure about a point.
HRESULT toFile(const std::string &format, const std::string &filePath)
Write to file.
void add(ThreeDFVertexData *v)
Add a vertex.
bool has(ThreeDFEdgeData *e)
Test whether an edge is a constituent.
ThreeDFComponentContainer queueRemove
Definition tfThreeDFStructure.h:67
void remove(ThreeDFVertexData *v)
Remove a vertex.
void remove(ThreeDFFaceData *f)
Remove a face and all constituent data.
bool has(ThreeDFMeshData *m)
Test whether a mesh is a constituent.
unsigned int getNumFaces()
Get the number of constituent faces.
std::vector< ThreeDFVertexData * > getVertices()
Get all constituent vertices.
HRESULT rotate(const FMatrix3 &rotMat)
Rotate the structure about its centroid.
HRESULT scaleFrom(const FloatP_t &scale, const FVector3 &scalePt)
Scale the structure uniformly about a point.
HRESULT fromFile(const std::string &filePath)
Load from file.
HRESULT scale(const FloatP_t &scale)
Scale the structure uniformly about its centroid.
std::vector< ThreeDFFaceData * > getFaces()
Get all constituent faces.
HRESULT extend(const ThreeDFStructure &s)
Extend a structure.
bool has(ThreeDFFaceData *f)
Test whether a face is a constituent.
void add(ThreeDFFaceData *f)
Add a face and all constituent data.
HRESULT translateTo(const FVector3 &position)
Translate the structure to a position.
HRESULT flush()
Flush stucture. All scheduled processes are executed.
HRESULT scale(const FVector3 &scales)
Scale the structure about its centroid.
FVector3 getCentroid()
Get the centroid of the structure.
std::vector< ThreeDFMeshData * > getMeshes()
Get all constituent meshes.
3D data file vertex data
Definition tfThreeDFVertexData.h:41
int32_t HRESULT
Definition tf_port.h:255