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


C# Polygon.GetBoundingBox方法代码示例

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


在下文中一共展示了Polygon.GetBoundingBox方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: PolyBoundingBox

        public void PolyBoundingBox()
        {
            var polygon = new Polygon(new Point(0, 0), new Point(5, 10), new Point(3, 11));

            Assert.AreEqual(3, polygon.Points.Length);

            var box = polygon.GetBoundingBox();

            Assert.AreEqual(11, box.Top);
            Assert.AreEqual(5, box.Right);
            Assert.AreEqual(0, box.Bottom);
            Assert.AreEqual(0, box.Left);

            polygon = new Polygon(new Point(0, 0), new Point(5, 10), new Point(-10, -15));

            box = polygon.GetBoundingBox();

            Assert.AreEqual(-10, box.Left);
            Assert.AreEqual(-15, box.Bottom);
        }
开发者ID:carbon,项目名称:Geography,代码行数:20,代码来源:PolygonTests.cs

示例3: BuildNode

        private static RooBSPItem BuildNode(List<RooWall> Walls, Polygon Polygon, int Sector)
        {
            if (Polygon.Count == 0 || (Walls.Count == 0 && Sector == 0))
                return null;

            Polygon.RemoveZeroEdges();

            if (!Polygon.IsConvexPolygon())
            {
                if (FoundNonConvexPolygon != null)
                    FoundNonConvexPolygon(null, new PolygonEventArgs(Polygon));

                //return null; // WTF ?
            }

            // No walls left ==> leaf
            if (Walls.Count == 0)
            {
                RooSubSector leaf = new RooSubSector(RooFile.VERSIONHIGHRESGRID, (ushort)Sector, Polygon);

                // fills in sector reference
                leaf.ResolveIndices(room);
                
                return leaf;
            }

            // get best splitter of remaining walls
            RooWall splitter = ChooseSplitter(Walls);

            if (splitter == null)
                return null; // WTF ?

            // split up walls into right/left
            Tuple<List<RooWall>, List<RooWall>> splitWalls = 
                SplitWalls(Walls, splitter);
            
            // split up polygon into right/left
            Tuple<Polygon, Polygon> splitPolygons = 
                Polygon.SplitConvexPolygon(splitter.P1, splitter.P2);

            Real a, b, c;
            GetLineEquation2DCoefficients(splitter.P1, splitter.P2,
                out a, out b, out c);

            // create new splitter node
            RooPartitionLine node = new RooPartitionLine(RooFile.VERSIONHIGHRESGRID,
                Polygon.GetBoundingBox(), a, b, c, 0, 0, (ushort)splitter.Num);

            // fills in wall reference
            node.Wall = splitter;

            // recursively descend to children
            node.LeftChild = BuildNode(splitWalls.Item1, splitPolygons.Item1, splitter.LeftSectorNum);
            node.RightChild  = BuildNode(splitWalls.Item2, splitPolygons.Item2, splitter.RightSectorNum);

            return node;
        }
开发者ID:GJiin,项目名称:meridian59-dotnet,代码行数:57,代码来源:BSPBuilder.cs

示例4: RooSubSector

        /// <summary>
        /// Constructor by values
        /// </summary>
        /// <param name="RooVersion"></param>
        /// <param name="SectorNum"></param>
        /// <param name="Vertices"></param>
        public RooSubSector(uint RooVersion, ushort SectorNum, Polygon Vertices) 
            : base(RooVersion)
        {
            this.SectorNum = SectorNum; 
            this.Vertices = Vertices;

            if (Vertices != null && Vertices.Count > 0)            
                boundingBox = Vertices.GetBoundingBox();
            
            else
                boundingBox = BoundingBox2D.NULL;
        }
开发者ID:GJiin,项目名称:meridian59-dotnet,代码行数:18,代码来源:RooSubSector.cs

示例5: InvalidatePoly

 private void InvalidatePoly(Polygon poly)
 {
     Rectangle rect = poly.GetBoundingBox();
     rect.Inflate(2 * VertexRadius, 2 * VertexRadius);
     InvalidateRect(rect);
 }
开发者ID:rasgele,项目名称:Poly-Editor,代码行数:6,代码来源:PolyDrawer.cs

示例6: GetPolyRectInflated

 private Rectangle GetPolyRectInflated(Polygon poly)
 {
     Rectangle r = poly.GetBoundingBox();
     r.Inflate(VertexRadius * 2, VertexRadius * 2);
     return r;
 }
开发者ID:rasgele,项目名称:Poly-Editor,代码行数:6,代码来源:PolyDrawer.cs

示例7: DrawPoly

        private void DrawPoly(Graphics g, Polygon poly)
        {
            Pen linePen = Pens.Black;
            if (poly.Points.Count > 1)
            {
                var points = poly.Points.ConvertAll(new Converter<Vector2, Point>(v => new Point(v.X, v.Y)));
                g.DrawLines(linePen, points.ToArray());
                g.DrawLine(linePen, poly.Points[0], poly.Points[poly.Points.Count - 1]);
            }

            foreach (var point in poly.Points)
            {
                Brush vertexBrush = IsSelected(point) ? Brushes.Coral : Brushes.BlueViolet;
                g.FillEllipse(vertexBrush, GetSquareCenteredOnPoint(point, VertexRadius));
                g.DrawEllipse(Pens.Black, GetSquareCenteredOnPoint(point, VertexRadius));
            }
            if (DrawBoundingBox)
            {
                Pen bbPen = new Pen(Color.FromArgb(100, Color.Red));

                g.DrawRectangle(bbPen, poly.GetBoundingBox());

                bbPen.Dispose();
            }
        }
开发者ID:rasgele,项目名称:Poly-Editor,代码行数:25,代码来源:PolyDrawer.cs


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