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


C# IPolygon类代码示例

本文整理汇总了C#中IPolygon的典型用法代码示例。如果您正苦于以下问题:C# IPolygon类的具体用法?C# IPolygon怎么用?C# IPolygon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Write

        /// <summary>
        /// 
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="writer"></param>
        public void Write(IPolygon polygon, BinaryWriter writer)
        {
            writer.Write((int) ShapeGeometryTypes.Polygon);

            // Write BoundingBox            
            WriteBoundingBox(polygon, writer);

            // Write NumParts and NumPoints            
            writer.Write((int) (polygon.NumInteriorRings + 1));
            writer.Write((int)  polygon.NumPoints);

            // Write IndexParts
            int count = 0;
            writer.Write((int) count);
            if (polygon.NumInteriorRings != 0)
            {
                // Write external shell index
                count += polygon.ExteriorRing.NumPoints;
                writer.Write((int) count);
                for (int i = 1; i < polygon.NumInteriorRings; i++)
                {
                    // Write internal holes index
                    count += polygon.GetInteriorRingN(i - 1).NumPoints;
                    writer.Write((int) count);
                }
            }

            // Write Coordinates
            for (int i = 0; i < polygon.NumPoints; i++)
                Write(polygon.Coordinates[i], writer);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:36,代码来源:ShapeWriter.cs

示例2: FindBestFitPlane

 /**
  * Finds a best-fit plane for the polygon, 
  * by sampling a few points from the exterior ring.
  * <p>
  * The algorithm used is Newell's algorithm:
  * - a base point for the plane is determined from the average of all vertices
  * - the normal vector is determined by
  *   computing the area of the projections on each of the axis planes
  * 
  * @param poly the polygon to determine the plane for
  * @return the best-fit plane
  */
 private static Plane3D FindBestFitPlane(IPolygon poly)
 {
     var seq = poly.ExteriorRing.CoordinateSequence;
     var basePt = AveragePoint(seq);
     var normal = AverageNormal(seq);
     return new Plane3D(normal, basePt);
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:19,代码来源:PlanarPolygon3D.cs

示例3: HandleNewInput

        public void HandleNewInput(IPolygon geometry)
        {
            // Reset labels
            lbNumVert2.Text = "-";
            lbNumTri2.Text = "-";
            lbNumSeg2.Text = "-";

            lbNumVert.Text = geometry.Points.Count.ToString();
            lbNumSeg.Text = geometry.Segments.Count().ToString();
            lbNumTri.Text = "0";

            // Statistics labels
            lbAreaMin.Text = "-";
            lbAreaMax.Text = "-";
            lbEdgeMin.Text = "-";
            lbEdgeMax.Text = "-";
            lbAngleMin.Text = "-";
            lbAngleMax.Text = "-";

            // Quality labels
            lbQualAlphaMin.Text = "-";
            lbQualAlphaAve.Text = "-";
            lbQualAspectMin.Text = "-";
            lbQualAspectAve.Text = "-";

            angleHistogram1.SetData(null, null);
        }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:27,代码来源:StatisticView.cs

示例4: HandleMeshImport

 public void HandleMeshImport(IPolygon geometry, Mesh mesh)
 {
     // Previous mesh stats
     lbNumVert2.Text = "-";
     lbNumTri2.Text = "-";
     lbNumSeg2.Text = "-";
 }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:7,代码来源:StatisticView.cs

示例5: OnRenderInternal

 protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g)
 {
     IPoint pt = polygon.Centroid;
     Point renderingOrigin = Point.Truncate(Transform.WorldtoMap(pt.Coordinate, map));
     g.RenderingOrigin = new PointStruct(renderingOrigin.X, renderingOrigin.Y);
     base.OnRenderInternal(map, polygon, g);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:7,代码来源:PolygonSymbolizerTest.cs

示例6: AppendCurvePoint

        // 0 0 0 0
        // 0 1 0 0
        // 0 1 2 0
        // 0 1 2 3 0 ...
        private void AppendCurvePoint(IPolygon polygon, ICoordinate worldPos)
        {
            List<ICoordinate> vertices = new List<ICoordinate>();

            ILineString linearRing = polygon.ExteriorRing;
            for (int i = 0; i < linearRing.Coordinates.Length; i++)
            {
                if (linearRing.Coordinates.Length <= 4)
                {
                    if (1 == i)
                    {
                        if (linearRing.Coordinates[0].Equals2D(linearRing.Coordinates[1]))
                        {
                            // 0 0 ? 0 -> 0 1 ? 0 
                            vertices.Add(worldPos);
                        }
                        else
                        {
                            // 0 1 ? 0 -> 0 1 ? 0
                            vertices.Add(linearRing.Coordinates[i]);
                        }
                    }
                    else if (2 == i)
                    {
                        if (linearRing.Coordinates[1].Equals2D(linearRing.Coordinates[2]))
                        {
                            // 0 0 0 0 -> 0 1 1 0
                            vertices.Add(worldPos);
                        }
                        else
                        {
                            // 0 1 2 0 -> 0 1 2 3 0
                            vertices.Add(linearRing.Coordinates[i]);
                            vertices.Add(worldPos);
                        }
                    }
                    else
                    {
                        vertices.Add(linearRing.Coordinates[i]);
                    }
                }
                else
                {
                    if (i == (linearRing.Coordinates.Length - 1))
                    {
                        // insert before last point to keep ring closed
                        vertices.Add(worldPos);
                    }
                    vertices.Add(linearRing.Coordinates[i]);
                }
            }
            int index = FeatureProvider.GetFeatureCount() - 1;
            ILinearRing newLinearRing = GeometryFactory.CreateLinearRing(vertices.ToArray());
            IPolygon newPolygon = GeometryFactory.CreatePolygon(newLinearRing, null);
            //##layerEditor.UpdateCurvePointInserted(index, newPolygon, vertices.Count - 1);
            //((FeatureProvider)layerEditor.VectorLayer.DataSource).UpdateGeometry(index, newPolygon);
            ((Feature)FeatureProvider.Features[index]).Geometry = newPolygon;
            Layer.RenderRequired = true;
            // do not remove see newline MapControl.SelectTool.Select((VectorLayer)Layer, newPolygon, -1);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:64,代码来源:NewPolygonTool.cs

示例7: Station

		/// <summary>
		/// Create a new Station object typing all the property values
		/// </summary>
		/// <param name="lat"></param>
		/// <param name="lon"></param>
		/// <param name="alt"></param>
		/// <param name="compass"></param>
		public Station (string stationID, IPolygon grid, double lat, double lon, double alt, double compass)
		{
			_lat=lat;
			_lon=lon;
			_alt=alt;
			_compass=compass;
			_stationID=stationID;
		}
开发者ID:jiashida,项目名称:cameratrapmanager,代码行数:15,代码来源:Station.cs

示例8: ComputeDistance

 public static void ComputeDistance(IPolygon poly, Coordinate pt, PointPairDistance ptDist)
 {
     ComputeDistance(poly.ExteriorRing, pt, ptDist);
     for (var i = 0; i < poly.NumInteriorRings; i++)
     {
         ComputeDistance(poly.GetInteriorRingN(i), pt, ptDist);
     }
 }
开发者ID:leoliusg,项目名称:NetTopologySuite,代码行数:8,代码来源:DistanceToPoint.cs

示例9: HasRepeatedPoint

 /// <summary>
 /// 
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 private bool HasRepeatedPoint(IPolygon p)
 {
     if (HasRepeatedPoint(p.ExteriorRing.Coordinates))
         return true;
     for (int i = 0; i < p.NumInteriorRings; i++)
         if (HasRepeatedPoint(p.GetInteriorRingN(i).Coordinates)) 
             return true;            
     return false;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:14,代码来源:RepeatedPointTester.cs

示例10: Benchmark

 private void Benchmark(IPolygon poly)
 {
     var start = DateTime.Now;
     var valid = poly.IsValid;
     var end = DateTime.Now;
     var diff = end - start;
     var td = diff.TotalSeconds;
     LogLine("{0} \t{1} \t{2} \t{3}", poly.NumInteriorRings, poly.NumPoints, valid, td);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:9,代码来源:SortedListsFixture.cs

示例11: IsAllCW

        private static bool IsAllCW(IPolygon poly)
        {
            IList<Coordinate> shell = poly.Shell.Coordinates;
            for (int i = 0, c = shell.Count - 3; i < c; i++)
            {
                if (CgAlgorithms.ComputeOrientation(shell[i], shell[i + 1], shell[i + 2]) == 1)
                    return false;
            }

            return true;
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:11,代码来源:LabelPositioning.cs

示例12: Triangulatable

        public Triangulatable(IPolygon polygon)
        {
            List<Vector2D> vPoints = new List<Vector2D>(polygon.VerticesArray);
             List<TriangulationPoint> tPoints = vPoints.ConvertAll(p => (TriangulationPoint) (p));

             if (tPoints.Count < 3) throw new ArgumentException("List has fewer than 3 points", "points");

             // Lets do one sanity check that first and last point haven't got same position
             // It's something that often happens when importing polygon data from other formats
             if (tPoints[0].Equals(tPoints[tPoints.Count - 1])) tPoints.RemoveAt(tPoints.Count - 1);

             points.AddRange(tPoints);
        }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:13,代码来源:TriangulatablePolygon.cs

示例13: Write

        /// <summary>
        /// Save a polygon geometry to disk.
        /// </summary>
        /// <param name="mesh">An instance of the <see cref="IPolygon" /> class.</param>
        /// <param name="filename">The path of the file to save.</param>
        public static void Write(IPolygon polygon, string filename)
        {
            foreach (IPolygonFormat format in formats)
            {
                if (format != null && format.IsSupported(filename))
                {
                    format.Write(polygon, filename);
                    return;
                }
            }

            throw new Exception("File format not supported.");
        }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:18,代码来源:FileProcessor.cs

示例14: ContainsPointInPolygon

 public static Boolean ContainsPointInPolygon(Coordinate p, IPolygon poly)
 {
     if (poly.IsEmpty) return false;
     ILinearRing shell = (ILinearRing)poly.ExteriorRing;
     if (!IsPointInRing(p, shell)) return false;
     // now test if the point lies in or on the holes
     for (int i = 0; i < poly.NumInteriorRings; i++)
     {
         ILinearRing hole = (ILinearRing)poly.GetInteriorRingN(i);
         if (IsPointInRing(p, hole)) return false;
     }
     return true;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:13,代码来源:SimplePointInAreaLocator.cs

示例15: Apply

        /// <summary>
        /// Insert segments into the mesh.
        /// </summary>
        /// <param name="input">The polygon.</param>
        /// <param name="options">Constraint options.</param>
        public void Apply(IPolygon input, ConstraintOptions options)
        {
            behavior.Poly = input.Segments.Count > 0;

            // Copy constraint options
            if (options != null)
            {
                behavior.ConformingDelaunay = options.ConformingDelaunay;
                behavior.Convex = options.Convex;
                behavior.NoBisect = options.SegmentSplitting;

                if (behavior.ConformingDelaunay)
                {
                    behavior.Quality = true;
                }
            }

            //if (input.EdgeMarkers != null)
            //{
            //    behavior.UseBoundaryMarkers = true;
            //}

            behavior.useRegions = input.Regions.Count > 0;

            // Ensure that no vertex can be mistaken for a triangular bounding
            // box vertex in insertvertex().
            mesh.infvertex1 = null;
            mesh.infvertex2 = null;
            mesh.infvertex3 = null;

            if (behavior.useSegments)
            {
                // Segments will be introduced next.
                mesh.checksegments = true;

                // Insert PSLG segments and/or convex hull segments.
                FormSkeleton(input);
            }

            if (behavior.Poly && (mesh.triangles.Count > 0))
            {
                // Copy holes and regions
                mesh.holes.AddRange(input.Holes);
                mesh.regions.AddRange(input.Regions);

                // Carve out holes and concavities.
                CarveHoles();
            }
        }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:54,代码来源:ConstraintMesher.cs


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