Merge pull request #4943 from theartful/envelope_traits_functions

Add envelope free functions that accept traits object
This commit is contained in:
Laurent Rineau 2020-09-24 16:43:20 +02:00
commit 90fdf37f7c
3 changed files with 95 additions and 3 deletions

View File

@ -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<class InputIterator, class EnvelopeDiagram, class Traits>
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<class InputIterator, class EnvelopeDiagram, class Traits>
void upper_envelope_x_monotone_2
(InputIterator begin, InputIterator end,
EnvelopeDiagram& diag, const Traits& traits);
} /* namespace CGAL */

View File

@ -62,9 +62,9 @@ protected:
typedef Arr_traits_adaptor_2<Traits_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& );

View File

@ -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 <class InputIterator, class EnvelopeDiagram, class Traits>
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<Traits_2, EnvelopeDiagram> 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 <class InputIterator, class EnvelopeDiagram, class Traits>
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<Traits_2, EnvelopeDiagram> Envelope_2;
Envelope_2 env{&traits};
env.insert_x_monotone_curves (begin, end,
false, // Upper envelope.
diag);
return;
}
} //namespace CGAL
#endif