/// <summary> /// Creates the layering of the graph. (Assigns every vertex to a layer.) /// </summary> protected void AssignLayers() { var lts = new LayeredTopologicalSortAlgorithm <SugiVertex, SugiEdge>(_graph); lts.Compute(); for (int i = 0; i < lts.LayerCount; i++) { var vl = new VertexLayer(_graph, i, lts.Layers[i].ToList()); _layers.Add(vl); } }
public void Vertex2LayerTest() { var input = new VertexLayer { Flags = 8, VertexCount = 2, Positions = new float[2 * 3], Colors = new float[2 * 4], TexCoords = new float[2 * 2], Normals = new float[2 * 3], Bones = new VertexLayer.BoneArray { Mba = 5, Bones = new [] { new VertexLayer.Bone { Name = "123", Vertices = new [] { new VertexLayer.BoneVertex { Vn = 2, Weights = new float[2] } } } } } }; var serializer = new Vertex2LayerHandler(); var output = (VertexLayer)serializer.Reserialize(input); Assert.That(output.Flags, Is.EqualTo(input.Flags)); Assert.That(output.VertexCount, Is.EqualTo(input.VertexCount)); Assert.That(output.Positions, Is.EquivalentTo(input.Positions)); Assert.That(output.Colors, Is.EquivalentTo(input.Colors)); Assert.That(output.TexCoords, Is.EquivalentTo(input.TexCoords)); Assert.That(output.Normals, Is.EquivalentTo(input.Normals)); Assert.That(output.Tangents, Is.Null); Assert.That(output.Bitangents, Is.Null); Assert.That(output.Bones, Is.Not.Null); Assert.That(output.Bones.Mba, Is.EqualTo(input.Bones.Mba)); Assert.That(output.Bones.Bones, Is.Not.Null); Assert.That(output.Bones.Bones.Length, Is.EqualTo(input.Bones.Bones.Length)); }