|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78343 - in trunk: boost/polygon boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-05-05 18:40:44
Author: asydorchuk
Date: 2012-05-05 18:40:43 EDT (Sat, 05 May 2012)
New Revision: 78343
URL: http://svn.boost.org/trac/boost/changeset/78343
Log:
Polygon: Fixing test targets failing on trunk.
Text files modified:
trunk/boost/polygon/detail/transform_detail.hpp | 177 +++++++++++++++++++--------------------
trunk/boost/polygon/polygon_90_set_traits.hpp | 47 +++++-----
trunk/libs/polygon/test/gtl_boost_unit_test.cpp | 180 +++++++++++++++++++--------------------
3 files changed, 199 insertions(+), 205 deletions(-)
Modified: trunk/boost/polygon/detail/transform_detail.hpp
==============================================================================
--- trunk/boost/polygon/detail/transform_detail.hpp (original)
+++ trunk/boost/polygon/detail/transform_detail.hpp 2012-05-05 18:40:43 EDT (Sat, 05 May 2012)
@@ -1,6 +1,6 @@
/*
Copyright 2008 Intel Corporation
-
+
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
@@ -54,7 +54,7 @@
};
atr_ = tmp[orient.to_int()];
}
-
+
inline axis_transformation::axis_transformation(const orientation_2d& orient) : atr_(NULL_TRANSFORM) {
const ATR tmp[3] = {
NORTH_EAST_UP, //sort by z, then x, then y
@@ -62,7 +62,7 @@
};
atr_ = tmp[orient.to_int()];
}
-
+
inline axis_transformation::axis_transformation(const direction_3d& dir) : atr_(NULL_TRANSFORM) {
const ATR tmp[6] = {
DOWN_EAST_NORTH, //sort by -x, then z, then y
@@ -74,7 +74,7 @@
};
atr_ = tmp[dir.to_int()];
}
-
+
inline axis_transformation::axis_transformation(const direction_2d& dir) : atr_(NULL_TRANSFORM) {
const ATR tmp[4] = {
SOUTH_EAST_UP, //sort by z, then x, then y
@@ -84,7 +84,7 @@
};
atr_ = tmp[dir.to_int()];
}
-
+
inline axis_transformation& axis_transformation::operator=(const axis_transformation& a) {
atr_ = a.atr_;
return *this;
@@ -113,13 +113,13 @@
bool abit3 = (a.atr_ & 8) != 0;
bool abit2 = (a.atr_ & 4) != 0;
bool abit1 = (a.atr_ & 2) != 0;
- bool abit0 = (a.atr_ & 1) != 0;
+ bool abit0 = (a.atr_ & 1) != 0;
bool bit5 = (atr_ & 32) != 0;
bool bit4 = (atr_ & 16) != 0;
bool bit3 = (atr_ & 8) != 0;
bool bit2 = (atr_ & 4) != 0;
bool bit1 = (atr_ & 2) != 0;
- bool bit0 = (atr_ & 1) != 0;
+ bool bit0 = (atr_ & 1) != 0;
int indexes[2][3] = {
{
((int)((bit5 & bit2) | (bit4 & !bit2)) << 1) +
@@ -127,7 +127,7 @@
((int)((bit4 & bit2) | (bit5 & !bit2)) << 1) +
(int)(!bit5 & !bit2),
((int)(!bit4 & !bit5) << 1) +
- (int)(bit5)
+ (int)(bit5)
},
{
((int)((abit5 & abit2) | (abit4 & !abit2)) << 1) +
@@ -135,7 +135,7 @@
((int)((abit4 & abit2) | (abit5 & !abit2)) << 1) +
(int)(!abit5 & !abit2),
((int)(!abit4 & !abit5) << 1) +
- (int)(abit5)
+ (int)(abit5)
}
};
int zero_bits[2][3] = {
@@ -153,19 +153,19 @@
int nbit2 = (!(nbit5 | nbit4) & (bool)(indexes[0][0] & 1)) | //swap xy
(nbit5 & ((indexes[0][0] & 2) >> 1)) | //z->y x->z
(nbit4 & ((indexes[0][1] & 2) >> 1)); //z->x y->z
- atr_ = (ATR)((nbit5 << 5) +
- (nbit4 << 4) +
- (nbit3 << 3) +
- (nbit2 << 2) +
+ atr_ = (ATR)((nbit5 << 5) +
+ (nbit4 << 4) +
+ (nbit3 << 3) +
+ (nbit2 << 2) +
(nbit1 << 1) + nbit0);
return *this;
}
-
+
inline axis_transformation axis_transformation::operator+(const axis_transformation& a) const {
axis_transformation retval(*this);
return retval+=a;
}
-
+
// populate_axis_array writes the three INDIVIDUAL_AXIS values that the
// ATR enum value of 'this' represent into axis_array
inline void axis_transformation::populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const {
@@ -174,24 +174,24 @@
bool bit3 = (atr_ & 8) != 0;
bool bit2 = (atr_ & 4) != 0;
bool bit1 = (atr_ & 2) != 0;
- bool bit0 = (atr_ & 1) != 0;
- axis_array[2] =
+ bool bit0 = (atr_ & 1) != 0;
+ axis_array[2] =
(INDIVIDUAL_AXIS)((((int)(!bit4 & !bit5)) << 2) +
- ((int)(bit5) << 1) +
+ ((int)(bit5) << 1) +
bit3);
- axis_array[1] =
+ axis_array[1] =
(INDIVIDUAL_AXIS)((((int)((bit4 & bit2) | (bit5 & !bit2))) << 2)+
- ((int)(!bit5 & !bit2) << 1) +
+ ((int)(!bit5 & !bit2) << 1) +
bit1);
- axis_array[0] =
+ axis_array[0] =
(INDIVIDUAL_AXIS)((((int)((bit5 & bit2) | (bit4 & !bit2))) << 2) +
- ((int)(bit2 & !bit5) << 1) +
+ ((int)(bit2 & !bit5) << 1) +
bit0);
}
-
+
// combine_axis_arrays concatenates this_array and that_array overwriting
// the result into this_array
- inline void
+ inline void
axis_transformation::combine_axis_arrays (INDIVIDUAL_AXIS this_array[],
const INDIVIDUAL_AXIS that_array[]){
int indexes[3] = {this_array[0] >> 1,
@@ -203,21 +203,21 @@
};
this_array[0] = that_array[indexes[0]];
this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] & (int)((int)PZ+(int)PY));
- this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] |
- ((int)zero_bits[0][0] ^
+ this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] |
+ ((int)zero_bits[0][0] ^
(int)zero_bits[1][indexes[0]]));
this_array[1] = that_array[indexes[1]];
this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] & (int)((int)PZ+(int)PY));
- this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] |
- ((int)zero_bits[0][1] ^
+ this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] |
+ ((int)zero_bits[0][1] ^
(int)zero_bits[1][indexes[1]]));
this_array[2] = that_array[indexes[2]];
this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] & (int)((int)PZ+(int)PY));
- this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] |
- ((int)zero_bits[0][2] ^
+ this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] |
+ ((int)zero_bits[0][2] ^
(int)zero_bits[1][indexes[2]]));
}
-
+
// write_back_axis_array converts an array of three INDIVIDUAL_AXIS values
// to the ATR enum value and sets 'this' to that value
inline void axis_transformation::write_back_axis_array(const INDIVIDUAL_AXIS this_array[]) {
@@ -230,16 +230,16 @@
(bit4 & (((int)this_array[1] & 4) >> 2)); //z->x y->z
int bit1 = ((int)this_array[1] & 1);
int bit0 = ((int)this_array[0] & 1);
- atr_ = ATR((bit5 << 5) +
- (bit4 << 4) +
- (bit3 << 3) +
- (bit2 << 2) +
+ atr_ = ATR((bit5 << 5) +
+ (bit4 << 4) +
+ (bit3 << 3) +
+ (bit2 << 2) +
(bit1 << 1) + bit0);
}
-
+
// behavior is deterministic but undefined in the case where illegal
- // combinations of directions are passed in.
- inline axis_transformation&
+ // combinations of directions are passed in.
+ inline axis_transformation&
axis_transformation::set_directions(const direction_2d& horizontalDir,
const direction_2d& verticalDir){
int bit2 = (static_cast<orientation_2d>(horizontalDir).to_int()) != 0;
@@ -248,42 +248,39 @@
atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
return *this;
}
-
+
// behavior is deterministic but undefined in the case where illegal
// combinations of directions are passed in.
- inline axis_transformation& axis_transformation::set_directions(const direction_3d& horizontalDir,
- const direction_3d& verticalDir,
- const direction_3d& proximalDir){
- int this_array[3] = {horizontalDir.to_int(),
- verticalDir.to_int(),
- proximalDir.to_int()};
- int bit5 = (this_array[2] & 2) != 0;
- int bit4 = !(((this_array[2] & 4) != 0) | ((this_array[2] & 2) != 0));
- int bit3 = !((this_array[2] & 1) != 0);
+ inline axis_transformation& axis_transformation::set_directions(
+ const direction_3d& horizontalDir,
+ const direction_3d& verticalDir,
+ const direction_3d& proximalDir){
+ unsigned int this_array[3] = {horizontalDir.to_int(),
+ verticalDir.to_int(),
+ proximalDir.to_int()};
+ unsigned int bit5 = (this_array[2] & 2) != 0;
+ unsigned int bit4 = !(((this_array[2] & 4) != 0) | ((this_array[2] & 2) != 0));
+ unsigned int bit3 = !((this_array[2] & 1) != 0);
//bit 2 is the tricky bit
- int bit2 = (!(bit5 | bit4) & ((this_array[0] & 2) != 0 )) | //swap xy
- (bit5 & ((this_array[0] & 4) >> 2)) | //z->y x->z
- (bit4 & ((this_array[1] & 4) >> 2)); //z->x y->z
- int bit1 = !(this_array[1] & 1);
- int bit0 = !(this_array[0] & 1);
- atr_ = ATR((bit5 << 5) +
- (bit4 << 4) +
- (bit3 << 3) +
- (bit2 << 2) +
- (bit1 << 1) + bit0);
+ unsigned int bit2 = (!(bit5 | bit4) & ((this_array[0] & 2) != 0 )) | //swap xy
+ (bit5 & ((this_array[0] & 4) >> 2)) | //z->y x->z
+ (bit4 & ((this_array[1] & 4) >> 2)); //z->x y->z
+ unsigned int bit1 = !(this_array[1] & 1);
+ unsigned int bit0 = !(this_array[0] & 1);
+ atr_ = ATR((bit5 << 5) | (bit4 << 4) | (bit3 << 3) | (bit2 << 2) | (bit1 << 1) | bit0);
return *this;
}
-
+
template <typename coordinate_type_2>
inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y) const {
int bit2 = (atr_ & 4) != 0;
int bit1 = (atr_ & 2) != 0;
int bit0 = (atr_ & 1) != 0;
x *= -((bit0 << 1) - 1);
- y *= -((bit1 << 1) - 1);
+ y *= -((bit1 << 1) - 1);
predicated_swap(bit2 != 0,x,y);
}
-
+
template <typename coordinate_type_2>
inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
int bit5 = (atr_ & 32) != 0;
@@ -293,13 +290,13 @@
int bit1 = (atr_ & 2) != 0;
int bit0 = (atr_ & 1) != 0;
x *= -((bit0 << 1) - 1);
- y *= -((bit1 << 1) - 1);
+ y *= -((bit1 << 1) - 1);
z *= -((bit3 << 1) - 1);
predicated_swap(bit2 != 0, x, y);
predicated_swap(bit5 != 0, y, z);
predicated_swap(bit4 != 0, x, z);
}
-
+
inline axis_transformation& axis_transformation::invert_2d() {
int bit2 = ((atr_ & 4) != 0);
int bit1 = ((atr_ & 2) != 0);
@@ -311,15 +308,15 @@
atr_ = (ATR)(atr_ | bit0 | bit1);
return *this;
}
-
+
inline axis_transformation axis_transformation::inverse_2d() const {
axis_transformation retval(*this);
return retval.invert_2d();
}
-
+
inline axis_transformation& axis_transformation::invert() {
int bit5 = ((atr_ & 32) != 0);
- int bit4 = ((atr_ & 16) != 0);
+ int bit4 = ((atr_ & 16) != 0);
int bit3 = ((atr_ & 8) != 0);
int bit2 = ((atr_ & 4) != 0);
int bit1 = ((atr_ & 2) != 0);
@@ -328,24 +325,24 @@
predicated_swap(bit4 != 0, bit0, bit3);
predicated_swap(bit5 != 0, bit1, bit3);
predicated_swap(bit2 != 0, bit0, bit1);
- atr_ = (ATR)((bit5 << 5) +
- (bit4 << 4) +
- (bit3 << 3) +
- (bit2 << 2) +
+ atr_ = (ATR)((bit5 << 5) +
+ (bit4 << 4) +
+ (bit3 << 3) +
+ (bit2 << 2) +
(bit1 << 1) + bit0);
return *this;
}
-
+
inline axis_transformation axis_transformation::inverse() const {
axis_transformation retval(*this);
return retval.invert();
}
-
+
template <typename scale_factor_type>
inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::get(orientation_3d orient) const {
return scale_[orient.to_int()];
}
-
+
template <typename scale_factor_type>
inline void anisotropic_scale_factor<scale_factor_type>::set(orientation_3d orient, scale_factor_type value) {
scale_[orient.to_int()] = value;
@@ -363,14 +360,14 @@
inline void anisotropic_scale_factor<scale_factor_type>::y(scale_factor_type value) { scale_[VERTICAL] = value; }
template <typename scale_factor_type>
inline void anisotropic_scale_factor<scale_factor_type>::z(scale_factor_type value) { scale_[PROXIMAL] = value; }
-
+
//concatenation operator (convolve scale factors)
template <typename scale_factor_type>
inline anisotropic_scale_factor<scale_factor_type> anisotropic_scale_factor<scale_factor_type>::operator+(const anisotropic_scale_factor<scale_factor_type>& s) const {
anisotropic_scale_factor<scale_factor_type> retval(*this);
return retval+=s;
}
-
+
//concatenate this with that
template <typename scale_factor_type>
inline const anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::operator+=(const anisotropic_scale_factor<scale_factor_type>& s){
@@ -379,7 +376,7 @@
scale_[2] *= s.scale_[2];
return *this;
}
-
+
//transform
template <typename scale_factor_type>
inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::transform(axis_transformation atr){
@@ -453,30 +450,30 @@
}
template <typename coordinate_type>
- inline transformation<coordinate_type>::transformation(const transformation<coordinate_type>& tr) :
+ inline transformation<coordinate_type>::transformation(const transformation<coordinate_type>& tr) :
atr_(tr.atr_), p_(tr.p_) {;}
-
+
template <typename coordinate_type>
inline bool transformation<coordinate_type>::operator==(const transformation<coordinate_type>& tr) const {
return atr_ == tr.atr_ && p_ == tr.p_;
}
-
+
template <typename coordinate_type>
inline bool transformation<coordinate_type>::operator!=(const transformation<coordinate_type>& tr) const {
return !(*this == tr);
}
-
+
template <typename coordinate_type>
inline bool transformation<coordinate_type>::operator<(const transformation<coordinate_type>& tr) const {
- return atr_ < tr.atr_ || atr_ == tr.atr_ && p_ < tr.p_;
+ return atr_ < tr.atr_ || (atr_ == tr.atr_ && p_ < tr.p_);
}
-
+
template <typename coordinate_type>
inline transformation<coordinate_type> transformation<coordinate_type>::operator+(const transformation<coordinate_type>& tr) const {
transformation<coordinate_type> retval(*this);
return retval+=tr;
}
-
+
template <typename coordinate_type>
inline const transformation<coordinate_type>& transformation<coordinate_type>::operator+=(const transformation<coordinate_type>& tr){
//apply the inverse transformation of this to the translation point of that
@@ -491,24 +488,24 @@
atr_ += tr.atr_;
return *this;
}
-
+
template <typename coordinate_type>
inline void transformation<coordinate_type>::set_axis_transformation(const axis_transformation& atr) {
atr_ = atr;
}
-
+
template <typename coordinate_type>
template <typename point_type>
inline void transformation<coordinate_type>::get_translation(point_type& p) const {
assign(p, p_);
}
-
+
template <typename coordinate_type>
template <typename point_type>
inline void transformation<coordinate_type>::set_translation(const point_type& p) {
assign(p_, p);
}
-
+
template <typename coordinate_type>
inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y) const {
//subtract each component of new origin point
@@ -525,7 +522,7 @@
x -= p_.get(HORIZONTAL);
atr_.transform(x,y,z);
}
-
+
// sets the axis_transform portion to its inverse
// transforms the tranlastion portion by that inverse axis_transform
// multiplies the translation portion by -1 to reverse it
@@ -540,7 +537,7 @@
atr_.invert();
return *this;
}
-
+
template <typename coordinate_type>
inline transformation<coordinate_type> transformation<coordinate_type>::inverse() const {
transformation<coordinate_type> retval(*this);
@@ -549,5 +546,3 @@
}
}
#endif
-
-
Modified: trunk/boost/polygon/polygon_90_set_traits.hpp
==============================================================================
--- trunk/boost/polygon/polygon_90_set_traits.hpp (original)
+++ trunk/boost/polygon/polygon_90_set_traits.hpp 2012-05-05 18:40:43 EDT (Sat, 05 May 2012)
@@ -1,6 +1,6 @@
/*
Copyright 2008 Intel Corporation
-
+
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
@@ -24,6 +24,8 @@
template <typename T>
struct traits_by_concept<T, rectangle_concept> { typedef rectangle_traits<T> type; };
template <typename T>
+ struct traits_by_concept<T, segment_concept> { typedef segment_concept<T> type; };
+ template <typename T>
struct traits_by_concept<T, polygon_90_concept> { typedef polygon_traits<T> type; };
template <typename T>
struct traits_by_concept<T, polygon_90_with_holes_concept> { typedef polygon_traits<T> type; };
@@ -63,7 +65,7 @@
typedef typename traits_type::coordinate_type type;
};
template <typename T>
- struct get_coordinate_type<T, undefined_concept> {
+ struct get_coordinate_type<T, undefined_concept> {
typedef typename get_coordinate_type_2<typename std::iterator_traits
<typename T::iterator>::value_type,
typename geometry_concept<typename std::iterator_traits
@@ -71,7 +73,7 @@
template <typename T, typename T2>
struct get_iterator_type_2 {
- typedef const T* type;
+ typedef const T* type;
static type begin(const T& t) { return &t; }
static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
};
@@ -88,7 +90,7 @@
static type begin(const T& t) { return t.begin(); }
static type end(const T& t) { return t.end(); }
};
-
+
// //helpers for allowing polygon 45 and containers of polygon 45 to behave interchangably in polygon_45_set_traits
// template <typename T, typename T2>
// struct get_coordinate_type_45 {};
@@ -109,25 +111,25 @@
// struct get_iterator_type_45 {};
// template <typename T>
// struct get_iterator_type_45<T, void> {
-// typedef typename T::const_iterator type;
+// typedef typename T::const_iterator type;
// static type begin(const T& t) { return t.begin(); }
// static type end(const T& t) { return t.end(); }
// };
// template <typename T>
-// struct get_iterator_type_45<T, polygon_45_concept> {
-// typedef const T* type;
+// struct get_iterator_type_45<T, polygon_45_concept> {
+// typedef const T* type;
// static type begin(const T& t) { return &t; }
// static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
// };
// template <typename T>
-// struct get_iterator_type_45<T, polygon_45_with_holes_concept> {
-// typedef const T* type;
+// struct get_iterator_type_45<T, polygon_45_with_holes_concept> {
+// typedef const T* type;
// static type begin(const T& t) { return &t; }
// static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
// };
// template <typename T>
-// struct get_iterator_type_45<T, polygon_90_set_concept> {
-// typedef const T* type;
+// struct get_iterator_type_45<T, polygon_90_set_concept> {
+// typedef const T* type;
// static type begin(const T& t) { return &t; }
// static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
// };
@@ -170,13 +172,13 @@
typedef typename is_manhattan_polygonal_concept<typename geometry_concept<T>::type>::type type;
};
template <typename T>
- struct is_polygon_90_set_type<std::list<T> > {
+ struct is_polygon_90_set_type<std::list<T> > {
typedef typename gtl_or<
typename is_manhattan_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
};
template <typename T>
- struct is_polygon_90_set_type<std::vector<T> > {
+ struct is_polygon_90_set_type<std::vector<T> > {
typedef typename gtl_or<
typename is_manhattan_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
@@ -187,15 +189,15 @@
typedef typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<T>::type>::type type;
};
template <typename T>
- struct is_mutable_polygon_90_set_type<std::list<T> > {
+ struct is_mutable_polygon_90_set_type<std::list<T> > {
typedef typename gtl_or<
- typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::list<T> >::type>::type,
+ typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::list<T> >::type>::type,
typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
};
template <typename T>
- struct is_mutable_polygon_90_set_type<std::vector<T> > {
+ struct is_mutable_polygon_90_set_type<std::vector<T> > {
typedef typename gtl_or<
- typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
+ typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
};
@@ -304,8 +306,8 @@
struct polygon_90_set_mutable_traits<polygon_90_set_data<T> > {
template <typename input_iterator_type>
- static inline void set(polygon_90_set_data<T>& polygon_set,
- input_iterator_type input_begin, input_iterator_type input_end,
+ static inline void set(polygon_90_set_data<T>& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
orientation_2d orient) {
polygon_set.clear();
polygon_set.reserve(std::distance(input_begin, input_end));
@@ -346,15 +348,15 @@
struct is_polygon_90_set_concept<polygon_90_concept> { typedef gtl_yes type; };
template <>
struct is_polygon_90_set_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
-
+
template <typename T>
struct is_mutable_polygon_90_set_concept { typedef gtl_no type; };
template <>
struct is_mutable_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
-
+
template <typename T>
struct geometry_concept<polygon_90_set_data<T> > { typedef polygon_90_set_concept type; };
-
+
//template <typename T>
//typename enable_if<typename is_polygon_90_set_type<T>::type, void>::type
//print_is_polygon_90_set_concept(const T& t) { std::cout << "is polygon 90 set concept\n"; }
@@ -364,4 +366,3 @@
}
}
#endif
-
Modified: trunk/libs/polygon/test/gtl_boost_unit_test.cpp
==============================================================================
--- trunk/libs/polygon/test/gtl_boost_unit_test.cpp (original)
+++ trunk/libs/polygon/test/gtl_boost_unit_test.cpp 2012-05-05 18:40:43 EDT (Sat, 05 May 2012)
@@ -1,6 +1,6 @@
/*
Copyright 2008 Intel Corporation
-
+
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
@@ -20,18 +20,17 @@
}
namespace boost { namespace polygon{
- void addpoly(polygon_45_set_data<int>& pset,
- int* pts, int numpts) {
- std::vector<point_data<int> > mppts;
- for(unsigned int i = 0; i < numpts*2; i += 2) {
- point_data<int> pt(pts[i], pts[i+1]);
- mppts.push_back(pt);
- }
- polygon_45_data<int> poly;
- poly.set(mppts.begin(), mppts.end());
- pset += poly;
+ void addpoly(polygon_45_set_data<int>& pset,
+ int* pts, unsigned int numpts) {
+ std::vector<point_data<int> > mppts;
+ for(unsigned int i = 0; i < numpts*2; i += 2) {
+ point_data<int> pt(pts[i], pts[i+1]);
+ mppts.push_back(pt);
}
-
+ polygon_45_data<int> poly;
+ poly.set(mppts.begin(), mppts.end());
+ pset += poly;
+ }
template <class T>
std::ostream& operator << (std::ostream& o, const interval_data<T>& i)
@@ -46,11 +45,11 @@
template <typename T>
std::ostream& operator<<(std::ostream& o, const polygon_45_data<T>& poly) {
o << "Polygon { ";
- for(typename polygon_45_data<T>::iterator_type itr = poly.begin();
+ for(typename polygon_45_data<T>::iterator_type itr = poly.begin();
itr != poly.end(); ++itr) {
if(itr != poly.begin()) o << ", ";
o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
- }
+ }
o << " } ";
return o;
}
@@ -89,7 +88,7 @@
std::istream& operator >> (std::istream& i, polygon_90_data<T>& r)
{
std::size_t size;
- i >> size;
+ i >> size;
std::vector<T> vec;
vec.reserve(size);
for(std::size_t ii = 0; ii < size; ++ii) {
@@ -100,12 +99,12 @@
r.set_compact(vec.begin(), vec.end());
return i;
}
-
+
template <typename T>
std::ostream& operator << (std::ostream& o, const std::vector<polygon_90_data<T> >& r) {
o << r.size() << ' ';
for(std::size_t ii = 0; ii < r.size(); ++ii) {
- o << (r[ii]);
+ o << (r[ii]);
}
return o;
}
@@ -125,14 +124,14 @@
template <typename T>
std::ostream& operator<<(std::ostream& o, const polygon_data<T>& poly) {
o << "Polygon { ";
- for(typename polygon_data<T>::iterator_type itr = poly.begin();
+ for(typename polygon_data<T>::iterator_type itr = poly.begin();
itr != poly.end(); ++itr) {
if(itr != poly.begin()) o << ", ";
o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
- }
+ }
o << " } ";
return o;
- }
+ }
template <typename T>
std::ostream& operator << (std::ostream& o, const polygon_set_data<T>& r)
{
@@ -146,7 +145,7 @@
template <typename T>
std::ostream& operator<<(std::ostream& o, const polygon_90_with_holes_data<T>& poly) {
o << "Polygon With Holes { ";
- for(typename polygon_90_with_holes_data<T>::iterator_type itr = poly.begin();
+ for(typename polygon_90_with_holes_data<T>::iterator_type itr = poly.begin();
itr != poly.end(); ++itr) {
if(itr != poly.begin()) o << ", ";
o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
@@ -161,7 +160,7 @@
template <typename T>
std::ostream& operator<<(std::ostream& o, const polygon_45_with_holes_data<T>& poly) {
o << "Polygon With Holes { ";
- for(typename polygon_45_with_holes_data<T>::iterator_type itr = poly.begin();
+ for(typename polygon_45_with_holes_data<T>::iterator_type itr = poly.begin();
itr != poly.end(); ++itr) {
if(itr != poly.begin()) o << ", ";
o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
@@ -176,7 +175,7 @@
template <typename T>
std::ostream& operator<<(std::ostream& o, const polygon_with_holes_data<T>& poly) {
o << "Polygon With Holes { ";
- for(typename polygon_with_holes_data<T>::iterator_type itr = poly.begin();
+ for(typename polygon_with_holes_data<T>::iterator_type itr = poly.begin();
itr != poly.end(); ++itr) {
if(itr != poly.begin()) o << ", ";
o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
@@ -216,7 +215,7 @@
booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
booleanOr.advanceScan();
booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
- if(container.size() != 2) {
+ if(container.size() != 2) {
std::cout << "Test one rectangle, wrong output size\n";
return false;
}
@@ -351,7 +350,7 @@
polygon_90_set_data<int> ps90;
polygon_45_set_data<int> ps45;
polygon_set_data<int> ps;
-
+
assign(p, rect);
assign(p90, view_as<polygon_90_concept>(p));
if(!equivalence(p90, rect))
@@ -385,7 +384,7 @@
std::cout << "fail 11\n";
assign(p90wh, view_as<polygon_90_with_holes_concept>(p45wh));
if(!equivalence(p90wh, rect))
- std::cout << "fail 12\n";
+ std::cout << "fail 12\n";
assign(p90, view_as<polygon_90_concept>(pwh));
if(!equivalence(p90, rect))
std::cout << "fail 13\n";
@@ -591,7 +590,7 @@
//poly.set(points.begin(), points.end());
//ps.insert(poly);
polygon_45_set_data<int> preps(polys[0]);
-
+
ps.insert(polys[0]);
convolve(polys[0], point_data<int>(0, 1) );
@@ -922,18 +921,18 @@
//assign(p_90, p_wh);
//assign(p_90, p_45_wh);
//assign(p_90, p_90_wh);
- assign(p_wh, p);
- assign(p_wh, p_45);
- assign(p_wh, p_90);
+ assign(p_wh, p);
+ assign(p_wh, p_45);
+ assign(p_wh, p_90);
assign(p_wh1, p_wh);
assign(p_wh, p_45_wh);
assign(p_wh, p_90_wh);
- //assign(p_45_wh, p);
- assign(p_45_wh, p_45);
- assign(p_45_wh, p_90);
+ //assign(p_45_wh, p);
+ assign(p_45_wh, p_45);
+ assign(p_45_wh, p_90);
//assign(p_45_wh, p_wh);
assign(p_45_wh1, p_45_wh);
- //assign(p_90_wh, p);
+ //assign(p_90_wh, p);
//assign(p_90_wh, p_45);
assign(p_90_wh, p_90);
assign(p_90_wh1, p_90_wh);
@@ -1038,7 +1037,7 @@
x(pts[1], x(pts[1]) + disp);
if(dir)
y(pts[1], y(pts[1]) + disp);
- else
+ else
y(pts[1], y(pts[1]) - disp);
return Polygon45(pts, pts+3);
}
@@ -2150,23 +2149,23 @@
// inline iterator_type begin() const {
// return polygon_traits<T>::begin_points(*t);
// }
-
+
// /// Get the end iterator
// inline iterator_type end() const {
// return polygon_traits<T>::end_points(*t);
// }
-
+
// /// Get the number of sides of the polygon
// inline unsigned int size() const {
// return polygon_traits<T>::size(*t);
// }
-
+
// /// Get the winding direction of the polygon
// inline winding_direction winding() const {
// return polygon_traits<T>::winding(*t);
// }
// };
-
+
// template <typename T1, typename T2>
// view_of<T1, T2> view_as(const T2& obj) { return view_of<T1, T2>(obj); }
@@ -2189,18 +2188,18 @@
// return compact_iterator_type(polygon_traits<T>::begin_points(*t),
// polygon_traits<T>::end_points(*t));
// }
-
+
// /// Get the end iterator
// inline compact_iterator_type end_compact() const {
// return compact_iterator_type(polygon_traits<T>::end_points(*t),
// polygon_traits<T>::end_points(*t));
// }
-
+
// /// Get the number of sides of the polygon
// inline unsigned int size() const {
// return polygon_traits<T>::size(*t);
// }
-
+
// /// Get the winding direction of the polygon
// inline winding_direction winding() const {
// return polygon_traits<T>::winding(*t);
@@ -2232,7 +2231,7 @@
bool test_extents() {
PolygonSet psT(gtl::VERTICAL);
- //int xy[] = { 126, 69, 54, 69, 54, 81, 126, 81 };
+ //int xy[] = { 126, 69, 54, 69, 54, 81, 126, 81 };
//CPolygonQuery polygon(0, 4, xy);
//Rectangle rectIn(54, 69, 126, 81);
polygon_data<int> polygon;
@@ -2243,11 +2242,11 @@
pts.push_back(Point(126, 81));
set_points(polygon, pts.begin(), pts.end());
psT.insert(view_as<polygon_90_concept>(polygon));
-
+
Rectangle rect, rect2;
psT.extents(rect2);
gtl::extents(rect, psT);
-
+
if (rect != rect2) {
std::cout << "gtl::Rectangles differ: " << gtl::xl(rect) << " " << gtl::xh(rect) << " " << gtl::yl(rect) << " " << gtl::yh(rect) << std::endl;
std::cout << " " << gtl::xl(rect2) << " " << gtl::xh(rect2) << " " << gtl::yl(rect2) << " " << gtl::yh(rect2) << std::endl;
@@ -2258,23 +2257,23 @@
bool test_extents2() {
Polygon45Set psT;
- Point xy[] = { Point(130, 50), Point(50, 50), Point(50, 100), Point(119, 100),
+ Point xy[] = { Point(130, 50), Point(50, 50), Point(50, 100), Point(119, 100),
Point(119, 59), Point(89, 89), Point(59, 59), Point(119, 59), Point(119, 100), Point(130, 100) };
Polygon45 polygon(xy, xy+10);
-
+
psT.insert(polygon);
psT += 2;
-
+
Rectangle rect, rect2;
psT.extents(rect2);
- gtl::extents(rect, psT);
+ gtl::extents(rect, psT);
std::cout << "Extents: " << gtl::xl(rect) << " " << gtl::xh(rect) << " " << gtl::yl(rect) << " " << gtl::yh(rect) << std::endl;
std::cout << "Extents: " << gtl::xl(rect2) << " " << gtl::xh(rect2) << " " << gtl::yl(rect2) << " " << gtl::yh(rect2) << std::endl;
std::vector<Polygon45WithHoles> pwhs;
psT.get(pwhs);
for(unsigned int i = 0; i < pwhs.size(); ++i) {
std::cout << pwhs[i] << std::endl;
- }
+ }
return gtl::equivalence(rect, rect2);
}
@@ -2410,7 +2409,7 @@
point_data<int> pt(1, 1);
std::cout << contains(p, pt) << std::endl;
std::cout << contains(p90, pt) << std::endl;
-
+
interval_data<int> ivl = construct<interval_data<int> >(0, 10);
std::cout << get(ivl, LOW) << std::endl;
set(ivl, HIGH, 20);
@@ -2658,7 +2657,7 @@
}
std::cout << area(rv) << std::endl;
std::cout << area(rv) << std::endl;
-
+
scale_up(rv, 10);
std::cout << area(rv) << std::endl;
scale_down(rv, 7);
@@ -2732,7 +2731,7 @@
std::cout << pwh << std::endl;
std::cout << area(pwh) << std::endl;
if(area(pwh) != 9900) return 1;
-
+
//test point scale up / down
Point pt(10, 10);
scale_up(pt, 25);
@@ -2976,7 +2975,7 @@
ps451.transform(tr);
std::cout << (ps451 == ps452) << std::endl;
if(ps451 != ps452) return 1;
-
+
//test polygon45set area
std::cout << area(ps451) << std::endl;
if(area(ps451) != 12.5) return 1;
@@ -3231,7 +3230,7 @@
ps45.insert(ps90);
ps45.insert(p90whv);
ps45.insert(p90whv + p90whv);
-
+
ps45.insert(polygon_90_with_holes_data<int>());
polygon_with_holes_data<int> pwh;
snap_to_45(pwh);
@@ -3463,7 +3462,7 @@
//if(!equivalence(ps, ps45)) {
// std::cout << "test 45 vs general resize up failed\n";
// return 1;
- //}
+ //}
ps.shrink(9);
ps45.resize(-9);
if(!equivalence(ps, ps45)) {
@@ -3486,16 +3485,16 @@
std::cout << rupolys[0] << std::endl;
std::cout << rupolys45[0] << std::endl;
pts.clear();
- pts.push_back(point_data<int>(12, -1));
- pts.push_back(point_data<int>(5, 6));
- pts.push_back(point_data<int>(5, 2));
- pts.push_back(point_data<int>(2, 2));
- pts.push_back(point_data<int>(2, 5));
- pts.push_back(point_data<int>(5, 2));
- pts.push_back(point_data<int>(5, 6));
- pts.push_back(point_data<int>(-1, 12));
- pts.push_back(point_data<int>(-1, -1));
- pts.push_back(point_data<int>(12, -1));
+ pts.push_back(point_data<int>(12, -1));
+ pts.push_back(point_data<int>(5, 6));
+ pts.push_back(point_data<int>(5, 2));
+ pts.push_back(point_data<int>(2, 2));
+ pts.push_back(point_data<int>(2, 5));
+ pts.push_back(point_data<int>(5, 2));
+ pts.push_back(point_data<int>(5, 6));
+ pts.push_back(point_data<int>(-1, 12));
+ pts.push_back(point_data<int>(-1, -1));
+ pts.push_back(point_data<int>(12, -1));
set_points(poly, pts.begin(), pts.end());
//waived
//if(!equivalence(ps, poly)) {
@@ -3506,64 +3505,64 @@
//if(!equivalence(ps, ps45)) {
// std::cout << "test 45 vs general resize up with holes failed\n";
// return 1;
- //}
+ //}
ps.shrink(1);
ps45.resize(-1);
if(!equivalence(ps, ps45)) {
std::cout << "test 45 vs general resize down with holes failed\n";
return 1;
- }
+ }
ps.shrink(10);
ps45.resize(-10);
if(!equivalence(ps, ps45)) {
std::cout << "test 45 vs general resize down 2 with holes failed\n";
return 1;
- }
+ }
}
{
- Point pts[] = {construct<Point>(1565, 5735),
- construct<Point>(915, 5735),
- construct<Point>(915, 7085),
- construct<Point>(1565, 7085) };
- Polygon poly;
- set_points(poly, pts, pts+4);
- bool ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
+ Point pts[] = {construct<Point>(1565, 5735),
+ construct<Point>(915, 5735),
+ construct<Point>(915, 7085),
+ construct<Point>(1565, 7085) };
+ Polygon poly;
+ set_points(poly, pts, pts+4);
+ bool ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
if(!ret) {
std::cout << "contains failed!" << std::endl;
return 1;
}
polygon_data<int> poly_aa;
set_points(poly_aa, pts, pts+4);
- ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
+ ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
if(!ret) {
std::cout << "contains 90 failed!" << std::endl;
return 1;
}
polygon_with_holes_data<int> pwh;
polygon_90_with_holes_data<int> p90wh;
- Point pts2[] = {construct<Point>(565, 15735),
- construct<Point>(15, 15735),
- construct<Point>(15, 17085),
- construct<Point>(565, 17085) };
- set_points(pwh, pts2, pts2+4);
- set_points(p90wh, pts2, pts2+4);
+ Point pts2[] = {construct<Point>(565, 15735),
+ construct<Point>(15, 15735),
+ construct<Point>(15, 17085),
+ construct<Point>(565, 17085) };
+ set_points(pwh, pts2, pts2+4);
+ set_points(p90wh, pts2, pts2+4);
pwh.set_holes(&poly_aa, (&poly_aa)+1);
p90wh.set_holes(&poly, (&poly)+1);
- ret=gtl::contains(pwh,gtl::construct<Point>(920, 7080));
+ ret=gtl::contains(pwh,gtl::construct<Point>(920, 7080));
if(ret) {
std::cout << "contains wh failed!" << std::endl;
return 1;
}
- ret=gtl::contains(p90wh,gtl::construct<Point>(920, 7080));
+ ret=gtl::contains(p90wh,gtl::construct<Point>(920, 7080));
if(ret) {
std::cout << "contains 90wh failed!" << std::endl;
return 1;
}
std::reverse(pts, pts+4);
- set_points(poly, pts, pts+4);
- ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
+ set_points(poly, pts, pts+4);
+ ret=gtl::contains(poly,gtl::construct<Point>(920, 7080));
if(!ret) {
std::cout << "reverse contains failed!" << std::endl;
return 1;
@@ -3630,8 +3629,8 @@
testbug.insert(orr);
std::cout << area(testbug) << std::endl;
polygon_set_data<int> testbug2;
- for(int i = 0; i < polys.size(); ++i) {
- for(int j = 0; j < polys.size(); ++j) {
+ for(size_t i = 0; i < polys.size(); ++i) {
+ for(size_t j = 0; j < polys.size(); ++j) {
testbug2.clear();
testbug2.insert(polys[i]);
testbug2.insert(polys[j]);
@@ -3712,8 +3711,7 @@
bool ir = intersection(p, dls1, dls2);
std::cout << ir << " " << p << std::endl;
}
-
+
std::cout << "ALL TESTS COMPLETE\n";
return 0;
}
-
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk