diff --git a/Envelope_2/doc/Envelope_2/CGAL/envelope_2.h b/Envelope_2/doc/Envelope_2/CGAL/envelope_2.h index 5dd0d75a15f..7a07ab96e3b 100644 --- a/Envelope_2/doc/Envelope_2/CGAL/envelope_2.h +++ b/Envelope_2/doc/Envelope_2/CGAL/envelope_2.h @@ -40,6 +40,28 @@ namespace CGAL { /*! \ingroup PkgEnvelope2Ref +Computes the lower envelope of a set of \f$ x\f$-monotone curves in +\f$ \mathbb{R}^2\f$, as given by the range `[begin, end)` with the help +of the arrangement traits object `traits` responsible for their creation. +Reusing the same traits object improves speed if the traits class caches data. +The lower envelope is represented using the output minimization diagram `diag`. + +\tparam InputIterator must be an input iterator with value type `EnvelopeDiagram::X_monotone_curve_2`. +\tparam EnvelopeDiagram must be a model of the concept `EnvelopeDiagram_1`. +\tparam Traits must be a model of the concept `ArrangementXMonotoneTraits_2`. +*/ +template +void lower_envelope_x_monotone_2 +(InputIterator begin, InputIterator end, +EnvelopeDiagram& diag, const Traits& traits); + +} /* namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgEnvelope2Ref + Computes the upper envelope of a set of curves in \f$ \mathbb{R}^2\f$, as given by the range `[begin, end)`. The upper envelope is represented using the output maximization diagram `diag`. @@ -71,3 +93,25 @@ void upper_envelope_x_monotone_2 EnvelopeDiagram& diag); } /* namespace CGAL */ + +namespace CGAL { + +/*! +\ingroup PkgEnvelope2Ref + +Computes the upper envelope of a set of \f$ x\f$-monotone curves in +\f$ \mathbb{R}^2\f$, as given by the range `[begin, end)` with the help +of the arrangement traits object `traits` responsbile for their creation. +Reusing the same traits object improves speed if the traits class caches data. +The upper envelope is represented using the output maximization diagram `diag`. + +\tparam InputIterator must be an input iterator with value type `EnvelopeDiagram::X_monotone_curve_2`. +\tparam EnvelopeDiagram must be a model of the concept `EnvelopeDiagram_1`. +\tparam Traits must be a model of the concept `ArrangementXMonotoneTraits_2`. +*/ +template +void upper_envelope_x_monotone_2 +(InputIterator begin, InputIterator end, +EnvelopeDiagram& diag, const Traits& traits); + +} /* namespace CGAL */ diff --git a/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h b/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h index bc72cace257..fc2f04a27ec 100644 --- a/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h +++ b/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h @@ -62,9 +62,9 @@ protected: typedef Arr_traits_adaptor_2 Traits_adaptor_2; // Data members: - Traits_adaptor_2 *traits; // The traits object. - bool own_traits; // Whether we own the traits object. - Envelope_type env_type; // Either LOWER or UPPER. + const Traits_adaptor_2 *traits; // The traits object. + bool own_traits; // Whether we own the traits object. + Envelope_type env_type; // Either LOWER or UPPER. // Copy constructor and assignment operator - not supported. Envelope_divide_and_conquer_2 (const Self& ); diff --git a/Envelope_2/include/CGAL/envelope_2.h b/Envelope_2/include/CGAL/envelope_2.h index 7eb007edc94..6d23f724393 100644 --- a/Envelope_2/include/CGAL/envelope_2.h +++ b/Envelope_2/include/CGAL/envelope_2.h @@ -93,6 +93,30 @@ void lower_envelope_x_monotone_2 (InputIterator begin, InputIterator end, return; } +/*! + * Compute the lower envelope of a range of x-monotone curves. + * \param begin An iterator for the first x-monotone curve. + * \param end A past-the-end iterator for the x-monotone curves. + * \param diag Output: The minimization diagram. + * \param traits The arrangement traits responsible for the x-monotone curves. + * \pre The value-type of the iterator is Traits::X_monotone_curve_2. + */ +template +void lower_envelope_x_monotone_2 (InputIterator begin, InputIterator end, + EnvelopeDiagram& diag, const Traits& traits) +{ + typedef typename EnvelopeDiagram::Traits_2 Traits_2; + typedef Envelope_divide_and_conquer_2 Envelope_2; + + Envelope_2 env{&traits}; + + env.insert_x_monotone_curves (begin, end, + true, // Lower envelope. + diag); + + return; +} + /*! * Compute the upper envelope of a range of x-monotone curves. * \param begin An iterator for the first x-monotone curve. @@ -116,6 +140,30 @@ void upper_envelope_x_monotone_2 (InputIterator begin, InputIterator end, return; } +/*! + * Compute the upper envelope of a range of x-monotone curves. + * \param begin An iterator for the first x-monotone curve. + * \param end A past-the-end iterator for the x-monotone curves. + * \param diag Output: The maximization diagram. + * \param traits The arrangement traits responsible for the x-monotone curves. + * \pre The value-type of the iterator is Traits::X_monotone_curve_2. + */ +template +void upper_envelope_x_monotone_2 (InputIterator begin, InputIterator end, + EnvelopeDiagram& diag, const Traits& traits) +{ + typedef typename EnvelopeDiagram::Traits_2 Traits_2; + typedef Envelope_divide_and_conquer_2 Envelope_2; + + Envelope_2 env{&traits}; + + env.insert_x_monotone_curves (begin, end, + false, // Upper envelope. + diag); + + return; +} + } //namespace CGAL #endif