| 226 | namespace |
| 227 | { |
| 228 | bool TrianglesIntersect(double p1[3], double p2[3], double p3[3], double q1[3], double q2[3], |
| 229 | double q3[3], double tolerance, vtkCellStatus& status) |
| 230 | { |
| 231 | if (vtkTriangle::TrianglesIntersect(p1, p2, p3, q1, q2, q3) == 1) |
| 232 | { |
| 233 | double* p[3] = { p1, p2, p3 }; |
| 234 | double* q[3] = { q1, q2, q3 }; |
| 235 | |
| 236 | int nCoincidentPoints = 0; |
| 237 | |
| 238 | // Triangles intersect, but potentially are vertex-, edge-, or face-neighbors. |
| 239 | // It is also possible that \a tolerance is too large and all points are coincident |
| 240 | // to within the tolerance. Do not report coincident vertices, edges, or triangles |
| 241 | // as "intersecting". |
| 242 | for (int i = 0; i < 3; i++) |
| 243 | { |
| 244 | for (int j = 0; j < 3; j++) |
| 245 | { |
| 246 | if (LineSegmentsIntersect(p[i], p[(i + 1) % 3], q[j], q[(j + 1) % 3], tolerance)) |
| 247 | { |
| 248 | return false; |
| 249 | } |
| 250 | nCoincidentPoints += int(PointsAreCoincident(p[i], q[j], tolerance)); |
| 251 | } |
| 252 | } |
| 253 | if (nCoincidentPoints > 2) |
| 254 | { |
| 255 | status |= vtkCellStatus::CoincidentPoints; |
| 256 | } |
| 257 | return nCoincidentPoints == 0; |
| 258 | } |
| 259 | // Triangles are disjoint. |
| 260 | return false; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | //------------------------------------------------------------------------------ |