Fixed the code so it compiles.

This commit is contained in:
Ron Wein 2006-08-01 07:08:47 +00:00
parent a21a1a7061
commit d805e4b4d0
5 changed files with 130 additions and 95 deletions

View File

@ -8,6 +8,7 @@
#include <iostream> #include <iostream>
typedef CGAL::Gmpq NT; typedef CGAL::Gmpq NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2; typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2; typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Curve_2 Segment_2; typedef Traits_2::Curve_2 Segment_2;
@ -15,19 +16,21 @@ typedef CGAL::Env_default_diagram_1<Traits_2> Diagram_1;
int main () int main ()
{ {
Traits_2 traits; // Consrtuct the input segments.
std::list<Segment_2> segments; std::list<Segment_2> segments;
Diagram_1 diag;
segments.push_back (Segment_2 (Point_2 (1, 1), Point_2 (6, 3))); segments.push_back (Segment_2 (Point_2 (1, 1), Point_2 (6, 3)));
segments.push_back (Segment_2 (Point_2 (5, 3), Point_2 (9, 1))); segments.push_back (Segment_2 (Point_2 (5, 3), Point_2 (9, 1)));
segments.push_back (Segment_2 (Point_2 (2, 2), Point_2 (5, 2))); segments.push_back (Segment_2 (Point_2 (2, 2), Point_2 (5, 2)));
segments.push_back (Segment_2 (Point_2 (6, 1), Point_2 (8, 4))); segments.push_back (Segment_2 (Point_2 (6, 1), Point_2 (8, 4)));
lower_envelope_2 (traits, // Compute their lower envelope.
segments.begin(), segments.end(). Diagram_1 diag;
lower_envelope_2 (segments.begin(), segments.end(),
diag); diag);
// Print the minimization diagram.
Diagram_1::Edge_const_handle e = diag.leftmost(); Diagram_1::Edge_const_handle e = diag.leftmost();
Diagram_1::Vertex_const_handle v; Diagram_1::Vertex_const_handle v;

View File

@ -139,6 +139,16 @@ public:
return; return;
} }
/*! Associate a range of new curves with the vertex. */
void add_curves (Curve_const_iterator begin, Curve_const_iterator end)
{
Curve_const_iterator iter;
for (iter = begin; iter != end; ++iter)
_cvs.push_back (*iter);
return;
}
/*! Set the left edge. */ /*! Set the left edge. */
void set_left (Edge* e) void set_left (Edge* e)
{ {
@ -383,7 +393,7 @@ public:
} }
/*! Create a new vertex. */ /*! Create a new vertex. */
Vertex* new_vertex (const Point_2& p) Vertex_handle new_vertex (const Point_2& p)
{ {
Vertex *v = vertex_alloc.allocate (1); Vertex *v = vertex_alloc.allocate (1);
@ -392,16 +402,16 @@ public:
} }
/*! Create a new edge. */ /*! Create a new edge. */
Vertex* new_edge () Edge_handle new_edge ()
{ {
Vertex *e = edge_alloc.allocate (1); Edge *e = edge_alloc.allocate (1);
edge_alloc.construct (e, Edge()); edge_alloc.construct (e, Edge());
return (e); return (e);
} }
/*! Delete an existing vertex. */ /*! Delete an existing vertex. */
void delete_vertex (Vertex * v) void delete_vertex (Vertex_handle v)
{ {
vertex_alloc.destroy (v); vertex_alloc.destroy (v);
vertex_alloc.deallocate (v, 1); vertex_alloc.deallocate (v, 1);
@ -410,7 +420,7 @@ public:
} }
/*! Delete an existing edge. */ /*! Delete an existing edge. */
void delete_edge (Edge * e) void delete_edge (Edge_handle e)
{ {
edge_alloc.destroy (e); edge_alloc.destroy (e);
edge_alloc.deallocate (e, 1); edge_alloc.deallocate (e, 1);
@ -425,8 +435,8 @@ private:
*/ */
void _free () void _free ()
{ {
Vertex *v = _leftmostP; Vertex *v;
Edge *e; Edge *e = _leftmostP;
while (e != NULL) while (e != NULL)
{ {

View File

@ -20,7 +20,8 @@
#ifndef CGAL_ENVELOPE_DIVIDE_AND_CONQUER_2_H #ifndef CGAL_ENVELOPE_DIVIDE_AND_CONQUER_2_H
#define CGAL_ENVELOPE_DIVIDE_AND_CONQUER_2_H #define CGAL_ENVELOPE_DIVIDE_AND_CONQUER_2_H
#include <CGAL/Env_default_diagram_1.h> #include <CGAL/Arr_enums.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
@ -28,8 +29,7 @@ CGAL_BEGIN_NAMESPACE
* A class implementing the divide-and-conquer algorithm for computing the * A class implementing the divide-and-conquer algorithm for computing the
* lower (or upper) envelope of a set of curves. * lower (or upper) envelope of a set of curves.
*/ */
template <class Traits_, template <class Traits_, class Diagram_>
class Diagram_ = Env_default_diagram_1<Traits_> >
class Envelope_divide_and_conquer_2 class Envelope_divide_and_conquer_2
{ {
public: public:
@ -41,6 +41,8 @@ public:
typedef Diagram_ Envelope_diagram_1; typedef Diagram_ Envelope_diagram_1;
protected:
typedef Envelope_divide_and_conquer_2<Traits_2, Envelope_diagram_1> Self; typedef Envelope_divide_and_conquer_2<Traits_2, Envelope_diagram_1> Self;
enum Envelope_type enum Envelope_type
@ -49,8 +51,6 @@ public:
UPPER UPPER
}; };
protected:
typedef typename Envelope_diagram_1::Vertex_const_handle Vertex_const_handle; typedef typename Envelope_diagram_1::Vertex_const_handle Vertex_const_handle;
typedef typename Envelope_diagram_1::Vertex_handle Vertex_handle; typedef typename Envelope_diagram_1::Vertex_handle Vertex_handle;
typedef typename Envelope_diagram_1::Edge_const_handle Edge_const_handle; typedef typename Envelope_diagram_1::Edge_const_handle Edge_const_handle;
@ -59,8 +59,10 @@ protected:
typedef std::list<X_monotone_curve_2 *> Curve_pointer_list; typedef std::list<X_monotone_curve_2 *> Curve_pointer_list;
typedef typename Curve_pointer_list::iterator Curve_pointer_iterator; typedef typename Curve_pointer_list::iterator Curve_pointer_iterator;
typedef Arr_traits_adaptor_2<Traits_2> Traits_adaptor_2;
// Data members: // Data members:
Traits_2 *traits; // The traits object. Traits_adaptor_2 *traits; // The traits object.
bool own_traits; // Whether we own the traits object. bool own_traits; // Whether we own the traits object.
Envelope_type env_type; // Either LOWER or UPPER. Envelope_type env_type; // Either LOWER or UPPER.
@ -77,7 +79,7 @@ public:
own_traits(true), own_traits(true),
env_type(LOWER) env_type(LOWER)
{ {
traits = new Traits_2; traits = new Traits_adaptor_2;
} }
/*! /*!
@ -85,10 +87,11 @@ public:
* \param _traits The traits object. * \param _traits The traits object.
*/ */
Envelope_divide_and_conquer_2 (const Traits_2* _traits) : Envelope_divide_and_conquer_2 (const Traits_2* _traits) :
traits (_traits),
own_traits(false), own_traits(false),
env_type(LOWER) env_type(LOWER)
{} {
traits = static_cast<const Traits_adaptor_2*> (_traits);
}
/*! /*!
* Destructor. * Destructor.
@ -103,13 +106,12 @@ public:
* Construct the lower (or upper) envelope to the given range of curves. * Construct the lower (or upper) envelope to the given range of curves.
* \param begin An iterator pointing at the beginning of the curves range. * \param begin An iterator pointing at the beginning of the curves range.
* \param end A past-the-end iterator for the curves range. * \param end A past-the-end iterator for the curves range.
* \param type The envelope type (LOWER or UPPER). * \param type The envelope type (true for lower, false of upper).
* \param diagram Output: The minimization (or maximization) diagram. * \param diagram Output: The minimization (or maximization) diagram.
*/ */
template <class CurvesIterator> template <class CurvesIterator>
void insert_curves (const CurvesIterator& begin, void insert_curves (CurvesIterator begin, CurvesIterator end,
const CurvesIterator& end, bool type,
const Envelope_type& type,
Envelope_diagram_1& diagram) Envelope_diagram_1& diagram)
{ {
// Subdivide the curves into x-monotone subcurves. // Subdivide the curves into x-monotone subcurves.
@ -127,7 +129,7 @@ public:
for (obj_it = objects.begin(); obj_it != objects.end(); ++obj_it) for (obj_it = objects.begin(); obj_it != objects.end(); ++obj_it)
{ {
if(CGAL::assign (xcv, *obj_itr)) if(CGAL::assign (xcv, *obj_it))
x_curves.push_back (xcv); x_curves.push_back (xcv);
} }
} }
@ -144,17 +146,16 @@ public:
* x-monotone curves. * x-monotone curves.
* \param begin An iterator pointing at the beginning of the curves range. * \param begin An iterator pointing at the beginning of the curves range.
* \param end A past-the-end iterator for the curves range. * \param end A past-the-end iterator for the curves range.
* \param type The envelope type (LOWER or UPPER). * \param type The envelope type (true for lower, false for upper).
* \param diagram Output: The minimization (or maximization) diagram. * \param diagram Output: The minimization (or maximization) diagram.
*/ */
template <class XCurvesIterator> template <class XCurvesIterator>
void insert_x_monotone_curves (const XCurvesIterator& begin, void insert_x_monotone_curves (XCurvesIterator begin, XCurvesIterator end,
const XCurvesIterator& end, bool type,
const Envelope_type& type,
Envelope_diagram_1& diagram) Envelope_diagram_1& diagram)
{ {
// Set the envelope type. // Set the envelope type.
env_type = type; env_type = (type ? LOWER : UPPER);
// Separate the regular curves from the vertical ones. // Separate the regular curves from the vertical ones.
typename Traits_2::Is_vertical_2 is_vertical = typename Traits_2::Is_vertical_2 is_vertical =
@ -286,7 +287,7 @@ protected:
* \return A handle for the vertex. * \return A handle for the vertex.
*/ */
Vertex_handle _append_vertex (Envelope_diagram_1& diag, Vertex_handle _append_vertex (Envelope_diagram_1& diag,
const Point_2& p, Edge_handle e); const Point_2& p, Edge_const_handle e);
/*! \struct /*! \struct
* A functor used to sort vertical segments by their x-coordinate. * A functor used to sort vertical segments by their x-coordinate.
@ -301,12 +302,13 @@ protected:
traits(_traits) traits(_traits)
{} {}
bool operator() (const M_curve_2 *mcv1, const M_curve_2 *mcv2) const bool operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const
{ {
/* RWRW! return (traits->compare_x_2_object()
return (traits->compare_x_2_object() (traits->construct_min_vertex_2_object()(mcv1->xcv), (traits->construct_min_vertex_2_object()(cv1),
traits->construct_min_vertex_2_object()(mcv1->xcv)) == SMALLER); traits->construct_min_vertex_2_object()(cv2)) == SMALLER);
*/
return (true); return (true);
} }
}; };

View File

@ -49,7 +49,7 @@ _construct_envelope_non_vertical (Curve_pointer_iterator begin,
if (iter == end) if (iter == end)
{ {
// Construct a singleton diagram, which matches a single curve. // Construct a singleton diagram, which matches a single curve.
_construct_singleton_digram (*begin, out_d); _construct_singleton_diagram (*(*begin), out_d);
} }
else else
{ {
@ -112,7 +112,7 @@ _construct_singleton_diagram (const X_monotone_curve_2& cv,
Vertex_handle v = Vertex_handle v =
out_d.new_vertex (traits->construct_max_vertex_2_object() (cv)); out_d.new_vertex (traits->construct_max_vertex_2_object() (cv));
Edge_hanfle e_right = out_d.new_edge(); Edge_handle e_right = out_d.new_edge();
v->add_curve (cv); v->add_curve (cv);
v->set_left (out_d.leftmost()); v->set_left (out_d.leftmost());
@ -137,7 +137,7 @@ _construct_singleton_diagram (const X_monotone_curve_2& cv,
Vertex_handle v = Vertex_handle v =
out_d.new_vertex (traits->construct_min_vertex_2_object() (cv)); out_d.new_vertex (traits->construct_min_vertex_2_object() (cv));
Edge_hanfle e_left = out_d.new_edge(); Edge_handle e_left = out_d.new_edge();
v->add_curve (cv); v->add_curve (cv);
v->set_left (e_left); v->set_left (e_left);
@ -203,8 +203,10 @@ _merge_envelopes (const Envelope_diagram_1& d1,
Envelope_diagram_1& out_d) Envelope_diagram_1& out_d)
{ {
Edge_const_handle e1 = d1.leftmost(); Edge_const_handle e1 = d1.leftmost();
bool is_leftmost1 = true;
Vertex_const_handle v1; Vertex_const_handle v1;
Edge_const_handle e2 = d2.leftmost(); Edge_const_handle e2 = d2.leftmost();
bool is_leftmost2 = true;
Vertex_const_handle v2; Vertex_const_handle v2;
Vertex_const_handle next_v; Vertex_const_handle next_v;
bool next_exists = true; bool next_exists = true;
@ -252,7 +254,8 @@ _merge_envelopes (const Envelope_diagram_1& d1,
if (! e1->is_empty() && ! e2->is_empty()) if (! e1->is_empty() && ! e2->is_empty())
{ {
// Both edges are not empty, and there are curves defined on them. // Both edges are not empty, and there are curves defined on them.
_merge_two_intervals (e1, e2, _merge_two_intervals (e1, is_leftmost1,
e2, is_leftmost2,
next_v, next_exists, next_v, next_exists,
(res_v == SMALLER) ? 1 : 2, (res_v == SMALLER) ? 1 : 2,
out_d); out_d);
@ -262,7 +265,7 @@ _merge_envelopes (const Envelope_diagram_1& d1,
// e1 is not empty but e2 is empty: // e1 is not empty but e2 is empty:
_merge_single_interval (e1, _merge_single_interval (e1,
next_v, next_exists, next_v, next_exists,
(res == SMALLER), (res_v == SMALLER),
out_d); out_d);
} }
else if (e1->is_empty() && ! e2->is_empty()) else if (e1->is_empty() && ! e2->is_empty())
@ -270,14 +273,17 @@ _merge_envelopes (const Envelope_diagram_1& d1,
// e1 is empty and e2 is not empty: // e1 is empty and e2 is not empty:
_merge_single_interval (e2, _merge_single_interval (e2,
next_v, next_exists, next_v, next_exists,
(res != SMALLER), (res_v != SMALLER),
out_d); out_d);
} }
else else
{ {
// Both edges are empty: append an empty edge to out_d: // Both edges are empty: append an empty edge to out_d:
if (next_exists) if (next_exists)
_append_vertex (out_d, next_v, e1); {
Vertex_handle new_v = _append_vertex (out_d, next_v->point(), e1);
new_v->add_curves (next_v->curves_begin(), next_v->curves_end());
}
} }
// Proceed to the next diagram edge(s), if possible. // Proceed to the next diagram edge(s), if possible.
@ -287,19 +293,32 @@ _merge_envelopes (const Envelope_diagram_1& d1,
if (res_v == SMALLER) if (res_v == SMALLER)
{ {
e1 = v1->right(); e1 = v1->right();
is_leftmost1 = false;
if (same_x) if (same_x)
{
e2 = v2->right(); e2 = v2->right();
is_leftmost2 = false;
}
} }
else if (res_v == LARGER) else if (res_v == LARGER)
{ {
e2 = v2->right(); e2 = v2->right();
is_leftmost2 = false;
if (same_x) if (same_x)
{
e1 = v1->right(); e1 = v1->right();
is_leftmost1 = false;
}
} }
else else
{ {
e1 = v1->right(); e1 = v1->right();
is_leftmost1 = false;
e2 = v2->right(); e2 = v2->right();
is_leftmost2 = false;
} }
} }
@ -360,7 +379,7 @@ _merge_single_interval (Edge_const_handle e,
{ {
// The non-empty edge e is unbounded from the right, so we simply have // The non-empty edge e is unbounded from the right, so we simply have
// to update the rightmost edge in out_d. // to update the rightmost edge in out_d.
out_d->rightmost()->add_curves (e->curves_begin(), e->curves_end()); out_d.rightmost()->add_curves (e->curves_begin(), e->curves_end());
return; return;
} }
@ -419,8 +438,8 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
if (is_leftmost2) if (is_leftmost2)
{ {
// Both curves are defined at -oo: compare them there: // Both curves are defined at -oo: compare them there:
u_res = traits->compare_y_at_x_2_object() (e1->curve(), MIN_END, u_res = traits->compare_y_at_x_2_object() (e1->curve(), e2->curve(),
e2->curve(), MIN_END); MIN_END);
} }
else else
{ {
@ -439,9 +458,8 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
else else
{ {
// Find the rightmost of the two left endpoints and compare there. // Find the rightmost of the two left endpoints and compare there.
const Comparison_result res; const Comparison_result res =
traits->compare_xy_2_object() (e1->left()->point(),
res = traits->compare_xy_2_object() (e1->left()->point(),
e2->left()->point()); e2->left()->point());
if (res == SMALLER) if (res == SMALLER)
@ -486,10 +504,10 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
u_res = CGAL::opposite (u_res); u_res = CGAL::opposite (u_res);
// Use the current rightmost of the diagram as a reference point. // Use the current rightmost of the diagram as a reference point.
const bool v_rm_exist = (out_d.leftmost() != out_d.rightmost()); bool v_rm_exists = (out_d.leftmost() != out_d.rightmost());
Vertex_handle v_rm; Vertex_handle v_rm;
if (v_rm_exist) if (v_rm_exists)
v_rm = out_d.rightmost()->left(); v_rm = out_d.rightmost()->left();
// Find the next intersection of the envelopes to the right of the current // Find the next intersection of the envelopes to the right of the current
@ -499,12 +517,14 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
X_monotone_curve_2 icv; X_monotone_curve_2 icv;
std::pair<Point_2, unsigned int> ipt; std::pair<Point_2, unsigned int> ipt;
traits->intersect_2_object()(cv1, cv2, std::back_inserter(objects)); traits->intersect_2_object() (e1->curve(), e2->curve(),
std::back_inserter(objects));
while (! objects.empty()) while (! objects.empty())
{ {
// Pop the xy-lexicographically smallest intersection object. // Pop the xy-lexicographically smallest intersection object.
obj = objects.pop_first(); obj = objects.front();
objects.pop_front();
if (CGAL::assign(ipt, obj)) if (CGAL::assign(ipt, obj))
{ {
@ -707,16 +727,16 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
return; return;
} }
if (! v_exist) if (! v_exists)
{ {
// Both edges are unbounded from the right, so we simply have // Both edges are unbounded from the right, so we simply have
// to update the rightmost edge in out_d. // to update the rightmost edge in out_d.
CGAL_assertion (u_res != EQUAL); CGAL_assertion (u_res != EQUAL);
if (u_res == SMALLER) if (u_res == SMALLER)
out_d->rightmost()->add_curves (e1->curves_begin(), e1->curves_end()); out_d.rightmost()->add_curves (e1->curves_begin(), e1->curves_end());
else else
out_d->rightmost()->add_curves (e2->curves_begin(), e2->curves_end()); out_d.rightmost()->add_curves (e2->curves_begin(), e2->curves_end());
return; return;
} }
@ -726,9 +746,9 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
if (u_res == SMALLER) if (u_res == SMALLER)
{ {
// The final part of the interval is taken from e1.
Vertex_handle new_v; Vertex_handle new_v;
// The final part of the interval is taken from e1.
if (org_v == 1) if (org_v == 1)
{ {
// In case v is also from e1, append it to the merged diagram. // In case v is also from e1, append it to the merged diagram.
@ -739,7 +759,8 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
{ {
// If v is from e2, check if it below (or above, in case of an upper // If v is from e2, check if it below (or above, in case of an upper
// envelope) cv1 to insert it. // envelope) cv1 to insert it.
res = traits->compare_y_at_x_2_object() (v->point(), const Comparison_result res =
traits->compare_y_at_x_2_object() (v->point(),
e1->curve()); e1->curve());
if (res == EQUAL || if (res == EQUAL ||
@ -757,6 +778,8 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
else else
{ {
// The final part of the interval is taken from e2. // The final part of the interval is taken from e2.
Vertex_handle new_v;
if (org_v == 2) if (org_v == 2)
{ {
// In case v is also from e2, append it to the merged diagram. // In case v is also from e2, append it to the merged diagram.
@ -767,7 +790,8 @@ _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1,
{ {
// If v is from e1, check if it below (or above, in case of an upper // If v is from e1, check if it below (or above, in case of an upper
// envelope) cv2 to insert it. // envelope) cv2 to insert it.
res = traits->compare_y_at_x_2_object() (v->point(), const Comparison_result res =
traits->compare_y_at_x_2_object() (v->point(),
e2->curve()); e2->curve());
if (res == EQUAL || if (res == EQUAL ||
@ -793,7 +817,7 @@ template <class Traits, class Diagram>
typename Envelope_divide_and_conquer_2<Traits,Diagram>::Vertex_handle typename Envelope_divide_and_conquer_2<Traits,Diagram>::Vertex_handle
Envelope_divide_and_conquer_2<Traits,Diagram>::_append_vertex Envelope_divide_and_conquer_2<Traits,Diagram>::_append_vertex
(Envelope_diagram_1& diag, (Envelope_diagram_1& diag,
const Point_2& p, Edge_handle e) const Point_2& p, Edge_const_handle e)
{ {
// Create the new vertex and the new edge. // Create the new vertex and the new edge.
Vertex_handle new_v = diag.new_vertex (p); Vertex_handle new_v = diag.new_vertex (p);
@ -819,7 +843,7 @@ Envelope_divide_and_conquer_2<Traits,Diagram>::_append_vertex
{ {
// The diagram is empty: Make the new edge the leftmost. // The diagram is empty: Make the new edge the leftmost.
new_e->set_right (new_v); new_e->set_right (new_v);
diag->set_leftmost (new_e); diag.set_leftmost (new_e);
diag.rightmost()->set_left (new_v); diag.rightmost()->set_left (new_v);
} }

View File

@ -31,23 +31,22 @@ CGAL_BEGIN_NAMESPACE
/*! /*!
* Compute the lower envelope of a range of curves. * Compute the lower envelope of a range of curves.
* \param traits A traits class instance.
* \param begin An iterator for the first curve. * \param begin An iterator for the first curve.
* \param end A past-the-end iterator for the curves. * \param end A past-the-end iterator for the curves.
* \param diag Output: The minimization diagram. * \param diag Output: The minimization diagram.
* \pre The value-type of the iterator is Traits::Curve_2. * \pre The value-type of the iterator is Traits::Curve_2.
*/ */
template <class Traits, class InputIterator, class EnvelopeDiagram> template <class InputIterator, class EnvelopeDiagram>
void lower_envelope_2 (Traits& traits, void lower_envelope_2 (InputIterator begin, InputIterator end,
InputIterator begin, InputIterator end,
EnvelopeDiagram& diag) EnvelopeDiagram& diag)
{ {
typedef Envelope_divide_and_conquer_2<Traits, Diagram> Envelope_2; typedef typename EnvelopeDiagram::Traits_2 Traits_2;
typedef Envelope_divide_and_conquer_2<Traits_2, EnvelopeDiagram> Envelope_2;
Envelope_2 env (&traits); Envelope_2 env;
env.insert_curves (begin, end, env.insert_curves (begin, end,
typename Envelope_2::LOWER, true, // Lower envelope.
diag); diag);
return; return;
@ -55,23 +54,22 @@ void lower_envelope_2 (Traits& traits,
/*! /*!
* Compute the upper envelope of a range of curves. * Compute the upper envelope of a range of curves.
* \param traits A traits class instance.
* \param begin An iterator for the first curve. * \param begin An iterator for the first curve.
* \param end A past-the-end iterator for the curves. * \param end A past-the-end iterator for the curves.
* \param diag Output: The maximization diagram. * \param diag Output: The maximization diagram.
* \pre The value-type of the iterator is Traits::Curve_2. * \pre The value-type of the iterator is Traits::Curve_2.
*/ */
template <class Traits, class InputIterator, class EnvelopeDiagram> template <class Traits, class InputIterator, class EnvelopeDiagram>
void upper_envelope_2 (Traits& traits, void upper_envelope_2 (InputIterator begin, InputIterator end,
InputIterator begin, InputIterator end,
EnvelopeDiagram& diag) EnvelopeDiagram& diag)
{ {
typedef Envelope_divide_and_conquer_2<Traits, Diagram> Envelope_2; typedef typename EnvelopeDiagram::Traits_2 Traits_2;
typedef Envelope_divide_and_conquer_2<Traits_2, EnvelopeDiagram> Envelope_2;
Envelope_2 env (&traits); Envelope_2 env;
env.insert_curves (begin, end, env.insert_curves (begin, end,
typename Envelope_2::UPPER, false, // Upper envelope.
diag); diag);
return; return;
@ -79,23 +77,22 @@ void upper_envelope_2 (Traits& traits,
/*! /*!
* Compute the lower envelope of a range of x-monotone curves. * Compute the lower envelope of a range of x-monotone curves.
* \param traits A traits class instance.
* \param begin An iterator for the first x-monotone curve. * \param begin An iterator for the first x-monotone curve.
* \param end A past-the-end iterator for the x-monotone curves. * \param end A past-the-end iterator for the x-monotone curves.
* \param diag Output: The minimization diagram. * \param diag Output: The minimization diagram.
* \pre The value-type of the iterator is Traits::X_monotone_curve_2. * \pre The value-type of the iterator is Traits::X_monotone_curve_2.
*/ */
template <class Traits, class InputIterator, class EnvelopeDiagram> template <class InputIterator, class EnvelopeDiagram>
void lower_envelope_x_monotone_2 (Traits& traits, void lower_envelope_x_monotone_2 (InputIterator begin, InputIterator end,
InputIterator begin, InputIterator end,
EnvelopeDiagram& diag) EnvelopeDiagram& diag)
{ {
typedef Envelope_divide_and_conquer_2<Traits, Diagram> Envelope_2; typedef typename EnvelopeDiagram::Traits_2 Traits_2;
typedef Envelope_divide_and_conquer_2<Traits_2, EnvelopeDiagram> Envelope_2;
Envelope_2 env (&traits); Envelope_2 env;
env.insert_x_monotone_curves (begin, end, env.insert_x_monotone_curves (begin, end,
typename Envelope_2::LOWER, true, // Lower envelope.
diag); diag);
return; return;
@ -103,23 +100,22 @@ void lower_envelope_x_monotone_2 (Traits& traits,
/*! /*!
* Compute the upper envelope of a range of x-monotone curves. * Compute the upper envelope of a range of x-monotone curves.
* \param traits A traits class instance.
* \param begin An iterator for the first x-monotone curve. * \param begin An iterator for the first x-monotone curve.
* \param end A past-the-end iterator for the x-monotone curves. * \param end A past-the-end iterator for the x-monotone curves.
* \param diag Output: The maximization diagram. * \param diag Output: The maximization diagram.
* \pre The value-type of the iterator is Traits::X_monotone_curve_2. * \pre The value-type of the iterator is Traits::X_monotone_curve_2.
*/ */
template <class Traits, class InputIterator, class EnvelopeDiagram> template <class InputIterator, class EnvelopeDiagram>
void upper_envelope_x_monotone_2 (Traits& traits, void upper_envelope_x_monotone_2 (InputIterator begin, InputIterator end,
InputIterator begin, InputIterator end,
EnvelopeDiagram& diag) EnvelopeDiagram& diag)
{ {
typedef Envelope_divide_and_conquer_2<Traits, Diagram> Envelope_2; typedef typename EnvelopeDiagram::Traits_2 Traits_2;
typedef Envelope_divide_and_conquer_2<Traits_2, EnvelopeDiagram> Envelope_2;
Envelope_2 env (&traits); Envelope_2 env;
env.insert_x_monotone_curves (begin, end, env.insert_x_monotone_curves (begin, end,
typename Envelope_2::UPPER, false, // Upper envelope.
diag); diag);
return; return;