polycurve

This commit is contained in:
Efi Fogel 2015-02-16 11:26:39 +02:00
parent e35966bac3
commit 0e1716a7eb
15 changed files with 1018 additions and 881 deletions

View File

@ -325,16 +325,16 @@ protected:
Poly_const_max_v poly_const_max_v=poly_tr.construct_max_vertex_2_object();
// Construct needed functors from the segment traits
typedef typename Arr_poly_traits::Segment_traits_2 Segment_traits;
typedef typename Segment_traits::Construct_min_vertex_2 Seg_const_min_v;
typedef typename Segment_traits::Construct_max_vertex_2 Seg_const_max_v;
Seg_const_min_v construct_min_v = poly_tr.segment_traits_2()->
typedef typename Arr_poly_traits::Subcurve_traits_2 Subcurve_traits;
typedef typename Subcurve_traits::Construct_min_vertex_2 Seg_const_min_v;
typedef typename Subcurve_traits::Construct_max_vertex_2 Seg_const_max_v;
Seg_const_min_v construct_min_v = poly_tr.subcurve_traits_2()->
construct_min_vertex_2_object();
Seg_const_max_v construct_max_v = poly_tr.segment_traits_2()->
Seg_const_max_v construct_max_v = poly_tr.subcurve_traits_2()->
construct_max_vertex_2_object();
// Iterator of the segments of an x-monotone polyline
typename X_monotone_curve_2::Segment_const_iterator seg_it;
typename X_monotone_curve_2::Subcurve_const_iterator seg_it;
QVector< QPointF > pts; // holds the points of the polygon
X_monotone_curve_2 cv;
@ -349,8 +349,8 @@ protected:
// Determine the direction of cv (left-to-right or right-to-left)
Comparison_result dir = comp_end_pts(cv);
for (seg_it = cv.begin_segments();
seg_it != cv.end_segments() ; ++seg_it)
for (seg_it = cv.begin_subcurves();
seg_it != cv.end_subcurves() ; ++seg_it)
{
if (dir == SMALLER)
{

View File

@ -259,9 +259,9 @@ public:
public: // methods
ArrangementPainterOstream& operator<<( const X_monotone_curve_2& curve )
{
for (typename X_monotone_curve_2::Segment_const_iterator it =
curve.begin_segments();
it != curve.end_segments(); ++it)
for (typename X_monotone_curve_2::Subcurve_const_iterator it =
curve.begin_subcurves();
it != curve.end_subcurves(); ++it)
{
this->painterOstream << *it;
}

View File

@ -338,16 +338,16 @@ public:
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Traits::Curve_2 Curve_2;
typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
typedef typename Curve_2::Segment_const_iterator Seg_const_it;
typedef typename Curve_2::Subcurve_const_iterator Seg_const_it;
double operator() ( const Point_2& p, const X_monotone_curve_2& c ) const
{
Seg_const_it seg_it_s = c.begin_segments();
Seg_const_it seg_it_s = c.begin_subcurves();
bool first = true;
FT min_dist = 0;
while (seg_it_s != c.end_segments())
while (seg_it_s != c.end_subcurves())
{
Segment_2 seg = *seg_it_s;
FT dist = this->squared_distance( p, seg );

View File

@ -32,7 +32,7 @@
#include <CGAL/basic.h>
#include <CGAL/tags.h>
#include <CGAL/Arr_non_caching_segment_traits_2.h>
#include <CGAL/Arr_geometry_traits/Polyline_2.h>
#include <CGAL/Arr_geometry_traits/Polycurve_2.h>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
@ -73,7 +73,7 @@ private:
typedef Arr_polycurve_basic_traits_2<Subcurve_traits_2> Self;
// Data members:
const Subcurve_traits_2* m_geometry_traits; // The base segment-traits class.
const Subcurve_traits_2* m_subcurve_traits; // The base segment-traits class.
bool m_own_traits;
protected:
@ -82,7 +82,7 @@ protected:
public:
/*! Construct default. */
Arr_polycurve_basic_traits_2() :
m_geometry_traits(new Subcurve_traits_2()),
m_subcurve_traits(new Subcurve_traits_2()),
m_own_traits(true)
{}
@ -91,20 +91,20 @@ public:
* be used by the class.
*/
Arr_polycurve_basic_traits_2(const Subcurve_traits_2* geom_traits) :
m_geometry_traits(geom_traits), m_own_traits(false){ }
m_subcurve_traits(geom_traits), m_own_traits(false){ }
/* Destructor
* Deletes the subcurve tarits class in case it was constructed during the
* construction of this.
*/
~Arr_polycurve_basic_traits_2()
{ if (m_own_traits) delete m_geometry_traits; }
{ if (m_own_traits) delete m_subcurve_traits; }
/*! Obtain the subcurve traits.
* \return the subcurve traits.
*/
const Subcurve_traits_2* geometry_traits_2() const
{ return m_geometry_traits; }
const Subcurve_traits_2* subcurve_traits_2() const
{ return m_subcurve_traits; }
/// \name Types and functors defined here, required by the
// ArrangementBasicTraits concept.
@ -114,7 +114,7 @@ public:
* curve which is either strongly x-monotone or vertical. Again,
* the polycurve is without degenerated subcurves.
*/
typedef polyline::X_monotone_polyline_2<X_monotone_subcurve_2, Point_2>
typedef internal::X_monotone_polycurve_2<X_monotone_subcurve_2, Point_2>
X_monotone_curve_2;
typedef typename X_monotone_curve_2::Size Size;
typedef typename X_monotone_curve_2::size_type size_type;
@ -145,7 +145,7 @@ public:
* \pre p2 does not lie on the boundary.
*/
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const
{ return m_poly_traits.geometry_traits_2()->compare_x_2_object()(p1, p2); }
{ return m_poly_traits.subcurve_traits_2()->compare_x_2_object()(p1, p2); }
/*! Compare two ends of x-monotone curves in x.
* \param xs1 the first curve.
@ -182,7 +182,7 @@ public:
const Point_2& p2,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p1 = (ce1 == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs1) :
geom_traits->construct_min_vertex_2_object()(xs1);
@ -195,7 +195,7 @@ public:
const Point_2& p2,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
geom_traits->parameter_space_in_x_2_object();
const Arr_parameter_space ps_x1 = ps_x(xs1, ce1);
@ -226,7 +226,7 @@ public:
Arr_curve_end ce2,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p1 = (ce1 == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs1) :
geom_traits->construct_min_vertex_2_object()(xs1);
@ -243,7 +243,7 @@ public:
Arr_curve_end ce2,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
geom_traits->parameter_space_in_x_2_object();
const Arr_parameter_space ps_x1 = ps_x(xs1, ce1);
@ -320,7 +320,7 @@ public:
* \pre p2 does not lie on the boundary.
*/
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const
{ return m_poly_traits.geometry_traits_2()->compare_xy_2_object()(p1, p2); }
{ return m_poly_traits.subcurve_traits_2()->compare_xy_2_object()(p1, p2); }
/*! Compare two ends of x-monotone curves lexicographically.
* \param xs1 the first curve.
@ -357,7 +357,7 @@ public:
const Point_2& p2,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p1 = (ce1 == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs1) :
geom_traits->construct_min_vertex_2_object()(xs1);
@ -370,7 +370,7 @@ public:
const Point_2& p2,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
geom_traits->parameter_space_in_x_2_object();
typename Subcurve_traits_2::Parameter_space_in_y_2 ps_y =
@ -407,7 +407,7 @@ public:
Arr_curve_end ce2,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p1 = (ce1 == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs1) :
geom_traits->construct_min_vertex_2_object()(xs1);
@ -424,7 +424,7 @@ public:
Arr_curve_end ce2,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
geom_traits->parameter_space_in_x_2_object();
typename Subcurve_traits_2::Parameter_space_in_y_2 ps_y =
@ -546,7 +546,7 @@ public:
{
CGAL_assertion(cv.number_of_subcurves() > 0);
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
if (geom_traits->compare_endpoints_xy_2_object()(cv[0]) == SMALLER)
return geom_traits->construct_min_vertex_2_object()(cv[0]);
@ -584,7 +584,7 @@ public:
{
CGAL_assertion(cv.number_of_subcurves() > 0);
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
if (geom_traits->compare_endpoints_xy_2_object()(cv[0]) == SMALLER)
return geom_traits->
@ -621,7 +621,7 @@ public:
// An x-monotone polycurve can represent a vertical segment only if it
// is comprised of vertical segments. If the first subcurve is vertical,
// all subcurves are vertical in an x-monotone polycurve
return m_poly_traits.geometry_traits_2()->is_vertical_2_object()(cv[0]);
return m_poly_traits.subcurve_traits_2()->is_vertical_2_object()(cv[0]);
}
};
@ -637,7 +637,7 @@ public:
const X_monotone_subcurve_2& xs2,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p = (ce1 == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs1) :
geom_traits->construct_min_vertex_2_object()(xs1);
@ -650,7 +650,7 @@ public:
const X_monotone_subcurve_2& xs2,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
geom_traits->parameter_space_in_x_2_object();
typename Subcurve_traits_2::Parameter_space_in_y_2 ps_y =
@ -727,7 +727,7 @@ public:
CGAL_precondition(i != INVALID_INDEX);
// Compare the subcurve xcv[i] and p.
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->compare_y_at_x_2_object()(p, xcv[i]);
}
@ -792,7 +792,7 @@ public:
CGAL_precondition(i2 != INVALID_INDEX);
// Compare cv1[i1] and cv2[i2] at p's left.
return m_poly_traits.geometry_traits_2()->
return m_poly_traits.subcurve_traits_2()->
compare_y_at_x_left_2_object()(cv1[i1], cv2[i2], p);
}
};
@ -838,7 +838,7 @@ public:
CGAL_precondition(i2 != INVALID_INDEX);
// Compare cv1[i1] and cv2[i2] at p's right.
return m_poly_traits.geometry_traits_2()->
return m_poly_traits.subcurve_traits_2()->
compare_y_at_x_right_2_object()(cv1[i1], cv2[i2], p);
}
};
@ -866,7 +866,7 @@ public:
* \return (true) if the two point are the same;(false) otherwise.
*/
bool operator()(const Point_2& p1, const Point_2& p2) const
{ return m_poly_traits.geometry_traits_2()->equal_2_object()(p1, p2); }
{ return m_poly_traits.subcurve_traits_2()->equal_2_object()(p1, p2); }
/*! Check whether the two x-monotone curves are the same (have the same
* graph).
@ -878,7 +878,7 @@ public:
const X_monotone_curve_2& cv2) const
{
// Check the pairwise equality of the contained subcurves.
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Equal_2 equal =
geom_traits->equal_2_object();
typename Subcurve_traits_2::Compare_x_2 compare_x =
@ -993,7 +993,7 @@ public:
*/
Comparison_result operator()(const X_monotone_curve_2& xcv) const
{
return (m_poly_traits.geometry_traits_2()->
return (m_poly_traits.subcurve_traits_2()->
compare_endpoints_xy_2_object()(xcv[0]) == SMALLER) ?
(SMALLER) : (LARGER);
}
@ -1031,7 +1031,7 @@ public:
*/
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Construct_opposite_2 const_op =
geom_traits->construct_opposite_2_object();
std::vector<X_monotone_subcurve_2> rev_segs(xcv.number_of_subcurves());;
@ -1067,7 +1067,7 @@ public:
/*! Obtain an Approximate_2 functor object. */
Approximate_2 approximate_2_object() const
{ return geometry_traits_2()->approximate_2_object(); }
{ return subcurve_traits_2()->approximate_2_object(); }
#else
// The following block defines the nested types Approximate_number_type and
// Approximate_2 and the member function approximate_2_object() based on the
@ -1108,7 +1108,7 @@ public:
/*! Obtain an Approximate_2 functor object. */
Approximate_2 approximate_2_object_impl(boost::false_type) const
{ return geometry_traits_2()->approximate_2_object(); }
{ return subcurve_traits_2()->approximate_2_object(); }
Approximate_2 approximate_2_object_impl(boost::true_type) const { }
@ -1147,7 +1147,7 @@ public:
* allow a polycurve with degenerated subcurves.
*/
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Construct_min_vertex_2 get_min_v =
geom_traits->construct_min_vertex_2_object();
typename Subcurve_traits_2::Construct_max_vertex_2 get_max_v =
@ -1160,9 +1160,9 @@ public:
);
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
if (m_poly_traits.geometry_traits_2()->
if (m_poly_traits.subcurve_traits_2()->
compare_endpoints_xy_2_object()(seg) == LARGER)
return X_monotone_subcurve_2(m_poly_traits.geometry_traits_2()->
return X_monotone_subcurve_2(m_poly_traits.subcurve_traits_2()->
construct_opposite_2_object()(seg));
#endif
@ -1228,7 +1228,7 @@ public:
CGAL_precondition_code
(
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
typename Subcurve_traits_2::Construct_min_vertex_2 get_min_v =
@ -1285,7 +1285,7 @@ public:
);
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
if (m_poly_traits.geometry_traits_2()->
if (m_poly_traits.subcurve_traits_2()->
compare_endpoints_xy_2_object()(*begin) == LARGER)
{
X_monotone_curve_2 xcv(begin, end);
@ -1346,7 +1346,7 @@ public:
Arr_parameter_space operator()(const X_monotone_curve_2& xcv,
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Comparison_result direction =
geom_traits->compare_endpoints_xy_2_object()(xcv[0]);
const X_monotone_subcurve_2& xs =
@ -1363,7 +1363,7 @@ public:
*/
Arr_parameter_space operator()(const Point_2 p) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->parameter_space_in_x_2_object()(p);
}
};
@ -1411,7 +1411,7 @@ public:
Arr_parameter_space operator()(const X_monotone_curve_2& xcv,
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Comparison_result direction =
geom_traits->compare_endpoints_xy_2_object()(xcv[0]);
const X_monotone_subcurve_2& xs =
@ -1429,7 +1429,7 @@ public:
*/
Arr_parameter_space operator()(const Point_2 p) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->parameter_space_in_y_2_object()(p);
}
};
@ -1475,7 +1475,7 @@ public:
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
Comparison_result direction =
geom_traits->compare_endpoints_xy_2_object()(xcv[0]);
const X_monotone_subcurve_2& xs =
@ -1511,7 +1511,7 @@ public:
const X_monotone_curve_2& xcv2,
Arr_curve_end ce2) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Comparison_result direction1 =
geom_traits->compare_endpoints_xy_2_object()(xcv1[0]);
const X_monotone_subcurve_2& xs1 =
@ -1568,7 +1568,7 @@ public:
const X_monotone_curve_2& xcv,
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_x_at_limit_2 compare_x_at_limit =
geom_traits->compare_x_at_limit_2_object();
@ -1581,7 +1581,7 @@ public:
const X_monotone_curve_2 & xcv2,
Arr_curve_end ce2/*! for xcv2 */) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_x_at_limit_2 compare_x_at_limit =
geom_traits->compare_x_at_limit_2_object();
@ -1596,7 +1596,7 @@ public:
const X_monotone_subcurve_2& xseg,
Arr_curve_end ce2/*! for xseg */) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_x_at_limit_2
compare_x_at_limit = geom_traits->compare_x_at_limit_2_object();
@ -1645,7 +1645,7 @@ public:
const X_monotone_curve_2 xcv2,
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_x_near_limit_2
cmp_x_near_limit = geom_traits->compare_x_near_limit_2_object();
@ -1688,7 +1688,7 @@ public:
*/
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->compare_y_on_boundary_2_object()(p1, p2);
}
};
@ -1731,7 +1731,7 @@ public:
const X_monotone_curve_2& xcv2,
Arr_curve_end ce) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Comparison_result direction1 =
geom_traits->compare_endpoints_xy_2_object()(xcv1[0]);
const X_monotone_subcurve_2& xs1 =
@ -1775,7 +1775,7 @@ public:
*/
bool operator()(const Point_2& p) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->is_on_y_identification_2_object()(p);
}
@ -1785,7 +1785,7 @@ public:
*/
bool operator()(const X_monotone_curve_2& xcv) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename X_monotone_curve_2::Subcurve_const_iterator it;
for (it = xcv.begin_subcurves(); it != xcv.end_subcurves(); ++it)
if (! geom_traits->is_on_y_identification_2_object()(*it)) return false;
@ -1820,7 +1820,7 @@ public:
*/
bool operator()(const Point_2& p) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
return geom_traits->is_on_x_identification_2_object()(p);
}
@ -1830,7 +1830,7 @@ public:
*/
bool operator()(const X_monotone_curve_2& xcv) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename X_monotone_curve_2::Subcurve_const_iterator it;
for (it = xcv.begin_subcurves(); it != xcv.end_subcurves(); ++it)
if (! geom_traits->is_on_x_identification_2_object()(*it)) return false;
@ -1898,7 +1898,7 @@ public:
CGAL_precondition_code
(
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
Comparison_result dir = cmp_seg_endpts(seg);
@ -1954,7 +1954,7 @@ public:
CGAL_precondition_code
(
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
Comparison_result dir = cmp_seg_endpts(seg);
@ -2090,7 +2090,7 @@ public:
typedef typename X_monotone_curve_2::size_type size_type;
size_type num_seg = xcv.number_of_subcurves();
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
Comparison_result dir = cmp_seg_endpts(seg);
@ -2143,7 +2143,7 @@ public:
typedef typename X_monotone_curve_2::size_type size_type;
size_type num_seg = xcv.number_of_subcurves();
const Subcurve_traits_2* geom_traits =
m_poly_traits.geometry_traits_2();
m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
Comparison_result dir = cmp_seg_endpts(seg);
@ -2259,7 +2259,7 @@ public:
const Point_2& src,
const Point_2& tgt)const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Trim_2 trim = geom_traits->trim_2_object();
//check whether src and tgt lies on the polycurve/polycurve.
@ -2391,7 +2391,7 @@ protected:
// The direction of cv. SMALLER means left-to-right and
// otherwise right-to-left
Comparison_result direction =
geometry_traits_2()->compare_endpoints_xy_2_object()(cv[0]);
subcurve_traits_2()->compare_endpoints_xy_2_object()(cv[0]);
std::size_t from, to;
if (direction == SMALLER) {
from = 0;
@ -2474,7 +2474,7 @@ protected:
Comparison_result operator()(const X_monotone_subcurve_2& xs,
Arr_curve_end ce)
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
const Point_2& p = (ce == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs) :
geom_traits->construct_min_vertex_2_object()(xs);
@ -2541,7 +2541,7 @@ protected:
Arr_curve_end ce,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = geometry_traits_2();
const Subcurve_traits_2* geom_traits = subcurve_traits_2();
if (geom_traits->is_vertical_2_object()(xcv[0])) {
// Verify that q has the same x-coord as xcv (which is vertical)
Compare_x_2 compare_x = compare_x_2_object();
@ -2569,7 +2569,7 @@ protected:
Arr_curve_end ce,
Arr_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = geometry_traits_2();
const Subcurve_traits_2* geom_traits = subcurve_traits_2();
const Point_2& p = (ce == ARR_MAX_END) ?
geom_traits->construct_max_vertex_2_object()(xs) :
geom_traits->construct_min_vertex_2_object()(xs);
@ -2587,7 +2587,7 @@ protected:
const Point_2& p,
Arr_not_all_sides_oblivious_tag) const
{
const Subcurve_traits_2* geom_traits = geometry_traits_2();
const Subcurve_traits_2* geom_traits = subcurve_traits_2();
if (geom_traits->is_vertical_2_object()(xcv[0])) {
// Verify that q has the same x-coord as xcv (which is vertical)
Compare_x_2 compare_x = compare_x_2_object();
@ -2616,7 +2616,7 @@ protected:
//
std::size_t locate(const X_monotone_curve_2& xcv, const Point_2& q) const
{
const Subcurve_traits_2* geom_traits = geometry_traits_2();
const Subcurve_traits_2* geom_traits = subcurve_traits_2();
if (geom_traits->is_vertical_2_object()(xcv[0])) {
// Verify that q has the same x-coord as cv (which is vertical)
typename Subcurve_traits_2::Construct_min_vertex_2 min_vertex =
@ -2652,17 +2652,17 @@ protected:
if (i == INVALID_INDEX) return INVALID_INDEX;
typename Subcurve_traits_2::Equal_2 equal =
geometry_traits_2()->equal_2_object();
subcurve_traits_2()->equal_2_object();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geometry_traits_2()->compare_endpoints_xy_2_object();
subcurve_traits_2()->compare_endpoints_xy_2_object();
typename Subcurve_traits_2::Compare_x_2 comp_x =
geometry_traits_2()->compare_x_2_object();
subcurve_traits_2()->compare_x_2_object();
typename Subcurve_traits_2::Is_vertical_2 is_vert =
geometry_traits_2()->is_vertical_2_object();
subcurve_traits_2()->is_vertical_2_object();
typename Subcurve_traits_2::Construct_max_vertex_2 get_max_v =
geometry_traits_2()->construct_max_vertex_2_object();
subcurve_traits_2()->construct_max_vertex_2_object();
typename Subcurve_traits_2::Construct_min_vertex_2 get_min_v =
geometry_traits_2()->construct_min_vertex_2_object();
subcurve_traits_2()->construct_min_vertex_2_object();
Comparison_result direction = cmp_seg_endpts(cv[i]);

View File

@ -33,7 +33,7 @@
#include <CGAL/tags.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arr_polycurve_basic_traits_2.h>
#include <CGAL/Arr_geometry_traits/Polyline_2.h>
#include <CGAL/Arr_geometry_traits/Polycurve_2.h>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
@ -129,7 +129,7 @@ public:
/*! A polycurve represents a general continuous piecewise-linear
* curve, without degenerated subcurves.
*/
typedef polyline::Polyline_2<Subcurve_2, Point_2> Curve_2;
typedef internal::Polycurve_2<Subcurve_2, Point_2> Curve_2;
/// \name Basic predicate functors(based on the subcurve traits).
//@{
@ -194,14 +194,14 @@ public:
m_poly_traits.construct_x_monotone_curve_2_object();
typename Subcurve_traits_2::Make_x_monotone_2 make_seg_x_monotone =
m_poly_traits.geometry_traits_2()->make_x_monotone_2_object();
m_poly_traits.subcurve_traits_2()->make_x_monotone_2_object();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
m_poly_traits.geometry_traits_2()->compare_endpoints_xy_2_object();
m_poly_traits.subcurve_traits_2()->compare_endpoints_xy_2_object();
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
typename Subcurve_traits_2::Construct_opposite_2 ctr_seg_opposite =
m_poly_traits.geometry_traits_2()->construct_opposite_2_object();
m_poly_traits.subcurve_traits_2()->construct_opposite_2_object();
#endif
// Convert the input polycurve to a sequence of CGAL objects, such
@ -236,11 +236,11 @@ public:
// To be used in order to verify continuity and well-orientedness
// of the input curve cv.
typename Subcurve_traits_2::Construct_min_vertex_2 min_seg_v =
m_poly_traits.geometry_traits_2()->construct_min_vertex_2_object();
m_poly_traits.subcurve_traits_2()->construct_min_vertex_2_object();
typename Subcurve_traits_2::Construct_max_vertex_2 max_seg_v =
m_poly_traits.geometry_traits_2()->construct_max_vertex_2_object();
m_poly_traits.subcurve_traits_2()->construct_max_vertex_2_object();
typename Subcurve_traits_2::Equal_2 equal =
m_poly_traits.geometry_traits_2()->equal_2_object();
m_poly_traits.subcurve_traits_2()->equal_2_object();
Point_2 last_target = (cmp_seg_endpts(x_seg) == SMALLER) ?
max_seg_v(x_seg) : min_seg_v(x_seg);
Point_2 next_src;
@ -249,7 +249,7 @@ public:
// The polycurve consists of at least 2 x-monotone subcurves:
Push_back_2 push_back = m_poly_traits.push_back_2_object();
typename Subcurve_traits_2::Is_vertical_2 is_seg_vertical =
m_poly_traits.geometry_traits_2()->is_vertical_2_object();
m_poly_traits.subcurve_traits_2()->is_vertical_2_object();
bool is_start_vertical = is_seg_vertical(x_seg);
Comparison_result start_dir = cmp_seg_endpts(x_seg);
@ -330,19 +330,19 @@ public:
m_poly_traits.construct_x_monotone_curve_2_object();
typename Subcurve_traits_2::Make_x_monotone_2 make_seg_x_monotone =
m_poly_traits.geometry_traits_2()->make_x_monotone_2_object();
m_poly_traits.subcurve_traits_2()->make_x_monotone_2_object();
typename Subcurve_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
m_poly_traits.geometry_traits_2()->compare_endpoints_xy_2_object();
m_poly_traits.subcurve_traits_2()->compare_endpoints_xy_2_object();
typename Subcurve_traits_2::Parameter_space_in_x_2 ps_x =
m_poly_traits.geometry_traits_2()->parameter_space_in_x_2_object();
m_poly_traits.subcurve_traits_2()->parameter_space_in_x_2_object();
typename Subcurve_traits_2::Parameter_space_in_y_2 ps_y =
m_poly_traits.geometry_traits_2()->parameter_space_in_y_2_object();
m_poly_traits.subcurve_traits_2()->parameter_space_in_y_2_object();
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
typename Subcurve_traits_2::Construct_opposite_2 ctr_seg_opposite =
m_poly_traits.geometry_traits_2()->construct_opposite_2_object();
m_poly_traits.subcurve_traits_2()->construct_opposite_2_object();
#endif
// Convert the input polycurve to a sequence of CGAL objects, such
@ -377,11 +377,11 @@ public:
// To be used in order to verify continuity and well-orientedness
// of the input curve cv.
typename Subcurve_traits_2::Construct_min_vertex_2 min_seg_v =
m_poly_traits.geometry_traits_2()->construct_min_vertex_2_object();
m_poly_traits.subcurve_traits_2()->construct_min_vertex_2_object();
typename Subcurve_traits_2::Construct_max_vertex_2 max_seg_v =
m_poly_traits.geometry_traits_2()->construct_max_vertex_2_object();
m_poly_traits.subcurve_traits_2()->construct_max_vertex_2_object();
typename Subcurve_traits_2::Equal_2 equal =
m_poly_traits.geometry_traits_2()->equal_2_object();
m_poly_traits.subcurve_traits_2()->equal_2_object();
Point_2 last_target = (cmp_seg_endpts(x_seg) == SMALLER) ?
max_seg_v(x_seg) : min_seg_v(x_seg);
Point_2 next_src;
@ -390,7 +390,7 @@ public:
// The polycurve consists of at least 2 x-monotone subcurves:
Push_back_2 push_back = m_poly_traits.push_back_2_object();
typename Subcurve_traits_2::Is_vertical_2 is_seg_vertical =
m_poly_traits.geometry_traits_2()->is_vertical_2_object();
m_poly_traits.subcurve_traits_2()->is_vertical_2_object();
bool is_start_vertical = is_seg_vertical(x_seg);
Comparison_result start_dir = cmp_seg_endpts(x_seg);
@ -563,7 +563,7 @@ public:
void operator()(const X_monotone_curve_2& xcv, const Point_2& p,
X_monotone_curve_2& xcv1, X_monotone_curve_2& xcv2) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Subcurve_traits_2::Construct_min_vertex_2 min_vertex =
geom_traits->construct_min_vertex_2_object();
typename Subcurve_traits_2::Construct_max_vertex_2 max_vertex =
@ -610,7 +610,7 @@ public:
// The i'th subcurve should be split: The left part(seg1)
// goes to xcv1, and the right part(seg2) goes to xcv2.
X_monotone_subcurve_2 seg1, seg2;
m_poly_traits.geometry_traits_2()->split_2_object()(xcv[i], p,
m_poly_traits.subcurve_traits_2()->split_2_object()(xcv[i], p,
seg1, seg2);
xcv1.push_back(seg1);
@ -626,7 +626,7 @@ public:
}
else {
X_monotone_subcurve_2 seg1, seg2;
m_poly_traits.geometry_traits_2()->
m_poly_traits.subcurve_traits_2()->
split_2_object()(xcv[i], p, seg1, seg2);
if (cmp_seg_endpts(seg2) == LARGER){
@ -634,7 +634,7 @@ public:
}
else {
// seg2 has to be reversed
seg2 = m_poly_traits.geometry_traits_2()->
seg2 = m_poly_traits.subcurve_traits_2()->
construct_opposite_2_object()(seg2);
xcv1.push_back(seg2);
}
@ -644,7 +644,7 @@ public:
}
else {
// seg2 has to be reversed
seg1 = m_poly_traits.geometry_traits_2()->
seg1 = m_poly_traits.subcurve_traits_2()->
construct_opposite_2_object()(seg1);
xcv1.push_back(seg1);
}
@ -689,7 +689,7 @@ public:
const X_monotone_curve_2& cv2,
OutputIterator oi) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Compare_y_at_x_2 cmp_y_at_x = m_poly_traits.compare_y_at_x_2_object();
typename Subcurve_traits_2::Equal_2 equal =
geom_traits->equal_2_object();
@ -978,7 +978,7 @@ public:
bool operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const
{
const Subcurve_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Subcurve_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
Construct_min_vertex_2 min_vertex =
m_poly_traits.construct_min_vertex_2_object();
Construct_max_vertex_2 max_vertex =
@ -1057,28 +1057,26 @@ public:
Equal_2 equal = m_poly_traits.equal_2_object();
c.clear();
if (
// Either both are left-to-right and cv2 is to the right of cv1
if (// Either both are left-to-right and cv2 is to the right of cv1
((cmp_seg_endpts(cv1)==SMALLER) &&
(equal(get_max_v(cv1),get_min_v(cv2)))) ||
// or both are right-to-left and cv2 is to the left of cv1
((cmp_seg_endpts(cv1)==LARGER) &&
(equal(get_min_v(cv1), get_max_v(cv2))))
)
(equal(get_min_v(cv1), get_max_v(cv2)))))
{
const std::size_t n1 = cv1.number_of_subcurves();
const std::size_t n2 = cv2.number_of_subcurves();
std::size_t i;
// cv2 extends cv1 to the right:
for (i = 0; i < n1 - 1; ++i)
c.push_back(cv1[i]);
for (i = 0; i < n1 - 1; ++i) c.push_back(cv1[i]);
// Try to merge the to contiguous line subcurves:
if (m_poly_traits.geometry_traits_2()->
are_mergeable_2_object()(cv1[n1 - 1], cv2[0])) {
if (m_poly_traits.subcurve_traits_2()->
are_mergeable_2_object()(cv1[n1 - 1], cv2[0]))
{
X_monotone_subcurve_2 seg;
m_poly_traits.geometry_traits_2()->
m_poly_traits.subcurve_traits_2()->
merge_2_object()(cv1[n1 - 1], cv2[0], seg);
c.push_back(seg);
}
@ -1087,8 +1085,7 @@ public:
c.push_back(cv2[0]);
}
for (i = 1; i < n2; ++i)
c.push_back(cv2[i]);
for (i = 1; i < n2; ++i) c.push_back(cv2[i]);
}
else
return this->operator()(cv2,cv1,c);

View File

@ -34,7 +34,6 @@
#include <CGAL/basic.h>
#include <CGAL/tags.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arr_geometry_traits/Polyline_2.h>
#include <CGAL/Arr_polycurve_traits_2.h>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
@ -153,7 +152,7 @@ public:
CGAL_precondition(num_seg > 0);
int last_seg = num_seg-1;
const Segment_traits_2* seg_traits = m_poly_traits.segment_traits_2();
const Segment_traits_2* seg_traits = m_poly_traits.subcurve_traits_2();
typename Segment_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
seg_traits->compare_endpoints_xy_2_object();
@ -186,7 +185,7 @@ public:
size_type num_seg = xcv.number_of_subcurves();
CGAL_precondition(num_seg > 0);
const Segment_traits_2* seg_traits = m_poly_traits.segment_traits_2();
const Segment_traits_2* seg_traits = m_poly_traits.subcurves_traits_2();
CGAL_precondition_code
(
typename Segment_traits_2::Compare_x_2 comp_x =
@ -267,7 +266,7 @@ public:
);
CGAL_precondition(num_seg > 0);
const Segment_traits_2* geom_traits = m_poly_traits.geometry_traits_2();
const Segment_traits_2* geom_traits = m_poly_traits.subcurve_traits_2();
typename Segment_traits_2::Compare_endpoints_xy_2 cmp_seg_endpts =
geom_traits->compare_endpoints_xy_2_object();
@ -290,7 +289,7 @@ public:
/*! Append a point `p` to an existing polyline `xcv` at the front. */
void operator()(const X_monotone_curve_2& xcv, Point_2& p) const
{
const SegmentTraits_2* geom_traits = m_poly_traits.geometry_traits_2();
const SegmentTraits_2* geom_traits = m_poly_traits.subcurve_traits_2();
CGAL_precondition_code
(
typedef typename X_monotone_curve_2::size_type size_type;
@ -410,7 +409,7 @@ public:
CGAL_precondition_code
(
typename Segment_traits_2::Equal_2 equal =
this->m_poly_traits.geometry_traits_2()->equal_2_object();
this->m_poly_traits.subcurve_traits_2()->equal_2_object();
);
// Check whether there are no points in the range:
@ -457,15 +456,15 @@ public:
X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q) const
{
CGAL_precondition_msg
(!this->m_poly_traits.geometry_traits_2()->equal_2_object()(p,q),
(!this->m_poly_traits.subcurve_traits_2()->equal_2_object()(p,q),
"Cannot construct a degenerated segment as a polyline");
X_monotone_subcurve_2 seg = this->m_poly_traits.geometry_traits_2()->
X_monotone_subcurve_2 seg = this->m_poly_traits.subcurve_traits_2()->
construct_x_monotone_curve_2_object()(p, q);
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
if (this->m_poly_traits.geometry_traits_2()->compare_xy_2_object()(p,q) ==
if (this->m_poly_traits.subcurve_traits_2()->compare_xy_2_object()(p,q) ==
LARGER)
seg = m_poly_traits.geometry_traits_2()->
seg = m_poly_traits.subcurve_traits_2()->
construct_opposite_2_object()(seg);
#endif
@ -541,7 +540,7 @@ public:
CGAL_precondition_code
(
const Segment_traits_2* geom_traits =
this->m_poly_traits.geometry_traits_2();
this->m_poly_traits.subcurve_traits_2();
// Initialize two comparison functors
typename Segment_traits_2::Compare_x_2 compare_x =
geom_traits->compare_x_2_object();
@ -568,7 +567,7 @@ public:
}
#ifdef CGAL_ALWAYS_LEFT_TO_RIGHT
if (m_poly_traits.geometry_traits_2()->
if (m_poly_traits.subcurve_traits_2()->
compare_endpoints_xy_2_object()(*segs.begin()) == LARGER)
{
X_monotone_curve_2 xcv(segs.begin(), segs.end());
@ -589,7 +588,7 @@ public:
* \return the segment traits.
*/
CGAL_DEPRECATED const Segment_traits_2* segment_traits_2() const
{ return this->geometry_traits_2(); }
{ return this->subcurve_traits_2(); }
};
} // namespace CGAL

View File

@ -57,11 +57,11 @@ struct Default_arr_traits<CGAL::Arr_segment_2<Kernel> >
typedef CGAL::Arr_segment_traits_2<Kernel> Traits;
};
template <typename SegTraits>
struct Default_arr_traits<CGAL::polyline::Polyline_2
<SegTraits, typename SegTraits::Point_2> >
template <typename SubcurveTraits>
struct Default_arr_traits<CGAL::internal::Polycurve_2
<SubcurveTraits, typename SubcurveTraits::Point_2> >
{
typedef CGAL::Arr_polyline_traits_2<SegTraits> Traits;
typedef CGAL::Arr_polyline_traits_2<SubcurveTraits> Traits;
};
template <typename Rat_kernel_, class Alg_kernel_, class Nt_traits_>

View File

@ -14,12 +14,12 @@ public:
TEST_GEOM_TRAITS == POLYCURVE_BEZIER_GEOM_TRAITS || \
TEST_GEOM_TRAITS == POLYLINE_GEOM_TRAITS ||\
TEST_GEOM_TRAITS == NON_CACHING_POLYLINE_GEOM_TRAITS
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
// Poly curves needs some testing where Segments and X-monotone segments are
// required instead of polycurves/x-monotone polycurves.
template <typename InputStream_>
bool read_segment(InputStream_& is, Segment_2& seg);
template <typename InputStream_>
bool read_xsegment(InputStream_& is, X_monotone_segment_2& xseg);
bool read_xsegment(InputStream_& is, X_monotone_subcurve_2& xseg);
#endif
/*! Constructor */
@ -166,35 +166,25 @@ bool IO_base_test<Base_geom_traits>::read_segment(InputStream_& is,
Segment_2& seg)
{
Basic_number_type x, y;
is >> x >> y;
Point_2 p_src(x, y);
is >> x >> y;
Point_2 p_tgt(x, y);
seg = Segment_2(p_src, p_tgt);
return true;
}
template <>
template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
X_monotone_segment_2& xseg)
X_monotone_subcurve_2& xseg)
{
Basic_number_type x, y;
is >> x >> y;
Point_2 p_src(x, y);
is >> x >> y;
Point_2 p_tgt(x, y);
xseg = X_monotone_segment_2(p_src, p_tgt);
xseg = X_monotone_subcurve_2(p_src, p_tgt);
return true;
}
@ -324,13 +314,14 @@ bool read_general_curve(InputStream_& is, Curve& cv)
template <>
template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
X_monotone_curve_2& xcv) //read x-curve
X_monotone_curve_2& xcv)
{
//since we are dealing with polycurve, we will make more than 1 conic curves (polycurve compatible)
//and return the x-monotone-constructed polycurve.
// since we are dealing with polycurve, we will make more than 1 conic curves
// (polycurve compatible) and return the x-monotone-constructed polycurve.
//to store x-monotoneConic curves i.e in Arr_polyline_traits_2 they are called X_monotone_segment_2
std::vector<X_monotone_segment_2> conic_x_monotone_segments;
// to store x-monotoneConic curves i.e in Arr_polyline_traits_2 they are
// called X_monotone_subcurve_2
std::vector<X_monotone_subcurve_2> conic_x_monotone_segments;
Segment_2 tmp_cv;
@ -349,7 +340,7 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
if( !read_general_curve(is, tmp_cv) )
return false;
X_monotone_segment_2 tmp_xcv(tmp_cv);
X_monotone_subcurve_2 tmp_xcv(tmp_cv);
conic_x_monotone_segments.push_back ( tmp_xcv );
}
@ -358,7 +349,7 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
if( !read_general_conic(is, tmp_cv) )
return false;
X_monotone_segment_2 tmp_xcv(tmp_cv);
X_monotone_subcurve_2 tmp_xcv(tmp_cv);
conic_x_monotone_segments.push_back ( tmp_xcv );
}
@ -367,7 +358,7 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
if( !read_general_arc(is, tmp_cv) )
return false;
X_monotone_segment_2 tmp_xcv(tmp_cv);
X_monotone_subcurve_2 tmp_xcv(tmp_cv);
conic_x_monotone_segments.push_back ( tmp_xcv );
}
@ -478,7 +469,7 @@ bool IO_base_test<Base_geom_traits>::read_segment(InputStream_& is,
template <>
template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
X_monotone_segment_2& xseg)
X_monotone_subcurve_2& xseg)
{
char type;
is >> type;
@ -487,7 +478,7 @@ bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
if( !read_general_curve(is, tmp_seg) )
return false;
xseg = X_monotone_segment_2(tmp_seg);
xseg = X_monotone_subcurve_2(tmp_seg);
return true;
}
@ -511,7 +502,7 @@ template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
X_monotone_curve_2& xcv)
{
std::vector<X_monotone_segment_2> x_segments;
std::vector<X_monotone_subcurve_2> x_segments;
char type;
is >> type;
@ -547,7 +538,7 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
is >> point_x >> point_y;
pt = Point_2 ( Number_type(point_x, 1), Number_type(point_y, 1) );
X_monotone_segment_2 x_seg (c, ps, pt, c.orientation());
X_monotone_subcurve_2 x_seg (c, ps, pt, c.orientation());
x_segments.push_back( x_seg );
}
@ -662,7 +653,7 @@ bool IO_base_test<Base_geom_traits>::read_segment(InputStream_& is,
template <>
template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
X_monotone_segment_2& xseg)
X_monotone_subcurve_2& xseg)
{
//we dont need to check this type as it has already been checked in the IO_test.h
char type;
@ -691,7 +682,7 @@ bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
is >> point_x >> point_y;
pt = Point_2 ( Number_type(point_x, 1), Number_type(point_y, 1) );
X_monotone_segment_2 x_seg (c, ps, pt, c.orientation());
X_monotone_subcurve_2 x_seg (c, ps, pt, c.orientation());
xseg = x_seg;
@ -760,7 +751,7 @@ bool IO_base_test<Base_geom_traits>::read_segment(InputStream_& is,
template <>
template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
X_monotone_segment_2& xseg)
X_monotone_subcurve_2& xseg)
{
char type;
is >> type;
@ -786,8 +777,8 @@ bool IO_base_test<Base_geom_traits>::read_xsegment(InputStream_& is,
std::vector<CGAL::Object> obj_vector;
bezier_traits.make_x_monotone_2_object()(seg,
std::back_inserter(obj_vector));
X_monotone_segment_2 x_segment =
CGAL::object_cast<X_monotone_segment_2>((obj_vector[0]));
X_monotone_subcurve_2 x_segment =
CGAL::object_cast<X_monotone_subcurve_2>((obj_vector[0]));
xseg = x_segment;
@ -800,7 +791,7 @@ template <typename InputStream_>
bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
X_monotone_curve_2& xcv)
{
std::vector<X_monotone_segment_2> x_segments;
std::vector<X_monotone_subcurve_2> x_segments;
std::vector<Control_point_2> point_vector;
Bezier_tratis bezier_traits;
@ -833,8 +824,8 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
std::vector<CGAL::Object> obj_vector;
bezier_traits.make_x_monotone_2_object()(seg,
std::back_inserter(obj_vector));
X_monotone_segment_2 x_seg =
CGAL::object_cast<X_monotone_segment_2>( (obj_vector[0]) );
X_monotone_subcurve_2 x_seg =
CGAL::object_cast<X_monotone_subcurve_2>((obj_vector[0]));
x_segments.push_back( x_seg );
@ -1678,7 +1669,7 @@ bool IO_base_test<Base_geom_traits>::read_xcurve(InputStream_& is,
X_monotone_curve_2& xcv)
{
Base_geom_traits traits;
Base_geom_traits::Construct_x_monotone_segment_2 construct_segment_2 =
Base_geom_traits::Construct_x_monotone_subcurve_2 construct_segment_2 =
traits.construct_x_monotone_segment_2_object();
char type;
is >> type;

View File

@ -29,10 +29,10 @@ public:
TEST_GEOM_TRAITS == POLYLINE_GEOM_TRAITS ||\
TEST_GEOM_TRAITS == NON_CACHING_POLYLINE_GEOM_TRAITS
typedef typename Geom_traits_T::X_monotone_segment_2 X_monotone_segment_2;
typedef typename Geom_traits_T::Segment_2 Segment_2;
typedef typename std::vector<X_monotone_segment_2> Xsegment_vector;
typedef typename std::vector<Segment_2> Segment_vector;
typedef typename Geom_traits_T::X_monotone_subcurve_2 X_monotone_subcurve_2;
typedef typename Geom_traits_T::Segment_2 Segment_2;
typedef typename std::vector<X_monotone_subcurve_2> Xsegment_vector;
typedef typename std::vector<Segment_2> Segment_vector;
//vector containers for segments and xsegments
Xsegment_vector m_xsegments;
@ -299,7 +299,7 @@ bool IO_test<Geom_traits_T>::read_xcurves(const char* filename,
if (line[0] == 's') //segment (see segment in 'Arr_polyline_traits.h')
{
std::istringstream line_stream(line);
typename Geom_traits::X_monotone_segment_2 xseg;
typename Geom_traits::X_monotone_subcurve_2 xseg;
this->read_xsegment(line_stream, xseg);
m_xsegments.push_back(xseg);
line_stream.clear();

View File

@ -39,7 +39,7 @@ private:
TEST_GEOM_TRAITS == POLYCURVE_BEZIER_GEOM_TRAITS
typedef typename Traits::Segment_2 Segment_2;
typedef typename Traits::X_monotone_segment_2 X_monotone_segment_2;
typedef typename Traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#endif
@ -458,7 +458,7 @@ push_back_wrapper(std::istringstream& str_stream)
else if (type == 1) {
X_monotone_curve_2 base_curve = this->m_xcurves[id1];
X_monotone_segment_2 x_segment = this->m_xsegments[segment_id];
X_monotone_subcurve_2 x_segment = this->m_xsegments[segment_id];
std::cout << "Test: push_back ( "
<< x_segment << " into "
@ -535,7 +535,7 @@ push_front_wrapper(std::istringstream& str_stream)
else if (type == 1) {
X_monotone_curve_2 base_curve = this->m_xcurves[id1];
X_monotone_segment_2 x_segment = this->m_xsegments[segment_id];
X_monotone_subcurve_2 x_segment = this->m_xsegments[segment_id];
std::cout << "Test: push_front ( "
<< x_segment << "into"

View File

@ -28,7 +28,7 @@ typedef Geom_traits_2::Segment_2 Segment_2;
typedef Geom_traits_2::Curve_2 Polyline_2;
typedef CGAL::Arrangement_2<Geom_traits_2> Arrangement_2;
typedef Geom_traits_2::X_monotone_curve_2 X_monotone_polyline;
typedef Geom_traits_2::X_monotone_segment_2 X_monotone_segment;
typedef Geom_traits_2::X_monotone_subcurve_2 X_monotone_subcurve;
int main(int argc, char* argv[])
{
@ -36,13 +36,14 @@ int main(int argc, char* argv[])
Arrangement_2 arr(&traits);
Geom_traits_2::Construct_x_monotone_curve_2 x_mono_polyline_construct =
traits.construct_x_monotone_curve_2_object();
traits.construct_x_monotone_curve_2_object();
std::vector<X_monotone_segment> x_segments;
x_segments.push_back(X_monotone_segment( Point_2(0,0), Point_2(1,1) ));
x_segments.push_back(X_monotone_segment( Point_2(1,1), Point_2(10,10) ));
x_segments.push_back(X_monotone_segment( Point_2(10,10), Point_2(15,20) ));
X_monotone_polyline pi1 = x_mono_polyline_construct( x_segments.begin(), x_segments.end() );
std::vector<X_monotone_subcurve> x_segments;
x_segments.push_back(X_monotone_subcurve( Point_2(0,0), Point_2(1,1) ));
x_segments.push_back(X_monotone_subcurve( Point_2(1,1), Point_2(10,10) ));
x_segments.push_back(X_monotone_subcurve( Point_2(10,10), Point_2(15,20) ));
X_monotone_polyline pi1 = x_mono_polyline_construct(x_segments.begin(),
x_segments.end() );
std::cout << "polline is: " << pi1 << std::endl;
@ -51,6 +52,5 @@ int main(int argc, char* argv[])
X_monotone_polyline trimmed_polyline = traits.trim_2_object()(pi1, src, tgt);
std::cout << "trimmed polline is: " << trimmed_polyline << std::endl;
return 0;
}

View File

@ -4,9 +4,9 @@
#include <CGAL/basic.h>
#ifndef CGAL_USE_CORE
#include <iostream>
int main ()
int main()
{
std::cout << "Sorry, this example needs CORE ..." << std::endl;
std::cout << "Sorry, this example needs CORE ..." << std::endl;
return 0;
}
@ -27,45 +27,53 @@ int main ()
///////////////
//circle segment traits
//////////////
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Arc_traits_2;
typedef CGAL::Arr_polyline_traits_2<Arc_traits_2> Polycurve_arc_traits_2;
typedef Arc_traits_2::CoordNT CoordNT;
typedef Arc_traits_2::Point_2 Arc_point_2;
typedef Arc_traits_2::Curve_2 Arc_section_2;
typedef Arc_traits_2::X_monotone_curve_2 Arc_section_x_monotone_2;
typedef CGAL::Arrangement_2<Polycurve_arc_traits_2> Arc_arrangment_2;
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Arc_traits_2;
typedef CGAL::Arr_polyline_traits_2<Arc_traits_2> Polycurve_arc_traits_2;
typedef Arc_traits_2::CoordNT CoordNT;
typedef Arc_traits_2::Point_2 Arc_point_2;
typedef Arc_traits_2::Curve_2 Arc_section_2;
typedef Arc_traits_2::X_monotone_curve_2 Arc_section_x_monotone_2;
typedef CGAL::Arrangement_2<Polycurve_arc_traits_2> Arc_arrangment_2;
void check_equal()
{
Polycurve_arc_traits_2 Polycurve_traits_2;
Polycurve_arc_traits_2::Equal_2 equal_2 = Polycurve_traits_2.equal_2_object();
Polycurve_arc_traits_2::Construct_x_monotone_curve_2 construct_x_monotone_curve_2 = Polycurve_traits_2.construct_x_monotone_curve_2_object();
Polycurve_arc_traits_2::Construct_x_monotone_curve_2
construct_x_monotone_curve_2 =
Polycurve_traits_2.construct_x_monotone_curve_2_object();
Arc_section_2 curve1, curve2, curve3;
Kernel::Point_2 p1 = Kernel::Point_2 (-5, 0);
Kernel::Point_2 mid = Kernel::Point_2 (0, 5);
Kernel::Point_2 p2 = Kernel::Point_2 (5, 0);
curve1= Arc_section_2 (p1, mid, p2);
curve2= Arc_section_2 (p1, mid, p2);
Kernel::Point_2 p1 = Kernel::Point_2(-5, 0);
Kernel::Point_2 mid = Kernel::Point_2(0, 5);
Kernel::Point_2 p2 = Kernel::Point_2(5, 0);
curve1= Arc_section_2(p1, mid, p2);
curve2= Arc_section_2(p1, mid, p2);
// //make x_monotone
//Polycurve_arc_traits_2::X_monotone_curve_2 xmc1 = construct_x_monotone_curve_2(curve1);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc2 = construct_x_monotone_curve_2(curve2);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc3 = construct_x_monotone_curve_2(curve3);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc1 =
// construct_x_monotone_curve_2(curve1);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc2 =
// construct_x_monotone_curve_2(curve2);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc3 =
// construct_x_monotone_curve_2(curve3);
// //simple equal
// bool Are_equal = equal_2(xmc1, xmc1);
// std::cout << "Equal_2::Two equal semi circles are computed as: " << ( (Are_equal) ? "Equal" : "Not equal") << std::endl;
// std::cout << "Equal_2::Two equal semi circles are computed as: "
// << ((Are_equal) ? "Equal" : "Not equal") << std::endl;
// Are_equal = equal_2(xmc1, xmc3);
// std::cout << "Equal_2::Two un-equal semi circles are computed as: " << ( (Are_equal) ? "Equal" : "Not equal") << std::endl;
// std::cout << "Equal_2::Two un-equal semi circles are computed as: "
// << ((Are_equal) ? "Equal" : "Not equal") << std::endl;
}
void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2, Polycurve_arc_traits_2::Intersect_2 intersect_2)
void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2
make_x_monotone_2,
Polycurve_arc_traits_2::Intersect_2 intersect_2)
{
Arc_section_2 curve1, curve2, curve3;
@ -73,47 +81,55 @@ void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_
// circle centered at (1,1) with squared radius 3. We create the
// circle with clockwise orientation, so the arc is directed from
// (1 - sqrt(3), 1) to (1 + sqrt(3), 1).
Kernel::Point_2 c1 = Kernel::Point_2 (1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2 (c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT (1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT (1, 1, 3);
Arc_point_2 s1 = Arc_point_2 (one_minus_sqrt_3, CoordNT (1));
Arc_point_2 t1 = Arc_point_2 (one_plus_sqrt_3, CoordNT (1));
curve1= Arc_section_2 (circ1, s1, t1);
curve2= Arc_section_2 (circ1, s1, t1);
Kernel::Point_2 c1 = Kernel::Point_2(1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1));
curve1 = Arc_section_2(circ1, s1, t1);
curve2 = Arc_section_2(circ1, s1, t1);
//push the same semi circle again
//curves.push_back (Arc_section_2 (circ1, s1, t1));
//curves.push_back(Arc_section_2(circ1, s1, t1));
//make x_monotone
std::vector<CGAL::Object> X_monotone_curves;
make_x_monotone_2(curve1, std::back_inserter(X_monotone_curves));
make_x_monotone_2(curve2, std::back_inserter(X_monotone_curves));
Arc_section_x_monotone_2 X_monotone_curve1, X_monotone_curve2, X_monotone_curve3 ;
CGAL::assign( X_monotone_curve1, X_monotone_curves[ 0 ] );
CGAL::assign( X_monotone_curve2, X_monotone_curves[ 1 ] );
Arc_section_x_monotone_2 X_monotone_curve1, X_monotone_curve2,
X_monotone_curve3 ;
CGAL::assign(X_monotone_curve1, X_monotone_curves[0]);
CGAL::assign(X_monotone_curve2, X_monotone_curves[1]);
std::vector<CGAL::Object> Points_of_intersection;
//intersect_2(X_monotone_curve1, X_monotone_curve2, std::back_inserter(Points_of_intersection));
//intersect_2(X_monotone_curve1, X_monotone_curve2,
// std::back_inserter(Points_of_intersection));
// Create a circular arc of the unit circle, directed clockwise from
// (-1/2, sqrt(3)/2) to (1/2, sqrt(3)/2). Note that we orient the
// supporting circle accordingly.
Kernel::Point_2 c6 = Kernel::Point_2 (0, 0);
CoordNT sqrt_3_div_2 = CoordNT (Number_type(0), Number_type(1,2), Number_type(3));
Arc_point_2 s6 = Arc_point_2 (Number_type (-1, 2), sqrt_3_div_2);
Arc_point_2 t6 = Arc_point_2 (Number_type (1, 2), sqrt_3_div_2);
curve3 = Arc_section_2 (c6, 1, CGAL::CLOCKWISE, s6, t6);
Kernel::Point_2 c6 = Kernel::Point_2(0, 0);
CoordNT sqrt_3_div_2 =
CoordNT(Number_type(0), Number_type(1,2), Number_type(3));
Arc_point_2 s6 = Arc_point_2(Number_type(-1, 2), sqrt_3_div_2);
Arc_point_2 t6 = Arc_point_2(Number_type(1, 2), sqrt_3_div_2);
curve3 = Arc_section_2(c6, 1, CGAL::CLOCKWISE, s6, t6);
make_x_monotone_2(curve3, std::back_inserter(X_monotone_curves));
CGAL::assign( X_monotone_curve2, X_monotone_curves[ 2 ] );
CGAL::assign(X_monotone_curve2, X_monotone_curves[2]);
Points_of_intersection.clear();
//intersect_2(X_monotone_curve1, X_monotone_curve2, std::back_inserter(Points_of_intersection));
//intersect_2(X_monotone_curve1, X_monotone_curve2,
// std::back_inserter(Points_of_intersection));
}
void check_compare_end_points_xy_2(Polycurve_arc_traits_2::Compare_endpoints_xy_2 compare_endpoints_xy_2, Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2)
void
check_compare_end_points_xy_2(Polycurve_arc_traits_2::Compare_endpoints_xy_2
compare_endpoints_xy_2,
Polycurve_arc_traits_2::Make_x_monotone_2
make_x_monotone_2)
{
Arc_section_2 curve1, curve2;
@ -121,42 +137,41 @@ void check_compare_end_points_xy_2(Polycurve_arc_traits_2::Compare_endpoints_xy_
// circle centered at (1,1) with squared radius 3. We create the
// circle with clockwise orientation, so the arc is directed from
// (1 - sqrt(3), 1) to (1 + sqrt(3), 1).
Kernel::Point_2 c1 = Kernel::Point_2 (1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2 (c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT (1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT (1, 1, 3);
Arc_point_2 s1 = Arc_point_2 (one_minus_sqrt_3, CoordNT (1));
Arc_point_2 t1 = Arc_point_2 (one_plus_sqrt_3, CoordNT (1));
curve1= Arc_section_2 (circ1, s1, t1);
Kernel::Point_2 c1 = Kernel::Point_2(1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1));
curve1= Arc_section_2(circ1, s1, t1);
//make x_monotone
std::vector<CGAL::Object> X_monotone_curves;
make_x_monotone_2(curve1, std::back_inserter(X_monotone_curves));
Arc_section_x_monotone_2 X_monotone_curve1, X_monotone_curve2 ;
CGAL::assign( X_monotone_curve1, X_monotone_curves[ 0 ] );
CGAL::assign(X_monotone_curve1, X_monotone_curves[ 0 ]);
int res = compare_endpoints_xy_2(X_monotone_curve1);
std::cout<< "The first result is: " << res << std::endl;
std::cout<< "The first result is: " << res << std::endl;
Kernel::Point_2 c2 = Kernel::Point_2 (1, 1);
Kernel::Circle_2 circ2 = Kernel::Circle_2 (c2, 3, CGAL::COUNTERCLOCKWISE);
Arc_point_2 t2 = Arc_point_2 (one_minus_sqrt_3, CoordNT (1));
Arc_point_2 s2 = Arc_point_2 (one_plus_sqrt_3, CoordNT (1));
curve2= Arc_section_2 (circ2, s1, t1);
Kernel::Point_2 c2 = Kernel::Point_2(1, 1);
Kernel::Circle_2 circ2 = Kernel::Circle_2(c2, 3, CGAL::COUNTERCLOCKWISE);
Arc_point_2 t2 = Arc_point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 s2 = Arc_point_2(one_plus_sqrt_3, CoordNT(1));
curve2= Arc_section_2(circ2, s1, t1);
make_x_monotone_2(curve2, std::back_inserter(X_monotone_curves));
CGAL::assign( X_monotone_curve2, X_monotone_curves[ 1 ] );
CGAL::assign(X_monotone_curve2, X_monotone_curves[ 1 ]);
res = compare_endpoints_xy_2(X_monotone_curve2);
std::cout<< "The second result is: " << res << std::endl;
std::cout<< "The second result is: " << res << std::endl;
}
void check_split( Polycurve_arc_traits_2::Split_2 split_2, Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2)
void check_split(Polycurve_arc_traits_2::Split_2 split_2,
Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2)
{
Arc_section_2 curve;
@ -164,204 +179,235 @@ void check_split( Polycurve_arc_traits_2::Split_2 split_2, Polycurve_arc_traits
// circle centered at (1,1) with squared radius 3. We create the
// circle with clockwise orientation, so the arc is directed from
// (1 - sqrt(3), 1) to (1 + sqrt(3), 1).
Kernel::Point_2 c1 = Kernel::Point_2 (1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2 (c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT (1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT (1, 1, 3);
Arc_point_2 s1 = Arc_point_2 (one_minus_sqrt_3, CoordNT (1));
Arc_point_2 t1 = Arc_point_2 (one_plus_sqrt_3, CoordNT (1));
curve= Arc_section_2 (circ1, s1, t1);
Kernel::Point_2 c1 = Kernel::Point_2(1, 1);
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1));
curve= Arc_section_2(circ1, s1, t1);
//make x_monotone
std::vector<CGAL::Object> X_monotone_curves;
make_x_monotone_2(curve, std::back_inserter(X_monotone_curves));
Arc_section_x_monotone_2 X_monotone_curve, split_x_monotone_curve1, split_x_monotone_curve2 ;
CGAL::assign( X_monotone_curve, X_monotone_curves[ 0 ] );
//split_2(X_monotone_curve, Kernel::Point_2::Kernel::Point_2(1, 4), split_x_monotone_curve1, split_x_monotone_curve2);
Arc_section_x_monotone_2 X_monotone_curve, split_x_monotone_curve1,
split_x_monotone_curve2 ;
CGAL::assign(X_monotone_curve, X_monotone_curves[0]);
//split_2(X_monotone_curve, Kernel::Point_2::Kernel::Point_2(1, 4),
// split_x_monotone_curve1, split_x_monotone_curve2);
}
void check_is_vertical(Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2, Polycurve_arc_traits_2::Is_vertical_2 is_vertical)
void check_is_vertical(Polycurve_arc_traits_2::Make_x_monotone_2
make_x_monotone_2,
Polycurve_arc_traits_2::Is_vertical_2 is_vertical)
{
std::vector<Arc_section_2> curves;
// Create a circular arc defined by two endpoints and a midpoint,
// all having rational coordinates. This arc is the upper-right
// quarter of a circle centered at the origin with radius 5.
Kernel::Point_2 p1 = Kernel::Point_2 (0, 5);
Kernel::Point_2 mid = Kernel::Point_2 (3, 4);
Kernel::Point_2 p2 = Kernel::Point_2 (5, 0);
Kernel::Point_2 p3 = Kernel::Point_2 (0, -5);
curves.push_back (Arc_section_2 (p1, mid, p2)); //quarter of a circle
curves.push_back (Arc_section_2 (p1, mid, p3)); //semi-circle
Kernel::Point_2 p1 = Kernel::Point_2(0, 5);
Kernel::Point_2 mid = Kernel::Point_2(3, 4);
Kernel::Point_2 p2 = Kernel::Point_2(5, 0);
Kernel::Point_2 p3 = Kernel::Point_2(0, -5);
curves.push_back(Arc_section_2(p1, mid, p2)); //quarter of a circle
curves.push_back(Arc_section_2(p1, mid, p3)); //semi-circle
//convert all curves to x-monotone curves
std::vector<CGAL::Object> X_monotone_curves;
for(int i=0; i<curves.size(); i++)
for(int i = 0; i < curves.size(); ++i)
make_x_monotone_2(curves[i], std::back_inserter(X_monotone_curves));
//std::vector<Arc_section_x_monotone_2> x_monotone_polycurves;
Arc_section_x_monotone_2 x_monotone_polycurve1, x_monotone_polycurve2;
CGAL::assign( x_monotone_polycurve1, X_monotone_curves[ 0 ] );
CGAL::assign( x_monotone_polycurve2, X_monotone_curves[ 1 ] );
CGAL::assign(x_monotone_polycurve1, X_monotone_curves[0]);
CGAL::assign(x_monotone_polycurve2, X_monotone_curves[1]);
bool res = is_vertical(x_monotone_polycurve1);
std::cout << "Is_verticle:: The xmonotone curve (quarter circle) is : " << ( (res)? "vertical" : "not vertical" ) << std::endl;
std::cout << "Is_verticle:: The xmonotone curve (quarter circle) is : "
<< ((res)? "vertical" : "not vertical") << std::endl;
res = is_vertical(x_monotone_polycurve2);
std::cout << "Is_verticle:: The xmonotone curve (Smi-circle) is : " << ( (res)? "vertical" : "not vertical" ) << std::endl;
std::cout << "Is_verticle:: The xmonotone curve (Smi-circle) is : "
<< ((res)? "vertical" : "not vertical") << std::endl;
}
void check_compare_y_at_x_2(Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2, Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2)
void check_compare_y_at_x_2(Polycurve_arc_traits_2::Make_x_monotone_2
make_x_monotone_2,
Polycurve_arc_traits_2::Compare_y_at_x_2
cmp_y_at_x_2)
{
std::vector<Arc_section_2> curves;
// Create a circular arc defined by two endpoints and a midpoint,
// all having rational coordinates. This arc is the upper-right
// quarter of a circle centered at the origin with radius 5.
Kernel::Point_2 p1 = Kernel::Point_2 (1, 1);
Kernel::Point_2 mid = Kernel::Point_2 (4, 4);
Kernel::Point_2 p2 = Kernel::Point_2 (7, 1);
Kernel::Point_2 p3 = Kernel::Point_2 (1, 4);
curves.push_back (Arc_section_2 (p1, mid, p2)); //quarter of a circle
curves.push_back (Arc_section_2 (p1, mid, p3)); //semi-circle
Kernel::Point_2 p1 = Kernel::Point_2(1, 1);
Kernel::Point_2 mid = Kernel::Point_2(4, 4);
Kernel::Point_2 p2 = Kernel::Point_2(7, 1);
Kernel::Point_2 p3 = Kernel::Point_2(1, 4);
curves.push_back(Arc_section_2(p1, mid, p2)); //quarter of a circle
curves.push_back(Arc_section_2(p1, mid, p3)); //semi-circle
//convert all curves to x-monotone curves
std::vector<CGAL::Object> X_monotone_curves;
for(int i=0; i<curves.size(); i++)
for (int i = 0; i < curves.size(); ++i)
make_x_monotone_2(curves[i], std::back_inserter(X_monotone_curves));
Arc_section_x_monotone_2 x_monotone_polycurve1, x_monotone_polycurve2;
CGAL::assign( x_monotone_polycurve1, X_monotone_curves[ 0 ] );
CGAL::assign( x_monotone_polycurve2, X_monotone_curves[ 1 ] );
CGAL::assign(x_monotone_polycurve1, X_monotone_curves[ 0 ]);
CGAL::assign(x_monotone_polycurve2, X_monotone_curves[ 1 ]);
Kernel::Point_2 p_test = Kernel::Point_2 (3, 1);
Kernel::Point_2 p_test = Kernel::Point_2(3, 1);
//int res = cmp_y_at_x_2(p_test, x_monotone_polycurve1);
//cmp_y_at_x_2(x_monotone_polycurve1, CGAL::ARR_MIN_END, x_monotone_polycurve2);
// int res = cmp_y_at_x_2(p_test, x_monotone_polycurve1);
// cmp_y_at_x_2(x_monotone_polycurve1, CGAL::ARR_MIN_END,
// x_monotone_polycurve2);
}
void check_push_back(Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2, Polycurve_arc_traits_2::Push_back_2 push_back_2)
void check_push_back(Polycurve_arc_traits_2::Make_x_monotone_2
make_x_monotone_2,
Polycurve_arc_traits_2::Push_back_2 push_back_2)
{
std::vector<Arc_section_2> curves;
std::vector<Arc_section_2> curves;
//check if segment is pushed in empty curve.
Kernel::Point_2 p1 = Kernel::Point_2 (1, 1);
Kernel::Point_2 mid = Kernel::Point_2 (4, 4);
Kernel::Point_2 p2 = Kernel::Point_2 (7, 1);
//check if segment is pushed in empty curve.
Kernel::Point_2 p1 = Kernel::Point_2(1, 1);
Kernel::Point_2 mid = Kernel::Point_2(4, 4);
Kernel::Point_2 p2 = Kernel::Point_2(7, 1);
Kernel::Point_2 mid2 = Kernel::Point_2 (10, 3);
Kernel::Point_2 p3 = Kernel::Point_2 (7, 7);
Kernel::Point_2 mid2 = Kernel::Point_2(10, 3);
Kernel::Point_2 p3 = Kernel::Point_2(7, 7);
curves.push_back(Arc_section_2 (p1, mid, p2));
curves.push_back(Arc_section_2 (p2, mid2, p3));
CGAL::polyline::Polyline_2<Arc_section_2, Arc_point_2> polycurve;
curves.push_back(Arc_section_2(p1, mid, p2));
curves.push_back(Arc_section_2(p2, mid2, p3));
////pushing segments in polycurve
push_back_2(polycurve, curves[0]);
std::cout<< "size of polycurve after 1 push_back: " << polycurve.size() << std::endl;
CGAL::internal::Polycurve_2<Arc_section_2, Arc_point_2> polycurve;
push_back_2(polycurve, curves[1]);
std::cout<< "size of polycurve after 2 push_backs: " << polycurve.size() << std::endl; //throws a warning "size is depricated"
////pushing segments in polycurve
push_back_2(polycurve, curves[0]);
std::cout << "size of polycurve after 1 push_back: "
<< polycurve.number_of_subcurves()() << std::endl;
//pushing xmonotone segments in xmonotone polycurves
// CGAL::polyline::Polyline_2<Arc_section_x_monotone_2, Arc_point_2> x_monotone_polycurve;
push_back_2(polycurve, curves[1]);
//throws a warning "size is depricated"
std::cout << "size of polycurve after 2 push_backs: "
<< polycurve.number_of_subcurves()() << std::endl;
// Kernel::Point_2 p5 = Kernel::Point_2 (7, 1);
// Kernel::Point_2 p6 = Kernel::Point_2 (-3, -3);
// Kernel::Point_2 p7 = Kernel::Point_2 (13, 1);
// curves.push_back(Arc_section_2 (p5, p6, p7));
//pushing xmonotone segments in xmonotone polycurves
// CGAL::polyline::Polyline_2<Arc_section_x_monotone_2, Arc_point_2>
// x_monotone_polycurve;
// Kernel::Point_2 p5 = Kernel::Point_2(7, 1);
// Kernel::Point_2 p6 = Kernel::Point_2(-3, -3);
// Kernel::Point_2 p7 = Kernel::Point_2(13, 1);
// curves.push_back(Arc_section_2(p5, p6, p7));
// std::vector<CGAL::Object> X_monotone_curves;
// make_x_monotone_2(curves[0], std::back_inserter(X_monotone_curves));
// make_x_monotone_2(curves[1], std::back_inserter(X_monotone_curves));
// Arc_section_x_monotone_2 x_monotone_polycurve1, x_monotone_polycurve2;
// CGAL::assign( x_monotone_polycurve1, X_monotone_curves[ 0 ] );
// CGAL::assign( x_monotone_polycurve2, X_monotone_curves[ 1 ] );
// CGAL::assign(x_monotone_polycurve1, X_monotone_curves[0]);
// CGAL::assign(x_monotone_polycurve2, X_monotone_curves[1]);
// push_back_2(x_monotone_polycurve, x_monotone_polycurve1);
// std::cout<< "size of x-monotone-polycurve after 1 push_back: " << polycurve.size() << std::endl;
// push_back_2(x_monotone_polycurve, x_monotone_polycurve2);
// std::cout<< "size of x-monotone-polycurve after 2 push_backs: " << polycurve.size() << std::endl; //throws a warning "size is depricated"
// std::cout << "size of x-monotone-polycurve after 1 push_back: "
// << polycurve.size() << std::endl;
// push_back_2(x_monotone_polycurve, x_monotone_polycurve2);
// std::cout << "size of x-monotone-polycurve after 2 push_backs: "
// << polycurve.size() << std::endl;
// throws a warning "size is depricated"
}
int main ()
int main()
{
Polycurve_arc_traits_2 Polycurve_traits_2;
//Compare_x_2
//Polycurve_arc_traits_2::Compare_x_2 compare_x_2 = Polycurve_traits_2.compare_xy_2_object();
// Compare_x_2
// Polycurve_arc_traits_2::Compare_x_2 compare_x_2 =
// Polycurve_traits_2.compare_xy_2_object();
//number of points
//Polycurve_arc_traits_2::Number_of_points_2 num_of_points = Polycurve_traits_2.number_of_points_2_object();
// number of points
// Polycurve_arc_traits_2::Number_of_points_2 num_of_points =
// Polycurve_traits_2.number_of_points_2_object();
//construct min vertex
Polycurve_arc_traits_2::Construct_min_vertex_2 cnst_min_vertex = Polycurve_traits_2.construct_min_vertex_2_object();
Polycurve_arc_traits_2::Construct_min_vertex_2 cnst_min_vertex =
Polycurve_traits_2.construct_min_vertex_2_object();
//construct max vertex
Polycurve_arc_traits_2::Construct_max_vertex_2 cnst_max_vertex_2 = Polycurve_traits_2.construct_max_vertex_2_object();
Polycurve_arc_traits_2::Construct_max_vertex_2 cnst_max_vertex_2 =
Polycurve_traits_2.construct_max_vertex_2_object();
//is vertical (return bool)
Polycurve_arc_traits_2::Is_vertical_2 is_vertical = Polycurve_traits_2.is_vertical_2_object();
Polycurve_arc_traits_2::Is_vertical_2 is_vertical =
Polycurve_traits_2.is_vertical_2_object();
//Compare y at x 2 (return comparison_result)
Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 = Polycurve_traits_2.compare_y_at_x_2_object();
Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 =
Polycurve_traits_2.compare_y_at_x_2_object();
//compare y at x left
Polycurve_arc_traits_2::Compare_y_at_x_left_2 cmp_y_at_x_left_2 = Polycurve_traits_2.compare_y_at_x_left_2_object();
Polycurve_arc_traits_2::Compare_y_at_x_left_2 cmp_y_at_x_left_2 =
Polycurve_traits_2.compare_y_at_x_left_2_object();
//compare y at x right
Polycurve_arc_traits_2::Compare_y_at_x_right_2 cmp_y_at_x_right_2 = Polycurve_traits_2.compare_y_at_x_right_2_object();
Polycurve_arc_traits_2::Compare_y_at_x_right_2 cmp_y_at_x_right_2 =
Polycurve_traits_2.compare_y_at_x_right_2_object();
//equal_2
Polycurve_arc_traits_2::Equal_2 equal_2 = Polycurve_traits_2.equal_2_object();
Polycurve_arc_traits_2::Equal_2 equal_2 =
Polycurve_traits_2.equal_2_object();
//compare end points xy_2
Polycurve_arc_traits_2::Compare_endpoints_xy_2 compare_endpoints_xy_2 = Polycurve_traits_2.compare_endpoints_xy_2_object();
Polycurve_arc_traits_2::Compare_endpoints_xy_2 compare_endpoints_xy_2 =
Polycurve_traits_2.compare_endpoints_xy_2_object();
//construct opposite
Polycurve_arc_traits_2::Construct_opposite_2 construct_opposite_2 = Polycurve_traits_2.construct_opposite_2_object();
Polycurve_arc_traits_2::Construct_opposite_2 construct_opposite_2 =
Polycurve_traits_2.construct_opposite_2_object();
//make x_monotone
Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2 = Polycurve_traits_2.make_x_monotone_2_object();
Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2 =
Polycurve_traits_2.make_x_monotone_2_object();
//push back
Polycurve_arc_traits_2::Push_back_2 push_back_2 = Polycurve_traits_2.push_back_2_object();
Polycurve_arc_traits_2::Push_back_2 push_back_2 =
Polycurve_traits_2.push_back_2_object();
//push front
Polycurve_arc_traits_2::Push_front_2 push_front_2 = Polycurve_traits_2.push_front_2_object();
Polycurve_arc_traits_2::Push_front_2 push_front_2 =
Polycurve_traits_2.push_front_2_object();
//split_2
Polycurve_arc_traits_2::Split_2 split_2 = Polycurve_traits_2.split_2_object();
Polycurve_arc_traits_2::Split_2 split_2 =
Polycurve_traits_2.split_2_object();
//Intersect_2
Polycurve_arc_traits_2::Intersect_2 intersect_2 = Polycurve_traits_2.intersect_2_object();
Polycurve_arc_traits_2::Intersect_2 intersect_2 =
Polycurve_traits_2.intersect_2_object();
//Are_mergable
Polycurve_arc_traits_2::Are_mergeable_2 are_mergeable_2 = Polycurve_traits_2.are_mergeable_2_object();
Polycurve_arc_traits_2::Are_mergeable_2 are_mergeable_2 =
Polycurve_traits_2.are_mergeable_2_object();
//Merge_2
Polycurve_arc_traits_2::Merge_2 merge_2 = Polycurve_traits_2.merge_2_object();
Polycurve_arc_traits_2::Merge_2 merge_2 =
Polycurve_traits_2.merge_2_object();
//construct_curve_2
Polycurve_arc_traits_2::Construct_curve_2 construct_curve_2 = Polycurve_traits_2.construct_curve_2_object();
Polycurve_arc_traits_2::Construct_curve_2 construct_curve_2 =
Polycurve_traits_2.construct_curve_2_object();
//construct x_monotone curve_2
Polycurve_arc_traits_2::Construct_x_monotone_curve_2 construct_x_monotone_curve_2 = Polycurve_traits_2.construct_x_monotone_curve_2_object();
Polycurve_arc_traits_2::Construct_x_monotone_curve_2
construct_x_monotone_curve_2 =
Polycurve_traits_2.construct_x_monotone_curve_2_object();
//check_equal();
check_intersect(make_x_monotone_2, intersect_2);

View File

@ -6,7 +6,7 @@
#include <iostream>
int main ()
{
std::cout << "Sorry, this example needs CORE ..." << std::endl;
std::cout << "Sorry, this example needs CORE ..." << std::endl;
return 0;
}
@ -25,47 +25,49 @@ int main ()
///////////////
//circle segment traits
//////////////
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Arc_traits_2;
typedef CGAL::Arr_polyline_traits_2<Arc_traits_2> Polycurve_arc_traits_2;
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Arc_traits_2;
typedef CGAL::Arr_polyline_traits_2<Arc_traits_2> Polycurve_arc_traits_2;
typedef Arc_traits_2::CoordNT CoordNT;
typedef Arc_traits_2::Point_2 Point_2;
typedef Arc_traits_2::Curve_2 Arc_section_2;
typedef Arc_traits_2::X_monotone_curve_2 Arc_x_monotone_section_2;
typedef Polycurve_arc_traits_2::X_monotone_curve_2 X_monotone_polycurve;
typedef Polycurve_arc_traits_2::Curve_2 Polycurve;
typedef Kernel::Circle_2 Circle_2;
typedef Arc_traits_2::Has_construct_x_monotone_curve_from_two_points_category Has_construct_x_monotone_curve_from_two_points_category;
typedef Arc_traits_2::CoordNT CoordNT;
typedef Arc_traits_2::Point_2 Point_2;
typedef Arc_traits_2::Curve_2 Arc_section_2;
typedef Arc_traits_2::X_monotone_curve_2 Arc_x_monotone_section_2;
typedef Polycurve_arc_traits_2::X_monotone_curve_2 X_monotone_polycurve;
typedef Polycurve_arc_traits_2::Curve_2 Polycurve;
typedef Kernel::Circle_2 Circle_2;
template<typename Curve>
bool check_compare_y_at_x_2(Curve& cv)
{
Polycurve_arc_traits_2 traits;
Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 = traits.compare_y_at_x_2_object();
Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 =
traits.compare_y_at_x_2_object();
//create points
Polycurve_arc_traits_2::Point_2 point_above_line = Polycurve_arc_traits_2::Point_2(4,4),
point_below_line = Polycurve_arc_traits_2::Point_2(3,1),
point_on_line = Polycurve_arc_traits_2::Point_2(0,1);
Polycurve_arc_traits_2::Point_2 point_above_line =
Polycurve_arc_traits_2::Point_2(4,4),
point_below_line = Polycurve_arc_traits_2::Point_2(3,1),
point_on_line = Polycurve_arc_traits_2::Point_2(0,1);
CGAL::Comparison_result result;
result = cmp_y_at_x_2(point_above_line, cv);
std::cout << "Compare_y_at_x_2:: for point above the curve computed Answer is: "<< (result == CGAL::SMALLER ? "Below":
std::cout << "Compare_y_at_x_2:: for point above the curve computed Answer is: "
<< (result == CGAL::SMALLER ? "Below":
(result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;
result = cmp_y_at_x_2(point_below_line, cv);
std::cout << "Compare_y_at_x_2:: for point below the curve computed Answer is: "<< (result == CGAL::SMALLER ? "Below":
std::cout << "Compare_y_at_x_2:: for point below the curve computed Answer is: "
<< (result == CGAL::SMALLER ? "Below":
(result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;
result = cmp_y_at_x_2(point_on_line, cv);
std::cout << "Compare_y_at_x_2:: for point on the curve computed Answer is: "<< (result == CGAL::SMALLER ? "Below":
std::cout << "Compare_y_at_x_2:: for point on the curve computed Answer is: "
<< (result == CGAL::SMALLER ? "Below":
(result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;
return true;
@ -79,7 +81,6 @@ void check_intersect(const Curve& cv1, const Curve& cv2)
// std::vector<CGAL::Object> object_vec;
// traits.intersect_2_object()(cv1, cv2, object_vec);
// std::cout<< "number of intersections is: " << object_vec.size();
}
template<typename Curve>
@ -88,54 +89,50 @@ void check_make_x_monotone(Curve cv)
Polycurve_arc_traits_2 traits;
std::vector<CGAL::Object> object_vec;
traits.make_x_monotone_2_object()(cv, std::back_inserter(object_vec) );
std::cout << "Number of x-monotone curves: " << object_vec.size() << std::endl;
traits.make_x_monotone_2_object()(cv, std::back_inserter(object_vec));
std::cout << "Number of x-monotone curves: "
<< object_vec.size() << std::endl;
}
template<typename Curve>
void check_trim(Curve& xcv, int sx, int sy, int tx, int ty)
{
Polycurve_arc_traits_2 traits;
Point_2 source ( sx, sy );
Point_2 target ( tx, ty);
Point_2 source(sx, sy);
Point_2 target(tx, ty);
Polycurve_arc_traits_2::Trim_2 trim_polycurve = traits.trim_2_object();
X_monotone_polycurve trimmed_curve = trim_polycurve(xcv, source, target);
std::cout << "polycurvecurve: " << xcv << std::endl<<std::endl;
std::cout << "Trimmed curve: " << trimmed_curve << std::endl;
}
int main (int argc, char* argv[])
int main(int argc, char* argv[])
{
Polycurve_arc_traits_2 traits;
std::vector<Arc_section_2> curves;
std::vector<Arc_x_monotone_section_2> x_curves;
// Create a circular arc of the circle, directed clockwise from
// (-1, 0) to (1, 0). Note that we orient the
// supporting circle accordingly.
Kernel::Point_2 c6 = Kernel::Point_2 (0, 0);
Point_2 s6 = Point_2 ( Number_type (-1, 1), Number_type (0, 1) );
Point_2 t6 = Point_2 ( Number_type (1, 1), Number_type (0, 1));
Arc_section_2 circ_arc1 (c6, 1, CGAL::CLOCKWISE, s6, t6);
Kernel::Point_2 c6 = Kernel::Point_2(0, 0);
Point_2 s6 = Point_2(Number_type(-1, 1), Number_type(0, 1));
Point_2 t6 = Point_2(Number_type(1, 1), Number_type(0, 1));
Arc_section_2 circ_arc1(c6, 1, CGAL::CLOCKWISE, s6, t6);
curves.push_back (circ_arc1);
curves.push_back(circ_arc1);
// Create a circular arc of the unit circle, directed clockwise from
// (1, 0) to (3, 0). Note that we orient the
// supporting circle accordingly.
Kernel::Point_2 c1 = Kernel::Point_2 (3, 0);
Point_2 s1 = Point_2 ( Number_type (1, 1), Number_type (0, 1) );
Point_2 t1 = Point_2 ( Number_type (5, 1), Number_type (0, 1));
Arc_section_2 circ_arc2 (c1, 2, CGAL::CLOCKWISE, s1, t1);
curves.push_back (circ_arc2);
Kernel::Point_2 c1 = Kernel::Point_2(3, 0);
Point_2 s1 = Point_2(Number_type(1, 1), Number_type(0, 1));
Point_2 t1 = Point_2(Number_type(5, 1), Number_type(0, 1));
Arc_section_2 circ_arc2(c1, 2, CGAL::CLOCKWISE, s1, t1);
curves.push_back(circ_arc2);
Circle_2 circ = Circle_2(c6, 1, CGAL::CLOCKWISE);
Arc_x_monotone_section_2 xc1(circ, s6, t6, CGAL::CLOCKWISE);
@ -145,51 +142,56 @@ int main (int argc, char* argv[])
Arc_x_monotone_section_2 xc2(circ1, s1, t1, CGAL::CLOCKWISE);
x_curves.push_back(xc2);
// Polycurve circ_arc_polycurve =
// traits.construct_curve_2_object()(curves.begin(), curves.end());
X_monotone_polycurve x_polycurve_1 =
traits.construct_x_monotone_curve_2_object()(x_curves.begin(),
x_curves.end());
//Polycurve circ_arc_polycurve = traits.construct_curve_2_object() ( curves.begin(), curves.end() );
X_monotone_polycurve x_polycurve_1 = traits.construct_x_monotone_curve_2_object()( x_curves.begin(), x_curves.end() );
Kernel::Point_2 cen = Kernel::Point_2 (-2, 0);
Kernel::Point_2 cen = Kernel::Point_2(-2, 0);
Circle_2 circ2 = Circle_2(cen, 2, CGAL::CLOCKWISE);
Point_2 s2 = Point_2 ( Number_type (-4, 1), Number_type (0, 1) );
Point_2 t2 = Point_2 ( Number_type (0, 1), Number_type (0, 1));
Point_2 s2 = Point_2(Number_type(-4, 1), Number_type(0, 1));
Point_2 t2 = Point_2(Number_type(0, 1), Number_type(0, 1));
Arc_x_monotone_section_2 xc3(circ2, s2, t2, CGAL::CLOCKWISE);
x_curves.clear();
x_curves.push_back(xc3);
X_monotone_polycurve x_polycurve_2 = traits.construct_x_monotone_curve_2_object()( x_curves.begin(), x_curves.end() );
X_monotone_polycurve x_polycurve_2 =
traits.construct_x_monotone_curve_2_object()(x_curves.begin(),
x_curves.end());
//testing for arc construction from two points.
//Arc_x_monotone_section_2 x_segment( Kernel::Point_2(0, 0), Kernel::Point_2(2, 0) );
//Arc_x_monotone_section_2 x_segment(Kernel::Point_2(0, 0),
// Kernel::Point_2(2, 0));
//x_curves.clear();
//x_curves.push_back(x_segment);
//X_monotone_polycurve x_polycurve_3 = traits.construct_x_monotone_curve_2_object()( x_curves.begin(), x_curves.end() );
//X_monotone_polycurve x_polycurve_3 =
//traits.construct_x_monotone_curve_2_object()(x_curves.begin(),
// x_curves.end());
//std::cout<< "x_polycurve_3: " << x_polycurve_3 << std::endl;
//Another polycurve
curves.clear();
Kernel::Point_2 center = Kernel::Point_2 (-10, 10);
Point_2 source = Point_2 ( Number_type (-10, 1), Number_type (13, 1) );
Point_2 target = Point_2 ( Number_type (-7, 1), Number_type (10, 1));
Arc_section_2 circ_arc (center, 3, CGAL::CLOCKWISE, source, target);
curves.push_back( circ_arc );
center = Kernel::Point_2 (-20, 10);
source = Point_2 ( Number_type (-7, 1), Number_type (10, 1) );
target = Point_2 ( Number_type (-20, 1), Number_type (23, 1));
Kernel::Point_2 center = Kernel::Point_2(-10, 10);
Point_2 source = Point_2(Number_type(-10, 1), Number_type(13, 1));
Point_2 target = Point_2(Number_type(-7, 1), Number_type(10, 1));
Arc_section_2 circ_arc(center, 3, CGAL::CLOCKWISE, source, target);
curves.push_back(circ_arc);
center = Kernel::Point_2(-20, 10);
source = Point_2(Number_type(-7, 1), Number_type(10, 1));
target = Point_2(Number_type(-20, 1), Number_type(23, 1));
circ_arc = Arc_section_2(center, 13, CGAL::CLOCKWISE, source, target);
curves.push_back( circ_arc );
curves.push_back(circ_arc);
center = Kernel::Point_2 (-20, 25);
source = Point_2 ( Number_type (-20, 1), Number_type (23, 1) );
target = Point_2 ( Number_type (-20, 1), Number_type (27, 1));
center = Kernel::Point_2(-20, 25);
source = Point_2(Number_type(-20, 1), Number_type(23, 1));
target = Point_2(Number_type(-20, 1), Number_type(27, 1));
circ_arc = Arc_section_2(center, 2, CGAL::CLOCKWISE, source, target);
curves.push_back( circ_arc );
curves.push_back(circ_arc);
Polycurve curve_1 = traits.construct_curve_2_object()(curves.begin(), curves.end() );
Polycurve curve_1 =
traits.construct_curve_2_object()(curves.begin(), curves.end());
//////////////////////
//Functor testing
@ -199,30 +201,25 @@ int main (int argc, char* argv[])
// check_intersect(x_polycurve_1, x_polycurve_2);
//check_make_x_monotone(curve_1);
//checking if the cgal_assertion for curve construction for two points work or not.
//Point_2 push_back_point( Number_type (10, 1), Number_type (0, 1));
//checking if the cgal_assertion for curve construction for two points work
//or not.
//Point_2 push_back_point(Number_type(10, 1), Number_type(0, 1));
//traits.push_back_2_object()(x_polycurve_1, push_back_point);
// //checking for trim.
// Arc_traits_2 arc_traits;
// source = Point_2(Number_type(1, 1), Number_type(0, 1));
// target = Point_2(Number_type(3, 1), Number_type(2, 1));
// // source = Point_2(Number_type(2, 1), Number_type(-2, 1));
// // target = Point_2(Number_type(3, 1), Number_type(4, 1));
// std::cout << " curve is : " << xc2 << std::endl;
// Arc_x_monotone_section_2 trimmed_curve =
// arc_traits.trim_2_object()(xc2, source, target);
// std::cout << "trimmed conic curve is : " << trimmed_curve << std::endl;
//CHECK ARC TRIMMING
// if(Has_construct_x_monotone_curve_from_two_points_category())
// std::cout << "It has a line segment constructor. " << std::endl;
// //checking for trim.
// Arc_traits_2 arc_traits;
// source = Point_2 ( Number_type (1, 1), Number_type (0, 1) );
// target = Point_2 ( Number_type (3, 1), Number_type (2, 1));
// // source = Point_2 ( Number_type (2, 1), Number_type (-2, 1) );
// // target = Point_2 ( Number_type (3, 1), Number_type (4, 1));
// std::cout << " curve is : " << xc2 << std::endl;
// Arc_x_monotone_section_2 trimmed_curve = arc_traits.trim_2_object()(xc2, source, target);
// std::cout << "trimmed conic curve is : " << trimmed_curve << std::endl;
check_trim(x_polycurve_1, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
std::cout<< std::endl;
check_trim(x_polycurve_1, atoi(argv[1]), atoi(argv[2]),
atoi(argv[3]), atoi(argv[4]));
std::cout << std::endl;
return 0;
}

View File

@ -99,19 +99,19 @@ typedef CGAL::Arr_non_caching_segment_traits_2<Kernel> Base_geom_traits;
#elif TEST_GEOM_TRAITS == POLYLINE_GEOM_TRAITS
typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits;
typedef CGAL::Arr_polyline_traits_2<Segment_traits> Base_geom_traits;
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2;
// Poly curves needs some testing where Segments and X-monotone segments are
// required instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#define GEOM_TRAITS_TYPE "Polylines"
#elif TEST_GEOM_TRAITS == NON_CACHING_POLYLINE_GEOM_TRAITS
typedef CGAL::Arr_non_caching_segment_traits_2<Kernel> Segment_traits;
typedef CGAL::Arr_polyline_traits_2<Segment_traits> Base_geom_traits;
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2;
// Poly curves needs some testing where Segments and X-monotone segments are
// required instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#define GEOM_TRAITS_TYPE "Non Caching Polylines"
#elif TEST_GEOM_TRAITS == CORE_CONIC_GEOM_TRAITS
@ -132,138 +132,147 @@ typedef CGAL::Arr_linear_traits_2<Kernel> Base_geom_traits;
#define GEOM_TRAITS_TYPE "Linear Lines"
#elif TEST_GEOM_TRAITS == LINE_ARC_GEOM_TRAITS
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type> Algebraic_kernel;
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type>
Algebraic_kernel;
typedef CGAL::Circular_kernel_2<Linear_kernel,Algebraic_kernel>
Circular_kernel;
typedef Circular_kernel::Line_arc_2 Line_arc_2;
typedef CGAL::Arr_line_arc_traits_2<Circular_kernel> Base_geom_traits;
Circular_kernel;
typedef Circular_kernel::Line_arc_2 Line_arc_2;
typedef CGAL::Arr_line_arc_traits_2<Circular_kernel> Base_geom_traits;
#define GEOM_TRAITS_TYPE "Line Arc"
#elif TEST_GEOM_TRAITS == CIRCULAR_ARC_GEOM_TRAITS
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type> Algebraic_kernel;
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type>
Algebraic_kernel;
typedef CGAL::Circular_kernel_2<Linear_kernel,Algebraic_kernel>
Circular_kernel;
typedef CGAL::Arr_circular_arc_traits_2<Circular_kernel> Base_geom_traits;
Circular_kernel;
typedef CGAL::Arr_circular_arc_traits_2<Circular_kernel>
Base_geom_traits;
#define GEOM_TRAITS_TYPE "Circular Arc"
#elif TEST_GEOM_TRAITS == CIRCULAR_LINE_ARC_GEOM_TRAITS
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type> Algebraic_kernel;
typedef Kernel Linear_kernel;
typedef CGAL::Algebraic_kernel_for_circles_2_2<Number_type>
Algebraic_kernel;
typedef CGAL::Circular_kernel_2<Linear_kernel,Algebraic_kernel>
Circular_kernel;
typedef Circular_kernel::Circular_arc_2 Circular_arc_2;
typedef Circular_kernel::Line_arc_2 Line_arc_2;
typedef CGAL::Arr_circular_line_arc_traits_2<Circular_kernel> Base_geom_traits;
Circular_kernel;
typedef Circular_kernel::Circular_arc_2 Circular_arc_2;
typedef Circular_kernel::Line_arc_2 Line_arc_2;
typedef CGAL::Arr_circular_line_arc_traits_2<Circular_kernel>
Base_geom_traits;
#define GEOM_TRAITS_TYPE "Circular Line Arc"
#elif TEST_GEOM_TRAITS == CIRCLE_SEGMENT_GEOM_TRAITS
typedef CGAL::Cartesian<Number_type> Rat_kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Base_geom_traits;
typedef Rat_kernel::FT Rat_nt;
typedef Rat_kernel::Circle_2 Circle_2;
typedef Rat_kernel::Line_2 Line_2;
typedef Rat_kernel::Segment_2 Segment_2;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef CGAL::Cartesian<Number_type> Rat_kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Base_geom_traits;
typedef Rat_kernel::FT Rat_nt;
typedef Rat_kernel::Circle_2 Circle_2;
typedef Rat_kernel::Line_2 Line_2;
typedef Rat_kernel::Segment_2 Segment_2;
typedef Rat_kernel::Point_2 Rat_point_2;
#define GEOM_TRAITS_TYPE "Circle Segments"
#elif TEST_GEOM_TRAITS == BEZIER_GEOM_TRAITS
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Base_geom_traits;
typedef Base_geom_traits::Bezier_cache Bezier_cache;
Base_geom_traits;
typedef Base_geom_traits::Bezier_cache Bezier_cache;
#define GEOM_TRAITS_TYPE "Bezier"
#elif TEST_GEOM_TRAITS == GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel> Base_geom_traits;
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel>
Base_geom_traits;
#define GEOM_TRAITS_TYPE "Geodesic Arc on Sphere"
#elif TEST_GEOM_TRAITS == RATIONAL_ARC_GEOM_TRAITS
// TODO: This is for old Ron's traits---remove.
//typedef CGAL::CORE_algebraic_number_traits Nt_traits; //OS - new
//typedef CGAL::CORE_algebraic_number_traits Nt_traits; //OS - new
//typedef Nt_traits::Rational Rational;
//typedef Nt_traits::Algebraic Algebraic;
//typedef CGAL::Arr_rational_arc_traits_2<Kernel,Nt_traits> Base_geom_traits;
//typedef Base_geom_traits::Rat_vector Rat_vector;
//typedef Base_geom_traits::Rat_vector Rat_vector;
//#define GEOM_TRAITS_TYPE "Rational Arc"
typedef CGAL::Arr_rational_function_traits_2<Kernel> Base_geom_traits;
typedef Base_geom_traits::Rational Rational;
typedef Base_geom_traits::Algebraic_real_1 Algebraic_real_1;
typedef Base_geom_traits::Rat_vector Rat_vector;
typedef CGAL::Arr_rational_function_traits_2<Kernel> Base_geom_traits;
typedef Base_geom_traits::Rational Rational;
typedef Base_geom_traits::Algebraic_real_1 Algebraic_real_1;
typedef Base_geom_traits::Rat_vector Rat_vector;
#define GEOM_TRAITS_TYPE "Rational Arc"
#elif TEST_GEOM_TRAITS == ALGEBRAIC_GEOM_TRAITS
typedef CGAL::Arr_algebraic_segment_traits_2<Number_type> Base_geom_traits;
typedef CGAL::Arr_algebraic_segment_traits_2<Number_type>
Base_geom_traits;
#define GEOM_TRAITS_TYPE "Algebraic"
#elif TEST_GEOM_TRAITS == POLYCURVE_CONIC_GEOM_TRAITS
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits> Conic_traits_2;
typedef CGAL::Arr_polycurve_traits_2<Conic_traits_2> Base_geom_traits;
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Conic_traits_2;
typedef CGAL::Arr_polycurve_traits_2<Conic_traits_2> Base_geom_traits;
//needed when we want to construct ellips, parabola and hyperbolas
typedef Conic_traits_2::Rat_point_2 Rat_point;
typedef Conic_traits_2::Rat_circle_2 Rat_circle;
typedef Conic_traits_2::Rat_segment_2 Rat_segment;
typedef Conic_traits_2::Rat_point_2 Rat_point;
typedef Conic_traits_2::Rat_circle_2 Rat_circle;
typedef Conic_traits_2::Rat_segment_2 Rat_segment;
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2;
// Poly curves needs some testing where Segments and X-monotone segments are
// required instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#define GEOM_TRAITS_TYPE "Polycurves_conics"
#elif TEST_GEOM_TRAITS == POLYCURVE_CIRCULAR_ARC_GEOM_TRAITS
typedef CGAL::Cartesian<Number_type> Rat_kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Circle_segment_traits_2;
typedef CGAL::Arr_polycurve_traits_2<Circle_segment_traits_2> Base_geom_traits;
typedef CGAL::Cartesian<Number_type> Rat_kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Circle_segment_traits_2;
typedef CGAL::Arr_polycurve_traits_2<Circle_segment_traits_2>
Base_geom_traits;
typedef Rat_kernel::FT Rat_nt;
typedef Rat_kernel::Circle_2 Circle_2;
typedef Rat_kernel::Line_2 Line_2;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef Circle_segment_traits_2::Point_2 Point_2;
typedef Rat_kernel::FT Rat_nt;
typedef Rat_kernel::Circle_2 Circle_2;
typedef Rat_kernel::Line_2 Line_2;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef Circle_segment_traits_2::Point_2 Point_2;
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2;
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#define GEOM_TRAITS_TYPE "Polycurves_circular_arcs"
#elif TEST_GEOM_TRAITS == POLYCURVE_BEZIER_GEOM_TRAITS
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits> Bezier_tratis;
typedef Bezier_tratis::Bezier_cache Bezier_cache;
typedef Rat_kernel::Point_2 Control_point_2;
typedef Bezier_tratis::Point_2 Point_2;
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Bezier_tratis;
typedef Bezier_tratis::Bezier_cache Bezier_cache;
typedef Rat_kernel::Point_2 Control_point_2;
typedef Bezier_tratis::Point_2 Point_2;
typedef CGAL::Arr_polycurve_traits_2<Bezier_tratis> Base_geom_traits;
// Poly curves needs some testing where Segments and X-monotone segments are required
// instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2;
typedef CGAL::Arr_polycurve_traits_2<Bezier_tratis> Base_geom_traits;
// Poly curves needs some testing where Segments and X-monotone segments are
// required instead of polycurves/x-monotone polycurves.
typedef Base_geom_traits::Segment_2 Segment_2;
typedef Base_geom_traits::X_monotone_subcurve_2 X_monotone_subcurve_2;
#define GEOM_TRAITS_TYPE "polycurve_bezier"
@ -272,8 +281,8 @@ typedef Base_geom_traits::X_monotone_segment_2 X_monotone_segment_2
#error No geometry traits (GEOM_TRAITS) specified!
#endif
typedef Base_geom_traits::Point_2 Base_point_2;
typedef Base_geom_traits::Curve_2 Base_curve_2;
typedef Base_geom_traits::X_monotone_curve_2 Base_x_monotone_curve_2;
typedef Base_geom_traits::Point_2 Base_point_2;
typedef Base_geom_traits::Curve_2 Base_curve_2;
typedef Base_geom_traits::X_monotone_curve_2 Base_x_monotone_curve_2;
#endif