Exemple #1
0
        public void ByOrient()
        {
            var place =
                new Polygon
                (
                    new[]
            {
                new Vector3(0.0, 0.0),
                new Vector3(4.0, 0.0),
                new Vector3(4.0, 4.0),
                new Vector3(0.0, 4.0)
            }
                );
            var placeL =
                new Polygon
                (
                    new[]
            {
                new Vector3(0.0, 0.0),
                new Vector3(10.0, 0.0),
                new Vector3(10.0, 10.0),
                new Vector3(0.0, 10.0)
            }
                );
            var adjacentTo =
                new Polygon
                (
                    new[]
            {
                new Vector3(5.0, 5.0),
                new Vector3(9.0, 5.0),
                new Vector3(9.0, 9.0),
                new Vector3(5.0, 9.0)
            }
                );
            var within =
                new Polygon
                (
                    new[]
            {
                new Vector3(0.0, 0.0),
                new Vector3(14.0, 0.0),
                new Vector3(14.0, 14.0),
                new Vector3(0.0, 14.0)
            }
                );
            var among =
                new List <Polygon>
            {
                new Polygon(
                    new []
                {
                    new Vector3(1.0, 10.0),
                    new Vector3(4.0, 10.0),
                    new Vector3(4.0, 13.0),
                    new Vector3(1.0, 13.0)
                })
            };
            var placed = Place.ByOrient(place, Orient.SSW, adjacentTo, Orient.N, within, among);

            Assert.NotNull(placed);
            Assert.Contains(new Vector3(6.0, 9.0), placed.Vertices);
            placed = Place.ByOrient(place, Orient.W, adjacentTo, Orient.ESE, within, among);
            Assert.NotNull(placed);
            Assert.Contains(new Vector3(9.0, 4.0), placed.Vertices);
            placed = Place.ByOrient(place, Orient.N, adjacentTo, Orient.S, within, among);
            Assert.NotNull(placed);
            Assert.Contains(new Vector3(5.0, 1.0), placed.Vertices);
            placed = Place.ByOrient(place, Orient.NE, adjacentTo, Orient.WSW, within, among);
            Assert.NotNull(placed);
            Assert.Contains(new Vector3(1.0, 6.0), placed.Vertices);
            placed = Place.ByOrient(place, Orient.SE, adjacentTo, Orient.NW, within, among);
            Assert.Null(placed);
            placed = Place.ByOrient(place, Orient.SE, adjacentTo, Orient.NW, within);
            Assert.NotNull(placed);
            placed = Place.ByOrient(placeL, Orient.SW, adjacentTo, Orient.N, within);
            Assert.Null(placed);
        }