| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "Prerequisites/BsPrerequisitesUtil.h" |
| 6 | #include "Math/BsVector2I.h" |
| 7 | |
| 8 | namespace bs |
| 9 | { |
| 10 | /** @addtogroup General |
| 11 | * @{ |
| 12 | */ |
| 13 | |
| 14 | /** Contains information about a single tetrahedron. */ |
| 15 | struct Tetrahedron |
| 16 | { |
| 17 | /** Indices of vertices that form the tetrahedron pointing to an external point array. */ |
| 18 | INT32 vertices[4]; |
| 19 | |
| 20 | /** |
| 21 | * Indices pointing to neighbor tetrahedrons. Each neighbor index maps to the @p vertices array, so neighbor/vertex |
| 22 | * pair at the same location will be the only neighbor not containing that vertex (i.e. neighbor opposite to |
| 23 | * the vertex). If a tetrahedron is on the volume edge, it has only three neighbors and its last neighbor will be |
| 24 | * set to -1. |
| 25 | */ |
| 26 | INT32 neighbors[4]; |
| 27 | }; |
| 28 | |
| 29 | /** Contains information about a single face of a tetrahedron. */ |
| 30 | struct TetrahedronFace |
| 31 | { |
| 32 | INT32 vertices[3]; |
| 33 | INT32 tetrahedron; |
| 34 | }; |
| 35 | |
| 36 | /** Contains information about a volume made out of tetrahedrons. */ |
| 37 | struct TetrahedronVolume |
| 38 | { |
| 39 | Vector<Tetrahedron> tetrahedra; |
| 40 | Vector<TetrahedronFace> outerFaces; |
| 41 | }; |
| 42 | |
| 43 | /** Contains helper methods that triangulate point data. */ |
| 44 | class BS_UTILITY_EXPORT Triangulation |
| 45 | { |
| 46 | public: |
| 47 | /** |
| 48 | * Converts a set of input points into a set of tetrahedrons generated using Delaunay tetrahedralization |
| 49 | * algorithm. Minimum of 4 points must be provided in order for the process to work. |
| 50 | */ |
| 51 | static TetrahedronVolume tetrahedralize(const Vector<Vector3>& points); |
| 52 | }; |
| 53 | |
| 54 | /** @} */ |
| 55 | } |