Пример #1
0
        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);
        }
Пример #2
0
        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);
        }