mirror of https://github.com/CGAL/cgal
Try another workaround for VC++ and Intel compiler (CGAL::centroid). Add a call of overloaded CGAL::centroid function in test-suite.
This commit is contained in:
parent
b8324d2a50
commit
bd968201c3
|
|
@ -809,46 +809,44 @@ centroid(InputIterator begin,
|
||||||
// computes the centroid of a set of kernel objects
|
// computes the centroid of a set of kernel objects
|
||||||
// takes an iterator range over kernel objects
|
// takes an iterator range over kernel objects
|
||||||
|
|
||||||
// We use different overloads here in order to avoid a wrong match with
|
namespace internal {
|
||||||
// CGAL::centroid(Point_3, Point_3, Point_3, Point_3) (with VC++ and Intel).
|
|
||||||
template < typename InputIterator,
|
template < typename InputIterator, typename K, typename Dim_tag >
|
||||||
typename K >
|
struct Dispatch_centroid_3
|
||||||
inline
|
|
||||||
typename Access::Point<K, typename Ambient_dimension<typename std::iterator_traits<InputIterator>::value_type, K>::type>::type
|
|
||||||
centroid(InputIterator begin,
|
|
||||||
InputIterator end,
|
|
||||||
const K& k,
|
|
||||||
Dynamic_dimension_tag tag)
|
|
||||||
{
|
{
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
typedef typename Access::Point<K, typename Ambient_dimension<typename std::iterator_traits<InputIterator>::value_type, K>::type>::type result_type;
|
||||||
return internal::centroid(begin, end, k,(Value_type*) NULL, tag);
|
|
||||||
|
result_type operator()(InputIterator begin, InputIterator end, const K& k, Dim_tag tag) const
|
||||||
|
{
|
||||||
|
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||||
|
return centroid(begin, end, k,(Value_type*) NULL, tag);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined (__INTEL_COMPILER)
|
||||||
|
// Workaround for VC++ and Intel compiler
|
||||||
|
// (avoids wrong template function instanciation)
|
||||||
|
template <typename K>
|
||||||
|
struct Dispatch_centroid_3<Point_3<K>, Point_3<K>, Point_3<K> >
|
||||||
|
{
|
||||||
|
typedef void result_type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
template < typename InputIterator, typename K>
|
||||||
|
typename internal::Dispatch_centroid_3<InputIterator,K,Dynamic_dimension_tag>::result_type
|
||||||
|
centroid(InputIterator begin, InputIterator end, const K& k, Dynamic_dimension_tag tag)
|
||||||
|
{
|
||||||
|
return internal::Dispatch_centroid_3<InputIterator,K,Dynamic_dimension_tag>()(begin,end,k,tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename InputIterator, typename K >
|
template < typename InputIterator, typename K, int d >
|
||||||
inline
|
typename internal::Dispatch_centroid_3<InputIterator,K,Dimension_tag<d> >::result_type
|
||||||
typename Access::Point<K, typename Ambient_dimension<typename std::iterator_traits<InputIterator>::value_type, K>::type>::type
|
centroid(InputIterator begin, InputIterator end, const K& k, Dimension_tag<d> tag)
|
||||||
centroid(InputIterator begin, InputIterator end, const K& k, Dimension_tag<0> tag)
|
|
||||||
{
|
{
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
return internal::Dispatch_centroid_3<InputIterator,K,Dimension_tag<d> >()(begin,end,k,tag);
|
||||||
return internal::centroid(begin, end, k,(Value_type*) NULL, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename InputIterator, typename K >
|
|
||||||
inline
|
|
||||||
typename Access::Point<K, typename Ambient_dimension<typename std::iterator_traits<InputIterator>::value_type, K>::type>::type
|
|
||||||
centroid(InputIterator begin, InputIterator end, const K& k, Dimension_tag<1> tag)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
|
||||||
return internal::centroid(begin, end, k,(Value_type*) NULL, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename InputIterator, typename K >
|
|
||||||
inline
|
|
||||||
typename Access::Point<K, typename Ambient_dimension<typename std::iterator_traits<InputIterator>::value_type, K>::type>::type
|
|
||||||
centroid(InputIterator begin, InputIterator end, const K& k, Dimension_tag<2> tag)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
|
||||||
return internal::centroid(begin, end, k,(Value_type*) NULL, tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
@ -868,6 +866,14 @@ struct Dispatch_centroid
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Avoids wrong matching with
|
||||||
|
// CGAL::centroid(Point_3<K>, Point_3<K>, Point_3<K>)
|
||||||
|
template < typename K >
|
||||||
|
struct Dispatch_centroid < Point_3<K>, Point_3<K> >
|
||||||
|
{
|
||||||
|
typedef void result_type;
|
||||||
|
};
|
||||||
|
|
||||||
// this one takes an iterator range over kernel objects, and a dimension tag,
|
// this one takes an iterator range over kernel objects, and a dimension tag,
|
||||||
// and uses Kernel_traits<> to find out its kernel.
|
// and uses Kernel_traits<> to find out its kernel.
|
||||||
template < typename InputIterator, int dim >
|
template < typename InputIterator, int dim >
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ void test_3()
|
||||||
== CGAL::midpoint(p0, p1) );
|
== CGAL::midpoint(p0, p1) );
|
||||||
|
|
||||||
// Test other CGAL::centroid overloads
|
// Test other CGAL::centroid overloads
|
||||||
assert( CGAL::centroid(p0,p1,p0,p1) == CGAL::midpoint(p0,p1) );
|
Point_3 c = CGAL::centroid(p0,p1,p0,p1);
|
||||||
|
c = CGAL::centroid(p0,p1,p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue