/** * Checks if the given point is inside this closed polygon. If this * polyline is not closed (\see setClosed), false is returned. */ bool RPolyline::contains(const RVector& point, bool borderIsInside, double tolerance) const { if (!isGeometricallyClosed(tolerance)) { return false; } // check if point is on polyline: if (isOnShape(point, true, tolerance)) { return borderIsInside; } if (hasArcSegments()) { QPainterPath pp = toPainterPath(); return pp.contains(QPointF(point.x, point.y)); } int nvert = vertices.size(); int i, j; bool c = false; for (i=0, j=nvert-1; i<nvert; j=i++) { if (((vertices[i].y>point.y) != (vertices[j].y>point.y)) && (point.x < (vertices[j].x-vertices[i].x) * (point.y-vertices[i].y) / (vertices[j].y-vertices[i].y) + vertices[i].x) ) { c = !c; } } return c; }
/** * Checks if the given point is inside this closed polygon. If this * polyline is not closed (\see setClosed), false is returned. */ bool RPolyline::contains(const RVector& point) const { if (!closed) { return false; } QPainterPath pp = toPainterPath(); return pp.contains(QPointF(point.x, point.y)); }