mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
make combo_iterator more std::iterator-y
This commit is contained in:
@@ -6,6 +6,13 @@
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct ComboIterator {
|
struct ComboIterator {
|
||||||
|
typedef ComboIterator<T> self_type;
|
||||||
|
typedef const std::vector<T> value_type;;
|
||||||
|
typedef const std::vector<T> *pointer;
|
||||||
|
typedef const std::vector<T> &reference;
|
||||||
|
typedef size_t difference_type;
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
||||||
const std::vector<T> &vals;
|
const std::vector<T> &vals;
|
||||||
const size_t k;
|
const size_t k;
|
||||||
size_t n;
|
size_t n;
|
||||||
@@ -23,28 +30,43 @@ struct ComboIterator {
|
|||||||
set_curr();
|
set_curr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ComboIterator() = default;
|
||||||
|
|
||||||
void set_curr() {
|
void set_curr() {
|
||||||
for (size_t i = 0, j = 0; i < vals.size(); ++i) {
|
for (size_t i = 0, j = 0; i < vals.size(); ++i) {
|
||||||
if (bits[i]) curr[j++] = vals[i];
|
if (bits[i]) curr[j++] = vals[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<T> &operator*() const {
|
[[nodiscard]] bool operator==(const ComboIterator<T> &o) const {
|
||||||
return curr;
|
return n == o.n;
|
||||||
}
|
|
||||||
|
|
||||||
void operator++() {
|
|
||||||
std::next_permutation(bits.begin(), bits.end());
|
|
||||||
set_curr();
|
|
||||||
++n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool operator!=(const ComboIterator<T> &o) const {
|
[[nodiscard]] bool operator!=(const ComboIterator<T> &o) const {
|
||||||
return n != o.n;
|
return n != o.n;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool operator==(const ComboIterator<T> &o) const {
|
reference operator*() const {
|
||||||
return n == o.n;
|
return curr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer operator->() const {
|
||||||
|
return &curr;
|
||||||
|
}
|
||||||
|
|
||||||
|
self_type operator++(int) {
|
||||||
|
std::next_permutation(bits.begin(), bits.end());
|
||||||
|
set_curr();
|
||||||
|
++n;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
self_type operator++() {
|
||||||
|
self_type r = *this;
|
||||||
|
std::next_permutation(bits.begin(), bits.end());
|
||||||
|
set_curr();
|
||||||
|
++n;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -113,8 +113,16 @@ int main(int argc, char *argv[]) {
|
|||||||
std::vector<GLuint> ibos;
|
std::vector<GLuint> ibos;
|
||||||
std::vector<unsigned> counts;
|
std::vector<unsigned> counts;
|
||||||
|
|
||||||
for (auto sg_gens : Combos(g_gens, 3)) {
|
auto combos = Combos(g_gens, 3);
|
||||||
const std::vector<int> data = gg.tile(g_gens, sg_gens, gg.triangulate(sg_gens)).vals;
|
std::vector<std::vector<int>> chosen = {
|
||||||
|
{1, 2, 3},
|
||||||
|
{0, 2, 3},
|
||||||
|
};
|
||||||
|
// chosen = std::vector<std::vector<int>>(combos.begin(), combos.end());
|
||||||
|
|
||||||
|
for (auto sg_gens : chosen) {
|
||||||
|
auto s = gg.tile(g_gens, sg_gens, gg.triangulate(sg_gens));
|
||||||
|
const std::vector<int> data = s.vals;
|
||||||
|
|
||||||
GLuint vao = utilCreateVertexArray();
|
GLuint vao = utilCreateVertexArray();
|
||||||
GLuint ibo = utilCreateBuffer();
|
GLuint ibo = utilCreateBuffer();
|
||||||
@@ -162,9 +170,11 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
for (int i = 0; i < vaos.size(); ++i) {
|
for (int i = 0; i < vaos.size(); ++i) {
|
||||||
auto c = glm::mix(
|
auto c = glm::mix(
|
||||||
glm::vec3(.3, .2, .5),
|
glm::vec3(1,0,0),
|
||||||
glm::vec3(.9, .9, .95),
|
glm::vec3(.2,.2,.3),
|
||||||
(float) (i + 1) / vaos.size()
|
// glm::vec3(.3, .2, .5),
|
||||||
|
// glm::vec3(.9, .9, .95),
|
||||||
|
(float) (i) / (vaos.size()-1.f)
|
||||||
);
|
);
|
||||||
|
|
||||||
glBindProgramPipeline(pipe);
|
glBindProgramPipeline(pipe);
|
||||||
|
|||||||
Reference in New Issue
Block a user