First stage elliminating CGAL::Object

This commit is contained in:
Efi Fogel 2020-06-11 12:32:33 +03:00
parent 26eb367d71
commit 0626eb0a2e
32 changed files with 504 additions and 542 deletions

View File

@ -660,23 +660,33 @@ public:
return Equal_2(_traits);
}
/*! A functor that divides a curve into continues (x-monotone) curves. */
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2
{
private:
Traits& _traits;
public:
Make_x_monotone_2(Traits& traits) : _traits(traits) {}
template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) const
/*! Subdivide a given curve into x-monotone subcurves and insert them into
* a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return The past-the-end iterator.
*/
template <class OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{
Object_vector res (boost::apply_visitor(Make_x_monotone_2_visitor(_traits),cv.variant()));
re_cast_object_vector(res,oi);
return (oi);
}
private:
class Make_x_monotone_2_visitor
: public boost::static_visitor < Object_vector >
class Make_x_monotone_2_visitor :
public boost::static_visitor < Object_vector >
{
private:
typedef boost::static_visitor <Object_vector> Base;
@ -1787,4 +1797,3 @@ public:
#endif // CGAL_DONT_SUBMIT
#endif //CGAL_ARR_RATIONAL_ARC_TRAITS_D_1_H

View File

@ -80,7 +80,7 @@ public:
Arr_rational_arc_traits_2 ()
{}
/// \name Functor definitions.
/// \name Basic functor definitions.
//@{
/*! A functor that compares the x-coordinates of two points */
@ -381,19 +381,22 @@ public:
{
return Equal_2();
}
//@}
//! \name Intersections, subdivisions, and mergings
//@{
/*! A functor that divides a curve into continues (x-monotone) curves. */
class Make_x_monotone_2
{
public:
/*!
* Cut the given conic curve (or conic arc) into x-monotone subcurves
* and insert them to the given output iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The returned
* objects is a wrapper for an X_monotone_curve_2 object.
* \return The past-the-end iterator.
/*! Subdivide a given rational arc into x-monotone subcurves and insert them
* into a given output iterator.
* \param cv the arc.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi)

View File

@ -25,26 +25,26 @@ typedef CGAL::Curved_kernel_via_analysis_2< Algebraic_kernel_d_2 > CKvA_2;
Polynomial_2 makeParabola( )
{
Polynomial_2 x = CGAL::shift( Polynomial_2( 1 ), 1, 0 );
Polynomial_2 y = CGAL::shift( Polynomial_2( 1 ), 1, 1 );
Polynomial_2 parabola = y - x*x;
Polynomial_2 x = CGAL::shift( Polynomial_2( 1 ), 1, 0 );
Polynomial_2 y = CGAL::shift( Polynomial_2( 1 ), 1, 1 );
Polynomial_2 parabola = y - x*x;
return parabola;
return parabola;
}
X_monotone_curve_2 makeVerticalLine( Bound x )
{
Traits traits;
Traits::Construct_point_2 constructPoint =
traits.construct_point_2_object( );
Traits::Construct_x_monotone_segment_2 constructSegment =
traits.construct_x_monotone_segment_2_object( );
Traits traits;
Traits::Construct_point_2 constructPoint =
traits.construct_point_2_object( );
Traits::Construct_x_monotone_segment_2 constructSegment =
traits.construct_x_monotone_segment_2_object( );
std::vector< X_monotone_curve_2 > curves;
Point_2 p1 = constructPoint( Algebraic_real_1(x), Algebraic_real_1(Bound( -10000 )) );
Point_2 p2 = constructPoint( x, Bound( +10000 ) );
constructSegment( p1, p2, std::back_inserter( curves ) );
return curves[ 0 ];
std::vector< X_monotone_curve_2 > curves;
Point_2 p1 = constructPoint( Algebraic_real_1(x), Algebraic_real_1(Bound( -10000 )) );
Point_2 p2 = constructPoint( x, Bound( +10000 ) );
constructSegment( p1, p2, std::back_inserter( curves ) );
return curves[ 0 ];
}
typedef CGAL::Cartesian< Coefficient > Kernel;
@ -52,40 +52,38 @@ typedef Kernel::Point_2 Kernel_point_2;
int main( )
{
Algebraic_real_1 real( 1 );
//CGAL::Qt::Converter< Algebraic_kernel_d_2 > testConverter;
//CGAL::Qt::Converter< CKvA_2 > testConverter;
Algebraic_real_1 real( 1 );
//CGAL::Qt::Converter< Algebraic_kernel_d_2 > testConverter;
//CGAL::Qt::Converter< CKvA_2 > testConverter;
//CGAL::Qt::Converter< Cartesian > testConverter;
Kernel_point_2 testPt( 1, 2 );
Point_2 testPt2( testPt.x( ), testPt.y( ) );
Traits traits;
Construct_curve_2 constructCurve = traits.construct_curve_2_object( );
Curve_2 curve = constructCurve( makeParabola( ) );
Make_x_monotone_2 mm = traits.make_x_monotone_2_object( );
std::vector< CGAL::Object > curves;
mm( curve, std::back_inserter( curves ) );
std::cout << curves.size( ) << std::endl;
X_monotone_curve_2 c1;
CGAL::assign( c1, curves[ 0 ] );
double lb = -3;
double ub = 3;
double step = 6.0 / 1000;
//CGAL::Qt::Converter< Cartesian > testConverter;
Kernel_point_2 testPt( 1, 2 );
Point_2 testPt2( testPt.x( ), testPt.y( ) );
Traits traits;
Construct_curve_2 constructCurve = traits.construct_curve_2_object( );
Curve_2 curve = constructCurve( makeParabola( ) );
Make_x_monotone_2 mm = traits.make_x_monotone_2_object( );
std::vector< CGAL::Object > curves;
mm( curve, std::back_inserter( curves ) );
std::cout << curves.size( ) << std::endl;
X_monotone_curve_2 c1;
CGAL::assign( c1, curves[ 0 ] );
double lb = -3;
double ub = 3;
double step = 6.0 / 1000;
for ( int i = 0; i < 1000; ++i )
{
X_monotone_curve_2 c2 = makeVerticalLine( lb + step * i );
for ( int i = 0; i < 1000; ++i ) {
X_monotone_curve_2 c2 = makeVerticalLine( lb + step * i );
CGAL::Object o;
CGAL::Oneset_iterator< CGAL::Object > oi( o );
Intersect_2 intersect = traits.intersect_2_object( );
intersect( c1, c2, oi );
std::pair< Point_2, Multiplicity > res;
CGAL::assign( res, o );
std::pair< double, double > approx = res.first.to_double( );
std::cout << approx.first << " " << approx.second << std::endl;
}
CGAL::Object o;
CGAL::Oneset_iterator< CGAL::Object > oi( o );
Intersect_2 intersect = traits.intersect_2_object( );
intersect( c1, c2, oi );
std::pair< Point_2, Multiplicity > res;
CGAL::assign( res, o );
std::pair< double, double > approx = res.first.to_double( );
std::cout << approx.first << " " << approx.second << std::endl;
}
return 0;
return 0;
}

View File

@ -6,28 +6,29 @@
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Object.h>
typedef CGAL::Gmpq NT;
typedef CGAL::Cartesian< NT > Kernel;
typedef CGAL::Arr_linear_traits_2< Kernel > Traits;
typedef CGAL::Arr_default_dcel< Traits > Dcel;
typedef CGAL::Arrangement_with_history_2< Traits, Dcel > Arrangement;
typedef CGAL::Arr_walk_along_line_point_location< Arrangement > WalkAlongLinePointLocationStrategy;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Ray_2 Ray_2;
typedef Arrangement::Curve_2 Curve_2;
typedef CGAL::Gmpq NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_linear_traits_2<Kernel> Traits;
typedef CGAL::Arr_default_dcel<Traits> Dcel;
typedef CGAL::Arrangement_with_history_2< Traits, Dcel> Arrangement;
typedef CGAL::Arr_walk_along_line_point_location<Arrangement>
Walk_along_line_pl;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Ray_2 Ray_2;
typedef Arrangement::Curve_2 Curve_2;
int main( )
{
Point_2 p1( 0, 0 );
Point_2 p2( 1, 0 );
Ray_2 ray( p1, p2 );
Curve_2 curve( ray );
Point_2 p1(0, 0);
Point_2 p2(1, 0);
Ray_2 ray(p1, p2);
Curve_2 curve(ray);
Arrangement arr;
CGAL::insert( arr, curve );
CGAL::insert(arr, curve);
WalkAlongLinePointLocationStrategy pl( arr );
CGAL::Object o = pl.locate( Point_2( 1, -1 ) );
Walk_along_line_pl pl(arr);
auto o = pl.locate(Point_2(1, -1));
return 0;
}

View File

@ -239,19 +239,17 @@ namespace CGAL {
const Point_2& tgt) const;
};
/*! Subdivide the given subcurve into x-monotone subcurves and insert them
* into the given output iterator. Since the subcurves that
* constitute a general polycurve are not necessarily
* \f$x\f$-monotone, this functor may break them.
/*! Subdivide a given subcurve into x-monotone subcurves and insert them
* into a given output iterator.
*/
class Make_x_monotone_2 {
public:
/*!
* \pre if `cv` is not empty then it must be continuous and well-oriented.
* \param cv The subcurve.
* \param oi The output iterator, whose value-type is Object. The output
* object is a wrapper of a X_monotone_curve_2 objects.
* \return The past-the-end iterator.
* \param cv the subcurve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const;

View File

@ -7,9 +7,9 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Ron Wein <wein@post.tau.ac.il>
// Iddo Hanniel <iddoh@cs.technion.ac.il>
// Waqar Khan <wkhan@mpi-inf.mpg.de>
// Author(s): Ron Wein <wein@post.tau.ac.il>
// Iddo Hanniel <iddoh@cs.technion.ac.il>
// Waqar Khan <wkhan@mpi-inf.mpg.de>
#ifndef CGAL_ARR_BEZIER_CURVE_TRAITS_2_H
#define CGAL_ARR_BEZIER_CURVE_TRAITS_2_H
@ -163,7 +163,7 @@ public:
}
//@}
/// \name Functor definitions for the arrangement traits.
/// \name Basic functor definitions for the arrangement traits
//@{
/*! \class Compare_x_2
@ -473,31 +473,33 @@ public:
{
return (Equal_2 (p_cache));
}
//@}
//! \name Intersections, subdivisions, and mergings
//@{
/*! \class Make_x_monotone_2
* The Make_x_monotone_2 functor.
* A functor for subdividing curves into x-monotone curves.
*/
class Make_x_monotone_2
{
private:
Bezier_cache *p_cache;
Bezier_cache* p_cache;
public:
/*! Constructor. */
Make_x_monotone_2 (Bezier_cache *cache) :
p_cache (cache)
{}
/*!
* Cut the given Bezier curve into x-monotone subcurves and insert them
* into the given output iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The returned
* objects is a wrapper for an X_monotone_curve_2 object.
* \return The past-the-end iterator.
/*! Subdivide a given Bezier curve into x-monotone subcurves and insert them
* into a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<class OutputIterator>
template <class OutputIterator>
OutputIterator operator() (const Curve_2& B, OutputIterator oi) const
{
typedef typename Bounding_traits::Vertical_tangency_point
@ -756,7 +758,6 @@ public:
{
return Merge_2(this);
}
//@}
/// \name Functor definitions for the Boolean set-operation traits.

View File

@ -22,6 +22,7 @@
*/
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/Arr_point_location_result.h>
namespace CGAL {
@ -99,13 +100,16 @@ public:
* This object may wrap a Face_const_handle (the general case),
* or a Halfedge_const_handle (in case of an overlap).
*/
CGAL::Object locate_curve_end(const X_monotone_curve_2& cv,
Arr_curve_end ind,
Arr_parameter_space ps_x,
Arr_parameter_space ps_y) const
typedef Arr_point_location_result<Arrangement_2> Pl_result;
typename Pl_result::type locate_curve_end(const X_monotone_curve_2& cv,
Arr_curve_end ind,
Arr_parameter_space ps_x,
Arr_parameter_space ps_y) const
{
CGAL_precondition((ps_x != ARR_INTERIOR) || (ps_y != ARR_INTERIOR));
typedef Arr_point_location_result<Arrangement_2> Pl_result;
// Use the topology traits to locate the unbounded curve end.
CGAL::Object obj =
p_arr->topology_traits()->locate_curve_end(cv, ind, ps_x, ps_y);
@ -113,19 +117,19 @@ public:
// Return a handle to the DCEL feature.
DFace* f;
if (CGAL::assign(f, obj))
return (CGAL::make_object(p_arr->_const_handle_for(f)));
return (Pl_result::make_result(p_arr->_const_handle_for(f)));
DHalfedge* he;
if (CGAL::assign(he, obj))
return (CGAL::make_object(p_arr->_const_handle_for(he)));
return (Pl_result::make_result(p_arr->_const_handle_for(he)));
DVertex* v;
if (CGAL::assign(v, obj))
return (CGAL::make_object(p_arr->_const_handle_for(v)));
return (Pl_result::make_result(p_arr->_const_handle_for(v)));
// We should never reach here:
CGAL_error();
return Object();
return Pl_result::make_result(Vertex_const_handle());
}
/*!

View File

@ -264,138 +264,143 @@ public:
}
template<typename OutputIterator> OutputIterator
x_monotone_segment (Curve_2 cv,
Point_2 p,
boost::optional<Point_2> start,
boost::optional<Point_2> end,
OutputIterator out) const {
template <typename OutputIterator> OutputIterator
x_monotone_segment(Curve_2 cv,
Point_2 p,
boost::optional<Point_2> start,
boost::optional<Point_2> end,
OutputIterator out) const
{
typedef boost::variant<Point_2, X_monotone_curve_2>
Make_x_monotone_result;
//CGAL_assertion(is_one_one(cv,p));
//CGAL_assertion(is_one_one(cv,p));
std::list<X_monotone_curve_2> segs;
std::list<X_monotone_curve_2> segs;
Is_on_2 on_arc
= this->_ckva()->is_on_2_object();
Construct_min_vertex_2 left
= this->_ckva()->construct_min_vertex_2_object();
Construct_max_vertex_2 right
= this->_ckva()->construct_max_vertex_2_object();
Equal_2 equal = this->_ckva()->equal_2_object();
std::vector<CGAL::Object> arcs;
this->_ckva()->make_x_monotone_2_object()
(cv,std::back_inserter(arcs));
typename std::vector<CGAL::Object>::const_iterator
it = arcs.begin(),helper;
X_monotone_curve_2 it_seg;
CGAL::assign(it_seg,*it);
while(it!=arcs.end()) {
if( on_arc(p,it_seg) ) {
break;
}
CGAL_assertion(it!=arcs.end());
it++;
CGAL::assign(it_seg,*it);
}
bool left_on_arc = start && on_arc(start.get(),it_seg);
bool right_on_arc = end && on_arc(end.get(),it_seg);
if( left_on_arc && right_on_arc ) {
segs.push_back(it_seg.trim(start.get(),end.get()));
}
if(left_on_arc && (!right_on_arc)) {
if(!it_seg.is_finite(CGAL::ARR_MAX_END) ||
!equal(start.get(),right(it_seg))) {
if(it_seg.is_finite(CGAL::ARR_MIN_END) && equal(start.get(),left(it_seg))) {
segs.push_back(it_seg);
} else {
X_monotone_curve_2 split1,split2;
it_seg.split(start.get(),split1,split2);
segs.push_back(split2);
}
}
}
if((!left_on_arc) && right_on_arc) {
if(!it_seg.is_finite(CGAL::ARR_MIN_END) ||
! equal(left(it_seg),end.get())) {
if(it_seg.is_finite(CGAL::ARR_MAX_END) && equal(end.get(),right(it_seg))) {
segs.push_back(it_seg);
} else {
X_monotone_curve_2 split1,split2;
it_seg.split(end.get(),split1,split2);
segs.push_back(split1);
}
}
}
if( (!left_on_arc) && (!right_on_arc)) {
segs.push_back(it_seg);
}
helper=it; // for later usage
if(! left_on_arc) {
Point_2 point_it;
while(true) {
if(it_seg.is_finite(CGAL::ARR_MIN_END) &&
is_one_one(cv,left(it_seg) ) ) {
point_it=left(it_seg);
} else {
CGAL_assertion(! start);
break;
}
CGAL_assertion(it!=arcs.begin());
it--;
CGAL::assign(it_seg,*it);
while(! on_arc(point_it,it_seg)) {
CGAL_assertion(it!=arcs.begin());
it--;
CGAL::assign(it_seg,*it);
}
if(start && on_arc(start.get(),it_seg)) {
segs.push_front(it_seg.trim(start.get(),
right(it_seg)));
break;
} else {
segs.push_front(it_seg);
}
}
}
if(! right_on_arc) {
it=helper; // reset
CGAL::assign(it_seg,*it);
Point_2 point_it;
while(true) {
if(it_seg.is_finite(CGAL::ARR_MAX_END) &&
is_one_one(cv,right(it_seg) ) ) {
point_it=right(it_seg);
} else {
CGAL_assertion(! end);
break;
}
it++;
CGAL_assertion(it!=arcs.end());
CGAL::assign(it_seg,*it);
while(! on_arc(point_it,it_seg)) {
it++;
CGAL_assertion(it!=arcs.end());
CGAL::assign(it_seg,*it);
}
if(end && on_arc(end.get(),it_seg)) {
segs.push_back(it_seg.trim(left(it_seg),end.get()));
break;
} else {
segs.push_back(it_seg);
}
}
}
std::copy(segs.begin(),segs.end(),out);
return out;
Is_on_2 on_arc = this->_ckva()->is_on_2_object();
auto left = this->_ckva()->construct_min_vertex_2_object();
auto right = this->_ckva()->construct_max_vertex_2_object();
Equal_2 equal = this->_ckva()->equal_2_object();
std::vector<CGAL::Object> arcs;
this->_ckva()->make_x_monotone_2_object()(cv, std::back_inserter(arcs));
typename std::vector<CGAL::Object>::const_iterator it = arcs.begin();
typename std::vector<CGAL::Object>::const_iterator helper;
X_monotone_curve_2 it_seg;
CGAL::assign(it_seg, *it);
while (it != arcs.end()) {
if ( on_arc(p,it_seg) ) break;
CGAL_assertion(it != arcs.end());
it++;
CGAL::assign(it_seg, *it);
}
bool left_on_arc = start && on_arc(start.get(), it_seg);
bool right_on_arc = end && on_arc(end.get(), it_seg);
if ( left_on_arc && right_on_arc ) {
segs.push_back(it_seg.trim(start.get(),end.get()));
}
if (left_on_arc && (!right_on_arc)) {
if (!it_seg.is_finite(CGAL::ARR_MAX_END) ||
!equal(start.get(),right(it_seg))) {
if (it_seg.is_finite(CGAL::ARR_MIN_END) &&
equal(start.get(),left(it_seg)))
{
segs.push_back(it_seg);
}
else {
X_monotone_curve_2 split1,split2;
it_seg.split(start.get(),split1,split2);
segs.push_back(split2);
}
}
}
if ((!left_on_arc) && right_on_arc) {
if (!it_seg.is_finite(CGAL::ARR_MIN_END) ||
! equal(left(it_seg), end.get()))
{
if (it_seg.is_finite(CGAL::ARR_MAX_END) &&
equal(end.get(), right(it_seg)))
{
segs.push_back(it_seg);
}
else {
X_monotone_curve_2 split1,split2;
it_seg.split(end.get(), split1, split2);
segs.push_back(split1);
}
}
}
if ( (!left_on_arc) && (!right_on_arc)) {
segs.push_back(it_seg);
}
helper = it; // for later usage
if (! left_on_arc) {
Point_2 point_it;
while (true) {
if (it_seg.is_finite(CGAL::ARR_MIN_END) &&
is_one_one(cv, left(it_seg) ) ) {
point_it = left(it_seg);
} else {
CGAL_assertion(! start);
break;
}
CGAL_assertion(it != arcs.begin());
it--;
CGAL::assign(it_seg, *it);
while (! on_arc(point_it, it_seg)) {
CGAL_assertion(it != arcs.begin());
it--;
CGAL::assign(it_seg,*it);
}
if (start && on_arc(start.get(),it_seg)) {
segs.push_front(it_seg.trim(start.get(), right(it_seg)));
break;
}
else {
segs.push_front(it_seg);
}
}
}
if (! right_on_arc) {
it = helper; // reset
CGAL::assign(it_seg,*it);
Point_2 point_it;
while (true) {
if (it_seg.is_finite(CGAL::ARR_MAX_END) &&
is_one_one(cv,right(it_seg) ) )
{
point_it=right(it_seg);
} else {
CGAL_assertion(! end);
break;
}
it++;
CGAL_assertion(it != arcs.end());
CGAL::assign(it_seg, *it);
while(! on_arc(point_it, it_seg)) {
it++;
CGAL_assertion(it != arcs.end());
CGAL::assign(it_seg, *it);
}
if(end && on_arc(end.get(),it_seg)) {
segs.push_back(it_seg.trim(left(it_seg),end.get()));
break;
}
else {
segs.push_back(it_seg);
}
}
}
std::copy(segs.begin(), segs.end(), out);
return out;
}
public:
template<typename OutputIterator> OutputIterator

View File

@ -41,11 +41,9 @@ namespace Ss2 = Surface_sweep_2;
* \param oi Output: An output iterator for the query results.
* \pre The value-type of PointsIterator is Arrangement::Point_2,
* and the value-type of OutputIterator is is pair<Point_2, Result>,
* where Result is either
* (i) Object or
* (ii) boost::optional<boost::variant<Vertex_const_handle,
* Halfedge_const_handle,
* Face_const_handle> >.
* where Result is boost::optional<boost::variant<Vertex_const_handle,
* Halfedge_const_handle,
* Face_const_handle> >.
* It represents the arrangement feature containing the point.
*/
template <typename GeometryTraits_2, typename TopologyTraits,

View File

@ -308,15 +308,15 @@ public:
* \pre The curve has a boundary condition in either x or y.
* \return An object that contains the curve end.
*/
CGAL::Object place_boundary_vertex(Face*,
const X_monotone_curve_2&,
Arr_curve_end,
Arr_parameter_space /* ps_x */,
Arr_parameter_space /* ps_y */)
CGAL::Object place_boundary_vertex(Face*,
const X_monotone_curve_2&,
Arr_curve_end,
Arr_parameter_space /* ps_x */,
Arr_parameter_space /* ps_y */)
{
// This function should never be called:
CGAL_error();
return Object();
return CGAL::Object();
}
/*! Locate the predecessor halfedge for the given curve around a given

View File

@ -378,9 +378,10 @@ public:
}
//@}
/// \name Functor definitions for supporting intersections.
/// \name Intersections, subdivisions, and mergings
//@{
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2
{
private:
@ -389,35 +390,29 @@ public:
bool m_use_cache;
public:
Make_x_monotone_2(bool use_cache = false) : m_use_cache(use_cache) {}
Make_x_monotone_2(bool use_cache = false) : m_use_cache(use_cache)
{}
/*!
* Cut the given conic curve (ocv.is_in_x_range (p)r conic arc) into x-monotone subcurves
* and insert them to the given output iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The returned
* objects are all wrcv.is_in_x_range (p)appers X_monotone_curve_2 objects.
* \return The past-the-end iterator.
/*! Subdivide a given circular arc or line segment into x-monotone subcurves
* and insert them to a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) const
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{
// Increment the serial number of the curve cv, which will serve as its
// unique identifier.
unsigned int index = 0;
if(m_use_cache)
index = Self::get_index();
unsigned int index = 0;
if (m_use_cache) index = Self::get_index();
if (cv.orientation() == COLLINEAR)
{
if (cv.orientation() == COLLINEAR) {
// The curve is a line segment.
*oi = make_object (X_monotone_curve_2 (cv.supporting_line(),
*oi++ = make_object(X_monotone_curve_2(cv.supporting_line(),
cv.source(), cv.target(),
index));
++oi;
return (oi);
return oi;
}
// Check the case of a degenrate circle (a point).
@ -425,12 +420,10 @@ public:
CGAL::Sign sign_rad = CGAL::sign (circ.squared_radius());
CGAL_precondition (sign_rad != NEGATIVE);
if (sign_rad == ZERO)
{
if (sign_rad == ZERO) {
// Create an isolated point.
*oi = make_object (Point_2 (circ.center().x(), circ.center().y()));
++oi;
return (oi);
*oi++ = make_object(Point_2 (circ.center().x(), circ.center().y()));
return oi;
}
// The curve is circular: compute the to vertical tangency points
@ -438,76 +431,63 @@ public:
Point_2 vpts[2];
unsigned int n_vpts = cv.vertical_tangency_points (vpts);
if (cv.is_full())
{
if (cv.is_full()) {
CGAL_assertion (n_vpts == 2);
// Subdivide the circle into two arcs (an upper and a lower half).
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
vpts[0], vpts[1],
cv.orientation(),
index));
++oi;
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
vpts[1], vpts[0],
cv.orientation(),
index));
++oi;
}
else
{
else {
// Act according to the number of vertical tangency points.
if (n_vpts == 2)
{
if (n_vpts == 2) {
// Subdivide the circular arc into three x-monotone arcs.
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
cv.source(), vpts[0],
cv.orientation(),
index));
++oi;
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
vpts[0], vpts[1],
cv.orientation(),
index));
++oi;
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
vpts[1], cv.target(),
cv.orientation(),
index));
++oi;
}
else if (n_vpts == 1)
{
else if (n_vpts == 1) {
// Subdivide the circular arc into two x-monotone arcs.
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
cv.source(), vpts[0],
cv.orientation(),
index));
++oi;
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
vpts[0], cv.target(),
cv.orientation(),
index));
++oi;
}
else
{
CGAL_assertion (n_vpts == 0);
else {
CGAL_assertion(n_vpts == 0);
// The arc is already x-monotone:
*oi = make_object (X_monotone_curve_2 (circ,
*oi++ = make_object(X_monotone_curve_2(circ,
cv.source(), cv.target(),
cv.orientation(),
index));
++oi;
}
}
return (oi);
return oi;
}
};

View File

@ -259,6 +259,7 @@ namespace CGAL {
};
//! A functor for subdividing curves into x-monotone curves.
template <class CircularKernel, class Arc1, class Arc2>
class Make_x_monotone_2
{

View File

@ -448,24 +448,24 @@ public:
}
//@}
/// \name Functor definitions for supporting intersections.
/// \name Intersections, subdivisions, and mergings
//@{
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2
{
typedef Arr_conic_traits_2 <Rat_kernel_, Alg_kernel_, Nt_traits_> Self;
public:
/*!
* Cut the given conic curve (or conic arc) into x-monotone subcurves
* and insert them to the given output iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The returned
* objects are all wrappers X_monotone_curve_2 objects.
* \return The past-the-end iterator.
public:
/*! Subdivide a given conic curve (or conic arc) into x-monotone subcurves
* and insert them to a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<class OutputIterator>
OutputIterator operator() (const Curve_2& cv, OutputIterator oi) const
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{
// Increment the serial number of the curve cv, which will serve as its
// unique identifier.

View File

@ -101,6 +101,10 @@ public:
/// \name Overriden functors.
//@{
//! \name Intersections & subdivisions
//@{
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 {
private:
const Base_traits_2& m_base;
@ -109,12 +113,13 @@ public:
/*! Constructor. */
Make_x_monotone_2(const Base_traits_2& base) : m_base(base) {}
/*! Cut the given curve into x-monotone subcurves and insert them to the
* given output iterator. As segments are always x_monotone, only one
/*! Subdivide a given curve into x-monotone subcurves and insert them into
* a given output iterator. As segments are always x_monotone, only one
* x-monotone curve will be contained in the iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is X_monotone_curve_2.
* \return The past-the-end iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
@ -359,6 +364,8 @@ public:
/*! Obtain a Merge_2 functor object. */
Merge_2 merge_2_object() const { return Merge_2(*this); }
//@}
class Construct_x_monotone_curve_2 {
private:
const Base_traits_2& m_base;

View File

@ -1358,8 +1358,8 @@ public:
/// \name Functor definitions for supporting intersections.
//@{
/*! A functor that divides an arc into x-monotone arcs. That are, arcs that
* do not cross the identification arc.
/*! Subdivide an arc into x-monotone arcs, that are, arcs that do not cross
* the identification arc.
*/
class Make_x_monotone_2 {
protected:
@ -1376,13 +1376,12 @@ public:
friend class Arr_geodesic_arc_on_sphere_traits_2<Kernel>;
public:
/*! Cut the given curve into x-monotone subcurves and insert them into the
* given output iterator. As spherical_arcs are always x_monotone, only one
* object will be contained in the iterator.
/*! Subdivide a given curve into x-monotone subcurves and insert them into
* a given output iterator. As spherical_arcs are always x_monotone, only
* one object will be contained in the iterator.
* \param xc the curve.
* \param oi the output iterator, whose value-type is Object. The output
* object is a wrapper of either an X_monotone_curve_2, or - in
* case the input spherical_arc is degenerate - a Point_2 object.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<typename OutputIterator>

View File

@ -1262,36 +1262,26 @@ private:
// the intersection of the two skewed bounding boxes.
Bez_point_bbox ipt_bbox;
Control_points aux_vec;
CGAL::Object res;
Point_2 p;
res = f_intersect (skew1a, skew2a);
if (! assign (p, res))
{
CGAL_error();
}
aux_vec.push_back(p);
auto res1 = f_intersect(skew1a, skew2a);
const Point_2* p1 = boost::get<Point_2>(&*res1);
if (! p1) CGAL_error();
aux_vec.push_back(*p1);
res = f_intersect (skew1a, skew2b);
if (! assign(p, res))
{
CGAL_error();
}
aux_vec.push_back(p);
auto res2 = f_intersect(skew1a, skew2b);
const Point_2* p2 = boost::get<Point_2>(&*res2);
if (! p2) CGAL_error();
aux_vec.push_back(*p2);
res = f_intersect (skew1b, skew2a);
if (! assign(p, res))
{
CGAL_error();
}
aux_vec.push_back(p);
auto res3 = f_intersect(skew1b, skew2a);
const Point_2* p3 = boost::get<Point_2>(&*res3);
if (! p3) CGAL_error();
aux_vec.push_back(*p3);
res = f_intersect (skew1b, skew2b);
if (!assign(p, res))
{
CGAL_error();
}
aux_vec.push_back(p);
auto res4 = f_intersect (skew1b, skew2b);
const Point_2* p4 = boost::get<Point_2>(&*res4);
if (! p4) CGAL_error();
aux_vec.push_back(*p4);
construct_bbox (aux_vec, ipt_bbox);

View File

@ -1239,9 +1239,10 @@ public:
* given output iterator. As segments are always x_monotone, only one
* object will be contained in the iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The output
* object is a wrapper of an X_monotone_curve_2 which is
* essentially the same as the input curve.
* \param oi The output iterator, whose value-type is a variant of either
* Point_2 or X_monotone_curve_2. The output object is a wrapper
* of an X_monotone_curve_2 which is essentially the same as the
* input curve.
* \return The past-the-end iterator.
*/
template <typename OutputIterator>

View File

@ -122,10 +122,10 @@ public:
/*! Cut the given segment into x-monotone subcurves and insert them into
* the given output iterator. As segments are always x_monotone, only one
* x-monotone curve is inserted into the output iterator.
* \param cv The segment.
* \param oi The output iterator, whose value-type is Object. The output
* object is a wrapper of an X_monotone_curve_2 object.
* \return The past-the-end iterator.
* \param cv the segment.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const

View File

@ -56,15 +56,15 @@ Arr_landmarks_point_location<Arr, Gen>::locate(const Point_2& p) const
const Vertex_const_handle* vh;
const Halfedge_const_handle* hh;
const Face_const_handle* fh;
if ( ( vh = Result().template assign<Vertex_const_handle>(lm_location_obj) ) )
if ( ( vh = Result().template assign<Vertex_const_handle>(&lm_location_obj) ) )
out_obj = _walk_from_vertex(*vh, p, crossed_edges);
else if ( ( hh = Result().template assign<Halfedge_const_handle>(lm_location_obj) ) )
else if ( ( hh = Result().template assign<Halfedge_const_handle>(&lm_location_obj) ) )
out_obj = _walk_from_edge(*hh, landmark_point, p, crossed_edges);
else if ( ( fh = Result().template assign<Face_const_handle>(lm_location_obj) ) )
else if ( ( fh = Result().template assign<Face_const_handle>(&lm_location_obj) ) )
out_obj = _walk_from_face(*fh, landmark_point, p, crossed_edges);
else CGAL_error_msg("lm_location_obj of an unknown type.");
if ( ( fh = Result().template assign<Face_const_handle>(out_obj) ) ) {
if ( ( fh = Result().template assign<Face_const_handle>(&out_obj) ) ) {
// If we reached here, we did not locate the query point in any of the
// holes inside the current face, so we conclude it is contained in this
// face.
@ -159,7 +159,7 @@ _walk_from_vertex(Vertex_const_handle nearest_vertex,
if (new_vertex) {
// We found a vertex closer to p; Continue using this vertex.
const Vertex_const_handle* p_vh =
Result().template assign<Vertex_const_handle>(obj);
Result().template assign<Vertex_const_handle>(&obj);
CGAL_assertion(p_vh != nullptr);
vh = *p_vh;
continue;
@ -167,11 +167,12 @@ _walk_from_vertex(Vertex_const_handle nearest_vertex,
// If p is located on an edge or on a vertex, return the object
// that wraps this arrangement feature.
if (Result().template assign<Halfedge_const_handle>(obj) ||
Result().template assign<Vertex_const_handle>(obj))
if (Result().template assign<Halfedge_const_handle>(&obj) ||
Result().template assign<Vertex_const_handle>(&obj))
return obj;
const Face_const_handle* p_fh = Result().template assign<Face_const_handle>(obj);
const Face_const_handle* p_fh =
Result().template assign<Face_const_handle>(&obj);
if (p_fh)
// Walk to p from the face we have located:
return _walk_from_face(*p_fh, vh->point(), p, crossed_edges);

View File

@ -44,10 +44,8 @@ Arr_simple_point_location<Arrangement>::locate(const Point_2& p) const
// Go over arrangement halfedges and check whether one of them contains
// the query point in its interior.
typename Traits_adaptor_2::Is_in_x_range_2 is_in_x_range =
m_geom_traits->is_in_x_range_2_object();
typename Traits_adaptor_2::Compare_y_at_x_2 cmp_y_at_x =
m_geom_traits->compare_y_at_x_2_object();
auto is_in_x_range = m_geom_traits->is_in_x_range_2_object();
auto cmp_y_at_x = m_geom_traits->compare_y_at_x_2_object();
typename Arrangement::Edge_const_iterator eit;
for (eit = m_arr->edges_begin(); eit != m_arr->edges_end(); ++eit) {
@ -71,14 +69,14 @@ Arr_simple_point_location<Arrangement>::locate(const Point_2& p) const
// In case the ray-shooting returned a vertex, we have to locate the first
// halfedge whose source vertex is v, rotating clockwise around the vertex
// from "6 o'clock", and to return its incident face.
const Vertex_const_handle* vh = Result().template assign<Vertex_const_handle>(obj);
const auto* vh = Result::template assign<Vertex_const_handle>(&obj);
if (vh) {
Halfedge_const_handle hh = _first_around_vertex(*vh);
Face_const_handle fh = hh->face();
return make_result(fh);
}
const Halfedge_const_handle* hh = Result().template assign<Halfedge_const_handle>(obj);
const auto* hh = Result::template assign<Halfedge_const_handle>(&obj);
if (hh) {
// Make sure that the edge is directed from right to left, so that p
// (which lies below it) is contained in its incident face. If necessary,
@ -288,14 +286,13 @@ Arr_simple_point_location<Arrangement>::_vertical_ray_shoot(const Point_2& p,
if (! optional_empty(optional_obj)) {
const Result_type& obj = optional_assign(optional_obj);
const Vertex_const_handle* p_vh = Result().template assign<Vertex_const_handle>(obj);
const auto* p_vh = Result::template assign<Vertex_const_handle>(&obj);
if (p_vh) {
found_vertex = true;
closest_v = *p_vh;
}
else {
const Halfedge_const_handle* p_hh =
Result().template assign<Halfedge_const_handle>(obj);
const auto* p_hh = Result::template assign<Halfedge_const_handle>(&obj);
CGAL_assertion(p_hh != nullptr);
found_halfedge = true;
closest_he = *p_hh;

View File

@ -78,32 +78,34 @@ struct Arr_point_location_result {
// lead to conversion overhead, and so we rather go for the real type.
// Overloads for empty returns are also provided.
#if CGAL_ARR_POINT_LOCATION_VERSION < 2
template<typename T>
template <typename T>
static
inline CGAL::Object make_result(T t) { return CGAL::make_object(t); }
inline Type make_result(T t) { return CGAL::make_object(t); }
static
inline CGAL::Object empty_optional_result() { return CGAL::Object(); }
template<typename T>
const T* assign(CGAL::Object obj) const { return CGAL::object_cast<T>(&obj); }
template <typename T>
static
inline const T* assign(const Type* obj) { return CGAL::object_cast<T>(obj); }
#else
template<typename T>
template <typename T>
static
inline Type make_result(T t) { return Type(t); }
inline
static
boost::optional<Type> empty_optional_result() { return boost::optional<Type>(); }
inline boost::optional<Type> empty_optional_result()
{ return boost::optional<Type>(); }
template<typename T>
const T* assign(const Type& obj) const { return boost::get<T>(&obj); }
template <typename T>
static
inline const T* assign(const Type* obj) { return boost::get<T>(obj); }
#endif // CGAL_ARR_POINT_LOCATION_VERSION < 2
//this one is only to remove warnings in functions
static
inline Type default_result(){
CGAL_error_msg("This functions should never have been called!");
CGAL_error_msg("This functions should have never been called!");
return Type();
}
};

View File

@ -7,10 +7,10 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Efi Fogel <efif@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Dror Atariah <dror.atariah@fu-berlin.de>
// Waqar Khan <wkhan@mpi-inf.mpg.de>
// Author(s): Efi Fogel <efif@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il>
// Dror Atariah <dror.atariah@fu-berlin.de>
// Waqar Khan <wkhan@mpi-inf.mpg.de>
#ifndef CGAL_ARR_POLYCURVE_TRAITS_2_H
#define CGAL_ARR_POLYCURVE_TRAITS_2_H
@ -160,10 +160,8 @@ public:
#ifndef DOXYGEN_RUNNING
class Push_back_2;
#endif
/*! \class
* A functor that divides an arc into x-monotone arcs. That are, arcs that
* do not cross the identification arc.
*/
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 {
protected:
typedef Arr_polycurve_traits_2<Subcurve_traits_2> Polycurve_traits_2;
@ -176,14 +174,14 @@ public:
m_poly_traits(traits)
{}
/*! Cut the given curve into x-monotone sub-curves and insert them into the
* given output iterator.
/*! Subdivide a given curve into x-monotone sub-curves and insert them into
* a given output iterator.
*
* \pre if `cv` is not empty then it must be continuous and well-oriented.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The output
* object is a wrapper of a X_monotone_curve_2.
* \return The past-the-end iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
private:
template <typename OutputIterator>
@ -476,7 +474,8 @@ public:
x_seg_objects.clear();
return oi;
}
public:
public:
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{ return operator_impl(cv, oi, Are_all_sides_oblivious_tag()); }

View File

@ -808,37 +808,34 @@ public:
return Equal_2(this);
}
//! \name Intersections & subdivisions
//@{
/*! A functor that divides a curve into continues (x-monotone) curves. */
class Make_x_monotone_2
{
public:
/*!
* Cut the given conic curve (or conic arc) into x-monotone subcurves
* and insert them to the given output iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is Object. The returned
* objects is a wrapper for an X_monotone_curve_2 object.
* \return The past-the-end iterator.
/*! Subdivide a given rational-function curve into x-monotone subcurves
* and insert them to a given output iterator.
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or X_monotone_curve_2 objects.
* \return the past-the-end iterator.
*/
template<typename OutputIterator>
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{
// Make the rational arc continuous.
std::list<X_monotone_curve_2> arcs;
std::list<X_monotone_curve_2> arcs;
cv.make_continuous(std::back_inserter(arcs));
// Create objects.
typename std::list<X_monotone_curve_2>::const_iterator iter;
for (auto it = arcs.begin(); it != arcs.end(); ++it)
*oi++ = make_object(*it);
for (iter = arcs.begin(); iter != arcs.end(); ++iter)
{
*oi = make_object (*iter);
++oi;
}
return (oi);
return oi;
}
};
@ -975,6 +972,8 @@ public:
return Merge_2(this);
}
//@}
/// \name Functor definitions to handle boundaries
//@{

View File

@ -609,16 +609,18 @@ public:
Equal_2 equal_2_object() const { return Equal_2(*this); }
//@}
/// \name Functor definitions for supporting intersections.
//! \name Intersections, subdivisions, and mergings
//@{
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 {
public:
/*! Cut the given curve into x-monotone subcurves and insert them into the
* given output iterator. As segments are always x_monotone, only one
/*! Subdivide a given curve into x-monotone subcurves and insert them into
* a given output iterator. As segments are always x_monotone, only one
* object will be contained in the iterator.
* \param cv The curve.
* \param oi The output iterator, whose value-type is variant<....
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or an X_monotone_curve_2 objects.
* \return The past-the-end iterator.
*/
template <typename OutputIterator>

View File

@ -504,7 +504,10 @@ public:
}
};
/*! A functor that divides a curve into x-monotone curves. */
//! \name Intersections & subdivisions
//@{
//! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 {
private:
typename Base::Make_x_monotone_2 m_object;
@ -516,12 +519,12 @@ public:
m_object(base->make_x_monotone_2_object()), m_enabled(enabled) {}
/*! Operate
* \param cv the curve
* \param oi an output iterator that contains the result. It's value
* type is CGAL::Object, which wraps either an x-monotone curve or a point
* \return the output iterator
* \param cv the curve.
* \param oi an output iterator for the result. Its value type is a variant
* that wraps Point_2 or X_monotone_curve_2 objects.
* \return the output iterator.
*/
template<typename OutputIterator>
template <typename OutputIterator>
OutputIterator operator()(const Curve_2 & cv, OutputIterator oi) const
{
if (!m_enabled) return m_object(cv, oi);

View File

@ -8,27 +8,29 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Ophir Setter <ophirset@post.tau.ac.il>
// Author(s) : Ophir Setter <ophirset@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com>
//
#ifndef CGAL_ARR_COMPUTE_ZONE_VISITOR_H
#define CGAL_ARR_COMPUTE_ZONE_VISITOR_H
#include <CGAL/license/Arrangement_on_surface_2.h>
/*! \file
* Definition of the Arr_compute_zone_visitor class.
*/
#include <boost/variant.hpp>
namespace CGAL {
/*! \class
* A visitor class for Arrangement_zone_2, which outputs the
* zone of an x-monotone curve. Meaning, it output the arrangment's
* vertices, edges and faces that the x-monotone curve intersects.
* A visitor class for Arrangement_zone_2 that outputs the zone of an
* x-monotone curve. Specifically, it outputs handles to the the arrangment
* cells that the x-monotone curve intersects.
* The class should be templated by an Arrangement_2 class, and by an
* output iterator of CGAL Objects, where we store all arrangement
* features the x-monotone curve intersects.
* output iterator of a variant of types of handles to the arrangement cells
* that appear in the zone, namely, vertex, halfedge, and face handles.
*/
template <class Arrangement_, class OutputIterator_>
class Arr_compute_zone_visitor
@ -53,7 +55,7 @@ private:
const Vertex_handle invalid_v; // Invalid vertex.
OutputIterator& out_iter; // for outputing the zone objects.
// Its value type is CGAL::Object.
// Its value type is boost::variant.
bool output_left; // Determines wheter we should
// output the left end point of a
// subcurve (to avoid outputing
@ -65,8 +67,8 @@ public:
Arr_compute_zone_visitor (OutputIterator& oi) :
invalid_he(),
invalid_v(),
out_iter (oi),
output_left (true)
out_iter(oi),
output_left(true)
{}
/*! Initialize the visitor. */
@ -90,50 +92,35 @@ public:
* \return A handle to the halfedge obtained from the insertion of the
* subcurve into the arrangement.
*/
Result found_subcurve (const X_monotone_curve_2&,
Face_handle face,
Vertex_handle left_v, Halfedge_handle left_he,
Vertex_handle right_v, Halfedge_handle right_he)
Result found_subcurve(const X_monotone_curve_2&,
Face_handle face,
Vertex_handle left_v, Halfedge_handle left_he,
Vertex_handle right_v, Halfedge_handle right_he)
{
if (output_left)
{
typedef boost::variant<Vertex_handle, Halfedge_handle, Face_handle>
Zone_result;
if (output_left) {
// Only the first subcurve should output the arrangement feature incident
// to its left endpoint. This way we avoid reporting the same feature
// twice.
if (left_v != invalid_v)
{
*out_iter = CGAL::make_object (left_v);
++out_iter;
}
else if (left_he != invalid_he)
{
*out_iter = CGAL::make_object (left_he);
++out_iter;
}
if (left_v != invalid_v) *out_iter++ = Zone_result(left_v);
else if (left_he != invalid_he) *out_iter++ = Zone_result(left_he);
output_left = false;
}
// Report the face that contains the interior of the subcurve.
*out_iter = CGAL::make_object (face);
++out_iter;
*out_iter++ = Zone_result(face);
// If the right endpoint of the subcurve is incident to an arrangement
// vertex or an arrangement edge, report this feature.
if (right_v != invalid_v)
{
*out_iter = CGAL::make_object(right_v);
++out_iter;
}
else if (right_he != invalid_he)
{
*out_iter = CGAL::make_object(right_he);
++out_iter;
}
if (right_v != invalid_v) *out_iter++ = Zone_result(right_v);
else if (right_he != invalid_he) *out_iter++ = Zone_result(right_he);
// We did not modify the arrangement, so we return an invalid handle
// and a flag indicating that the zone-computation process should continue.
return (Result (invalid_he, false));
return Result(invalid_he, false);
}
/*!
@ -151,35 +138,28 @@ public:
Halfedge_handle he,
Vertex_handle left_v, Vertex_handle right_v)
{
if (output_left)
{
typedef boost::variant<Vertex_handle, Halfedge_handle, Face_handle>
Zone_result;
if (output_left) {
// Only the first subcurve should output the arrangement feature incident
// to its left endpoint. This way we avoid reporting the same feature
// twice.
if (left_v != invalid_v)
{
*out_iter = CGAL::make_object (left_v);
++out_iter;
}
if (left_v != invalid_v) *out_iter++ = Zone_result(left_v);
output_left = false;
}
// Report the arrangement edge the curve currently overlaps.
*out_iter = CGAL::make_object(he);
++out_iter;
*out_iter++ = Zone_result(he);
// If the right endpoint of the overlapping subcurve is incident to an
// arrangement vertex, report this vertex as well.
if (right_v != invalid_v)
{
*out_iter = CGAL::make_object (right_v);
++out_iter;
}
if (right_v != invalid_v) *out_iter++ = Zone_result(right_v);
// We did not modify the arrangement, so we return an invalid handle
// and a flag indicating that the zone-computation process should continue.
return (Result (invalid_he, false));
return Result(invalid_he, false);
}
};

View File

@ -32,6 +32,7 @@
#include <CGAL/Arrangement_2/Arr_compute_zone_visitor.h>
#include <CGAL/Arrangement_2/Arr_do_intersect_zone_visitor.h>
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
#include <CGAL/Arr_point_location_result.h>
#include <CGAL/No_intersection_surface_sweep_2.h>
#include <CGAL/Surface_sweep_2/Arr_insertion_ss_visitor.h>
#include <CGAL/Surface_sweep_2/Arr_no_intersection_insertion_ss_visitor.h>
@ -89,7 +90,6 @@ void insert(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
// Break the input curve into x-monotone subcurves and isolated points.
std::list<CGAL::Object> x_objects;
std::list<CGAL::Object>::const_iterator obj_iter;
const typename Gt2::X_monotone_curve_2* x_curve;
const typename Gt2::Point_2* iso_p;
@ -97,9 +97,9 @@ void insert(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
make_x_monotone_2_object()(c, std::back_inserter(x_objects));
// Insert each x-monotone curve into the arrangement.
for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) {
for (auto it = x_objects.begin(); it != x_objects.end(); ++it) {
// Act according to the type of the current object.
x_curve = object_cast<typename Gt2::X_monotone_curve_2>(&(*obj_iter));
x_curve = object_cast<typename Gt2::X_monotone_curve_2>(&(*it));
if (x_curve != nullptr) {
// Inserting an x-monotone curve:
@ -118,7 +118,7 @@ void insert(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
arr_access.notify_after_global_change();
}
else {
iso_p = object_cast<typename Gt2::Point_2>(&(*obj_iter));
iso_p = object_cast<typename Gt2::Point_2>(&(*it));
CGAL_assertion(iso_p != nullptr);
// Inserting a point into the arrangement:
@ -658,6 +658,7 @@ insert_non_intersecting_curve
Traits_adaptor_2;
typedef typename Arr::Vertex_const_handle Vertex_const_handle;
typedef typename Arr::Halfedge_const_handle Halfedge_const_handle;
typedef typename Arr::Face_const_handle Face_const_handle;
CGAL_USE_TYPE(Halfedge_const_handle);
const Traits_adaptor_2* geom_traits =
@ -666,13 +667,13 @@ insert_non_intersecting_curve
// Check whether the left end has boundary conditions, and locate it in the
// arrangement accordingly.
const Arr_parameter_space bx1 =
geom_traits->parameter_space_in_x_2_object()(c, ARR_MIN_END);
const Arr_parameter_space by1 =
geom_traits->parameter_space_in_y_2_object()(c, ARR_MIN_END);
CGAL::Object obj1;
auto bx1 = geom_traits->parameter_space_in_x_2_object()(c, ARR_MIN_END);
auto by1 = geom_traits->parameter_space_in_y_2_object()(c, ARR_MIN_END);
const Vertex_const_handle* vh1 = nullptr;
typedef Arr_point_location_result<Arr> Pl_result;
typename Pl_result::type obj1;
if ((bx1 == ARR_INTERIOR) && (by1 == ARR_INTERIOR)) {
// We have a normal left endpoint with no boundary conditions:
// use a point-location query.
@ -680,33 +681,26 @@ insert_non_intersecting_curve
// The endpoint must not lie on an existing edge, but may coincide with
// and existing vertex vh1.
CGAL_precondition_msg
(object_cast<Halfedge_const_handle>(&obj1) == nullptr,
"The curve must not intersect an existing edge.");
CGAL_precondition_msg(boost::get<Halfedge_const_handle>(&obj1) == nullptr,
"The curve must not intersect an existing edge.");
vh1 = object_cast<Vertex_const_handle>(&obj1);
}
else {
// We have a left end with boundary conditions. Use the accessor to locate
// the feature that contains it.
obj1 = arr_access.locate_curve_end(c, ARR_MIN_END, bx1, by1);
CGAL_precondition_msg
(object_cast<Halfedge_const_handle>(&obj1) == nullptr,
"The curve must not overlap an existing edge.");
vh1 = object_cast<Vertex_const_handle>(&obj1);
CGAL_precondition_msg(boost::get<Halfedge_const_handle>(&obj1) == nullptr,
"The curve must not overlap an existing edge.");
}
vh1 = Pl_result::template assign<Vertex_const_handle>(&obj1);
// Check whether the right end has boundary conditions, and locate it in the
// arrangement accordingly.
const Arr_parameter_space bx2 =
geom_traits->parameter_space_in_x_2_object()(c, ARR_MAX_END);
const Arr_parameter_space by2 =
geom_traits->parameter_space_in_y_2_object()(c, ARR_MAX_END);
CGAL::Object obj2;
auto bx2 = geom_traits->parameter_space_in_x_2_object()(c, ARR_MAX_END);
auto by2 = geom_traits->parameter_space_in_y_2_object()(c, ARR_MAX_END);
const Vertex_const_handle* vh2 = nullptr;
typename Pl_result::type obj2;
if ((bx2 == ARR_INTERIOR) && (by2 == ARR_INTERIOR)) {
// We have a normal right endpoint with no boundary conditions:
// use a point-location query.
@ -714,11 +708,8 @@ insert_non_intersecting_curve
// The endpoint must not lie on an existing edge, but may coincide with
// and existing vertex vh2.
CGAL_precondition_msg
(object_cast<Halfedge_const_handle>(&obj2) == nullptr,
"The curve must not intersect an existing edge.");
vh2 = object_cast<Vertex_const_handle>(&obj2);
CGAL_precondition_msg(boost::get<Halfedge_const_handle>(&obj2) == nullptr,
"The curve must not intersect an existing edge.");
}
else {
// We have a right end with boundary conditions. Use the accessor to locate
@ -728,13 +719,10 @@ insert_non_intersecting_curve
// << ", by2: " << by2
// << std::endl;
obj2 = arr_access.locate_curve_end(c, ARR_MAX_END, bx2, by2);
CGAL_precondition_msg
(object_cast<Halfedge_const_handle>(&obj2) == nullptr,
"The curve must not overlap an existing edge.");
vh2 = object_cast<Vertex_const_handle>(&obj2);
CGAL_precondition_msg(boost::get<Halfedge_const_handle>(&obj2) == nullptr,
"The curve must not overlap an existing edge.");
}
vh2 = Pl_result::template assign<Vertex_const_handle>(&obj2);
// Notify the arrangement observers that a global operation is about to
// take place.
@ -776,10 +764,8 @@ insert_non_intersecting_curve
// we must insert the curve in the interior of a face.
// In this case insert_in_face_interior() already returns a halfedge
// directed from left to right.
const typename Arr::Face_const_handle* fh1 =
object_cast<typename Arr::Face_const_handle>(&obj1);
const typename Arr::Face_const_handle* fh2 =
object_cast<typename Arr::Face_const_handle>(&obj2);
const Face_const_handle* fh1 = boost::get<Face_const_handle>(&obj1);
const Face_const_handle* fh2 = boost::get<Face_const_handle>(&obj2);
// std::cout << arr << std::endl;
// std::cout << "(*fh1)->number_of_outer_ccbs(): "
@ -1147,7 +1133,7 @@ insert_point(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
typename Arr::Vertex_handle vh_for_p;
// Locate the given point in the arrangement.
CGAL::Object obj = pl.locate (p);
CGAL::Object obj = pl.locate(p);
// Notify the arrangement observers that a global operation is about to
// take place.
@ -1615,28 +1601,27 @@ do_intersect(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
static_cast<const Traits_adaptor_2*>(arr.geometry_traits());
std::list<CGAL::Object> x_objects;
std::list<CGAL::Object>::const_iterator obj_iter;
const typename Gt2::X_monotone_curve_2* x_curve;
const typename Gt2::Point_2* iso_p;
traits->make_x_monotone_2_object()(c, std::back_inserter(x_objects));
// Insert each x-monotone curve into the arrangement.
for (obj_iter = x_objects.begin(); obj_iter != x_objects.end(); ++obj_iter) {
for (auto it = x_objects.begin(); it != x_objects.end(); ++it) {
// Act according to the type of the current object.
x_curve = object_cast<typename Gt2::X_monotone_curve_2>(&(*obj_iter));
x_curve = object_cast<typename Gt2::X_monotone_curve_2>(&(*it));
if (x_curve != nullptr) {
// Check if the x-monotone subcurve intersects the arrangement.
if (do_intersect(arr, *x_curve, pl) == true)
return true;
}
else {
iso_p = object_cast<typename Gt2::Point_2>(&(*obj_iter));
iso_p = object_cast<typename Gt2::Point_2>(&(*it));
CGAL_assertion(iso_p != nullptr);
// Check whether the isolated point lies inside a face (otherwise,
// it conincides with a vertex or an edge).
CGAL::Object obj = pl.locate (*iso_p);
auto obj = pl.locate(*iso_p);
return (object_cast<typename Arr::Face_const_handle>(&obj) != nullptr);
}

View File

@ -169,12 +169,10 @@ public:
Coordinate_1 asym_info1, asym_info2;
CGAL::Arr_parameter_space ps1, ps2;
obj1 = cv1.curve().asymptotic_value_of_arc(
cv1.location(ce), cv1.arcno()
);
obj2 = cv2.curve().asymptotic_value_of_arc(
cv2.location(ce), cv2.arcno()
);
obj1 =
cv1.curve().asymptotic_value_of_arc(cv1.location(ce), cv1.arcno());
obj2 =
cv2.curve().asymptotic_value_of_arc(cv2.location(ce), cv2.arcno());
CGAL::Comparison_result filter_res = CGAL::EQUAL;

View File

@ -23,7 +23,6 @@
* Defintion of the Arr_basic_insertion_traits_2<Traits,Arrangement> class.
*/
#include <CGAL/Object.h>
#include <CGAL/Arr_tags.h>
#include <list>

View File

@ -23,7 +23,6 @@
*/
#include <CGAL/Arr_point_location_result.h>
#include <CGAL/Object.h>
#include <CGAL/Surface_sweep_2/Default_visitor_base.h>
#include <CGAL/Default.h>

View File

@ -13,7 +13,6 @@
#include <boost/lexical_cast.hpp>
#include <CGAL/exceptions.h>
#include <CGAL/Object.h>
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
#include <CGAL/use.h>

View File

@ -8,13 +8,17 @@
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
typedef CGAL::Quotient<int> Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef Arrangement_2::Halfedge_handle Halfedge_handle;
typedef CGAL::Quotient<int> Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef Arrangement_2::Vertex_handle Vertex_handle;
typedef Arrangement_2::Halfedge_handle Halfedge_handle;
typedef Arrangement_2::Face_handle Face_handle;
typedef boost::variant<Vertex_handle, Halfedge_handle, Face_handle>
Zone_result;
#define N_SEGMENTS 3
@ -40,7 +44,7 @@ int main ()
for (k = 0; k < N_SEGMENTS; k++)
{
std::list<CGAL::Object> zone_elems;
std::list<Zone_result> zone_elems;
zone(arr, segs[k], std::back_inserter(zone_elems));
std::size_t zone_actual_comp = zone_elems.size();