💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.7 KiB

  1. /*
  2. * Copyright (C) 2023 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_GEOM_BREP_LOOP_HPP
  20. #define ANTKEEPER_GEOM_BREP_LOOP_HPP
  21. #include <engine/geom/brep/brep-element-container.hpp>
  22. #include <cstddef>
  23. namespace geom {
  24. class brep_vertex;
  25. class brep_edge;
  26. class brep_face;
  27. template <class T>
  28. class brep_element_container;
  29. /**
  30. * Connected boundary of a single face.
  31. */
  32. class brep_loop
  33. {
  34. public:
  35. friend class brep_mesh;
  36. friend class brep_edge_loop_list;
  37. friend class brep_face_loop_list;
  38. friend class brep_element_container<brep_loop>;
  39. friend class brep_loop_container;
  40. friend class brep_face_container;
  41. /**
  42. * Returns the index of this loop in the mesh loop array.
  43. *
  44. * @warning This index may change if any loops are removed from the mesh.
  45. */
  46. [[nodiscard]] inline constexpr std::size_t index() const noexcept
  47. {
  48. return m_index;
  49. }
  50. /// Returns a pointer to the loop vertex.
  51. [[nodiscard]] inline constexpr brep_vertex* vertex() const noexcept
  52. {
  53. return m_vertex;
  54. }
  55. /// Returns a pointer to the loop edge.
  56. [[nodiscard]] inline constexpr brep_edge* edge() const noexcept
  57. {
  58. return m_edge;
  59. }
  60. /// Returns a pointer to the loop face.
  61. [[nodiscard]] inline constexpr brep_face* face() const noexcept
  62. {
  63. return m_face;
  64. }
  65. private:
  66. std::size_t m_index;
  67. brep_vertex* m_vertex;
  68. brep_edge* m_edge;
  69. brep_face* m_face;
  70. brep_loop* m_edge_next;
  71. brep_loop* m_edge_previous;
  72. brep_loop* m_face_next;
  73. brep_loop* m_face_previous;
  74. };
  75. /**
  76. * B-rep loop container.
  77. */
  78. class brep_loop_container: public brep_element_container<brep_loop>
  79. {
  80. private:
  81. friend class brep_mesh;
  82. friend class brep_face_container;
  83. /**
  84. * Constructs a B-rep face container.
  85. *
  86. * @param mesh Pointer to the parent mesh.
  87. */
  88. inline explicit brep_loop_container(brep_mesh* mesh) noexcept:
  89. brep_element_container<brep_loop>(mesh)
  90. {}
  91. /**
  92. * Appends a new loop to the end of the container.
  93. *
  94. * @return Pointer to the new loop.
  95. */
  96. brep_loop* emplace_back() override;
  97. };
  98. } // namespace geom
  99. #endif // ANTKEEPER_GEOM_BREP_LOOP_HPP