Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bbox.hpp « geometry - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee681a194fa055311bcf49ff714b02efd08968f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include "geometry/point2d.hpp"

#include <limits>
#include <vector>

namespace m2
{
class BBox
{
public:
  BBox() = default;
  BBox(std::vector<m2::PointD> const & points);

  void Add(m2::PointD const & p) { return Add(p.x, p.y); }
  void Add(double x, double y);

  bool IsInside(m2::PointD const & p) const { return IsInside(p.x, p.y); }
  bool IsInside(double x, double y) const;

  m2::PointD Min() const { return m2::PointD(m_minX, m_minY); }
  m2::PointD Max() const { return m2::PointD(m_maxX, m_maxY); }

private:
  static_assert(std::numeric_limits<double>::has_infinity, "");
  static double constexpr kPositiveInfinity = std::numeric_limits<double>::infinity();
  static double constexpr kNegativeInfinity = -kPositiveInfinity;

  double m_minX = kPositiveInfinity;
  double m_minY = kPositiveInfinity;
  double m_maxX = kNegativeInfinity;
  double m_maxY = kNegativeInfinity;
};
}  // namespace m2