EdgeKey.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <Mathematics/FeatureKey.h>
  9. // An ordered edge has (V[0], V[1]) = (v0, v1). An unordered edge has
  10. // (V[0], V[1]) = (min(V[0],V[1]), max(V[0],V[1])).
  11. namespace WwiseGTE
  12. {
  13. template <bool Ordered>
  14. class EdgeKey : public FeatureKey<2, Ordered>
  15. {
  16. public:
  17. // Initialize to invalid indices.
  18. EdgeKey()
  19. {
  20. this->V = { -1, -1 };
  21. }
  22. // This constructor is specialized based on Ordered.
  23. explicit EdgeKey(int v0, int v1)
  24. {
  25. Initialize(v0, v1);
  26. }
  27. private:
  28. template <bool Dummy = Ordered>
  29. typename std::enable_if<Dummy, void>::type
  30. Initialize(int v0, int v1)
  31. {
  32. this->V[0] = v0;
  33. this->V[1] = v1;
  34. }
  35. template <bool Dummy = Ordered>
  36. typename std::enable_if<!Dummy, void>::type
  37. Initialize(int v0, int v1)
  38. {
  39. if (v0 < v1)
  40. {
  41. // v0 is minimum
  42. this->V[0] = v0;
  43. this->V[1] = v1;
  44. }
  45. else
  46. {
  47. // v1 is minimum
  48. this->V[0] = v1;
  49. this->V[1] = v0;
  50. }
  51. }
  52. };
  53. }