IntRect computeTextBoundingBox(const RenderText& textRenderer, const Layout& layout) { auto resolver = lineResolver(toRenderBlockFlow(*textRenderer.parent()), layout); auto it = resolver.begin(); auto end = resolver.end(); if (it == end) return IntRect(); auto firstLineRect = *it; float left = firstLineRect.x(); float right = firstLineRect.maxX(); float bottom = firstLineRect.maxY(); for (++it; it != end; ++it) { auto rect = *it; if (rect.x() < left) left = rect.x(); if (rect.maxX() > right) right = rect.maxX(); if (rect.maxY() > bottom) bottom = rect.maxY(); } float x = left; float y = firstLineRect.y(); float width = right - left; float height = bottom - y; return enclosingIntRect(FloatRect(x, y, width, height)); }
/// header consists of two lines HeaderInfo::HeaderInfo(const std::string& line1, const std::string& line2){ // this will contain matches to regular expressions smatch matches; // matches a single number followed by either tabs or spaces string singleNumber("([-+]?[0-9]*\\.?[0-9]+)[\\s\\t]*"); // coordinate system Vector origin(3); Vector maxX(3); Vector maxY(3); double xSpacing=0.0; double ySpacing=0.0; double offset=0.0; // first line defines coordinate system for illuminance map // there will be 9 numbers separated by spaces or tabs // first 3 are origin point, second 3 are max x, last 3 are max y stringstream coordSystemSS; for (unsigned i = 0; i < 9; ++i){ coordSystemSS << singleNumber; } const regex coordSystem(coordSystemSS.str()); if (regex_search(line1, matches, coordSystem)){ origin(0) = lexical_cast<double>( string(matches[1].first, matches[1].second) ); origin(1) = lexical_cast<double>( string(matches[2].first, matches[2].second) ); origin(2) = lexical_cast<double>( string(matches[3].first, matches[3].second) ); maxX(0) = lexical_cast<double>( string(matches[4].first, matches[4].second) ); maxX(1) = lexical_cast<double>( string(matches[5].first, matches[5].second) ); maxX(2) = lexical_cast<double>( string(matches[6].first, matches[6].second) ); maxY(0) = lexical_cast<double>( string(matches[7].first, matches[7].second) ); maxY(1) = lexical_cast<double>( string(matches[8].first, matches[8].second) ); maxY(2) = lexical_cast<double>( string(matches[9].first, matches[9].second) ); }else{ LOG(Fatal, "No coordinate system defined in line1: '" << line1 << "'"); } // second line defines offsets and spacing stringstream spacingOffsetSS; for (unsigned i = 0; i < 3; ++i){ spacingOffsetSS << singleNumber; } const regex spacingOffset(spacingOffsetSS.str()); if (regex_search(line2, matches, spacingOffset)){ xSpacing = lexical_cast<double>( string(matches[1].first, matches[1].second) ); ySpacing = lexical_cast<double>( string(matches[2].first, matches[2].second) ); offset = lexical_cast<double>( string(matches[3].first, matches[3].second) ); }else{ LOG(Fatal, "No spacing or offsets defined in line2: '" << line2 << "'"); } // we can now initialize x and y vectors // DLM@20090803: this is not correct for arbitrary grids, revist m_xVector = deltaSpace(origin(0) + offset, maxX(0), xSpacing); m_yVector = deltaSpace(origin(1) + offset, maxY(1), ySpacing); }
void LineDecoration::draw(Drawable* d) { for (int i=0; i<_top; i++) { ugui_line(i, i, maxX(d)-i, i, _color); // Top ugui_line(i, maxY(d)-i, maxX(d)-i, maxY(d)-i, _color); // Bottom ugui_line(i, i, i, maxY(d)-i, _color ); // Left ugui_line(maxX(d) - i, i, maxX(d)-i, maxY(d)-i, _color ); // Right } }
bool FloatRect::contains(const FloatPoint& point, ContainsMode containsMode) const { if (containsMode == InsideOrOnStroke) return contains(point.x(), point.y()); return x() < point.x() && maxX() > point.x() && y() < point.y() && maxY() > point.y(); }
void tScetch::setTrs() { scaleX=(width()-2*ofs)/(double)(maxX()-minX()); scaleY=(height()-2*ofs)/(double)maxY(); if(scaleX>scaleY) scaleX=scaleY; else scaleY=scaleX; }
void defiGroup::print(FILE* f) const { int i; fprintf(f, "Group '%s'\n", name()); if (hasRegionName()) { fprintf(f, " region name '%s'\n", regionName()); } if (hasRegionBox()) { int size = numRects_; int* xl = xl_; int* yl = yl_; int* xh = xh_; int* yh = yh_; for (i = 0; i < size; i++) fprintf(f, " region box %d,%d %d,%d\n", xl[i], yl[i], xh[i], yh[i]); } if (hasMaxX()) { fprintf(f, " max x %d\n", maxX()); } if (hasMaxY()) { fprintf(f, " max y %d\n", maxY()); } if (hasPerim()) { fprintf(f, " perim %d\n", perim()); } }
bool VertexPair::overlapsRect(const FloatRect& rect) const { bool boundsOverlap = (minX() < rect.maxX()) && (maxX() > rect.x()) && (minY() < rect.maxY()) && (maxY() > rect.y()); if (!boundsOverlap) return false; float leftSideValues[4] = { leftSide(vertex1(), vertex2(), rect.minXMinYCorner()), leftSide(vertex1(), vertex2(), rect.maxXMinYCorner()), leftSide(vertex1(), vertex2(), rect.minXMaxYCorner()), leftSide(vertex1(), vertex2(), rect.maxXMaxYCorner()) }; int currentLeftSideSign = 0; for (unsigned i = 0; i < 4; ++i) { if (!leftSideValues[i]) continue; int leftSideSign = leftSideValues[i] > 0 ? 1 : -1; if (!currentLeftSideSign) currentLeftSideSign = leftSideSign; else if (currentLeftSideSign != leftSideSign) return true; } return false; }
// True if this structure has valid values bool isValid() { return minX() <= maxX() && minY() <= maxY() && minZ() <= maxZ(); }
bool LayoutRect::intersects(const LayoutRect& other) const { // Checking emptiness handles negative widths as well as zero. return !isEmpty() && !other.isEmpty() && x() < other.maxX() && other.x() < maxX() && y() < other.maxY() && other.y() < maxY(); }
FloatShapeInterval OffsetPolygonEdge::clippedEdgeXRange(float y1, float y2) const { if (!overlapsYRange(y1, y2) || (y1 == maxY() && minY() <= y1) || (y2 == minY() && maxY() >= y2)) return FloatShapeInterval(); if (isWithinYRange(y1, y2)) return FloatShapeInterval(minX(), maxX()); // Clip the edge line segment to the vertical range y1,y2 and then return // the clipped line segment's horizontal range. FloatPoint minYVertex; FloatPoint maxYVertex; if (vertex1().y() < vertex2().y()) { minYVertex = vertex1(); maxYVertex = vertex2(); } else { minYVertex = vertex2(); maxYVertex = vertex1(); } float xForY1 = (minYVertex.y() < y1) ? xIntercept(y1) : minYVertex.x(); float xForY2 = (maxYVertex.y() > y2) ? xIntercept(y2) : maxYVertex.x(); return FloatShapeInterval(std::min(xForY1, xForY2), std::max(xForY1, xForY2)); }
void RRTstar_planning(){ ROS_INFO("RRT star planning"); ob::StateSpacePtr space(new ob::RealVectorStateSpace(2)); space->as<ob::RealVectorStateSpace>()->setBounds(minX(local_map->info), maxX(local_map->info)); space->setLongestValidSegmentFraction(0.01/(maxX(local_map->info)-minX(local_map->info))); ob::SpaceInformationPtr si(new ob::SpaceInformation(space)); si->setStateValidityChecker(ob::StateValidityCheckerPtr(new ValidityChecker(si))); si->setup(); ob::ScopedState<> start(space); start->as<ob::RealVectorStateSpace::StateType>()->values[0] = startState[0]; start->as<ob::RealVectorStateSpace::StateType>()->values[1] = startState[1]; ob::ScopedState<> goal(space); goal->as<ob::RealVectorStateSpace::StateType>()->values[0] = goalState[0]; goal->as<ob::RealVectorStateSpace::StateType>()->values[1] = goalState[1]; ob::ProblemDefinitionPtr pdef(new ob::ProblemDefinition(si)); pdef->setStartAndGoalStates(start, goal); pdef->setOptimizationObjective(ob::OptimizationObjectivePtr(new ClearanceObjective(si))); og::RRTstar *plan_pt=new og::RRTstar(si); plan_pt->setGoalBias(0.05); plan_pt->setRange(1.0); ob::PlannerPtr optimizingPlanner(plan_pt); optimizingPlanner->setProblemDefinition(pdef); optimizingPlanner->setup(); ob::PlannerStatus solved; int it=0; while(solved!=ompl::base::PlannerStatus::StatusType::EXACT_SOLUTION && it<100){ it++; solved = optimizingPlanner->solve(1.0); } if(solved==ompl::base::PlannerStatus::StatusType::EXACT_SOLUTION){ std::vector< ob::State * > sol = boost::static_pointer_cast<og::PathGeometric>(pdef->getSolutionPath())->getStates(); current_path_raw.resize(sol.size()); std::transform(sol.begin(), sol.end(), current_path_raw.begin(), &obstateState); /*std::cout << "Path length: " << pdef->getSolutionPath()->length() << std::endl; std::cout << "Path cost: " << pdef->getSolutionPath()->cost(pdef->getOptimizationObjective()) << std::endl; std::cout << "Path :" << std::endl; for(std::deque<State<2>>::iterator it=current_path_raw.begin(),end=current_path_raw.end();it!=end;++it){ std::cout << (*it) << " -- "; } std::cout << std::endl;*/ planned=true; }else{ ROS_INFO("Planning failed"); planned=false; } }
void LayoutRect::uniteEvenIfEmpty(const LayoutRect& other) { LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y())); LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()), std::max(maxY(), other.maxY())); m_location = newLocation; m_size = newMaxPoint - newLocation; }
bool AABB::overlapping(AABB& other) { if (maxX() < other.minX() || minX() > other.maxX() || maxY() < other.minY() || minY() > other.maxY()) { return false; } return true; }
bool Boundary::isValid() const { bool valid = std::isfinite (minX ()) && std::isfinite (maxX ()) && std::isfinite (minY ()) && std::isfinite (maxY ()) && std::isfinite (minZ ()) && std::isfinite (maxZ ()); return valid; }
void IntRect::uniteEvenIfEmpty(const IntRect& other) { int left = std::min(x(), other.x()); int top = std::min(y(), other.y()); int right = std::max(maxX(), other.maxX()); int bottom = std::max(maxY(), other.maxY()); m_location.setX(left); m_location.setY(top); m_size.setWidth(right - left); m_size.setHeight(bottom - top); }
// initializes the map (clearing any previous obstacles) // the heading is required because the specific grid cells that obstacles // occupy can vary void FovObstacleMap::initialize(Heading robotHeading) { this->robotHeading = robotHeading; // set all points to unknown for(int x = minX(); x < maxX(); x++) { for(int y = minY(); y < maxY(); y++) { CellData& cellData = map.cell(x, y); cellData.isKnownObstacle = false; } } }
QPointF SingleCellViewGraphPanelPlotWidget::canvasPoint(const QPoint &pPoint, const bool pNeedOffset) const { // Return the mouse position using canvas coordinates, making sure that they // are within our ranges QPointF realPoint = pPoint; if (pNeedOffset) realPoint -= plotLayout()->canvasRect().topLeft(); return QPointF(qMin(maxX(), qMax(minX(), canvasMap(QwtPlot::xBottom).invTransform(realPoint.x()))), qMin(maxY(), qMax(minY(), canvasMap(QwtPlot::yLeft).invTransform(realPoint.y())))); }
void LayoutRect::intersect(const LayoutRect& other) { LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y())); LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), other.maxY())); // Return a clean empty rectangle for non-intersecting cases. if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()) { newLocation = LayoutPoint(0, 0); newMaxPoint = LayoutPoint(0, 0); } m_location = newLocation; m_size = newMaxPoint - newLocation; }
void DataPlot::displayGraph(const QVector<QPointF>& points) { setAxisScale(QwtPlot::yLeft, minAxisScale(), maxY(points)); setAxisScale(QwtPlot::xBottom, minAxisScale(), maxX(points)); Curve->setSamples( points ); Curve->attach(this); createRegLine(plotDataPoints); resize( 1200, 800 ); replot(); show(); setFocus(); }
bool LayoutRect::inclusiveIntersect(const LayoutRect& other) { LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y())); LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), other.maxY())); if (newLocation.x() > newMaxPoint.x() || newLocation.y() > newMaxPoint.y()) { *this = LayoutRect(); return false; } m_location = newLocation; m_size = newMaxPoint - newLocation; return true; }
void QStackedBarSeriesPrivate::initializeDomain() { qreal minX(domain()->minX()); qreal minY(domain()->minY()); qreal maxX(domain()->maxX()); qreal maxY(domain()->maxY()); qreal x = categoryCount(); minX = qMin(minX, - (qreal)0.5); minY = qMin(minY, bottom()); maxX = qMax(maxX, x - (qreal)0.5); maxY = qMax(maxY, top()); domain()->setRange(minX, maxX, minY, maxY); }
void LayoutRect::uniteIfNonZero(const LayoutRect& other) { // Handle empty special cases first. if (!other.width() && !other.height()) return; if (!width() && !height()) { *this = other; return; } LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y())); LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()), std::max(maxY(), other.maxY())); m_location = newLocation; m_size = newMaxPoint - newLocation; }
void FloatRect::intersect(const FloatRect& other) { float left = std::max(x(), other.x()); float top = std::max(y(), other.y()); float right = std::min(maxX(), other.maxX()); float bottom = std::min(maxY(), other.maxY()); // Return a clean empty rectangle for non-intersecting cases. if (left >= right || top >= bottom) { left = 0; top = 0; right = 0; bottom = 0; } setLocationAndSizeFromEdges(left, top, right, bottom); }
void LayoutRect::unite(const LayoutRect& other) { // Handle empty special cases first. if (other.isEmpty()) return; if (isEmpty()) { *this = other; return; } LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y())); LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()), std::max(maxY(), other.maxY())); m_location = newLocation; m_size = newMaxPoint - newLocation; }
void FloatRect::uniteIfNonZero(const FloatRect& other) { // Handle empty special cases first. if (!other.width() && !other.height()) return; if (!width() && !height()) { *this = other; return; } float left = min(x(), other.x()); float top = min(y(), other.y()); float right = max(maxX(), other.maxX()); float bottom = max(maxY(), other.maxY()); setLocationAndSizeFromEdges(left, top, right, bottom); }
void FloatRect::unite(const FloatRect& other) { // Handle empty special cases first. if (other.isEmpty()) return; if (isEmpty()) { *this = other; return; } float l = min(x(), other.x()); float t = min(y(), other.y()); float r = max(maxX(), other.maxX()); float b = max(maxY(), other.maxY()); setLocationAndSizeFromEdges(l, t, r, b); }
void FloatRect::intersect(const FloatRect& other) { float l = max(x(), other.x()); float t = max(y(), other.y()); float r = min(maxX(), other.maxX()); float b = min(maxY(), other.maxY()); // Return a clean empty rectangle for non-intersecting cases. if (l >= r || t >= b) { l = 0; t = 0; r = 0; b = 0; } setLocationAndSizeFromEdges(l, t, r, b); }
bool SingleCellViewGraphPanelPlotWidget::setAxes(double pMinX, double pMaxX, double pMinY,double pMaxY, const bool &pCanReplot) { // Keep track of our axes' old values double oldMinX = minX(); double oldMaxX = maxX(); double oldMinY = minY(); double oldMaxY = maxY(); // Make sure that the given axes' values are fine checkAxesValues(pMinX, pMaxX, pMinY, pMaxY); // Update our axes' values, if needed bool axesValuesChanged = false; if ((pMinX != oldMinX) || (pMaxX != oldMaxX)) { setAxis(QwtPlot::xBottom, pMinX, pMaxX); axesValuesChanged = true; } if ((pMinY != oldMinY) || (pMaxY != oldMaxY)) { setAxis(QwtPlot::yLeft, pMinY, pMaxY); axesValuesChanged = true; } // Update our actions in case the axes' values have changed if (axesValuesChanged) updateActions(); // Replot ourselves, if needed and allowed if (axesValuesChanged && pCanReplot) { replotNow(); return true; } else { return false; } }
void Boundary::refer(const Boundary &boundary) { if (boundary.minX () < minX ()) setMinX (boundary.minX ()); if (boundary.maxX () > maxX ()) setMaxX (boundary.maxX ()); if (boundary.minY () < minY ()) setMinY (boundary.minY ()); if (boundary.maxY () > maxY ()) setMaxY (boundary.maxY ()); if (boundary.minZ () < minZ ()) setMinZ (boundary.minZ ()); if (boundary.maxZ () > maxZ ()) setMaxZ (boundary.maxZ ()); }
void Boundary::refer(const xjPoint &point) { if (point.x () < minX ()) setMinX (point.x ()); if (point.x () > maxX ()) setMaxX (point.x ()); if (point.y () < minY ()) setMinY (point.y ()); if (point.y () > maxY ()) setMaxY (point.y ()); if (point.z () < minZ ()) setMinZ (point.z ()); if (point.z () > maxZ ()) setMaxZ (point.z ()); }