/// <summary> /// Checks if the segment is intersecting with nearby front and mesh elements. /// </summary> private bool IsIntersecting(Segment s) { bool intersecting = false; // Get nearby triangles HashSet<Triangle> triangles = s.GetNearbyTriangles(this, cellDistance); // Check intersection with nearby triangles foreach (Triangle triangle in triangles) { Point p1 = s.Intersection(new Segment(triangle.Points[0], triangle.Points[1])); Point p2 = s.Intersection(new Segment(triangle.Points[1], triangle.Points[2])); Point p3 = s.Intersection(new Segment(triangle.Points[2], triangle.Points[0])); if (p1 != null || p2 != null || p3 != null) return true; } //Parallel.ForEach(triangles, (triangle, state) => //{ // Point p1 = s.Intersection(new Segment(triangle.Points[0], triangle.Points[1])); // Point p2 = s.Intersection(new Segment(triangle.Points[1], triangle.Points[2])); // Point p3 = s.Intersection(new Segment(triangle.Points[2], triangle.Points[0])); // if (p1 != null || p2 != null || p3 != null) // { // intersecting = true; // state.Stop(); // } //}); // Get nearby segments of the front HashSet<Segment> segments = s.GetNearbySegments(this.Front, cellDistance); // Check intersecion with nearby segments foreach (Segment other in segments) { Point p = s.Intersection(other); if (p != null) return true; } //Parallel.ForEach(segments, (other, state) => //{ // Point p = s.Intersection(other); // if (p != null) // { // intersecting = true; // state.Stop(); // } //}); return false; //return intersecting; }