MCPcopy Create free account
hub / github.com/Kitware/VTK / TrianglesIntersect

Function TrianglesIntersect

Filters/General/vtkCellValidator.cxx:228–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226namespace
227{
228bool 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//------------------------------------------------------------------------------

Callers 8

TestNegativeResultFunction · 0.85
TestPositiveResultFunction · 0.85
TestReciprocalResultFunction · 0.85
TestIssue17092Function · 0.85
TestMR4529Function · 0.85

Calls 2

LineSegmentsIntersectFunction · 0.85
PointsAreCoincidentFunction · 0.85

Tested by 7

TestNegativeResultFunction · 0.68
TestPositiveResultFunction · 0.68
TestReciprocalResultFunction · 0.68
TestIssue17092Function · 0.68
TestMR4529Function · 0.68