Compare commits
5 Commits
8a05e20c33
...
d95602fecd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d95602fecd | ||
|
|
1dfac53904 | ||
|
|
f1afeacf60 | ||
|
|
ec0fb04f7b | ||
|
|
03d9de7b1a |
@ -57,16 +57,18 @@ struct leaf_t {
|
||||
};
|
||||
|
||||
struct weighted_leaf_t {
|
||||
weighted_group_id_t m_weighed_group_id;
|
||||
weighted_group_id_t m_weighted_group_id;
|
||||
mtl::vec2 m_position;
|
||||
mtl::mat<2, 2> m_orientation;
|
||||
};
|
||||
|
||||
struct group_output_t {
|
||||
static constexpr size_t g_max_child_wleafs = 8;
|
||||
static constexpr size_t g_max_child_leafs = 16;
|
||||
static constexpr size_t g_max_child_markers = 8;
|
||||
|
||||
etl::vector<weighted_leaf_t, g_max_child_leafs> m_child_leafs;
|
||||
etl::vector<weighted_leaf_t, g_max_child_wleafs> m_child_wleafs;
|
||||
etl::vector<leaf_t, g_max_child_leafs> m_child_leafs;
|
||||
etl::vector<marker_t, g_max_child_markers> m_child_markers;
|
||||
};
|
||||
|
||||
@ -100,7 +102,10 @@ private:
|
||||
|
||||
etl::vector<branch_rule_t, g_max_branch_rules> m_branch_rules;
|
||||
|
||||
group_id_t m_axiom = 0;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Checks if the maximum number of tokens has been reached
|
||||
*
|
||||
@ -219,7 +224,27 @@ public:
|
||||
*/
|
||||
branch_rule_id_t add_branch_rule_weighted(token_id_t match, weighted_group_id_t wgroup);
|
||||
|
||||
/** @brief Sets the axiom
|
||||
*
|
||||
* @exception @c mtl::invalid_argument if an invalid group ID was supplied
|
||||
*/
|
||||
void set_axiom(group_id_t axiom) {
|
||||
m_axiom = valid_group_characteristic(axiom) ? axiom : throw mtl::invalid_argument();
|
||||
}
|
||||
group_id_t get_axiom() const { return m_axiom; }
|
||||
|
||||
const token_t& get_token(token_id_t id) const { return m_tokens[id]; }
|
||||
const group_characteristic_t& get_group_characteristic(group_id_t id) const { return m_group_characteristics[id]; }
|
||||
const weighted_group_t& get_weighted_group(weighted_group_id_t wgid) const { return m_weighted_groups[wgid]; }
|
||||
const branch_rule_t& get_branch_rule(branch_rule_id_t id) const { return m_branch_rules[id]; }
|
||||
|
||||
size_t num_tokens() const { return m_tokens.size(); }
|
||||
size_t num_groups() const { return m_group_characteristics.size(); }
|
||||
size_t num_weighted_groups() const { return m_weighted_groups.size(); }
|
||||
size_t num_branch_rules() const { return m_branch_rules.size(); }
|
||||
|
||||
template <typename CONTGROUP_T, typename CONTWGROUP_T>
|
||||
void find_token_matches(token_id_t token, CONTGROUP_T& out_groups, CONTWGROUP_T& out_wgroups) const;
|
||||
};
|
||||
|
||||
class generator_t {
|
||||
@ -471,5 +496,18 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename CONTGROUP_T, typename CONTWGROUP_T>
|
||||
void ruleset_t::find_token_matches(token_id_t token, CONTGROUP_T& out_groups, CONTWGROUP_T& out_wgroups) const {
|
||||
for (auto rule : m_branch_rules) {
|
||||
if (rule.m_match == token) {
|
||||
if (rule.m_weighted) {
|
||||
out_wgroups.push_back(rule.m_group.weighted);
|
||||
} else {
|
||||
out_groups.push_back(rule.m_group.basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fractal
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user