PolyFEM
Loading...
Searching...
No Matches
LocalBoundary.cpp
Go to the documentation of this file.
1#include "LocalBoundary.hpp"
2
3namespace polyfem::mesh
4{
5 LocalBoundary::LocalBoundary(const int global_element_id, BoundaryType type)
6 : global_element_id_(global_element_id), type_(type)
7 {
8 }
9
11 : global_primitive_id_(other.global_primitive_id_), local_primitive_id_(other.local_primitive_id_),
12 global_element_id_(other.global_element_id_), type_(other.type_)
13 {
14 }
15
16 void LocalBoundary::add_boundary_primitive(const int global_index, const int local_index)
17 {
18 global_primitive_id_.emplace_back(global_index);
19 local_primitive_id_.emplace_back(local_index);
20 }
21
23 {
24 std::vector<int> to_remove;
25
26 for (int j = 0; j < size(); ++j)
27 {
28 const int loc_id = (*this)[j];
29 for (int i = 0; i < other.size(); ++i)
30 {
31 if (other[i] == loc_id)
32 {
33 to_remove.push_back(j);
34 break;
35 }
36 }
37 }
38
39 for (int j : to_remove)
41 }
42
44 {
45 global_primitive_id_.erase(global_primitive_id_.begin() + index);
46 local_primitive_id_.erase(local_primitive_id_.begin() + index);
47 }
48
49 std::ostream &operator<<(std::ostream &os, const LocalBoundary &lb)
50 {
51 for (int i = 0; i < lb.size(); ++i)
52 os << lb[i] << " -> " << lb.global_primitive_id(i) << ", ";
53 return os;
54 }
55} // namespace polyfem::mesh
Boundary primitive IDs for a single element.
void add_boundary_primitive(const int global_index, const int local_index)
Mark a boundary primitive as a part of the global boundary.
void remove_tag_for_index(const int index)
Remove a boundary primitive from the element.
std::vector< int > global_primitive_id_
Global IDs of the boundary primitives.
LocalBoundary(const int global_element_id, BoundaryType type)
Construct a new Local Boundary object for a given element.
std::vector< int > local_primitive_id_
Local IDs of the boundary primitives.
int size() const
Number of boundary primitives for the element.
int global_primitive_id(const int index) const
Get the i-th boundary primitive's global ID.
void remove_from(const LocalBoundary &other)
Remove all boundary primitives that are also in another LocalBoundary.
std::ostream & operator<<(std::ostream &os, const LocalBoundary &lb)