Wildmeshing Toolkit
edge_insertion.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <wmtk/EdgeMesh.hpp>
4 #include <wmtk/TriMesh.hpp>
5 
6 #include <wmtk/Types.hpp>
8 
9 
11 
12 struct bbox
13 {
15 
16  bbox(const Vector2r& p0, const Vector2r& p1)
17  {
18  if (p0[0] < p1[0]) {
19  x_min = p0[0];
20  x_max = p1[0];
21  } else {
22  x_min = p1[0];
23  x_max = p0[0];
24  }
25 
26  if (p0[1] < p1[1]) {
27  y_min = p0[1];
28  y_max = p1[1];
29  } else {
30  y_min = p1[1];
31  y_max = p0[1];
32  }
33  }
34 
35  bbox(const Vector2r& p0, const Vector2r& p1, const Vector2r& p2)
36  {
37  if (p0[0] < p1[0]) {
38  x_min = p0[0];
39  x_max = p1[0];
40  } else {
41  x_min = p1[0];
42  x_max = p0[0];
43  }
44 
45  if (p0[1] < p1[1]) {
46  y_min = p0[1];
47  y_max = p1[1];
48  } else {
49  y_min = p1[1];
50  y_max = p0[1];
51  }
52 
53  x_min = (x_min > p2[0]) ? p2[0] : x_min;
54  x_max = (x_max < p2[0]) ? p2[0] : x_max;
55  y_min = (y_min > p2[1]) ? p2[1] : y_min;
56  y_max = (y_max < p2[1]) ? p2[1] : y_max;
57  }
58 };
59 class Segment
60 {
61 public:
62  const Vector2r p0, p1;
63  const int64_t idx0, idx1;
65  bool deprecated = false;
66  bool is_on_input = false;
67 
68  // std::vector<std::pair<int64_t, Rational>> points_on_segment;
69  std::vector<std::pair<int64_t, Vector2r>> points_on_segment;
70 
71  Segment(const Vector2r& _p0, const Vector2r& _p1, const int64_t _idx0, const int64_t _idx1)
72  : p0(_p0)
73  , p1(_p1)
74  , idx0(_idx0)
75  , idx1(_idx1)
76  {
77  Rational x_min, x_max, y_min, y_max;
78 
79  if (p0[0] < p1[0]) {
80  x_min = p0[0];
81  x_max = p1[0];
82  } else {
83  x_min = p1[0];
84  x_max = p0[0];
85  }
86 
87  if (p0[1] < p1[1]) {
88  y_min = p0[1];
89  y_max = p1[1];
90  } else {
91  y_min = p1[1];
92  y_max = p0[1];
93  }
94 
95  bbox_min = Vector2r(x_min, y_min);
96  bbox_max = Vector2r(x_max, y_max);
97 
98  points_on_segment.emplace_back(idx0, p0);
99  points_on_segment.emplace_back(idx1, p1);
100  }
101 };
102 
113  const wmtk::Vector2r& P,
114  const wmtk::Vector2r& A,
115  const wmtk::Vector2r& B,
116  const wmtk::Vector2r& C);
117 
118 
124  const Vector2r& s0,
125  const Vector2r& e0,
126  const Vector2r& s1,
127  const Vector2r& e1,
128  Vector2r& res);
129 
130 void edge_insertion(
131  TriMesh& _trimesh,
132  EdgeMesh& edgemesh,
133  std::vector<Vector2r>& v_final,
134  std::vector<std::array<int64_t, 3>>& FV_new,
135  std::vector<std::array<int, 3>>& local_e_on_input);
136 
137 } // namespace wmtk::components::internal
std::vector< std::pair< int64_t, Vector2r > > points_on_segment
Segment(const Vector2r &_p0, const Vector2r &_p1, const int64_t _idx0, const int64_t _idx1)
void edge_insertion(TriMesh &_trimesh, EdgeMesh &edgemesh, std::vector< Vector2r > &v_final, std::vector< std::array< int64_t, 3 >> &FV_new, std::vector< std::array< int, 3 >> &local_e_on_input)
bool segment_segment_inter(const Vector2r &s0, const Vector2r &e0, const Vector2r &s1, const Vector2r &e1, Vector2r &res, Rational &t0, Rational &t1)
int is_point_inside_triangle(const wmtk::Vector2r &P, const wmtk::Vector2r &A, const wmtk::Vector2r &B, const wmtk::Vector2r &C)
Vector< Rational, 2 > Vector2r
Definition: Types.hpp:42
bbox(const Vector2r &p0, const Vector2r &p1)
bbox(const Vector2r &p0, const Vector2r &p1, const Vector2r &p2)