public void ProcessTriangleMesh(Action <double, string> progress = null, CancellationToken?token = null) { if (triangleMesh == null) { return; } progress?.Invoke(0.2, null); foreach (var edge in triangleMesh.Edges) { if (token.HasValue && token.Value.IsCancellationRequested) { return; } if (edge.Triangles.Count() != 2) { continue; } var leftTriangle = edge.Triangles.First(); var rightTriangle = edge.Triangles.Last(); var angleBetweenVectors = Vector3d.Dot( leftTriangle.Normal.GetNormal(), rightTriangle.Normal.GetNormal()); if (Math.Abs(Math.Abs(angleBetweenVectors) - Cos0) <= FaceTolerance) { if (leftTriangle.SourceFace != null && rightTriangle.SourceFace != null) { if (leftTriangle.SourceFace == rightTriangle.SourceFace) { continue; } leftTriangle.SourceFace.Add(rightTriangle.SourceFace); continue; } if (leftTriangle.SourceFace != null) { leftTriangle.SourceFace.Add(rightTriangle); continue; } if (rightTriangle.SourceFace != null) { rightTriangle.SourceFace.Add(leftTriangle); continue; } var face = new Face3D(); face.Add(leftTriangle); face.Add(rightTriangle); } else { if (leftTriangle.SourceFace == null) { var newFace = new Face3D(); newFace.Add(leftTriangle); } if (rightTriangle.SourceFace == null) { var newFace = new Face3D(); newFace.Add(rightTriangle); } InternalEdges.Add(edge); } } progress?.Invoke(0.6, null); if (token.HasValue && token.Value.IsCancellationRequested) { return; } CalculateFaces(); progress?.Invoke(0.8, null); if (token.HasValue && token.Value.IsCancellationRequested) { return; } CalculateEdges(); progress?.Invoke(0.9, null); if (token.HasValue && token.Value.IsCancellationRequested) { return; } CalculateVertices(); }