BsTriangulation.h 1.6 KB

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