public void TestEnumerateTriangles() { var mesh = CreateMesh(out var vertices); var circulator = new VertexCirculator(mesh); var p = vertices[0]; var list = circulator.EnumerateTriangles(p).ToList(); Assert.AreEqual(1, list.Count); }
/// <summary> /// Find boundary triangles using vertices. /// </summary> private static void FindBoundary2(IMesh mesh) { var circulator = new VertexCirculator((Mesh)mesh); foreach (var vertex in mesh.Vertices) { int label = vertex.Label; if (label > 0) { var star = circulator.EnumerateTriangles(vertex); foreach (var triangle in star) { triangle.Label = label; } } } }
/// <summary> /// Find boundary triangles using vertices. /// </summary> private static void FindBoundary2(Mesh mesh) { var circulator = new VertexCirculator(mesh); foreach (var vertex in mesh.Vertices) { int label = vertex.Label; if (label > 0) { var star = circulator.EnumerateTriangles(vertex); // WARNING: triangles will be processed multiple times. foreach (var triangle in star) { triangle.Label = label; } } } }
/// <summary> /// Find boundary triangles using segments. /// </summary> private static void FindBoundary1(IMesh mesh, bool neigbours = true) { mesh.Renumber(); var cache = new List <Vertex>(mesh.Segments.Count + 1); var circulator = new VertexCirculator((Mesh)mesh); foreach (var s in mesh.Segments) { int label = s.Label; for (int i = 0; i < 2; i++) { var vertex = s.GetVertex(i); // Check the vertex ID to see if it was processed already. if (vertex.ID >= 0) { var star = circulator.EnumerateTriangles(vertex); foreach (var triangle in star) { triangle.Label = label; } // Mark the vertex as "processed". vertex.ID = -vertex.ID; cache.Add(vertex); } } } // Undo the vertex ID changes. foreach (var vertex in cache) { vertex.ID = -vertex.ID; } }