Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:48:03

0001 // Boost.Polygon library segment_data.hpp header file
0002 
0003 // Copyright (c) Intel Corporation 2008.
0004 // Copyright (c) 2008-2012 Simonson Lucanus.
0005 // Copyright (c) 2012-2012 Andrii Sydorchuk.
0006 
0007 // See http://www.boost.org for updates, documentation, and revision history.
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_POLYGON_SEGMENT_DATA_HPP
0013 #define BOOST_POLYGON_SEGMENT_DATA_HPP
0014 
0015 #include "isotropy.hpp"
0016 #include "segment_concept.hpp"
0017 
0018 namespace boost {
0019 namespace polygon {
0020 
0021 template <typename T>
0022 class segment_data {
0023  public:
0024   typedef T coordinate_type;
0025   typedef point_data<T> point_type;
0026 
0027   segment_data()
0028 #ifndef BOOST_POLYGON_MSVC
0029     : points_()
0030 #endif
0031   {}
0032 
0033   segment_data(const point_type& low, const point_type& high) {
0034     points_[LOW] = low;
0035     points_[HIGH] = high;
0036   }
0037 
0038   segment_data(const segment_data& that) {
0039     points_[0] = that.points_[0];
0040     points_[1] = that.points_[1];
0041   }
0042 
0043   segment_data& operator=(const segment_data& that) {
0044     points_[0] = that.points_[0];
0045     points_[1] = that.points_[1];
0046     return *this;
0047   }
0048 
0049   template <typename SegmentType>
0050   segment_data& operator=(const SegmentType& that) {
0051     assign(*this, that);
0052     return *this;
0053   }
0054 
0055   point_type get(direction_1d dir) const {
0056     return points_[dir.to_int()];
0057   }
0058 
0059   void set(direction_1d dir, const point_type& point) {
0060     points_[dir.to_int()] = point;
0061   }
0062 
0063   point_type low() const {
0064     return points_[LOW];
0065   }
0066 
0067   segment_data& low(const point_type& point) {
0068     points_[LOW] = point;
0069     return *this;
0070   }
0071 
0072   point_type high() const {
0073     return points_[HIGH];
0074   }
0075 
0076   segment_data& high(const point_type& point) {
0077     points_[HIGH] = point;
0078     return *this;
0079   }
0080 
0081   bool operator==(const segment_data& that) const {
0082     return (points_[0] == that.points_[0]) &&
0083            (points_[1] == that.points_[1]);
0084   }
0085 
0086   bool operator!=(const segment_data& that) const {
0087     return (points_[0] != that.points_[0]) ||
0088            (points_[1] != that.points_[1]);
0089   }
0090 
0091   bool operator<(const segment_data& that) const {
0092     if (points_[0] != that.points_[0]) {
0093       return points_[0] < that.points_[0];
0094     }
0095     return points_[1] < that.points_[1];
0096   }
0097 
0098   bool operator<=(const segment_data& that) const {
0099     return !(that < *this);
0100   }
0101 
0102   bool operator>(const segment_data& that) const {
0103     return that < *this;
0104   }
0105 
0106   bool operator>=(const segment_data& that) const {
0107     return !((*this) < that);
0108   }
0109 
0110  private:
0111   point_type points_[2];
0112 };
0113 
0114 template <typename CType>
0115 struct geometry_concept<segment_data<CType> > {
0116   typedef segment_concept type;
0117 };
0118 }  // polygon
0119 }  // boost
0120 
0121 #endif  // BOOST_POLYGON_SEGMENT_DATA_HPP