PolyFEM
Loading...
Searching...
No Matches
LocalBoundary.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <vector>
5#include <iostream>
6#include <cassert>
7
8namespace polyfem
9{
10 namespace mesh
11 {
12 enum class BoundaryType
13 {
14 TRI_LINE,
15 QUAD_LINE,
16 TRI,
17 QUAD,
18 POLYGON,
21 };
22
25 {
26 public:
30 LocalBoundary(const int global_element_id, BoundaryType type);
31
34 LocalBoundary(const LocalBoundary &other);
35
39 void add_boundary_primitive(const int global_index, const int local_index);
40
43 int size() const { return local_primitive_id_.size(); }
44
47 bool empty() const { return size() <= 0; }
48
51 int element_id() const { return global_element_id_; }
52
55 BoundaryType type() const { return type_; }
56
60 int local_primitive_id(const int index) const { return local_primitive_id_[index]; }
61
65 int global_primitive_id(const int index) const { return global_primitive_id_[index]; }
66
70 int operator[](const int index) const { return local_primitive_id(index); }
71
74 void remove_from(const LocalBoundary &other);
75
78 void remove_tag_for_index(const int index);
79
84 friend std::ostream &operator<<(std::ostream &os, const LocalBoundary &lb);
85
86 private:
88 std::vector<int> global_primitive_id_;
90 std::vector<int> local_primitive_id_;
91
96 };
97 } // namespace mesh
98} // namespace polyfem
Boundary primitive IDs for a single element.
const BoundaryType type_
Type of boundary primitives for the element.
bool empty() const
Check if the element has any boundary primitives.
void add_boundary_primitive(const int global_index, const int local_index)
Mark a boundary primitive as a part of the global boundary.
const int global_element_id_
Element ID.
int operator[](const int index) const
Get the i-th boundary primitive's local ID.
friend std::ostream & operator<<(std::ostream &os, const LocalBoundary &lb)
Print the LocalBoundary to an output stream.
int element_id() const
Get the element's ID.
int local_primitive_id(const int index) const
Get the i-th boundary primitive's local ID.
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.
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.
BoundaryType type() const
Get the type of boundary for the element.
void remove_from(const LocalBoundary &other)
Remove all boundary primitives that are also in another LocalBoundary.
@ QUAD_LINE
Boundary of a quad in 2D.
@ TRI_LINE
Boundary of a triangle in 2D.