PolyFEM
Loading...
Searching...
No Matches
NCMeshStorage.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4
5#include <algorithm>
6#include <vector>
7
8namespace polyfem::mesh
9{
12 template <typename T, int MaxSize>
13 using InlineVector = Eigen::Matrix<T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1>;
14
19 {
20 public:
21 using const_iterator = std::vector<int>::const_iterator;
22
23 void insert(const int id)
24 {
25 const auto it = std::lower_bound(ids_.begin(), ids_.end(), id);
26 if (it == ids_.end() || *it != id)
27 ids_.insert(it, id);
28 }
29
31 size_t erase(const int id)
32 {
33 const auto it = std::lower_bound(ids_.begin(), ids_.end(), id);
34 if (it == ids_.end() || *it != id)
35 return 0;
36 ids_.erase(it);
37 return 1;
38 }
39
40 size_t size() const { return ids_.size(); }
41 bool empty() const { return ids_.empty(); }
42 void clear() { ids_.clear(); }
43
44 const_iterator begin() const { return ids_.begin(); }
45 const_iterator end() const { return ids_.end(); }
46 const_iterator cbegin() const { return ids_.cbegin(); }
47 const_iterator cend() const { return ids_.cend(); }
48
49 private:
50 std::vector<int> ids_;
51 };
52} // namespace polyfem::mesh
Set of ids stored as a sorted vector: iterates in increasing order like std::set<int>,...
const_iterator cend() const
void insert(const int id)
std::vector< int >::const_iterator const_iterator
const_iterator begin() const
const_iterator cbegin() const
size_t erase(const int id)
Removes id; returns the number of removed ids (0 or 1).
std::vector< int > ids_
const_iterator end() const
Eigen::Matrix< T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1 > InlineVector
Small vector stored inline (no heap allocation), with the VectorXi / VectorXd API; used for the per-e...