当前位置: 首页>>代码示例>>C#>>正文


C# Polygon.Clone方法代码示例

本文整理汇总了C#中Polygon.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.Clone方法的具体用法?C# Polygon.Clone怎么用?C# Polygon.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon的用法示例。


在下文中一共展示了Polygon.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PolygonTest

        public void PolygonTest()
        {
            Polygon p = new Polygon();
            Assert.IsTrue(p.IsEmpty());
            Assert.AreEqual(0, p.NumInteriorRing);
            Assert.AreEqual(p.NumInteriorRing, p.InteriorRings.Count);
            Assert.IsFalse(p.Equals(null));
            Assert.IsTrue(p.Equals(new Polygon()));
            Assert.AreEqual(BoundingBox.Empty, p.GetBoundingBox());
            LinearRing ring = new LinearRing();
            ring.Vertices.Add(new Point(10, 10));
            ring.Vertices.Add(new Point(20, 10));
            ring.Vertices.Add(new Point(20, 20));
            Assert.IsFalse(ring.IsCcw());
            ring.Vertices.Add(new Point(10, 20));
            ring.Vertices.Add(ring.Vertices[0].Clone() as Point);
            Assert.IsTrue(ring.IsPointWithin(new Point(15, 15)));
            Assert.AreNotSame(ring.Clone(), ring);
            p.ExteriorRing = ring;


            Assert.AreEqual(100, p.Area);
            LinearRing ring2 = new LinearRing();
            ring2.Vertices.Add(new Point(11, 11));
            ring2.Vertices.Add(new Point(19, 11));
            ring2.Vertices.Add(new Point(19, 19));
            ring2.Vertices.Add(new Point(11, 19));
            ring2.Vertices.Add(ring2.Vertices[0].Clone() as Point);
            p.InteriorRings.Add(ring2);
            Assert.AreEqual(100 + 64, p.Area);
            // Reverse() doesn't exist for Collections
            //ring2.Vertices.Reverse();
            //Assert.AreEqual(100 - 64, p.Area);
            Assert.AreEqual(1, p.NumInteriorRing);
            Assert.AreEqual(new BoundingBox(10, 10, 20, 20), p.GetBoundingBox());

            Polygon p2 = p.Clone() as Polygon;
            Assert.AreEqual(p, p2);
            Assert.AreNotSame(p, p2);
            p2.InteriorRings.RemoveAt(0);
            Assert.AreNotEqual(p, p2);
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:42,代码来源:PolygonTests.cs

示例2: ClipPolygons

        // TODO: Check this function
        /// <summary>
        /// Recursively remove all polygons in `polygons` that are inside this BSP tree.
        /// </summary>
        public List<Polygon> ClipPolygons(Polygon[] polygons)
        {
            if (this.plane == null)
            {
                return polygons.Clone<Polygon>().ToList();
            } // TODO: Removed slice here?

            List<Polygon> front = new List<Polygon>();
            List<Polygon> back = new List<Polygon>();

            for (int i = 0; i < polygons.Length; i++)
            {
                this.plane.SplitPolygon(polygons[i], ref front, ref back, ref front, ref back);
            }
            if (this.front != null)
            {
                front = this.front.ClipPolygons(front.ToArray());
            }
            if (this.back != null)
            {
                back = this.back.ClipPolygons(back.ToArray());
            }
            else back = new List<Polygon>();

            return front.Concat(back).ToList();
        }
开发者ID:Avatarchik,项目名称:olde,代码行数:30,代码来源:Node.cs

示例3: getPolygonBuffer

        private static Polygon getPolygonBuffer(Polygon polygon, double distance, int pointsPerCircle, bool allowParallels)
        {
            polygon = (Polygon)polygon.Clone();
            polygon.Weed(distance - distance * Math.Cos(Math.PI / pointsPerCircle));
            polygon.Simplify();

            Polygon boundaryBuffer = getBoundsBuffer(polygon, distance, pointsPerCircle, allowParallels);

            ICollection<IGeometry> result;
            if (distance > 0)
                result = polygon.Union(boundaryBuffer);
            else
                result = polygon.Difference(boundaryBuffer);

            foreach (IGeometry g in result)
                if (g is Polygon)
                    return (Polygon)g;

            return new Polygon();
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:20,代码来源:Buffer.cs

示例4: CreateBaseTile

        public static Tile CreateBaseTile( TilingConfig config )
        {
            Polygon boundary = new Polygon(), drawn = new Polygon();
            boundary.CreateRegular( config.P, config.Q );
            drawn = boundary.Clone();

            //boundary.CreateRegular( 3, 10 );
            //drawn.CreateRegular( 3, 8 );
            //boundary.CreateRegular( 3, 7 );
            //drawn = Heart();

            //for( int i=0; i<drawn.NumSides; i++ )
            //	drawn.Segments[i].Center *= 0.1;

            // Good combos:
            // ( 5, 5 ), ( 10, 10 )
            // ( 3, 10 ), ( 3, 9 )
            // ( 6, 4 ), ( 6, 8 )
            // ( 7, 3 ), ( 7, 9 )

            Tile tile = new Tile( boundary, drawn, config.Geometry );
            Tile.ShrinkTile( ref tile, config.Shrink );
            return tile;
        }
开发者ID:roice3,项目名称:Honeycombs,代码行数:24,代码来源:Tiling.cs


注:本文中的Polygon.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。