| 11 | namespace PeriodicInflator2DHelper { |
| 12 | enum Location { INSIDE, ON_BORDER, OUTSIDE }; |
| 13 | Location bbox_check( |
| 14 | const Vector2F& bbox_min, |
| 15 | const Vector2F& bbox_max, |
| 16 | const Vector2F& p0, |
| 17 | const Vector2F& p1, |
| 18 | const Vector2F& p2) { |
| 19 | Vector2F bbox_center = 0.5 * (bbox_min + bbox_max); |
| 20 | Vector2F bbox_size = 0.5 * (bbox_max - bbox_min); |
| 21 | |
| 22 | bool inside = ( |
| 23 | (p0.array() < bbox_max.array()).all() && |
| 24 | (p0.array() > bbox_min.array()).all() && |
| 25 | (p1.array() < bbox_max.array()).all() && |
| 26 | (p1.array() > bbox_min.array()).all() && |
| 27 | (p2.array() < bbox_max.array()).all() && |
| 28 | (p2.array() > bbox_min.array()).all()); |
| 29 | if (inside) return INSIDE; |
| 30 | |
| 31 | const Float tri[3][2] = { |
| 32 | {p0[0], p0[1]}, {p1[0], p1[1]}, {p2[0], p2[1]} |
| 33 | }; |
| 34 | bool overlap = TriBox2D::triBoxOverlap( |
| 35 | bbox_center.data(), |
| 36 | bbox_size.data(), |
| 37 | tri); |
| 38 | if (!overlap) return OUTSIDE; |
| 39 | else return ON_BORDER; |
| 40 | } |
| 41 | |
| 42 | void cut_face( |
| 43 | const Vector2F& bbox_min, |
no test coverage detected