Skip to content

File Interval.h

File List > detail > Interval.h

Go to the documentation of this file

// Copyright (c) 2012-2013, IGN France.
// Copyright (c) 2012-2022, Oslandia.
// SPDX-License-Identifier: LGPL-2.0-or-later

#ifndef _SFCGAL_DETAIL_INTERVAL_H_
#define _SFCGAL_DETAIL_INTERVAL_H_

#include "SFCGAL/config.h"

namespace SFCGAL {
namespace detail {

class SFCGAL_API Interval {
public:
  Interval();
  Interval(const double &value);
  Interval(const double &v1, const double &v2);
  Interval(const Interval &other);
  Interval &
  operator=(const Interval &other);

  bool
  isEmpty() const;

  inline const double &
  lower() const
  {
    return _lower;
  }
  inline const double &
  upper() const
  {
    return _upper;
  }
  inline double
  width() const
  {
    return _upper - _lower;
  }

  void
  expandBy(const double &d);
  void
  expandToInclude(const Interval &other);
  void
  expandToInclude(const double &value);

  bool
  intersects(const Interval &other) const;

  bool
  operator==(const Interval &other) const;
  bool
  operator!=(const Interval &other) const;

private:
  double _lower;
  double _upper;
};

} // namespace detail
} // namespace SFCGAL

#endif