3#include "TopoOffsetTriMesh.h"
6namespace wmtk::components::topological_offset {
20 fit_square(
const Vector2d& p1,
const Vector2d& p2,
const Vector2d& p3, Vector2d& c,
double& l)
26 Eigen::RowVectorXd mins = V.colwise().minCoeff();
27 Eigen::RowVectorXd maxs = V.colwise().maxCoeff();
28 if ((maxs(0) - mins(0)) > (maxs(1) - mins(1))) {
29 l = maxs(0) - mins(0);
31 l = maxs(1) - mins(1);
33 c(0) = (maxs(0) + mins(0)) / 2.0;
34 c(1) = (maxs(1) + mins(1)) / 2.0;
37 Circle(
const Vector2d& c,
const double r)
42 Circle(
const TopoOffsetTriMesh& mesh,
const size_t f_id)
44 auto vs = mesh.oriented_tri_vids(f_id);
48 mesh.m_vertex_attribute[vs[0]].m_posf,
49 mesh.m_vertex_attribute[vs[1]].m_posf,
50 mesh.m_vertex_attribute[vs[2]].m_posf,
55 m_r = side_length / sqrt(2.0);
61 double radius()
const {
return m_r; }
66 Vector2d
center()
const {
return m_c; }
71 void refine(std::queue<Circle>& q)
const
73 double c_off_l = m_r / (2 * sqrt(2.0));
74 double new_r = m_r / 2.0;
75 q.emplace(m_c + (c_off_l * Vector2d(-1, -1)), new_r);
76 q.emplace(m_c + (c_off_l * Vector2d(-1, 1)), new_r);
77 q.emplace(m_c + (c_off_l * Vector2d(1, -1)), new_r);
78 q.emplace(m_c + (c_off_l * Vector2d(1, 1)), new_r);
87 Vector2d p0 = mesh.m_vertex_attribute[vs[0]].m_posf;
88 Vector2d p1 = mesh.m_vertex_attribute[vs[1]].m_posf;
89 Vector2d p2 = mesh.m_vertex_attribute[vs[2]].m_posf;
98 Vector2d closest_point;
99 igl::point_simplex_squared_distance<2>(m_c, V, F, 0, dist2, closest_point);
100 return (dist2 < (m_r * m_r));
std::array< size_t, 3 > oriented_tri_vids(const Tuple &t) const
Get the incident vertices for a triangle.
Definition TriMesh.cpp:1307
static void fit_square(const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, Vector2d &c, double &l)
given 2D triangle, fit square to triangle (return center and side length)
Definition Circle.hpp:20
void refine(std::queue< Circle > &q) const
add refinements of circle to given queue
Definition Circle.hpp:71
double radius() const
get radius of circle
Definition Circle.hpp:61
bool overlaps_tri(const TopoOffsetTriMesh &mesh, const size_t f_id) const
check if circle overlaps given triangle
Definition Circle.hpp:84
Vector2d center() const
get center of circle
Definition Circle.hpp:66
Definition TopoOffsetTriMesh.h:45