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


C# Polygon.ContainsPoint方法代码示例

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


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

示例1: isLinearEdgeEnabled

        private bool isLinearEdgeEnabled(PlanarGraphEdge edge, OverlayType operation, Polygon polygon, bool inverseArgs)
        {
            if (isAreaEdgeEnabled(edge, operation, polygon, inverseArgs))
                return false;

            switch (operation)
            {
                case OverlayType.Intersection:
                    return edge.Label.UsedByObject1 && (edge.Label.UsedByObject2 || polygon.ContainsPoint(edge.CenterPoint()));
                case OverlayType.Union:
                    return edge.Label.UsedByObject1 && !polygon.ContainsPoint(edge.CenterPoint());
                case OverlayType.Difference:
                    return inverseArgs ? false : 
                                         edge.Label.UsedByObject1 && 
                                         !polygon.ContainsPoint(edge.CenterPoint()) &&
                                         !edge.Label.UsedByObject2;
                case OverlayType.SymmetricDifference:
                    return edge.Label.UsedByObject1 &&
                           !polygon.ContainsPoint(edge.CenterPoint()) &&
                           !edge.Label.UsedByObject2;
            }

            return false;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:24,代码来源:Overlays.cs

示例2: hasPointInside

        private static bool hasPointInside(Polygon polygon, List<ICoordinate> points)
        {
            foreach (ICoordinate point in points)
                if (polygon.ContainsPoint(point))
                    return true;

            return false;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:8,代码来源:DataStructures.cs

示例3: isAreaEdgeEnabled

        private bool isAreaEdgeEnabled(PlanarGraphEdge edge, OverlayType operation, Polygon p1, Polygon p2)
        {
            bool usebyPolygon1 = edge.Label.UsedByObject1;
            bool usebyPolygon2 = edge.Label.UsedByObject2;

            switch (operation)
            {
                case OverlayType.Intersection:
                    if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 == edge.OrientationInObject2)
                        return true;

                    if ((usebyPolygon1 ^ usebyPolygon2))
                        if (usebyPolygon1)
                        {
                            if (p2.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                        else
                        {
                            if (p1.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                    break;
                case OverlayType.Union:
                    if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 == edge.OrientationInObject2)
                        return true;

                    if ((usebyPolygon1 ^ usebyPolygon2))
                        if (usebyPolygon1)
                        {
                            if (!p2.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                        else
                        {
                            if (!p1.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                    break;
                case OverlayType.Difference:
                    if (usebyPolygon1 && usebyPolygon2 && edge.OrientationInObject1 != edge.OrientationInObject2)
                        return true;

                    if ((usebyPolygon1 ^ usebyPolygon2))
                        if (usebyPolygon1)
                        {
                            if (!p2.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                        else
                        {
                            if (p1.ContainsPoint(edge.CenterPoint()))
                                return true;
                        }
                    break;
                case OverlayType.SymmetricDifference:
                    if ((usebyPolygon1 ^ usebyPolygon2))
                        return true;
                    break;
            }

            return false;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:63,代码来源:Overlays.cs

示例4: checkWeightedVertex

        private bool checkWeightedVertex(Polyline polyline, KDTree vertexIndex, SDMinVertex currentVertex, KDTree crossPointIndex)
        {
            // probably not an internal vertex
            if (currentVertex.Previous == null || currentVertex.Next == null)
                return true;

            // top with infinite weight ("do not remove")
            if (double.IsPositiveInfinity(currentVertex.Weight))
                return true;


            SDMinVertex previous = currentVertex.Previous;
            SDMinVertex next = currentVertex.Next;

            // One of the segments formed by the vertex in question may be one of the intersection points.
            // If so, you can not remove the top, as point of self-intersection, it may be removed.
            Segment s1 = new Segment(pointOfWeightedVertex(polyline, currentVertex),
                                     pointOfWeightedVertex(polyline, previous));
            Segment s2 = new Segment(pointOfWeightedVertex(polyline, currentVertex),
                                     pointOfWeightedVertex(polyline, next));

            List<SDMinCrossPoint> crossPoints = new List<SDMinCrossPoint>();
            crossPointIndex.QueryObjectsInRectangle(s1.GetBoundingRectangle(), crossPoints);
            crossPointIndex.QueryObjectsInRectangle(s2.GetBoundingRectangle(), crossPoints);
            foreach (SDMinCrossPoint point in crossPoints)
            {
                if (PlanimetryAlgorithms.LiesOnSegment(point.Point, s1))
                {
                    currentVertex.IsCrossSegmentVertex = true;
                    currentVertex.Previous.IsCrossSegmentVertex = true;
                    return false;
                }
                if(PlanimetryAlgorithms.LiesOnSegment(point.Point, s2))
                {
                    currentVertex.IsCrossSegmentVertex = true;
                    currentVertex.Next.IsCrossSegmentVertex = true;
                    return false;
                }
            }

            //One of the polyline vertices can belong to a triangle, 
            //the apex of which is considered the top. In this case,
            //the top can not be deleted because will be a new point of self-intersection.
            Polygon triangle = new Polygon(new ICoordinate[] { pointOfWeightedVertex(polyline, previous), 
                                                          pointOfWeightedVertex(polyline, currentVertex),
                                                          pointOfWeightedVertex(polyline, next) });

            List<SDMinVertex> vertices = new List<SDMinVertex>();
            vertexIndex.QueryObjectsInRectangle<SDMinVertex>(triangle.GetBoundingRectangle(), vertices);

            foreach (SDMinVertex vertex in vertices)
            {
                ICoordinate p = pointOfWeightedVertex(polyline, vertex);

                //point should not be the top of the triangle
                if (p.ExactEquals(triangle.Contours[0].Vertices[0]) ||
                   p.ExactEquals(triangle.Contours[0].Vertices[1]) ||
                   p.ExactEquals(triangle.Contours[0].Vertices[2]))
                    continue;

                if (triangle.ContainsPoint(p))
                    return false;
            }

            return true;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:66,代码来源:Simplifier.cs


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