Chris@16: // Boost.Polygon library segment_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_SEGMENT_DATA_HPP Chris@16: #define BOOST_POLYGON_SEGMENT_DATA_HPP Chris@16: Chris@16: #include "isotropy.hpp" Chris@16: #include "segment_concept.hpp" Chris@16: Chris@16: namespace boost { Chris@16: namespace polygon { Chris@16: Chris@16: template Chris@16: class segment_data { Chris@16: public: Chris@16: typedef T coordinate_type; Chris@16: typedef point_data point_type; Chris@16: Chris@16: segment_data() Chris@16: #ifndef BOOST_POLYGON_MSVC Chris@16: : points_() Chris@16: #endif Chris@16: {} Chris@16: Chris@16: segment_data(const point_type& low, const point_type& high) { Chris@16: points_[LOW] = low; Chris@16: points_[HIGH] = high; Chris@16: } Chris@16: Chris@16: segment_data(const segment_data& that) { Chris@16: points_[0] = that.points_[0]; Chris@16: points_[1] = that.points_[1]; Chris@16: } Chris@16: Chris@16: segment_data& operator=(const segment_data& that) { Chris@16: points_[0] = that.points_[0]; Chris@16: points_[1] = that.points_[1]; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: template Chris@16: segment_data& operator=(const SegmentType& that) { Chris@16: assign(*this, that); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: point_type get(direction_1d dir) const { Chris@16: return points_[dir.to_int()]; Chris@16: } Chris@16: Chris@16: void set(direction_1d dir, const point_type& point) { Chris@16: points_[dir.to_int()] = point; Chris@16: } Chris@16: Chris@16: point_type low() const { Chris@16: return points_[LOW]; Chris@16: } Chris@16: Chris@16: segment_data& low(const point_type& point) { Chris@16: points_[LOW] = point; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: point_type high() const { Chris@16: return points_[HIGH]; Chris@16: } Chris@16: Chris@16: segment_data& high(const point_type& point) { Chris@16: points_[HIGH] = point; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: bool operator==(const segment_data& that) const { Chris@16: return (points_[0] == that.points_[0]) && Chris@16: (points_[1] == that.points_[1]); Chris@16: } Chris@16: Chris@16: bool operator!=(const segment_data& that) const { Chris@16: return (points_[0] != that.points_[0]) || Chris@16: (points_[1] != that.points_[1]); Chris@16: } Chris@16: Chris@16: bool operator<(const segment_data& that) const { Chris@16: if (points_[0] != that.points_[0]) { Chris@16: points_[0] < that.points_[0]; Chris@16: } Chris@16: return points_[1] < that.points_[1]; Chris@16: } Chris@16: Chris@16: bool operator<=(const segment_data& that) const { Chris@16: return !(that < *this); Chris@16: } Chris@16: Chris@16: bool operator>(const segment_data& that) const { Chris@16: return that < *this; Chris@16: } Chris@16: Chris@16: bool operator>=(const segment_data& that) const { Chris@16: return !((*this) < that); Chris@16: } Chris@16: Chris@16: private: Chris@16: point_type points_[2]; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct geometry_concept > { Chris@16: typedef segment_concept type; Chris@16: }; Chris@16: } // polygon Chris@16: } // boost Chris@16: Chris@16: #endif // BOOST_POLYGON_SEGMENT_DATA_HPP