1 #ifndef VTESTBED_GEOMETRY_FACE_HH 2 #define VTESTBED_GEOMETRY_FACE_HH 5 #include <initializer_list> 9 #include <vtestbed/base/bstream.hh> 18 static_assert(N >= 3,
"bad N");
21 using value_type =
unsigned int;
22 using size_type = int;
23 using iterator = value_type*;
24 using const_iterator =
const value_type*;
27 value_type _indices[N] {};
33 Face& operator=(
const Face&) =
default;
38 std::copy_n(list.begin(), N, this->_indices);
41 template <
class ... Args>
43 Face(Args ... indices): _indices{indices...} {}
46 operator()(size_type i)
const {
47 return this->_indices[i];
51 operator()(size_type i) {
52 return this->_indices[i];
56 operator[](size_type i)
const {
57 return this->_indices[i];
61 operator[](size_type i) {
62 return this->_indices[i];
65 inline iterator begin() {
return this->_indices; }
66 inline iterator end() {
return this->_indices + N; }
67 inline const_iterator begin()
const {
return this->_indices; }
68 inline const_iterator end()
const {
return this->_indices + N; }
70 inline value_type front()
const {
return this->_indices[0]; }
71 inline value_type back()
const {
return this->_indices[N-1]; }
73 static constexpr
inline size_type size() {
return N; }
76 index_of(value_type value)
const {
77 for (size_type i=0; i<N; ++i) {
78 if (this->_indices[i] == value) {
86 contains(value_type value)
const {
87 for (size_type i=0; i<N; ++i) {
88 if (this->_indices[i] == value) {
97 std::swap(this->_indices[0], this->_indices[1]);
100 bool reorder(
const Face<N>& rhs, value_type shared_vertex);
104 operator+=(value_type rhs) {
105 for (
auto& idx : this->_indices) {
116 return std::equal(lhs.begin(), lhs.end(), rhs.begin());
121 operator!=(
const Face<N>& lhs,
const Face<N>& rhs) {
122 return !operator==(lhs, rhs);
127 operator<(
const Face<N>& lhs,
const Face<N>& rhs) {
128 return std::lexicographical_compare(
129 lhs.begin(), lhs.end(),
130 rhs.begin(), rhs.end()
154 #endif // vim:filetype=cpp