CenterPoint() public method

Computes a coordinate of the center point.
public CenterPoint ( ) : ICoordinate
return ICoordinate
Example #1
0
        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;
        }
Example #2
0
        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;
        }