예제 #1
0
    public void Test_S2LaxPolygonShape_SingleLoopPolygon()
    {
        // Test S2Polygon constructor.
        var vertices = ParsePointsOrDie("0:0, 0:1, 1:1, 1:0");
        var shape    = new S2LaxPolygonShape(new S2Polygon(new S2Loop(vertices)));

        Assert.Equal(1, shape.NumLoops);
        Assert.Equal(vertices.Count, shape.NumVertices);
        Assert.Equal(vertices.Count, shape.NumLoopVertices(0));
        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.LoopVertex(0, i));
            var edge = shape.GetEdge(i);
            Assert.Equal(vertices[i], edge.V0);
            Assert.Equal(vertices[(i + 1) % vertices.Count], edge.V1);
            Assert.Equal(edge.V0, shape.ChainEdge(0, i).V0);
            Assert.Equal(edge.V1, shape.ChainEdge(0, i).V1);
        }
        Assert.Equal(2, shape.Dimension());
        Assert.False(shape.IsEmpty());
        Assert.False(shape.IsFull());
        Assert.False(shape.ContainsBruteForce(S2.Origin));
        TestEncodedS2LaxPolygonShape(shape);
    }
    public void Test_GetReferencePoint_InvertedLoops()
    {
        List <List <S2Point> > loops = new(){
            ParsePointsOrDie("1:2, 1:1, 2:2"),
            ParsePointsOrDie("3:4, 3:3, 4:4")
        };
        var shape = new S2LaxPolygonShape(loops);

        Assert.True(shape.ContainsBruteForce(S2.Origin));
    }
예제 #3
0
    public void Test_S2LaxPolygonShape_InvertedLoops()
    {
        var loops = new List <List <S2Point> > {
            ParsePointsOrDie("1:2, 1:1, 2:2"),
            ParsePointsOrDie("3:4, 3:3, 4:4")
        };
        var shape = new S2LaxPolygonShape(loops);

        Assert.True(shape.ContainsBruteForce(S2.Origin));
        TestEncodedS2LaxPolygonShape(shape);
    }