introduce set_union wrapper

also rename set_difference wrapper
This commit is contained in:
2020-10-25 00:53:51 -04:00
parent a3233c2686
commit fbd23aea02
2 changed files with 21 additions and 12 deletions

View File

@@ -31,14 +31,23 @@ std::set<V> combinations(const V &options, size_t count) {
} }
template<class V> template<class V>
std::set<V> difference(const std::set<V> &a, const std::set<V> &b) { std::set<V> set_difference(const std::set<V> &a, const std::set<V> &b) {
std::set<V> result; std::set<V> result;
std::set_difference( std::set_difference(
a.begin(), a.end(), a.begin(), a.end(),
b.begin(), b.end(), b.begin(), b.end(),
std::inserter(result, result.end()) std::inserter(result, result.end())
); );
return result;
}
template<class V>
std::set<V> set_union(const std::set<V> &a, const std::set<V> &b) {
std::set<V> result;
std::set_union(
a.begin(), a.end(),
b.begin(), b.end(),
std::inserter(result, result.end())
);
return result; return result;
} }

View File

@@ -67,7 +67,7 @@ public:
std::vector<int> symbol = {3, 4, 3, 2}; std::vector<int> symbol = {3, 4, 3, 2};
auto group = tc::schlafli(symbol); auto group = tc::schlafli(symbol);
auto ctx = generators(group); auto ctx = generators(group);
auto selected_ctxs = difference( auto selected_ctxs = set_difference(
combinations(ctx, 3), combinations(ctx, 3),
{ {
{0, 1, 2}, {0, 1, 2},
@@ -84,18 +84,18 @@ public:
std::vector<int> symbol = {3, 4, 3, 2}; std::vector<int> symbol = {3, 4, 3, 2};
auto group = tc::schlafli(symbol); auto group = tc::schlafli(symbol);
auto ctx = generators(group); auto ctx = generators(group);
auto selected_ctxs = difference(
combinations(ctx, 3), auto selected_ctxs = set_union(
{ combinations(std::vector<int>{0, 2, 3, 4}, 3),
{0, 1, 2}, combinations(std::vector<int>{1, 2, 3, 4}, 3)
}
); );
auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs); auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs);
auto &slice = slices.emplace_back(group); auto &slice = slices.emplace_back(group);
slice.setMesh(mesh); slice.setMesh(mesh);
slice.root << .50, .02, .02, .02, .02; slice.root << .80, .02, .02, .03, .04;
slice.color << 0.1, 0.1, 0.9; slice.color << 0.9, 0.1, 0.1;
} }
ren = std::make_unique<SliceRenderer<4>>(); ren = std::make_unique<SliceRenderer<4>>();