public void SpinEdgeBackwardThrowsOnInteriorVerticesWithTwoNeighbors() { var indexer = new ManualFaceNeighborIndexer(5, 12, 2, 1); indexer.AddFace(0, 1, 2, 4); indexer.AddFace(2, 3, 0, 4); var topology = TopologyUtility.BuildTopology(indexer); Assert.Throws <InvalidOperationException>(() => { topology.SpinEdgeBackward(topology.vertices[4].firstEdge); }); Assert.Throws <InvalidOperationException>(() => { topology.SpinEdgeBackward(topology.vertices[4].firstEdge.next); }); }
public void SpinEdgeBetweenSquaresBackward() { // 0---1 0---1 // | P | |P ^| // 3-->2 --> 3 / 2 // | N | |/ N| // 4---5 4---5 var indexer = new ManualFaceNeighborIndexer(6, 14, 2, 1); indexer.AddFace(0, 1, 2, 3); indexer.AddFace(5, 4, 3, 2); var topology = TopologyUtility.BuildTopology(indexer); Topology.VertexEdge edgeToSpin; Assert.IsTrue(topology.vertices[3].TryFindEdge(topology.vertices[2], out edgeToSpin)); topology.SpinEdgeBackward(edgeToSpin); TopologyUtility.CheckVerticesForInvalidEdgeCycles(topology); TopologyUtility.CheckFacesForInvalidEdgeCycles(topology); Assert.AreEqual(2, topology.vertices[0].neighborCount); Assert.AreEqual(3, topology.vertices[1].neighborCount); Assert.AreEqual(2, topology.vertices[2].neighborCount); Assert.AreEqual(2, topology.vertices[3].neighborCount); Assert.AreEqual(3, topology.vertices[4].neighborCount); Assert.AreEqual(2, topology.vertices[5].neighborCount); Assert.AreEqual(4, topology.internalFaces[0].neighborCount); Assert.AreEqual(4, topology.internalFaces[1].neighborCount); Assert.AreEqual(topology.vertices[4], edgeToSpin.nearVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.farVertex); Assert.AreEqual(topology.internalFaces[0], edgeToSpin.prevFace); Assert.AreEqual(topology.internalFaces[1], edgeToSpin.nextFace); Assert.AreEqual(topology.vertices[3], edgeToSpin.prev.farVertex); Assert.AreEqual(topology.vertices[5], edgeToSpin.next.farVertex); Assert.AreEqual(topology.vertices[2], edgeToSpin.twin.prev.farVertex); Assert.AreEqual(topology.vertices[0], edgeToSpin.twin.next.farVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.faceEdge.nextVertex); Assert.AreEqual(topology.vertices[2], edgeToSpin.faceEdge.next.nextVertex); Assert.AreEqual(topology.vertices[5], edgeToSpin.faceEdge.next.next.nextVertex); Assert.AreEqual(topology.vertices[4], edgeToSpin.faceEdge.next.next.next.nextVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.faceEdge.next.next.next.next.nextVertex); Assert.AreEqual(topology.vertices[4], edgeToSpin.twin.faceEdge.nextVertex); Assert.AreEqual(topology.vertices[3], edgeToSpin.twin.faceEdge.next.nextVertex); Assert.AreEqual(topology.vertices[0], edgeToSpin.twin.faceEdge.next.next.nextVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.twin.faceEdge.next.next.next.nextVertex); Assert.AreEqual(topology.vertices[4], edgeToSpin.twin.faceEdge.next.next.next.next.nextVertex); }
public void SpinEdgeBetweenTrianglesForward() { // 1 1 // /^\ /P\ // 0P|N3 --> 0-->3 // \|/ \N/ // 2 2 var indexer = new ManualFaceNeighborIndexer(4, 10, 2, 1); indexer.AddFace(0, 1, 2); indexer.AddFace(3, 2, 1); var topology = TopologyUtility.BuildTopology(indexer); Topology.VertexEdge edgeToSpin; Assert.IsTrue(topology.vertices[2].TryFindEdge(topology.vertices[1], out edgeToSpin)); topology.SpinEdgeForward(edgeToSpin); TopologyUtility.CheckVerticesForInvalidEdgeCycles(topology); TopologyUtility.CheckFacesForInvalidEdgeCycles(topology); Assert.AreEqual(3, topology.vertices[0].neighborCount); Assert.AreEqual(2, topology.vertices[1].neighborCount); Assert.AreEqual(2, topology.vertices[2].neighborCount); Assert.AreEqual(3, topology.vertices[3].neighborCount); Assert.AreEqual(3, topology.internalFaces[0].neighborCount); Assert.AreEqual(3, topology.internalFaces[1].neighborCount); Assert.AreEqual(topology.vertices[0], edgeToSpin.nearVertex); Assert.AreEqual(topology.vertices[3], edgeToSpin.farVertex); Assert.AreEqual(topology.internalFaces[0], edgeToSpin.prevFace); Assert.AreEqual(topology.internalFaces[1], edgeToSpin.nextFace); Assert.AreEqual(topology.vertices[1], edgeToSpin.prev.farVertex); Assert.AreEqual(topology.vertices[2], edgeToSpin.next.farVertex); Assert.AreEqual(topology.vertices[2], edgeToSpin.twin.prev.farVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.twin.next.farVertex); Assert.AreEqual(topology.vertices[3], edgeToSpin.faceEdge.nextVertex); Assert.AreEqual(topology.vertices[2], edgeToSpin.faceEdge.next.nextVertex); Assert.AreEqual(topology.vertices[0], edgeToSpin.faceEdge.next.next.nextVertex); Assert.AreEqual(topology.vertices[3], edgeToSpin.faceEdge.next.next.next.nextVertex); Assert.AreEqual(topology.vertices[0], edgeToSpin.twin.faceEdge.nextVertex); Assert.AreEqual(topology.vertices[1], edgeToSpin.twin.faceEdge.next.nextVertex); Assert.AreEqual(topology.vertices[3], edgeToSpin.twin.faceEdge.next.next.nextVertex); Assert.AreEqual(topology.vertices[0], edgeToSpin.twin.faceEdge.next.next.next.nextVertex); }
public void SpinEdgeBackwardThrowsOnBoundaryVerticesWithTwoNeighbors() { var indexer = new ManualFaceNeighborIndexer(3, 6, 1, 1); indexer.AddFace(0, 1, 2); var topology = TopologyUtility.BuildTopology(indexer); foreach (var edge in topology.vertexEdges) { Assert.Throws <InvalidOperationException>(() => { topology.SpinEdgeBackward(edge); }); } }