1 // Boost.Polygon library segment_data.hpp header file
3 // Copyright (c) Intel Corporation 2008.
4 // Copyright (c) 2008-2012 Simonson Lucanus.
5 // Copyright (c) 2012-2012 Andrii Sydorchuk.
7 // See http://www.boost.org for updates, documentation, and revision history.
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_POLYGON_SEGMENT_DATA_HPP
13 #define BOOST_POLYGON_SEGMENT_DATA_HPP
15 #include "isotropy.hpp"
16 #include "segment_concept.hpp"
24 typedef T coordinate_type;
25 typedef point_data<T> point_type;
28 #ifndef BOOST_POLYGON_MSVC
33 segment_data(const point_type& low, const point_type& high) {
38 segment_data(const segment_data& that) {
39 points_[0] = that.points_[0];
40 points_[1] = that.points_[1];
43 segment_data& operator=(const segment_data& that) {
44 points_[0] = that.points_[0];
45 points_[1] = that.points_[1];
49 template <typename SegmentType>
50 segment_data& operator=(const SegmentType& that) {
55 point_type get(direction_1d dir) const {
56 return points_[dir.to_int()];
59 void set(direction_1d dir, const point_type& point) {
60 points_[dir.to_int()] = point;
63 point_type low() const {
67 segment_data& low(const point_type& point) {
72 point_type high() const {
76 segment_data& high(const point_type& point) {
77 points_[HIGH] = point;
81 bool operator==(const segment_data& that) const {
82 return (points_[0] == that.points_[0]) &&
83 (points_[1] == that.points_[1]);
86 bool operator!=(const segment_data& that) const {
87 return (points_[0] != that.points_[0]) ||
88 (points_[1] != that.points_[1]);
91 bool operator<(const segment_data& that) const {
92 if (points_[0] != that.points_[0]) {
93 return points_[0] < that.points_[0];
95 return points_[1] < that.points_[1];
98 bool operator<=(const segment_data& that) const {
99 return !(that < *this);
102 bool operator>(const segment_data& that) const {
106 bool operator>=(const segment_data& that) const {
107 return !((*this) < that);
111 point_type points_[2];
114 template <typename CType>
115 struct geometry_concept<segment_data<CType> > {
116 typedef segment_concept type;
121 #endif // BOOST_POLYGON_SEGMENT_DATA_HPP