Example #1
0
    public void Test_S2LaxLoopShape_EmptyLoop()
    {
        // Test S2Loop constructor.
        var shape = new S2LaxLoopShape(S2Loop.kEmpty);

        Assert.Equal(0, shape.NumVertices);
        Assert.Equal(0, shape.NumEdges());
        Assert.Equal(0, shape.NumChains());
        Assert.Equal(2, shape.Dimension());
        Assert.True(shape.IsEmpty());
        Assert.False(shape.IsFull());
        Assert.False(shape.GetReferencePoint().Contained);
    }
Example #2
0
    public void Test_S2LaxLoopShape_NonEmptyLoop()
    {
        // Test S2Point[] constructor.
        var vertices = ParsePointsOrDie("0:0, 0:1, 1:1, 1:0");
        var shape    = new S2LaxLoopShape(vertices.ToArray());

        Assert.Equal(vertices.Count, shape.NumVertices);
        Assert.Equal(vertices.Count, shape.NumEdges());
        Assert.Equal(1, shape.NumChains());
        Assert.Equal(0, shape.GetChain(0).Start);
        Assert.Equal(vertices.Count, shape.GetChain(0).Length);
        for (int i = 0; i < vertices.Count; ++i)
        {
            Assert.Equal(vertices[i], shape.Vertex(i));
            var edge = shape.GetEdge(i);
            Assert.Equal(vertices[i], edge.V0);
            Assert.Equal(vertices[(i + 1) % vertices.Count], edge.V1);
        }
        Assert.Equal(2, shape.Dimension());
        Assert.False(shape.IsEmpty());
        Assert.False(shape.IsFull());
        Assert.False(shape.GetReferencePoint().Contained);
    }