Chris@16: /* Chris@16: Copyright 2008 Intel Corporation Chris@16: Chris@16: Use, modification and distribution are 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_POLYGON_45_SET_VIEW_HPP Chris@16: #define BOOST_POLYGON_POLYGON_45_SET_VIEW_HPP Chris@16: namespace boost { namespace polygon{ Chris@16: Chris@16: template Chris@16: class polygon_45_set_view; Chris@16: Chris@16: template Chris@16: struct polygon_45_set_traits > { Chris@16: typedef typename polygon_45_set_view::coordinate_type coordinate_type; Chris@16: typedef typename polygon_45_set_view::iterator_type iterator_type; Chris@16: typedef typename polygon_45_set_view::operator_arg_type operator_arg_type; Chris@16: Chris@16: static inline iterator_type begin(const polygon_45_set_view& polygon_45_set); Chris@16: static inline iterator_type end(const polygon_45_set_view& polygon_45_set); Chris@16: Chris@16: template Chris@16: static inline void set(polygon_45_set_view& polygon_45_set, Chris@16: input_iterator_type input_begin, input_iterator_type input_end); Chris@16: Chris@16: static inline bool clean(const polygon_45_set_view& polygon_45_set); Chris@16: Chris@16: }; Chris@16: Chris@16: template Chris@16: struct compute_45_set_value { Chris@16: static Chris@16: void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_) { Chris@16: output_.set(polygon_45_set_traits::begin(lvalue_), Chris@16: polygon_45_set_traits::end(lvalue_)); Chris@16: value_type rinput_; Chris@16: rinput_.set(polygon_45_set_traits::begin(rvalue_), Chris@16: polygon_45_set_traits::end(rvalue_)); Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (push) Chris@16: #pragma warning (disable: 4127) Chris@16: #endif Chris@16: if(op_type == 0) Chris@16: output_ |= rinput_; Chris@16: else if(op_type == 1) Chris@16: output_ &= rinput_; Chris@16: else if(op_type == 2) Chris@16: output_ ^= rinput_; Chris@16: else Chris@16: output_ -= rinput_; Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (pop) Chris@16: #endif Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct compute_45_set_value, op_type> { Chris@16: static Chris@16: void value(value_type& output_, const ltype& lvalue_, const polygon_45_set_data& rvalue_) { Chris@16: output_.set(polygon_45_set_traits::begin(lvalue_), Chris@16: polygon_45_set_traits::end(lvalue_)); Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (push) Chris@16: #pragma warning (disable: 4127) Chris@16: #endif Chris@16: if(op_type == 0) Chris@16: output_ |= rvalue_; Chris@16: else if(op_type == 1) Chris@16: output_ &= rvalue_; Chris@16: else if(op_type == 2) Chris@16: output_ ^= rvalue_; Chris@16: else Chris@16: output_ -= rvalue_; Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (pop) Chris@16: #endif Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class polygon_45_set_view { Chris@16: public: Chris@16: typedef typename polygon_45_set_traits::coordinate_type coordinate_type; Chris@16: typedef polygon_45_set_data value_type; Chris@16: typedef typename value_type::iterator_type iterator_type; Chris@16: typedef polygon_45_set_view operator_arg_type; Chris@16: private: Chris@16: const ltype& lvalue_; Chris@16: const rtype& rvalue_; Chris@16: mutable value_type output_; Chris@16: mutable bool evaluated_; Chris@16: Chris@16: polygon_45_set_view& operator=(const polygon_45_set_view&); Chris@16: public: Chris@16: polygon_45_set_view(const ltype& lvalue, Chris@16: const rtype& rvalue ) : Chris@16: lvalue_(lvalue), rvalue_(rvalue), output_(), evaluated_(false) {} Chris@16: Chris@16: // get iterator to begin vertex data Chris@16: public: Chris@16: const value_type& value() const { Chris@16: if(!evaluated_) { Chris@16: evaluated_ = true; Chris@16: compute_45_set_value::value(output_, lvalue_, rvalue_); Chris@16: } Chris@16: return output_; Chris@16: } Chris@16: public: Chris@16: iterator_type begin() const { return value().begin(); } Chris@16: iterator_type end() const { return value().end(); } Chris@16: Chris@16: bool dirty() const { return value().dirty(); } //result of a boolean is clean Chris@16: bool sorted() const { return value().sorted(); } //result of a boolean is sorted Chris@16: Chris@16: // template Chris@16: // void set(input_iterator_type input_begin, input_iterator_type input_end, Chris@16: // orientation_2d orient) const { Chris@16: // orient_ = orient; Chris@16: // output_.clear(); Chris@16: // output_.insert(output_.end(), input_begin, input_end); Chris@16: // polygon_sort(output_.begin(), output_.end()); Chris@16: // } Chris@16: }; Chris@16: Chris@16: template Chris@16: typename polygon_45_set_traits >::iterator_type Chris@16: polygon_45_set_traits >:: Chris@16: begin(const polygon_45_set_view& polygon_45_set) { Chris@16: return polygon_45_set.begin(); Chris@16: } Chris@16: template Chris@16: typename polygon_45_set_traits >::iterator_type Chris@16: polygon_45_set_traits >:: Chris@16: end(const polygon_45_set_view& polygon_45_set) { Chris@16: return polygon_45_set.end(); Chris@16: } Chris@16: template Chris@16: bool polygon_45_set_traits >:: Chris@16: clean(const polygon_45_set_view& polygon_45_set) { Chris@16: return polygon_45_set.value().clean(); } Chris@16: Chris@16: template Chris@16: geometry_type_1& self_assignment_boolean_op_45(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) { Chris@16: typedef geometry_type_1 ltype; Chris@16: typedef geometry_type_2 rtype; Chris@16: typedef typename polygon_45_set_traits::coordinate_type coordinate_type; Chris@16: typedef polygon_45_set_data value_type; Chris@16: value_type output_; Chris@16: value_type rinput_; Chris@16: output_.set(polygon_45_set_traits::begin(lvalue_), Chris@16: polygon_45_set_traits::end(lvalue_)); Chris@16: rinput_.set(polygon_45_set_traits::begin(rvalue_), Chris@16: polygon_45_set_traits::end(rvalue_)); Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (push) Chris@16: #pragma warning (disable: 4127) Chris@16: #endif Chris@16: if(op_type == 0) Chris@16: output_ |= rinput_; Chris@16: else if(op_type == 1) Chris@16: output_ &= rinput_; Chris@16: else if(op_type == 2) Chris@16: output_ ^= rinput_; Chris@16: else Chris@16: output_ -= rinput_; Chris@16: #ifdef BOOST_POLYGON_MSVC Chris@16: #pragma warning (pop) Chris@16: #endif Chris@16: polygon_45_set_mutable_traits::set(lvalue_, output_.begin(), output_.end()); Chris@16: return lvalue_; Chris@16: } Chris@16: Chris@16: template Chris@16: struct fracture_holes_option_by_type { Chris@16: static const bool value = true; Chris@16: }; Chris@16: template <> Chris@16: struct fracture_holes_option_by_type { Chris@16: static const bool value = false; Chris@16: }; Chris@16: template <> Chris@16: struct fracture_holes_option_by_type { Chris@16: static const bool value = false; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct geometry_concept > { typedef polygon_45_set_concept type; }; Chris@16: Chris@16: namespace operators { Chris@16: struct y_ps45_b : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_b, Chris@16: typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_either_polygon_45_set_type::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_p : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_p, Chris@16: typename gtl_if::type>::type, Chris@16: typename gtl_if::type>::type, Chris@16: typename gtl_if::type>::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_s : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_s, typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_either_polygon_45_set_type::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_a : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_a, typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_either_polygon_45_set_type::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_x : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_x, typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_polygon_45_or_90_set_type::type, Chris@16: typename is_either_polygon_45_set_type::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_m : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4< y_ps45_m, Chris@16: typename gtl_if::type>::type, Chris@16: typename gtl_if::type>::type, Chris@16: typename gtl_if::type>::type>::type, Chris@16: polygon_45_set_view >::type Chris@16: operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return polygon_45_set_view Chris@16: (lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_pe : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_4::type, gtl_yes, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_be : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_se : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3< y_ps45_se, Chris@16: typename is_mutable_polygon_45_set_type::type, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_ae : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_xe : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< Chris@16: typename gtl_and_3::type, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_me : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type, Chris@16: typename is_polygon_45_or_90_set_type::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) { Chris@16: return self_assignment_boolean_op_45(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_rpe : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3< y_ps45_rpe, typename is_mutable_polygon_45_set_type::type, Chris@16: typename gtl_same_type::type, Chris@16: coordinate_concept>::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) { Chris@16: return resize(lvalue, rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_rme : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type>::type, Chris@16: typename gtl_same_type::type, Chris@16: coordinate_concept>::type>::type, Chris@16: geometry_type_1>::type & Chris@16: operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) { Chris@16: return resize(lvalue, -rvalue); Chris@16: } Chris@16: Chris@16: struct y_ps45_rp : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type>::type, Chris@16: typename gtl_same_type::type, Chris@16: coordinate_concept>::type> Chris@16: ::type, geometry_type_1>::type Chris@16: operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) { Chris@16: geometry_type_1 retval(lvalue); Chris@16: retval += rvalue; Chris@16: return retval; Chris@16: } Chris@16: Chris@16: struct y_ps45_rm : gtl_yes {}; Chris@16: Chris@16: template Chris@16: typename enable_if< typename gtl_and_3::type>::type, Chris@16: typename gtl_same_type::type, Chris@16: coordinate_concept>::type> Chris@16: ::type, geometry_type_1>::type Chris@16: operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) { Chris@16: geometry_type_1 retval(lvalue); Chris@16: retval -= rvalue; Chris@16: return retval; Chris@16: } Chris@16: } Chris@16: } Chris@16: } Chris@16: #endif