Chris@16: // Boost.Polygon library point_data.hpp header file Chris@16: Chris@16: // Copyright (c) Intel Corporation 2008. Chris@16: // Copyright (c) 2008-2012 Simonson Lucanus. Chris@16: // Copyright (c) 2012-2012 Andrii Sydorchuk. Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_POLYGON_POINT_DATA_HPP Chris@16: #define BOOST_POLYGON_POINT_DATA_HPP Chris@16: Chris@16: #include "isotropy.hpp" Chris@16: #include "point_concept.hpp" Chris@16: Chris@16: namespace boost { Chris@16: namespace polygon { Chris@16: Chris@16: template Chris@16: class point_data { Chris@16: public: Chris@16: typedef T coordinate_type; Chris@16: Chris@16: point_data() Chris@16: #ifndef BOOST_POLYGON_MSVC Chris@16: : coords_() Chris@16: #endif Chris@16: {} Chris@16: Chris@16: point_data(coordinate_type x, coordinate_type y) { Chris@16: coords_[HORIZONTAL] = x; Chris@16: coords_[VERTICAL] = y; Chris@16: } Chris@16: Chris@16: explicit point_data(const point_data& that) { Chris@16: coords_[0] = that.coords_[0]; Chris@16: coords_[1] = that.coords_[1]; Chris@16: } Chris@16: Chris@16: point_data& operator=(const point_data& that) { Chris@16: coords_[0] = that.coords_[0]; Chris@16: coords_[1] = that.coords_[1]; Chris@16: return *this; Chris@16: } Chris@16: Chris@101: #ifdef __GNUC__ Chris@101: // "explicit" to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63356 Chris@16: template Chris@16: explicit point_data(const PointType& that) { Chris@16: *this = that; Chris@16: } Chris@101: #else // __GNUC__ Chris@101: template Chris@101: point_data(const PointType& that) { Chris@101: *this = that; Chris@101: } Chris@101: #endif // __GNUC__ Chris@16: Chris@16: template Chris@16: point_data& operator=(const PointType& that) { Chris@16: assign(*this, that); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // TODO(asydorchuk): Deprecated. Chris@16: template Chris@16: point_data(const point_data& that) { Chris@16: coords_[HORIZONTAL] = (coordinate_type)that.x(); Chris@16: coords_[VERTICAL] = (coordinate_type)that.y(); Chris@16: } Chris@16: Chris@16: coordinate_type get(orientation_2d orient) const { Chris@16: return coords_[orient.to_int()]; Chris@16: } Chris@16: Chris@16: void set(orientation_2d orient, coordinate_type value) { Chris@16: coords_[orient.to_int()] = value; Chris@16: } Chris@16: Chris@16: coordinate_type x() const { Chris@16: return coords_[HORIZONTAL]; Chris@16: } Chris@16: Chris@16: point_data& x(coordinate_type value) { Chris@16: coords_[HORIZONTAL] = value; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: coordinate_type y() const { Chris@16: return coords_[VERTICAL]; Chris@16: } Chris@16: Chris@16: point_data& y(coordinate_type value) { Chris@16: coords_[VERTICAL] = value; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: bool operator==(const point_data& that) const { Chris@16: return (coords_[0] == that.coords_[0]) && Chris@16: (coords_[1] == that.coords_[1]); Chris@16: } Chris@16: Chris@16: bool operator!=(const point_data& that) const { Chris@16: return !(*this == that); Chris@16: } Chris@16: Chris@16: bool operator<(const point_data& that) const { Chris@16: return (coords_[0] < that.coords_[0]) || Chris@16: ((coords_[0] == that.coords_[0]) && Chris@16: (coords_[1] < that.coords_[1])); Chris@16: } Chris@16: Chris@16: bool operator<=(const point_data& that) const { Chris@16: return !(that < *this); Chris@16: } Chris@16: Chris@16: bool operator>(const point_data& that) const { Chris@16: return that < *this; Chris@16: } Chris@16: Chris@16: bool operator>=(const point_data& that) const { Chris@16: return !(*this < that); Chris@16: } Chris@16: Chris@16: private: Chris@16: coordinate_type coords_[2]; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct geometry_concept< point_data > { Chris@16: typedef point_concept type; Chris@16: }; Chris@16: } // polygon Chris@16: } // boost Chris@16: Chris@16: #endif // BOOST_POLYGON_POINT_DATA_HPP