BsTriangulation.h 1.7 KB

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