diff options
author | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-01 22:18:17 +0100 |
---|---|---|
committer | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-01 22:18:17 +0100 |
commit | d56c07b093bfea1690a81ebbef41b8bb9c7c2464 (patch) | |
tree | 0fae9f1e46df02aa92c8768ea87200b4c2929400 /matching/src/persistence_module.cpp | |
parent | f62d98e76b9dff173f9144caddff1217d0bb81a9 (diff) |
Keep only unique positions in module.
Other minor changes:
1. Remove bi-grades and unnecessary IntPoint class.
2. Remove ModulePresentation ctor from file.
Diffstat (limited to 'matching/src/persistence_module.cpp')
-rw-r--r-- | matching/src/persistence_module.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/matching/src/persistence_module.cpp b/matching/src/persistence_module.cpp index f759a2b..efb20ef 100644 --- a/matching/src/persistence_module.cpp +++ b/matching/src/persistence_module.cpp @@ -1,5 +1,6 @@ #include <numeric> #include <algorithm> +#include <unordered_set> #include <phat/boundary_matrix.h> #include <phat/compute_persistence_pairs.h> @@ -28,14 +29,13 @@ namespace md { // helper function to initialize const member positions_ in ModulePresentation PointVec - concat_gen_and_rel_positions(const PointVec& generators, const std::vector<ModulePresentation::Relation>& relations) + concat_gen_and_rel_positions(const PointVec& generators, const ModulePresentation::RelVec& relations) { - PointVec result(generators); - result.reserve(result.size() + relations.size()); + std::unordered_set<Point> ps(generators.begin(), generators.end()); for(const auto& rel : relations) { - result.push_back(rel.position_); + ps.insert(rel.position_); } - return result; + return PointVec(ps.begin(), ps.end()); } @@ -56,6 +56,14 @@ namespace md { bounding_box_ = Box(Point(min_x_, min_y_), Point(max_x_, max_y_)); } + + ModulePresentation::ModulePresentation(const PointVec& _generators, const RelVec& _relations) : + generators_(_generators), + relations_(_relations) + { + init_boundaries(); + } + void ModulePresentation::translate(md::Real a) { for(auto& g : generators_) { @@ -71,15 +79,6 @@ namespace md { } - ModulePresentation::ModulePresentation(const std::string& fname) // read from file - : - generators_(), - relations_(), - positions_(concat_gen_and_rel_positions(generators_, relations_)) - { - init_boundaries(); - } - /** * * @param slice line on which generators are projected @@ -170,7 +169,6 @@ namespace md { return positions_; } - Box ModulePresentation::bounding_box() const { return bounding_box_; |