diff --git a/.gitattributes b/.gitattributes index 8bdfa9ef549..36b02b0838b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1721,6 +1721,7 @@ Polynomial/doc_tex/Polynomial_ref/PolynomialTraits_d_GetInnermostCoefficient.tex Polynomial/doc_tex/Polynomial_ref/PolynomialTraits_d_InnermostLeadingCoefficient.tex -text Polynomial/doc_tex/Polynomial_ref/PolynomialTraits_d_Move.tex -text Polynomial/doc_tex/Polynomial_ref/Polynomial_1.tex -text +Polynomial/include/CGAL/Polynomial/Coercion_traits.h -text Polytope_distance_d/test/Polytope_distance_d/create_test_PD_cin -text Polytope_distance_d/test/Polytope_distance_d/test_PD.cin -text Polytope_distance_d/test/Polytope_distance_d/test_PD_data/intersecting_segments.data -text diff --git a/Polynomial/include/CGAL/Polynomial/Coercion_traits.h b/Polynomial/include/CGAL/Polynomial/Coercion_traits.h new file mode 100644 index 00000000000..c0a52d5b808 --- /dev/null +++ b/Polynomial/include/CGAL/Polynomial/Coercion_traits.h @@ -0,0 +1,80 @@ +// TODO: Add licence +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL:$ +// $Id:$ +// +// +// Author(s) : +// +// ============================================================================ + +// TODO: The comments are all original EXACUS comments and aren't adapted. So +// they may be wrong now. + +#ifndef CGAL_POLYNOMIAL_COERCION_TRAITS_H +#define CGAL_POLYNOMIAL_COERCION_TRAITS_H + +CGAL_BEGIN_NAMESPACE + +// COERCION_TRAITS BEGIN + +//Coercion_traits_polynomial----------------------------------- +// If there is a Polynomial_traits, valid for more than one Polynomial +// class this part should be adapted, using a Polynomial_traits +// and the nesting_depth +template +class Coercion_traits_for_level, Polynomial, CTL_POLYNOMIAL >{ + typedef Coercion_traits CT; +public: + typedef CGAL::Tag_true Are_explicit_interoperable; + typedef CGAL::Tag_false Are_implicit_interoperable; + typedef Polynomial Type; + struct Cast{ + typedef Type result_type; + Type operator()(const Polynomial& poly) const { + typename CT::Cast cast; + return Type(::boost::make_transform_iterator(poly.begin(),cast), + ::boost::make_transform_iterator(poly.end() ,cast)); + } + Type operator()(const Polynomial& poly) const { + typename CT::Cast cast; + return Type(::boost::make_transform_iterator(poly.begin(),cast), + ::boost::make_transform_iterator(poly.end() ,cast)); + } + }; +}; + +template +class Coercion_traits_for_level,B ,CTL_POLYNOMIAL >{ + typedef Coercion_traits CT; +public: + typedef CGAL::Tag_true Are_explicit_interoperable; + typedef CGAL::Tag_false Are_implicit_interoperable; + + typedef Polynomial Type; + struct Cast{ + typedef Type result_type; + Type operator()(const Polynomial& poly) const { + typename CT::Cast cast; + return Type(::boost::make_transform_iterator(poly.begin(),cast), + ::boost::make_transform_iterator(poly.end() ,cast)); + } + Type operator()(const B& x) const { + typename CT::Cast cast; + return Type(cast(x)); + } + }; +}; +template +class Coercion_traits_for_level,CTL_POLYNOMIAL > + :public Coercion_traits_for_level,B,CTL_POLYNOMIAL > +{}; + +// COERCION_TRAITS END + +CGAL_END_NAMESPACE + +#endif // CGAL_POLYNOMIAL_COERCION_TRAITS_H