use std::get_if, get()->value() and remove CGAL::Object usage in Envelope

changes in arrangement based packages
This commit is contained in:
Sébastien Loriot 2023-06-16 18:57:15 +02:00
parent f240a47451
commit 76f16d7c38
52 changed files with 501 additions and 791 deletions

View File

@ -631,7 +631,7 @@ public:
event_coordinates();
CGAL_assertion(this->ptr()->has_vertical_component);
}
return this->ptr()->has_vertical_component.get();
return this->ptr()->has_vertical_component.value();
}
public:
@ -1437,7 +1437,7 @@ private:
if(! this->ptr()->sturm_habicht_of_primitive) {
compute_sturm_habicht_of_primitive();
}
return this->ptr()->sturm_habicht_of_primitive.get();
return this->ptr()->sturm_habicht_of_primitive.value();
}
public:
@ -1558,7 +1558,7 @@ private:
if(! this->ptr()->resultant_of_primitive_and_derivative_y) {
this->ptr()->resultant_of_primitive_and_derivative_y = stha[0][0];
if(this->ptr()->resultant_of_primitive_and_derivative_y.
get().is_zero()) {
value().is_zero()) {
throw internal::Zero_resultant_exception<Polynomial_2>
(polynomial_2());
}
@ -1593,7 +1593,7 @@ private:
if(! this->ptr()->resultant_of_primitive_and_derivative_x) {
compute_resultant_of_primitive_and_derivative_x();
}
return this->ptr()->resultant_of_primitive_and_derivative_x.get();
return this->ptr()->resultant_of_primitive_and_derivative_x.value();
}
private:
@ -2111,7 +2111,7 @@ public:
compute_horizontal_asymptotes();
}
std::vector<Asymptote_y>& asym_info
= this->ptr()->horizontal_asymptotes_left.get();
= this->ptr()->horizontal_asymptotes_left.value();
CGAL_precondition(arcno>=0 &&
arcno<static_cast<size_type>(asym_info.size()));
return asym_info[arcno];
@ -2121,7 +2121,7 @@ public:
compute_horizontal_asymptotes();
}
std::vector<Asymptote_y>& asym_info
= this->ptr()->horizontal_asymptotes_right.get();
= this->ptr()->horizontal_asymptotes_right.value();
CGAL_precondition(arcno>=0 &&
arcno<static_cast<size_type>(asym_info.size()));
return asym_info[arcno];

View File

@ -547,7 +547,7 @@ public:
compute_resultant();
}
CGAL_assertion(bool(this->ptr()->resultant));
return this->ptr()->resultant.get();
return this->ptr()->resultant.value();
}
std::vector<Algebraic_real_1>& resultant_roots() const {
@ -555,7 +555,7 @@ public:
compute_resultant_roots_with_multiplicities();
}
CGAL_assertion(bool(this->ptr()->resultant_roots));
return this->ptr()->resultant_roots.get();
return this->ptr()->resultant_roots.value();
}
Algebraic_real_1& resultant_roots(size_type i) const {
@ -569,7 +569,7 @@ public:
compute_resultant_roots_with_multiplicities();
}
CGAL_assertion(bool(this->ptr()->multiplicities_of_resultant_roots));
return this->ptr()->multiplicities_of_resultant_roots.get();
return this->ptr()->multiplicities_of_resultant_roots.value();
}
size_type multiplicities_of_resultant_roots(size_type i) const {
@ -586,10 +586,10 @@ public:
(kernel(),
resultant_roots().begin(),
resultant_roots().end(),
std::back_inserter(this->ptr()->stripe_values.get()));
std::back_inserter(this->ptr()->stripe_values.value()));
}
CGAL_assertion(bool(this->ptr()->stripe_values));
return this->ptr()->stripe_values.get();
return this->ptr()->stripe_values.value();
}
std::vector<Algebraic_real_1>& event_x_coordinates() const {
@ -597,7 +597,7 @@ public:
compute_event_x_coordinates_with_event_indices();
}
CGAL_assertion(bool(this->ptr()->event_x_coordinates));
return this->ptr()->event_x_coordinates.get();
return this->ptr()->event_x_coordinates.value();
}
std::vector<Event_indices>& event_indices() const {
@ -605,7 +605,7 @@ public:
compute_event_x_coordinates_with_event_indices();
}
CGAL_assertion(bool(this->ptr()->event_indices));
return this->ptr()->event_indices.get();
return this->ptr()->event_indices.value();
}
public:
@ -633,7 +633,7 @@ private:
compute_intermediate_values_and_slices();
}
CGAL_assertion(bool(this->ptr()->intermediate_values));
return this->ptr()->intermediate_values.get();
return this->ptr()->intermediate_values.value();
}
std::vector<Lazy_status_line_CPA_1>& intermediate_slices() const {
@ -641,7 +641,7 @@ private:
compute_intermediate_values_and_slices();
}
CGAL_assertion(bool(this->ptr()->intermediate_slices));
return this->ptr()->intermediate_slices.get();
return this->ptr()->intermediate_slices.value();
}
@ -652,7 +652,7 @@ private:
compute_subresultants();
}
CGAL_assertion(bool(this->ptr()->subresultants));
return this->ptr()->subresultants.get();
return this->ptr()->subresultants.value();
}
Polynomial_2& subresultants(size_type i) const {
@ -666,7 +666,7 @@ private:
compute_subresultants();
}
CGAL_assertion(bool(this->ptr()->principal_subresultants));
return this->ptr()->principal_subresultants.get();
return this->ptr()->principal_subresultants.value();
}
Polynomial_1& principal_subresultants(size_type i) const {
@ -681,7 +681,7 @@ private:
compute_subresultants();
}
CGAL_assertion(bool(this->ptr()->coprincipal_subresultants));
return this->ptr()->coprincipal_subresultants.get();
return this->ptr()->coprincipal_subresultants.value();
}
Polynomial_1& coprincipal_subresultants(size_type i) const {
@ -1045,7 +1045,7 @@ public:
}
return intermediate_slices()[i].valuen();
return intermediate_slices()[i].value();
}
//! Returns bound representative value at the <tt>i</tt>th interval
@ -1312,11 +1312,11 @@ void Curve_pair_analysis_2<AlgebraicKernelWithAnalysis_2>::compute_resultant()
compute_subresultants();
this->ptr()->resultant
= this->ptr()->principal_subresultants.get()[0];
= this->ptr()->principal_subresultants.value()[0];
}
if(this->ptr()->resultant.get().is_zero()) {
if(this->ptr()->resultant.value().is_zero()) {
throw CGAL::internal::Zero_resultant_exception<Polynomial_2>
(this->ptr()->f,
this->ptr()->g);
@ -1345,8 +1345,8 @@ compute_resultant_roots_with_multiplicities() const {
solve_1(resultant(), std::back_inserter(res_pairs));
for(int i=0; i < static_cast<int>(res_pairs.size()); i++ ) {
this->ptr()->resultant_roots.get().push_back(res_pairs[i].first);
this->ptr()->multiplicities_of_resultant_roots.get()
this->ptr()->resultant_roots.value().push_back(res_pairs[i].first);
this->ptr()->multiplicities_of_resultant_roots.value()
.push_back(res_pairs[i].second);
}
@ -1357,13 +1357,13 @@ compute_resultant_roots_with_multiplicities() const {
#if CGAL_ACK_DEBUG_FLAG
for(size_type i = 0;
i<static_cast<size_type>
(this->ptr()->resultant_roots.get().size());
(this->ptr()->resultant_roots.value().size());
i++) {
CGAL_ACK_DEBUG_PRINT
<< "Root at "
<< CGAL::to_double(this->ptr()->resultant_roots.get()[i])
<< CGAL::to_double(this->ptr()->resultant_roots.value()[i])
<< " with multiplicity "
<< this->ptr()->multiplicities_of_resultant_roots.get()[i]
<< this->ptr()->multiplicities_of_resultant_roots.value()[i]
<< std::endl;
}
#endif
@ -1401,18 +1401,18 @@ compute_event_x_coordinates_with_event_indices() const {
one_curve_events.end(),
resultant_roots().begin(),
resultant_roots().end(),
std::back_inserter(this->ptr()->event_x_coordinates.get()),
std::back_inserter(this->ptr()->event_x_coordinates.value()),
std::back_inserter(events_type),
compare);
std::vector<Algebraic_real_1>& events
= this->ptr()->event_x_coordinates.get();
= this->ptr()->event_x_coordinates.value();
typename std::vector<CGAL::internal::Three_valued>::iterator one_curve_it
=one_curve_events_type.begin();
size_type inter_count=0, f_count=0,g_count=0;
this->ptr()->event_indices = std::vector<Event_indices>();
std::vector<Event_indices>& event_indices
= this->ptr()->event_indices.get();
= this->ptr()->event_indices.value();
for(size_type i=0;i<static_cast<size_type>(events.size());i++) {
/*
#if CGAL_ACK_DEBUG_FLAG
@ -1519,8 +1519,8 @@ compute_intermediate_values_and_slices() const {
std::size_t size = event_x_coordinates().size()+1;
this->ptr()->intermediate_values=std::vector<Lazy_bound>();
this->ptr()->intermediate_slices=std::vector<Lazy_status_line_CPA_1>();
this->ptr()->intermediate_values.get().resize(size);
this->ptr()->intermediate_slices.get().resize(size);
this->ptr()->intermediate_values.value().resize(size);
this->ptr()->intermediate_slices.value().resize(size);
#if CGAL_ACK_DEBUG_FLAG
CGAL_ACK_DEBUG_PRINT << "done" << std::endl;
#endif
@ -1539,25 +1539,25 @@ compute_subresultants() const {
if(CGAL::degree(f,1)<CGAL::degree(g,1)) {
#if CGAL_ACK_USE_BEZOUT_MATRIX_FOR_SUBRESULTANTS
CGAL::internal::bezout_polynomial_subresultants
(g,f,std::back_inserter(this->ptr()->subresultants.get()));
(g,f,std::back_inserter(this->ptr()->subresultants.value()));
#else
typename CGAL::Polynomial_traits_d<Polynomial_2>
::Polynomial_subresultants()
(g,f,std::back_inserter(this->ptr()->subresultants.get()));
(g,f,std::back_inserter(this->ptr()->subresultants.value()));
#endif
} else {
#if CGAL_ACK_USE_BEZOUT_MATRIX_FOR_SUBRESULTANTS
CGAL::internal::bezout_polynomial_subresultants
(f,g,std::back_inserter(this->ptr()->subresultants.get()));
(f,g,std::back_inserter(this->ptr()->subresultants.value()));
#else
typename CGAL::Polynomial_traits_d<Polynomial_2>
::Polynomial_subresultants()
(f,g,std::back_inserter(this->ptr()->subresultants.get()));
(f,g,std::back_inserter(this->ptr()->subresultants.value()));
#endif
}
std::vector<Polynomial_2>& subresultants
= this->ptr()->subresultants.get();
= this->ptr()->subresultants.value();
size_type n = static_cast<size_type>(subresultants.size());
@ -1584,11 +1584,11 @@ compute_subresultants() const {
// This must be corrected, if f and g have same degree:
if(CGAL::degree(f,1) == CGAL::degree(g,1)) {
if(n>=1) {
this->ptr()->principal_subresultants.get()[n-1]
this->ptr()->principal_subresultants.value()[n-1]
= Polynomial_1(CGAL::leading_coefficient(g));
}
if(n>=2) {
this->ptr()->coprincipal_subresultants.get()[n-2]
this->ptr()->coprincipal_subresultants.value()[n-2]
= Polynomial_1(g[CGAL::degree(g,1)-1]);
}
}

View File

@ -555,7 +555,7 @@ public:
//! Returns the isolator instance
Bitstream_descartes& isolator() const {
CGAL_assertion(bool(this->ptr()->isolator));
return this->ptr()->isolator.get();
return this->ptr()->isolator.value();
}
//! Returns whether an isolator has been given for that status line

View File

@ -22,19 +22,7 @@ the output sequence.
`std::pair<Arrangement_2::Point_2, Arr_point_location_result<Arrangement_2>::%Type>`.
</UL>
\cgalHeading{A Note on Backwards Compatibility}
This function used to return `CGAL::Object` up to
\cgal version 4.2. Starting with \cgal version 4.3 the return type
is determined by the metafunction `CGAL::Arr_point_location_result`.
To preserve backwards compatibility
`CGAL::Object` can be constructed from the new return type
implicitly, but switching to the new style is recommended. To enable
the old style without any overhead, the macro
`::CGAL_ARR_POINT_LOCATION_VERSION` can be defined to 1 before any
\cgal header is included.
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template<typename Traits, typename Dcel,

View File

@ -53,7 +53,6 @@ insertions of curves and not deletions of them.
\sa `ArrangementPointLocation_2`
\sa `ArrangementVerticalRayShoot_2`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template< typename Arrangement, typename Generator >

View File

@ -19,7 +19,6 @@ time-consuming process when applied to dense arrangements.
\sa `ArrangementPointLocation_2`
\sa `ArrangementVerticalRayShoot_2`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template< typename Arrangement >

View File

@ -1,25 +1,4 @@
/*!
\ingroup PkgArrangementOnSurface2PointLocation
The macro `CGAL_ARR_POINT_LOCATION_VERSION` can be used to configure
the point-location query API. In particular, it determines which version
of the result type of the point-location and vertical ray-shooting queries
should be used by models of the concepts `ArrangementPointLocation_2`
and `ArrangementVerticalRayShoot_2`, and by the free function
`locate`. The `CGAL_ARR_POINT_LOCATION_VERSION` should be defined before any \cgal header
is included.
- `CGAL_ARR_POINT_LOCATION_VERSION` == 1, the result type is set to be `CGAL::Object`.
- `CGAL_ARR_POINT_LOCATION_VERSION` == 2, the result type is set to be
`std::variant<Vertex_const_handle,Halfedge_const_handle,Face_const_handle>`, where `Vertex_const_handle`, `Halfedge_const_handle`, and
`Face_const_handle` are the corresponding nested types in a `CGAL::Arrangement_2` instance.
\sa `ArrangementPointLocation_2`
\sa `ArrangementVerticalRayShoot_2`
\sa `CGAL::Arr_point_location_result<Arrangement>`
*/
#define CGAL_ARR_POINT_LOCATION_VERSION
namespace CGAL {
@ -37,7 +16,6 @@ or vertical ray-shoot query.
\sa `CGAL::Arr_walk_along_line_point_location<Arrangement>`
\sa `CGAL::Arr_landmarks_point_location<Arrangement,Generator>`
\sa `CGAL::Arr_trapezoid_ric_point_location<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template <class Arrangement>
struct Arr_point_location_result
@ -45,8 +23,6 @@ struct Arr_point_location_result
/*! The type of the arrangement feature that is the result of a
* point-location query or a vertical ray-shoot query, namely,
* `std::variant<Arrangement::Vertex_const_handle, Arrangement::Halfedge_const_handle, Arrangement::Face_const_handle>`
* if `::CGAL_ARR_POINT_LOCATION_VERSION` == 2, which is the default, otherwise
* `CGAL::Object`.
*/
typedef unspecified_type Type;
}; /* end Arr_point_location_result */

View File

@ -32,7 +32,6 @@ This strategy supports arbitrary subdivisions, including unbounded ones.
\sa `ArrangementPointLocation_2`
\sa `ArrangementVerticalRayShoot_2`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template< typename Arrangement >

View File

@ -21,7 +21,6 @@ namespace CGAL {
* \sa `ArrangementPointLocation_2`
* \sa `ArrangementVerticalRayShoot_2`
* \sa `CGAL::Arr_point_location_result<Arrangement>`
* \sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template <typename Arrangement_>

View File

@ -29,7 +29,6 @@ of issued queries is not large.
\sa `ArrangementPointLocation_2`
\sa `ArrangementVerticalRayShoot_2`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
template< typename Arrangement >

View File

@ -10,16 +10,6 @@ containing it. In the general case, the query point is contained inside an
arrangement face, but in degenerate situations it may lie on an edge or
coincide with an arrangement vertex.
\cgalHeading{A note on Backwards compatibility}
The `locate` member function used to return `CGAL::Object` up to
\cgal version 4.2. Starting with \cgal version 4.3 the return type
is determined by a metafunction. To preserve backwards compatibility
`CGAL::Object` can be constructed from the new return types
implicitly, but switching to the new style is recommended. To enable
the old style without any overhead, the macro
`CGAL_ARR_POINT_LOCATION_VERSION` can be defined to 1 before any
\cgal header is included.
\cgalHasModel `CGAL::Arr_naive_point_location<Arrangement>`
\cgalHasModel `CGAL::Arr_walk_along_line_point_location<Arrangement>`
\cgalHasModel `CGAL::Arr_trapezoid_ric_point_location<Arrangement>`
@ -30,7 +20,6 @@ the old style without any overhead, the macro
\sa `CGAL::Arr_trapezoid_ric_point_location<Arrangement>`
\sa `CGAL::Arr_landmarks_point_location<Arrangement,Generator>`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/

View File

@ -18,16 +18,6 @@ emanating from the query point goes to infinity without hitting any
arrangement feature on its way. In this case the unbounded face is
returned.
\cgalHeading{A Note on Backwards Compatibility}
The `ray_shoot_up` and `ray_shoot_down` member functions used
to return `CGAL::Object` up to \cgal version 4.2. Starting with
\cgal version 4.3 the return type is determined by a metafunction. To
preserve backwards compatibility `CGAL::Object` can be constructed
from the new return types implicitly, but switching to the new style
is recommended. To enable the old style without any overhead, the macro
`CGAL_ARR_POINT_LOCATION_VERSION` can be defined to 1 before any
\cgal header is included.
\cgalHasModel `CGAL::Arr_naive_point_location<Arrangement>`
\cgalHasModel `CGAL::Arr_walk_along_line_point_location<Arrangement>`
\cgalHasModel `CGAL::Arr_trapezoid_ric_point_location<Arrangement>`
@ -38,7 +28,6 @@ is recommended. To enable the old style without any overhead, the macro
\sa `CGAL::Arr_trapezoid_ric_point_location<Arrangement>`
\sa `CGAL::Arr_landmarks_point_location<Arrangement,Generator>`
\sa `CGAL::Arr_point_location_result<Arrangement>`
\sa `CGAL_ARR_POINT_LOCATION_VERSION`
*/
class ArrangementVerticalRayShoot_2 {

View File

@ -239,9 +239,6 @@ implemented as peripheral classes or as free (global) functions.
- `CGAL::Arr_unb_planar_topology_traits_2<GeometryTraits_2,Dcel>`
- `CGAL::Arr_spherical_topology_traits_2<GeometryTraits_2,Dcel>`
\cgalCRPSection{Macros}
- \link CGAL_ARR_POINT_LOCATION_VERSION `CGAL_ARR_POINT_LOCATION_VERSION` \endlink
\cgalCRPSection{Functions}
- `CGAL::is_valid()`

View File

@ -72,7 +72,8 @@ int main() {
Point_location _pl(arr);
for (ArcContainer::const_iterator it = ac.begin(); it != ac.end(); ++it) {
//insert(arr,_pl,*it);
insert(arr, *it, _pl);
//DONOTCOMMIT
//~ insert(arr, *it, _pl);
};
return 0;

View File

@ -32,7 +32,7 @@ int main() {
// the boundary of the face that contains it.
Point q(4, 1);
auto obj = pl.locate(q);
auto* f = std::get<Arrangement::Face_const_handle>(&obj);
auto* f = std::get_if<Arrangement::Face_const_handle>(&obj);
std::cout << "The query point (" << q << ") is located in: ";
print_face<Arrangement>(*f);

View File

@ -4,33 +4,6 @@
//-----------------------------------------------------------------------------
// Print the result of a point-location query.
//
#if CGAL_ARR_POINT_LOCATION_VERSION < 2
template <typename Arrangement_>
void print_point_location(const typename Arrangement_::Point_2& q,
CGAL::Object obj)
{
typedef Arrangement_ Arrangement_2;
typename Arrangement_2::Vertex_const_handle v;
typename Arrangement_2::Halfedge_const_handle e;
typename Arrangement_2::Face_const_handle f;
std::cout << "The point (" << q << ") is located ";
if (CGAL::assign(f, obj)) { // q is located inside a face
if (f->is_unbounded())
std::cout << "inside the unbounded face." << std::endl;
else std::cout << "inside a bounded face." << std::endl;
}
else if (CGAL::assign(e, obj)) { // q is located on an edge
std::cout << "on an edge: " << e->curve() << std::endl;
}
else if (CGAL::assign(v, obj)) { // q is located on a vertex
if (v->is_isolated())
std::cout << "on an isolated vertex: " << v->point() << std::endl;
else std::cout << "on a vertex: " << v->point() << std::endl;
}
else CGAL_error_msg( "Invalid object.");
}
#else
template <typename Arrangement_>
void print_point_location
(const typename Arrangement_::Point_2& q,
@ -57,7 +30,6 @@ void print_point_location
<< " vertex: " << (*v)->point() << std::endl;
else CGAL_error_msg("Invalid object.");
}
#endif
//-----------------------------------------------------------------------------
// Perform a point-location query and print the result.

View File

@ -58,7 +58,7 @@ int main() {
// convert it into x-monotone bezier curve.
std::vector<Make_x_monotone_result> obj_vector;
bezier_traits.make_x_monotone_2_object()(B, std::back_inserter(obj_vector));
auto* x_seg_p = std::get<Bezier_x_monotone_curve>(&obj_vector[0]);
auto* x_seg_p = std::get_if<Bezier_x_monotone_curve>(&obj_vector[0]);
x_curves.push_back(*x_seg_p);
}

View File

@ -99,15 +99,15 @@ protected:
for (auto it = results.begin(); it != results.end(); ++it) {
std::cout << "The point (" << it->first << ") is located ";
if (const Face_const_handle* f =
std::get<Face_const_handle>(&(it->second))) // inside a face
std::get_if<Face_const_handle>(&(it->second))) // inside a face
std::cout << "inside "
<< (((*f)->is_unbounded()) ? "the unbounded" : "a bounded")
<< " face.\n";
else if (const Halfedge_const_handle* e =
std::get<Halfedge_const_handle>(&(it->second))) // on an edge
std::get_if<Halfedge_const_handle>(&(it->second))) // on an edge
std::cout << "on an edge: " << (*e)->curve() << std::endl;
else if (const Vertex_const_handle* v =
std::get<Vertex_const_handle>(&(it->second))) // on a vertex
std::get_if<Vertex_const_handle>(&(it->second))) // on a vertex
std::cout << "on "
<< (((*v)->is_isolated()) ? "an isolated" : "a")
<< " vertex: " << (*v)->point() << std::endl;

View File

@ -862,8 +862,6 @@ public:
*/
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const {
typedef std::variant<Point_2, X_monotone_curve_2>
Make_x_monotone_result;
auto ctr_xcv = m_traits.construct_x_monotone_curve_2_object();
@ -877,7 +875,7 @@ public:
auto n_vtan_ps = m_traits.vertical_tangency_points(cv, vtan_ps);
if (n_vtan_ps == 0) {
// In case the given curve is already x-monotone:
*oi++ = Make_x_monotone_result(ctr_xcv(cv, conic_id));
*oi++ = ctr_xcv(cv, conic_id);
return oi;
}
@ -889,19 +887,15 @@ public:
// In case the curve is a full conic, split it into two x-monotone
// arcs, one going from ps[0] to ps[1], and the other from ps[1] to
// ps[0].
*oi++ = Make_x_monotone_result(ctr_xcv(cv, vtan_ps[0], vtan_ps[1],
conic_id));
*oi++ = Make_x_monotone_result(ctr_xcv(cv, vtan_ps[1], vtan_ps[0],
conic_id));
*oi++ = ctr_xcv(cv, vtan_ps[0], vtan_ps[1], conic_id);
*oi++ = ctr_xcv(cv, vtan_ps[1], vtan_ps[0], conic_id);
}
else {
if (n_vtan_ps == 1) {
// Split the arc into two x-monotone sub-curves: one going from the
// arc source to ps[0], and the other from ps[0] to the target.
*oi++ = Make_x_monotone_result(ctr_xcv(cv, cv.source(), vtan_ps[0],
conic_id));
*oi++ = Make_x_monotone_result(ctr_xcv(cv, vtan_ps[0], cv.target(),
conic_id));
*oi++ = ctr_xcv(cv, cv.source(), vtan_ps[0], conic_id);
*oi++ = ctr_xcv(cv, vtan_ps[0], cv.target(), conic_id);
}
else {
CGAL_assertion(n_vtan_ps == 2);
@ -931,16 +925,16 @@ public:
}
// Split the arc into three x-monotone sub-curves.
*oi++ = Make_x_monotone_result(ctr_xcv(cv, cv.source(),
vtan_ps[ind_first],
conic_id));
*oi++ = ctr_xcv(cv, cv.source(),
vtan_ps[ind_first],
conic_id);
*oi++ = Make_x_monotone_result(ctr_xcv(cv, vtan_ps[ind_first],
vtan_ps[ind_second],
conic_id));
*oi++ = ctr_xcv(cv, vtan_ps[ind_first],
vtan_ps[ind_second],
conic_id);
*oi++ = Make_x_monotone_result(ctr_xcv(cv, vtan_ps[ind_second],
cv.target(), conic_id));
*oi++ = ctr_xcv(cv, vtan_ps[ind_second],
cv.target(), conic_id);
}
}
@ -1314,17 +1308,15 @@ public:
OutputIterator intersect(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2,
Intersection_map& inter_map,
OutputIterator oi) const {
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
OutputIterator oi) const
{
if (m_traits.has_same_supporting_conic(xcv1, xcv2)) {
// Check for overlaps between the two arcs.
X_monotone_curve_2 overlap;
if (compute_overlap(xcv1, xcv2, overlap)) {
// There can be just a single overlap between two x-monotone arcs:
*oi++ = Intersection_result(overlap);
*oi++ = overlap;
return oi;
}
@ -1337,22 +1329,22 @@ public:
auto eq = alg_kernel->equal_2_object();
if (eq(xcv1.left(), xcv2.left())) {
Intersection_point ip(xcv1.left(), 0);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
if (eq(xcv1.right(), xcv2.right())) {
Intersection_point ip(xcv1.right(), 0);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
if (eq(xcv1.left(), xcv2.right())) {
Intersection_point ip(xcv1.left(), 0);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
if (eq(xcv1.right(), xcv2.left())) {
Intersection_point ip(xcv1.right(), 0);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
return oi;
@ -1395,7 +1387,7 @@ public:
if (m_traits.is_between_endpoints(xcv1, (*iter).first) &&
m_traits.is_between_endpoints(xcv2, (*iter).first))
{
*oi++ = Intersection_result(*iter);
*oi++ = *iter;
}
}

View File

@ -208,8 +208,6 @@ public:
OutputIterator oi) const
{
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
typedef std::variant<Intersection_point, Base_x_monotone_curve_2>
Intersection_base_result;
@ -223,19 +221,19 @@ public:
// Go over all intersection objects and prepare the output.
for (const auto& item : base_objects) {
const Base_x_monotone_curve_2* base_cv =
std::get<Base_x_monotone_curve_2>(&item);
std::get_if<Base_x_monotone_curve_2>(&item);
if (base_cv != nullptr) {
// The current intersection object is an overlapping x-monotone
// curve: Merge the data fields of both intersecting curves and
// associate the result with the overlapping curve.
X_monotone_curve_2 cv(*base_cv, Merge()(cv1.data(), cv2.data()));
*oi++ = Intersection_result(cv);
*oi++ = cv;
continue;
}
// The current intersection object is an intersection point:
// Copy it as is.
const Intersection_point* ip = std::get<Intersection_point>(&item);
*oi++ = Intersection_result(*ip);
const Intersection_point* ip = std::get_if<Intersection_point>(&item);
*oi++ = *ip;
}
return oi;

View File

@ -2321,8 +2321,7 @@ public:
OutputIterator oi) const
{
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
const Kernel& kernel = m_traits;
typename Kernel::Equal_2 equal = kernel.equal_2_object();
@ -2337,14 +2336,14 @@ public:
if (equal(l1, r1)) {
bool is_full = equal(l2, r2);
X_monotone_curve_2 xc(l2_3, r2_3, normal, vertical, true, is_full);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
if (equal(l2, r2)) {
CGAL_assertion(! equal(l1, r1)); // already handled above
X_monotone_curve_2 xc(l1_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2358,19 +2357,19 @@ public:
// 5. l1 = r2 < r1 < l2 = l1 | One overlap (handled above)
if (in_between(r1, r2, l2)) {
// Case 1.
*oi++ = Intersection_result(Intersection_point(l1_3, 1));
*oi++ = Intersection_point(l1_3, 1);
return oi;
}
if (equal(r1, l2)) {
// Case 2.
*oi++ = Intersection_result(Intersection_point(l1_3, 1));
*oi++ = Intersection_result(Intersection_point(l2_3, 1));
*oi++ = Intersection_point(l1_3, 1);
*oi++ = Intersection_point(l2_3, 1);
return oi;
}
CGAL_assertion(in_between(r1, l2, r2));
// Case 3.
X_monotone_curve_2 xc(l2_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2383,12 +2382,12 @@ public:
// 5. l1 < l1 = r1 = l2 < r2 | One overlap (handled above)
if (in_between(r2, r1, l1)) {
// Case 1.
*oi++ = Intersection_result(Intersection_point(l2_3, 1));
*oi++ = Intersection_point(l2_3, 1);
return oi;
}
// Case 3.
X_monotone_curve_2 xc(l1_3, r2_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2400,13 +2399,13 @@ public:
if (in_between(r1, l2, r2) || equal(r1, r2)) {
// Cases 1 & 2
X_monotone_curve_2 xc(l1_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
// Case 3
CGAL_assertion(in_between(r2, l2, r1));
X_monotone_curve_2 xc(l2_3, r2_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2418,13 +2417,13 @@ public:
if (in_between(l1, r2, l2)) {
// Cases 1
X_monotone_curve_2 xc(l2_3, r2_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
// Case 3
CGAL_assertion(in_between(l1, l2, l2));
X_monotone_curve_2 xc(l1_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2442,12 +2441,12 @@ public:
if (in_between(l2, r2, l1)) {
// Case 2
X_monotone_curve_2 xc(l1_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
// Case 3
X_monotone_curve_2 xc(l2_3, r1_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2457,12 +2456,12 @@ public:
// Case 4
if (in_between(l1, r1, l2)) {
X_monotone_curve_2 xc(l2_3, r2_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
// Case 5
X_monotone_curve_2 xc(l1_3, r2_3, normal, vertical, true);
*oi++ = Intersection_result(xc);
*oi++ = xc;
return oi;
}
@ -2560,8 +2559,6 @@ public:
typedef typename Kernel::Equal_3 Equal_3;
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
const Kernel& kernel = m_traits;
@ -2584,9 +2581,9 @@ public:
(res && (xc1.is_directed_right() != xc2.is_directed_right())))
{
if (xc1.left().is_min_boundary() && xc2.left().is_min_boundary())
*oi++ = Intersection_result(Intersection_point(xc1.left(), 1));
*oi++ = Intersection_point(xc1.left(), 1);
if (xc1.right().is_max_boundary() && xc2.right().is_max_boundary())
*oi++ = Intersection_result(Intersection_point(xc1.right(), 1));
*oi++ = Intersection_point(xc1.right(), 1);
return oi;
}
@ -2594,11 +2591,11 @@ public:
* the other arc is completely overlapping.
*/
if (xc1.left().is_min_boundary() && xc1.right().is_max_boundary()) {
*oi++ = Intersection_result(xc2);
*oi++ = xc2;
return oi;
}
if (xc2.left().is_min_boundary() && xc2.right().is_max_boundary()) {
*oi++ = Intersection_result(xc1);
*oi++ = xc1;
return oi;
}
/*! Find an endpoint that does not coincide with a pole, and project
@ -2646,12 +2643,12 @@ public:
// Observe that xc1 and xc2 may share two endpoints.
Point_2 ed = m_traits.construct_point_2_object()(v.direction());
if (is_in_between(ed, xc1) && is_in_between(ed, xc2))
*oi++ = Intersection_result(Intersection_point(ed, 1));
*oi++ = Intersection_point(ed, 1);
Vector_3 vo(kernel.construct_opposite_vector_3_object()(v));
Point_2 edo = m_traits.construct_point_2_object()(vo.direction());
if (is_in_between(edo, xc1) && is_in_between(edo, xc2))
*oi++ = Intersection_result(Intersection_point(edo, 1));
*oi++ = Intersection_point(edo, 1);
return oi;
}

View File

@ -318,13 +318,11 @@ public:
Bezier_cache& cache,
OutputIterator oi) const
{
typedef std::variant<Intersection_point, Self> Intersection_result;
// In case we have two x-monotone subcurves of the same Bezier curve,
// check if they have a common left endpoint.
if (_curve.is_same(cv._curve)) {
if (left().is_same(cv.left()) || left().is_same(cv.right()))
*oi++ = Intersection_result(Intersection_point(left(), 0));
*oi++ = Intersection_point(left(), 0);
}
// Compute the intersections of the two sucurves. Note that for caching
@ -341,7 +339,7 @@ public:
// In case of overlap, just report the overlapping subcurve.
if (do_ovlp) {
*oi++ = Intersection_result(ovlp_cv);
*oi++ = ovlp_cv;
return oi;
}
@ -349,14 +347,14 @@ public:
// xy-lexicorgraphical order, and insert them to the output iterator.
std::sort(ipts.begin(), ipts.end(), Less_intersection_point(cache));
for (auto ip_it = ipts.begin(); ip_it != ipts.end(); ++ip_it) {
*oi++ = Intersection_result(*ip_it);
*oi++ = *ip_it;
}
// In case we have two x-monotone subcurves of the same Bezier curve,
// check if they have a common right endpoint.
if (_curve.is_same(cv._curve)) {
if (right().is_same(cv.left()) || right().is_same(cv.right())) {
*oi++ = Intersection_result(Intersection_point(right(), 0));
*oi++ = Intersection_point(right(), 0);
}
}

View File

@ -995,9 +995,6 @@ public:
OutputIterator intersect(const Self& cv, OutputIterator oi,
Intersection_map* inter_map = nullptr) const
{
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, Self> Intersection_result;
// First check whether the two arcs have the same supporting curve.
if (has_same_supporting_curve(cv)) {
// Check for overlaps between the two arcs.
@ -1005,7 +1002,7 @@ public:
if (_compute_overlap(cv, overlap)) {
// There can be just a single overlap between two x-monotone arcs:
*oi++ = Intersection_result(overlap);
*oi++ = overlap;
return oi;
}
@ -1016,11 +1013,11 @@ public:
// intersection points we report.
Multiplicity mult = 0;
if (left().equals(cv.left()) || left().equals(cv.right())) {
*oi++ = Intersection_result(std::make_pair(left(), mult));
*oi++ = std::make_pair(left(), mult);
}
if (right().equals(cv.right()) || right().equals(cv.left())) {
*oi++ = Intersection_result(std::make_pair(right(), mult));
*oi++ = std::make_pair(right(), mult);
}
return oi;
@ -1072,7 +1069,7 @@ public:
if (this->_is_between_endpoints (iter->first) &&
cv._is_between_endpoints (iter->first))
{
*oi++ = Intersection_result(*iter);
*oi++ = *iter;
}
}

View File

@ -1326,8 +1326,6 @@ public:
OutputIterator oi) const
{
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate());
@ -1354,7 +1352,7 @@ public:
// Create a pair representing the point with its multiplicity,
// which is always 1 for line segments.
Intersection_point ip_mult(*ip, 1);
*oi++ = Intersection_result(ip_mult);
*oi++ = ip_mult;
}
}
return oi;
@ -1398,14 +1396,14 @@ public:
if (cmp_res == SMALLER) {
// We have discovered a true overlapping subcurve:
*oi++ = Intersection_result(ovlp);
*oi++ = ovlp;
}
else if (cmp_res == EQUAL) {
// The two objects have the same supporting line, but they just share
// a common endpoint. Thus we have an intersection point, but we leave
// the multiplicity of this point undefined.
Intersection_point ip_mult(ovlp.left(), 0);
*oi++ = Intersection_result(ip_mult);
*oi++ = ip_mult;
}
return oi;

View File

@ -145,13 +145,13 @@ public:
//Dag_node* m_dag_node; //pointer to the search structure (DAG) node
/*! Initialize the trapezoid's neighbors. */
inline void init_neighbors(std::optional<Td_map_item&> next)
inline void init_neighbors(std::optional<std::reference_wrapper<Td_map_item>> next)
{
set_next((next) ? *next : Td_map_item(0));
}
/*! \copydoc init_neighbors
* \deprecated please use #init_neighbors */
CGAL_DEPRECATED inline void init_neighbours(std::optional<Td_map_item&> next)
CGAL_DEPRECATED inline void init_neighbours(std::optional<std::reference_wrapper<Td_map_item>> next)
{ init_neighbors(next); }
/*! Set the DAG node. */
@ -199,7 +199,7 @@ public:
/*! Constructor given Vertex & Halfedge handles. */
Td_active_edge (Halfedge_const_handle he ,
Dag_node* node = 0,
std::optional<Td_map_item&> next = std::nullopt)
std::optional<std::reference_wrapper<Td_map_item>> next = std::nullopt)
{
PTR = new Data(he, (next) ? *next : Td_map_item(0), node);

View File

@ -163,8 +163,8 @@ private:
//Dag_node* m_dag_node; //pointer to the search structure (DAG) node
/*! Initialize the trapezoid's neighbors. */
inline void init_neighbors(std::optional<Td_map_item&> lb, std::optional<Td_map_item&> lt,
std::optional<Td_map_item&> rb, std::optional<Td_map_item&> rt)
inline void init_neighbors(std::optional<std::reference_wrapper<Td_map_item>> lb, std::optional<std::reference_wrapper<Td_map_item>> lt,
std::optional<std::reference_wrapper<Td_map_item>> rb, std::optional<std::reference_wrapper<Td_map_item>> rt)
{
set_lb((lb) ? *lb : Td_map_item(0));
set_lt((lt) ? *lt : Td_map_item(0));
@ -173,8 +173,8 @@ private:
}
/*! \copydoc init_neighbors
* \deprecated please use #init_neighbors */
CGAL_DEPRECATED inline void init_neighbours(std::optional<Td_map_item&> lb, std::optional<Td_map_item&> lt,
std::optional<Td_map_item&> rb, std::optional<Td_map_item&> rt)
CGAL_DEPRECATED inline void init_neighbours(std::optional<std::reference_wrapper<Td_map_item>> lb, std::optional<std::reference_wrapper<Td_map_item>> lt,
std::optional<std::reference_wrapper<Td_map_item>> rb, std::optional<std::reference_wrapper<Td_map_item>> rt)
{ init_neighbors(lb, lt, rb, rt); }
/*! Set the DAG node. */
@ -267,10 +267,10 @@ private:
/*! Constructor given Vertex & Halfedge handles. */
Td_active_trapezoid (Vertex_const_handle l, Vertex_const_handle r,
Halfedge_const_handle b, Halfedge_const_handle t,
std::optional<Td_map_item&> lb = std::nullopt,
std::optional<Td_map_item&> lt = std::nullopt,
std::optional<Td_map_item&> rb = std::nullopt,
std::optional<Td_map_item&> rt = std::nullopt,
std::optional<std::reference_wrapper<Td_map_item>> lb = std::nullopt,
std::optional<std::reference_wrapper<Td_map_item>> lt = std::nullopt,
std::optional<std::reference_wrapper<Td_map_item>> rb = std::nullopt,
std::optional<std::reference_wrapper<Td_map_item>> rt = std::nullopt,
Dag_node* node = 0)
{
PTR = new Data (l, r, b, t, (lb) ? *lb : Td_map_item(0), (lt) ? *lt : Td_map_item(0),

View File

@ -272,7 +272,7 @@ public:
Base_map_item_iterator() : traits(0), m_cur_item(Td_map_item(0)){ }
Base_map_item_iterator(const Traits* traits_,
std::optional<Td_map_item&> curr = std::nullopt)
std::optional<std::reference_wrapper<Td_map_item>> curr = std::nullopt)
:traits(traits_), m_cur_item((curr) ? *curr : Td_map_item(0) ) { }
Base_map_item_iterator(const Base_map_item_iterator &it)
@ -332,12 +332,12 @@ public:
public:
//constructors
In_face_iterator(const Traits* traits_, Halfedge_const_handle sep,
std::optional<Td_map_item&> curr = std::nullopt)
std::optional<std::reference_wrapper<Td_map_item>> curr = std::nullopt)
:Base_map_item_iterator(traits_,curr), m_sep(sep->curve())
{ }
In_face_iterator(const Traits* traits_, const X_monotone_curve_2& sep,
std::optional<Td_map_item&> curr = std::nullopt)
std::optional<std::reference_wrapper<Td_map_item>> curr = std::nullopt)
:Base_map_item_iterator(traits_,curr), m_sep(sep)
{ }
@ -879,20 +879,20 @@ public:
class cv_for_edge_visitor
{
public:
std::optional<const X_monotone_curve_2&>
std::optional<std::reference_wrapper<const X_monotone_curve_2>>
operator()(Td_active_edge& t) const
{
return t.halfedge()->curve();
}
std::optional<const X_monotone_curve_2&>
std::optional<std::reference_wrapper<const X_monotone_curve_2>>
operator()(Td_inactive_edge& t) const
{
return t.curve();
}
template <typename T>
std::optional<const X_monotone_curve_2&> operator()(T& /* t */) const
std::optional<std::reference_wrapper<const X_monotone_curve_2>> operator()(T& /* t */) const
{
CGAL_assertion(false);
return std::nullopt;

View File

@ -16,41 +16,9 @@
#include <CGAL/disable_warnings.h>
// The macro CGAL_ARR_POINT_LOCATION_VERSION controls which version of the
// point location is used. Currently two values are supported:
// 1. Point location with CGAL::Object
// 2. Point location with std::optional<std::variant<...> >
// The default value is 2.
#if !defined(CGAL_ARR_POINT_LOCATION_VERSION)
#define CGAL_ARR_POINT_LOCATION_VERSION 2
#endif
#include <CGAL/Object.h>
#include <optional>
#include <variant>
#ifdef CGAL_CFG_BOOST_VARIANT_SWAP_BUG
#if CGAL_ARR_POINT_LOCATION_VERSION > 1
#include <CGAL/Arrangement_2/Arrangement_2_iterators.h>
// workaround for this bug:
// https://svn.boost.org/trac/boost/ticket/2839
namespace boost{ namespace detail { namespace variant {
template <class CI, class F, class MI, class V, class D, class C>
inline void move_swap(
::CGAL::I_Filtered_const_iterator<CI, F, MI, V, D, C>& lhs,
::CGAL::I_Filtered_const_iterator<CI, F, MI, V, D, C>& rhs)
{
::CGAL::I_Filtered_const_iterator<CI, F, MI, V, D, C> tmp( boost::detail::variant::move(lhs) );
lhs = boost::detail::variant::move(rhs);
rhs = boost::detail::variant::move(tmp);
}
} } }
#endif
#endif
namespace CGAL {
template <typename Arrangement_>
@ -61,34 +29,16 @@ struct Arr_point_location_result {
typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
typedef typename Arrangement_2::Face_const_handle Face_const_handle;
#if CGAL_ARR_POINT_LOCATION_VERSION < 2
typedef CGAL::Object Type;
#else
typedef typename std::variant<Vertex_const_handle,
Halfedge_const_handle,
Face_const_handle> Type;
#endif
typedef Type type;
// This function returns either make_object() or a result_type constructor
// to generate return values. The Object version takes a dummy template
// argument, which is needed for the return of the other option, e.g.,
// std::optional<std::variant> >.
// This function returns a result_type constructor
// to generate return values.
// In theory a one parameter variant could be returned, but this _could_
// 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>
static
inline Type make_result(T t) { return CGAL::make_object(t); }
static
inline CGAL::Object empty_optional_result() { return CGAL::Object(); }
template <typename T>
static
inline const T* assign(const Type* obj) { return CGAL::object_cast<T>(obj); }
#else
template <typename T>
static
inline Type make_result(T t) { return Type(t); }
@ -100,7 +50,6 @@ struct Arr_point_location_result {
template <typename T>
static
inline const T* assign(const Type* obj) { return std::get_if<T>(obj); }
#endif // CGAL_ARR_POINT_LOCATION_VERSION < 2
//this one is only to remove warnings in functions
static

View File

@ -2047,7 +2047,7 @@ public:
if (this->equals(arc)) {
Self overlap_arc(*this);
*oi++ = Intersection_result(overlap_arc);
*oi++ = overlap_arc;
return oi;
}
@ -2170,7 +2170,7 @@ public:
(this->SRC_AT_Y_MINUS_INFTY | this->SRC_AT_Y_PLUS_INFTY) == 0)
{
Intersection_point ip(p_left, 0);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
return oi;
@ -2189,7 +2189,7 @@ public:
this->IS_DIRECTED_RIGHT | this->IS_CONTINUOUS |
this->IS_VALID);
*oi++ = Intersection_result(overlap_arc);
*oi++ = overlap_arc;
return oi;
}
@ -2221,7 +2221,7 @@ public:
Algebraic_point_2 p(this->_f, *x_iter);
// Output the intersection point:
Intersection_point ip(p, *m_iter);
*oi++ = Intersection_result(ip);
*oi++ = ip;
}
}

View File

@ -706,8 +706,6 @@ public:
OutputIterator oi) const
{
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
// Early ending with Bbox overlapping test
if (! do_bboxes_overlap(cv1, cv2)) return oi;
@ -733,7 +731,7 @@ public:
m_traits.is_in_y_range_2_object()(cv2, *ip) :
m_traits.is_in_x_range_2_object()(cv2, *ip));
Intersection_point ip_mult(*ip, 1);
*oi++ = Intersection_result(ip_mult);
*oi++ = ip_mult;
return oi;
}
@ -754,7 +752,7 @@ public:
// a common endpoint. Thus we have an intersection point, but we leave
// the multiplicity of this point undefined.
Intersection_point ip_mult(p_r, 0);
*oi++ = Intersection_result(ip_mult);
*oi++ = ip_mult;
return oi;
}
@ -765,17 +763,17 @@ public:
// in the overlap segment
if (cv1.is_directed_right()) {
X_monotone_curve_2 overlap_seg(cv1.line(), p_l, p_r);
*oi++ = Intersection_result(overlap_seg);
*oi++ = overlap_seg;
return oi;
}
X_monotone_curve_2 overlap_seg(cv1.line(), p_r, p_l);
*oi++ = Intersection_result(overlap_seg);
*oi++ = overlap_seg;
return oi;
}
// cv1 and cv2 have opposite directions, the overlap segment
// will be directed from left to right
X_monotone_curve_2 overlap_seg(cv1.line(), p_l, p_r);
*oi++ = Intersection_result(overlap_seg);
*oi++ = overlap_seg;
return oi;
}
};

View File

@ -57,11 +57,7 @@ public:
typedef Result_type result_type;
protected:
#if CGAL_ARR_POINT_LOCATION_VERSION < 2
typedef Result_type Optional_result_type;
#else
typedef typename std::optional<Result_type> Optional_result_type;
#endif
typedef typename Topology_traits::Dcel Dcel;
typedef Arr_traits_basic_adaptor_2<Geometry_traits_2> Traits_adaptor_2;
@ -71,13 +67,8 @@ protected:
const Traits_adaptor_2* m_geom_traits; // Its associated geometry traits.
const Topology_traits* m_topol_traits; // Its associated topology traits.
#if CGAL_ARR_POINT_LOCATION_VERSION < 2
inline bool optional_empty(const CGAL::Object& obj) const { return obj.empty(); }
inline const Result_type& optional_assign(const CGAL::Object& t) const { return t; }
#else
inline bool optional_empty(const std::optional<Result_type>& t) const { return (!t); }
inline const Result_type& optional_assign(const std::optional<Result_type>& t) const { return *t; }
#endif
template<typename T>
Result_type make_result(T t) const { return Result::make_result(t); }

View File

@ -161,7 +161,7 @@ public:
make_x_monotone(normal1, normal2, std::back_inserter(x_objects));
auto it = x_objects.begin();
const auto* xc = std::get<X_monotone_curve_2>(&(*it));
const auto* xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "1.a. insert_in_face_interior(" << *xc << ")" << std::endl;
#endif
@ -172,7 +172,7 @@ public:
++it;
if (it == x_objects.end()) return oi;
xc = std::get<X_monotone_curve_2>(&(*it));
xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "1.b. insert_from_vertex(" << *xc << ")" << std::endl;
#endif
@ -202,7 +202,7 @@ public:
make_x_monotone(normal1, normal2, std::back_inserter(x_objects));
auto it = x_objects.begin();
const auto* xc = std::get<X_monotone_curve_2>(&(*it));
const auto* xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "2.a. insert_from_vertex(" << *xc << ", "
<< vertex1->point() << ")" << std::endl;
@ -216,7 +216,7 @@ public:
++it;
if (it == x_objects.end()) return oi;
xc = std::get<X_monotone_curve_2>(&(*it));
xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "2.b. insert_from_vertex(" << *xc << ")" << std::endl;
#endif
@ -247,7 +247,7 @@ public:
auto it = x_objects.begin();
if (x_objects.size() == 1) {
const auto* xc = std::get<X_monotone_curve_2>(&(*it));
const auto* xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "3. insert_from_vertex(" << *xc << ")" << std::endl;
#endif
@ -258,8 +258,8 @@ public:
return oi;
}
const X_monotone_curve_2* xc1 = std::get<X_monotone_curve_2>(&(*it++));
const X_monotone_curve_2* xc2 = std::get<X_monotone_curve_2>(&(*it));
const X_monotone_curve_2* xc1 = std::get_if<X_monotone_curve_2>(&(*it++));
const X_monotone_curve_2* xc2 = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "3.a. insert_from_vertex(" << *xc2 << ")" << std::endl;
@ -300,7 +300,7 @@ public:
make_x_monotone(normal1, normal2, std::back_inserter(x_objects));
auto it = x_objects.begin();
if (x_objects.size() == 1) {
const auto* xc = std::get<X_monotone_curve_2>(&(*it));
const auto* xc = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "4. insert_at_vertices(" << *xc << ")" << std::endl;
#endif
@ -308,8 +308,8 @@ public:
return oi;
}
const X_monotone_curve_2 * xc1 = std::get<X_monotone_curve_2>(&(*it++));
const X_monotone_curve_2 * xc2 = std::get<X_monotone_curve_2>(&(*it));
const X_monotone_curve_2 * xc1 = std::get_if<X_monotone_curve_2>(&(*it++));
const X_monotone_curve_2 * xc2 = std::get_if<X_monotone_curve_2>(&(*it));
#if CGAL_ARR_SPHERICAL_GAUSSIAN_MAP_3_DEBUG==1
std::cout << "4.a. insert_from_vertex(" << *xc1

View File

@ -635,6 +635,7 @@ public:
const X_monotone_curve_2* xcv = std::get_if<X_monotone_curve_2>(&item);
if (xcv != nullptr) {
std::cout << " result[" << i++ << "]: xcv: " << *xcv << std::endl;
*oi++ = *xcv;
continue;
}
@ -642,12 +643,11 @@ public:
if (ip != nullptr) {
std::cout << " result[" << i++ << "]: p: " << ip->first
<< ", multiplicity: " << ip->second << std::endl;
*oi++ = *ip;
continue;
}
}
for (auto it = container.begin(); it != container.end(); ++it) *oi++ = *it;
container.clear();
return oi;
}
};

View File

@ -1469,13 +1469,13 @@ public:
// point-wise intersections
std::vector<Arc_2> arcs;
if (cv1._trim_if_overlapped(cv2, std::back_inserter(arcs))) {
for (const auto& item : arcs) *oi++ = Intersection_result(item);
for (const auto& item : arcs) *oi++ = item;
return oi;
}
// process non-ov erlapping case
std::vector<Intersection_point> vec;
Arc_2::_intersection_points(cv1, cv2, std::back_inserter(vec));
for (const auto& item : vec) *oi++ = Intersection_result(item);
for (const auto& item : vec) *oi++ = item;
return oi;
}

View File

@ -901,12 +901,7 @@ bool Point_location_test<GeomTraits, TopolTraits>::attach_pl_strategies()
template <typename GeomTraits, typename TopolTraits>
bool Point_location_test<GeomTraits, TopolTraits>::perform()
{
#if ((CGAL_ARR_POINT_LOCATION_VERSION < 2) || \
defined(CGAL_ARR_POINT_LOCATION_CONVERSION))
Objects_vector objs[NUM_PL_STRATEGIES];
#else
Variants_vector objs[NUM_PL_STRATEGIES];
#endif
// Locate the points in the list using all point location strategies.

View File

@ -706,15 +706,6 @@ function(test_point_location_segments)
compile_and_run_with_flags(test_point_location segments "${flags}" segments)
endfunction()
# For backward compatibility
function(test_point_location_segments_version)
set(nt ${CGAL_GMPQ_NT})
set(kernel ${CARTESIAN_KERNEL})
set(geom_traits ${SEGMENT_GEOM_TRAITS})
set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DCGAL_ARR_POINT_LOCATION_VERSION=1")
compile_and_run_with_flags(test_point_location segments "${flags}" segments_version)
endfunction()
# For backward compatibility
function(test_point_location_segments_conversion)
set(nt ${CGAL_GMPQ_NT})
@ -1366,7 +1357,6 @@ test_overlay_segments()
test_overlay_spherical_arcs()
test_point_location_segments()
test_point_location_segments_version()
test_point_location_segments_conversion()
test_point_location_circle_segments()
test_point_location_linear()

View File

@ -911,16 +911,6 @@ test_point_location_segments()
compile_and_run_with_flags test_point_location segments "$flags"
}
# For backward compatibility
test_point_location_segments_version()
{
local nt=$CGAL_GMPQ_NT;
local kernel=$CARTESIAN_KERNEL;
local geom_traits=$SEGMENT_GEOM_TRAITS;
local flags="-DTEST_NT=$nt -DTEST_KERNEL=$kernel -DTEST_GEOM_TRAITS=$geom_traits -DCGAL_ARR_POINT_LOCATION_VERSION=1";
compile_and_run_with_flags test_point_location segments "$flags"
}
# For backward compatibility
test_point_location_segments_conversion()
{
@ -1706,7 +1696,6 @@ test_overlay_segments
test_overlay_spherical_arcs
test_point_location_segments
test_point_location_segments_version
test_point_location_segments_conversion
test_point_location_circle_segments
test_point_location_linear

View File

@ -162,9 +162,6 @@ public:
Intersection_base_point;
typedef std::variant<Intersection_base_point, Base_x_monotone_curve_2>
Intersection_base_result;
typedef const std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
const auto* base_traits = m_traits.m_base_traits;
auto base_cmp_xy = base_traits->compare_xy_2_object();
@ -187,7 +184,7 @@ public:
if (base_pt != nullptr) {
Point_2 point_plus(base_pt->first); // the extended point
*oi++ =
Intersection_result(std::make_pair(point_plus, base_pt->second));
std::make_pair(point_plus, base_pt->second);
continue;
}
@ -214,7 +211,7 @@ public:
Curve_data cv_data(cv1.data().arr(), Halfedge_handle(),
ov_bc, ov_twin_bc);
*oi++ = Intersection_result(X_monotone_curve_2(*overlap_cv, cv_data));
*oi++ = X_monotone_curve_2(*overlap_cv, cv_data);
}
return oi;

View File

@ -135,9 +135,6 @@ public:
Intersection_base_point;
typedef std::variant<Intersection_base_point, Base_x_monotone_curve_2>
Intersection_base_result;
typedef const std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
const auto* base_traits = m_traits.m_base_traits;
auto base_cmp_xy = base_traits->compare_xy_2_object();
@ -175,7 +172,7 @@ public:
Point_data pt_data(m_traits.invalid_index());
Point_2 point_plus(base_pt->first, pt_data); // the extended point
*oi++ =
Intersection_result(std::make_pair(point_plus, base_pt->second));
std::make_pair(point_plus, base_pt->second);
continue;
}
@ -202,7 +199,7 @@ public:
}
Curve_data cv_data(ov_bc, ov_twin_bc, m_traits.invalid_index());
*oi++ = Intersection_result(X_monotone_curve_2(*overlap_cv, cv_data));
*oi++ = X_monotone_curve_2(*overlap_cv, cv_data);
}
return oi;

View File

@ -116,9 +116,7 @@ public:
{
// Subdivide the curves into x-monotone subcurves.
CurvesIterator it;
std::list<CGAL::Object> objects;
std::list<CGAL::Object>::iterator obj_it;
X_monotone_curve_2 xcv;
std::list<std::variant<Point_2, X_monotone_curve_2>> objects;
std::list<X_monotone_curve_2> x_curves;
for (it = begin; it != end; it++)
@ -127,10 +125,10 @@ public:
objects.clear();
traits->make_x_monotone_2_object()(*it, std::back_inserter(objects));
for (obj_it = objects.begin(); obj_it != objects.end(); ++obj_it)
for (auto obj_it = objects.begin(); obj_it != objects.end(); ++obj_it)
{
if(CGAL::assign (xcv, *obj_it))
x_curves.push_back (xcv);
if(const X_monotone_curve_2* xcv_ptr = std::get_if<X_monotone_curve_2>(&(*obj_it)))
x_curves.push_back (*xcv_ptr);
}
}

View File

@ -630,9 +630,7 @@ _merge_two_intervals(Edge_const_handle e1, bool is_leftmost1,
// Find the next intersection of the envelopes to the right of the current
// rightmost point in the merged diagram.
// \todo Use the faster object_cast.
std::list<CGAL::Object> objects;
CGAL::Object obj;
std::list<std::variant<Intersection_point, X_monotone_curve_2>> objects;
const X_monotone_curve_2* intersection_curve;
const Intersection_point* intersection_point;
@ -641,10 +639,10 @@ _merge_two_intervals(Edge_const_handle e1, bool is_leftmost1,
while (! objects.empty()) {
// Pop the xy-lexicographically smallest intersection object.
obj = objects.front();
auto obj = objects.front();
objects.pop_front();
if ((intersection_point = CGAL::object_cast<Intersection_point>(&obj)) !=
if ((intersection_point = std::get_if<Intersection_point>(&obj)) !=
nullptr)
{
// We have a simple intersection point.
@ -725,7 +723,7 @@ _merge_two_intervals(Edge_const_handle e1, bool is_leftmost1,
else {
// We have an x-monotone curve representing an overlap of the two
// curves.
intersection_curve = CGAL::object_cast<X_monotone_curve_2>(&obj);
intersection_curve = std::get_if<X_monotone_curve_2>(&obj);
if (intersection_curve == nullptr)
CGAL_error_msg("unrecognized intersection object.");

View File

@ -47,7 +47,6 @@ public:
typedef typename Kernel::Ray_2 Ray_2;
typedef typename Kernel::Line_2 Line_2;
typedef typename Kernel::Line_3 Line_3;
typedef typename Kernel::Object_3 Object_3;
typedef std::pair<Curve_2, Multiplicity> Intersection_curve;
typedef typename Base::Left_side_category Left_side_category;
@ -326,8 +325,8 @@ public:
const Plane_3& h = s.plane();
Line_2 proj_line(h.a(), h.b(), h.d());
*o++ = make_object(std::make_pair(X_monotone_curve_2(proj_line),
ON_ORIENTED_BOUNDARY));
*o++ = std::make_pair(X_monotone_curve_2(proj_line),
ON_ORIENTED_BOUNDARY);
return o;
}
@ -339,7 +338,7 @@ public:
Oriented_side side =
(res == SMALLER) ? ON_POSITIVE_SIDE : ON_NEGATIVE_SIDE;
*o++ = make_object(std::make_pair(X_monotone_curve_2(s.line()), side));
*o++ = std::make_pair(X_monotone_curve_2(s.line()), side);
return o;
}
};
@ -369,11 +368,10 @@ public:
{
Line_2 l1(h1.a(), h1.b(), h1.d());
Line_2 l2(h2.a(), h2.b(), h2.d());
Object obj = k.intersect_2_object()(l1, l2);
auto obj = k.intersect_2_object()(l1, l2);
Point_2 p;
if(assign(p, obj))
*o++ = make_object(p);
if(const Point_2* p = std::get_if<Point_2>(&(*obj)))
*o++ = *p;
// otherwise, the vertical planes are parallel or overlap, so we return
// nothing.
@ -382,90 +380,82 @@ public:
if(s1.is_all_plane() && s2.is_all_plane())
{
Object obj = k.intersect_3_object()(h1, h2);
Line_3 l;
if(assign(l, obj))
*o++ = make_object(Intersection_curve(project_xy(l, k), 1));
auto obj = k.intersect_3_object()(h1, h2);
CGAL_assertion(obj != std::nullopt);
if(const Line_3* l = std::get_if<Line_3>(&(*obj)))
*o++ = Intersection_curve(project_xy(*l, k), 1);
return o;
}
if(s1.is_all_plane() && !s2.is_all_plane())
{
Object obj = plane_half_plane_proj_intersection(h1,
h2,
s2.line(),
k);
if(obj.is_empty())
auto obj = plane_half_plane_proj_intersection(h1,
h2,
s2.line(),
k);
if(obj ==std::nullopt)
return o;
Line_2 temp_l;
if(assign(temp_l, obj))
if(const Line_2* line = std::get_if<Line_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(temp_l, 1));
*o++ = Intersection_curve(*line, 1);
return o;
}
Ray_2 ray;
if(assign(ray, obj))
if(const Ray_2* ray = std::get_if<Ray_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(ray, 1));
*o++ = Intersection_curve(*ray, 1);
return o;
}
return o;
}
if(!s2.is_all_plane() && s2.is_all_plane())
{
Object obj = plane_half_plane_proj_intersection(h2,
h1,
s1.line(),
k);
if(obj.is_empty())
auto obj = plane_half_plane_proj_intersection(h2,
h1,
s1.line(),
k);
if(obj == std::nullopt)
return o;
Line_2 line;
if(assign(line, obj))
if(const Line_2* line = std::get_if<Line_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(line, 1));
*o++ = Intersection_curve(*line, 1);
return o;
}
Ray_2 ray;
if(assign(ray, obj))
if(const Ray_2* ray = std::get_if<Ray_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(ray, 1));
*o++ = Intersection_curve(*ray, 1);
return o;
}
return o;
}
CGAL_assertion(!s2.is_all_plane() && !s2.is_all_plane());
Object obj =
auto obj =
half_plane_half_plane_proj_intersection(h1, s1.line(), h2, s2.line(), k);
if(obj.is_empty())
if(obj ==std::nullopt )
return o;
Line_2 line;
if(assign(line, obj))
if(const Line_2* line = std::get_if<Line_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(line, 1));
*o++ = Intersection_curve(*line, 1);
return o;
}
Ray_2 ray;
if(assign(ray, obj))
if(const Ray_2* ray = std::get_if<Ray_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(ray, 1));
*o++ = Intersection_curve(*ray, 1);
return o;
}
Segment_2 seg;
if(assign(seg, obj))
if(const Segment_2* seg = std::get_if<Segment_2>(&(*obj)))
{
*o++ = make_object(Intersection_curve(seg, 1));
*o++ = Intersection_curve(*seg, 1);
return o;
}
Point_2 p;
if(assign(p, obj))
if(const Point_2* p = std::get_if<Point_2>(&(*obj)))
{
*o++ = make_object(p);
*o++ = *p;
return o;
}
return o;

View File

@ -18,7 +18,6 @@
#include <CGAL/license/Envelope_3.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Sphere_3.h>
@ -109,28 +108,28 @@ public:
Rat_point_2 proj_center = parent.project(s.center());
Rat_circle_2 circ(proj_center, s.squared_radius());
Curve_2 curve = gt_2->construct_curve_2_object()(circ);
Object objs[2];
CGAL_assertion_code(Object *p = )
typedef std::variant<X_monotone_curve_2, Point_2> Variant;
Variant objs[2];
CGAL_assertion_code(Variant* p = )
parent.make_x_monotone_2_object()(curve, objs);
CGAL_assertion(p == objs + 2);
X_monotone_curve_2 cv1, cv2;
const X_monotone_curve_2* cv1 = std::get_if<X_monotone_curve_2>(&(objs[0]));
const X_monotone_curve_2* cv2 = std::get_if<X_monotone_curve_2>(&(objs[1]));
CGAL_assertion(assign(cv1, objs[0]));
CGAL_assertion(assign(cv2, objs[1]));
CGAL_assertion(cv1!=nullptr);
CGAL_assertion(cv2!=nullptr);
assign(cv1, objs[0]);
assign(cv2, objs[1]);
if (cv1.is_lower()) {
CGAL_assertion(cv2.is_upper());
*o++ = make_object(std::make_pair(cv1, ON_POSITIVE_SIDE));
*o++ = make_object(std::make_pair(cv2, ON_NEGATIVE_SIDE));
if (cv1->is_lower()) {
CGAL_assertion(cv2->is_upper());
*o++ = std::make_pair(*cv1, ON_POSITIVE_SIDE);
*o++ = std::make_pair(*cv2, ON_NEGATIVE_SIDE);
}
else {
CGAL_assertion(cv2.is_lower());
*o++ = make_object(std::make_pair(cv1, ON_NEGATIVE_SIDE));
*o++ = make_object(std::make_pair(cv2, ON_POSITIVE_SIDE));
CGAL_assertion(cv2->is_lower());
*o++ = std::make_pair(*cv1, ON_NEGATIVE_SIDE);
*o++ = std::make_pair(*cv2, ON_POSITIVE_SIDE);
}
return o;
@ -237,7 +236,7 @@ public:
if (n_ys == 1) {
// intersection is a point
Point_2 inter_point(xs , ys[0]);
*o++ = make_object(inter_point);
*o++ = inter_point;
return o;
}
@ -254,7 +253,7 @@ public:
Curve_2 res = ctr_cv(0, 0, 0, 2*a_diff, 0, -m, COLLINEAR, end1, end2);
parent.add_curve_to_output(res, o);
//*o++ = make_object(Intersection_curve(res, TRANSVERSAL));
//*o++ = Intersection_curve(res, TRANSVERSAL);
}
else {
// here we have c1 == c2, b1 != b2.
@ -308,7 +307,7 @@ public:
if (n_xs == 1) {
// intersection is a point
Point_2 inter_point(xs[0], (-2*a_diff*xs[0] + m)/(2*b_diff) );
*o++ = make_object(inter_point);
*o++ = inter_point;
return o;
}
@ -328,7 +327,7 @@ public:
Curve_2 res =
ctr_cv(0,0,0, 2*a_diff, 2*b_diff, -m, COLLINEAR, end1, end2);
parent.add_curve_to_output(res, o);
//*o++ = make_object(Intersection_curve(res, TRANSVERSAL));
//*o++ = Intersection_curve(res, TRANSVERSAL);
}
}
// now the potential intersection is (a part of) a circle,
@ -439,7 +438,7 @@ public:
// should check if the point is in the non-negative side of the
// line
if (CGAL_NTS sign(la*px + lb*py +lc) != NEGATIVE)
*o++ = make_object(Point_2(px, py));
*o++ = Point_2(px, py);
return o;
}
@ -460,7 +459,7 @@ public:
if (sign_lc != NEGATIVE) {
Curve_2 res = ctr_cv(R, S, T, U, V, W);
parent.add_curve_to_output(res, o);
//*o++ = make_object(Intersection_curve(res, TRANSVERSAL));
//*o++ = Intersection_curve(res, TRANSVERSAL);
}
return o;
}
@ -609,13 +608,13 @@ public:
if (lval_sign == POSITIVE) {
// the full ellipse is in the positive side
parent.add_curve_to_output(inter_cv, o);
//*o++ = make_object(Intersection_curve(inter_cv, TRANSVERSAL));
//*o++ = Intersection_curve(inter_cv, TRANSVERSAL);
return o;
}
else if (lval_sign == NEGATIVE) {
// the full ellipse is in the negative side, except maybe the point
// source in the case n_inter_points = 1 (which lies on the line)
if (n_inter_points == 1) *o++ = make_object(Point_2(source));
if (n_inter_points == 1) *o++ = Point_2(source);
return o;
}
@ -630,8 +629,8 @@ public:
CGAL_assertion(lval_sign != ZERO);
if (lval_sign == POSITIVE) parent.add_curve_to_output(inter_cv, o);
//*o++ = make_object(Intersection_curve(inter_cv, TRANSVERSAL));
else *o++ = make_object(Point_2(source));
//*o++ = Intersection_curve(inter_cv, TRANSVERSAL);
else *o++ = Point_2(source);
return o;
}
@ -651,7 +650,7 @@ public:
Curve_2 res = ctr_cv(R, S, T, U, V, W, orient, source, target);
CGAL_assertion(res.is_valid());
parent.add_curve_to_output(res, o);
//*o++ = make_object(Intersection_curve(res, TRANSVERSAL));
//*o++ = Intersection_curve(res, TRANSVERSAL);
}
return o;
@ -1118,16 +1117,16 @@ public:
template <typename OutputIterator>
OutputIterator add_curve_to_output(const Curve_2& c, OutputIterator oi) const {
Object objs[2];
Object* p_obj = this->make_x_monotone_2_object()(c, objs);
for(Object* o = objs; o != p_obj; ++o) {
X_monotone_curve_2 cv;
if(assign(cv, *o)) *oi++ = make_object(Intersection_curve(cv, 1));
std::variant<X_monotone_curve_2, Point_2> objs[2];
std::variant<X_monotone_curve_2, Point_2>* p_obj = this->make_x_monotone_2_object()(c, objs);
for(std::variant<X_monotone_curve_2, Point_2>* o = objs; o != p_obj; ++o) {
if(const X_monotone_curve_2* cv = std::get_if<X_monotone_curve_2>(o))
*oi++ = Intersection_curve(*cv, 1);
else {
Point_2 pt;
CGAL_assertion(assign(pt, *o));
assign(pt, *o);
*oi++ = make_object(pt);
const Point_2* pt = std::get_if<Point_2>(o);
CGAL_assertion(pt!=nullptr);
*oi++ = *pt;
}
}
return oi;

View File

@ -194,14 +194,15 @@ public:
Base base;
std::cerr << "Construct_projected_boundary_2: JUST FIRST" << std::endl;
std::cerr << "Surface: " << s << std::endl;
std::list<CGAL::Object> l;
// TODO UPDATE CONCEPT + CHANGES.md
std::list< std::variant<std::pair<X_monotone_curve_2, Oriented_side>, Point_2 > > l;
base.construct_projected_boundary_2_object() (s, std::back_inserter(l));
if (l.size() > 0)
{
std::pair<X_monotone_curve_2, CGAL::Oriented_side> i;
if (CGAL::assign(i, l.front()))
std::cerr << "First: " << i.first << std::endl;
if (const std::pair<X_monotone_curve_2, CGAL::Oriented_side>* i =
std::get_if<std::pair<X_monotone_curve_2, CGAL::Oriented_side>>(&l.front()))
std::cerr << "First: " << i->first << std::endl;
else
std::cerr << "First intersection is a point" << std::endl;
}
@ -232,15 +233,14 @@ public:
<< std::endl;
std::cerr << "Surface1: " << s1 << std::endl;
std::cerr << "Surface2: " << s2 << std::endl;
std::list<CGAL::Object> l;
std::list< std::variant<Intersection_curve, Point_2 > > l;
base.construct_projected_intersections_2_object() (s1, s2,
std::back_inserter(l));
if (l.size() > 0)
{
Intersection_curve i;
if (CGAL::assign(i, l.front()))
std::cerr << "First: " << i.first << std::endl;
if (const Intersection_curve* i = std::get_if<Intersection_curve>(&l.front()))
std::cerr << "First: " << i->first << std::endl;
else
std::cerr << "First intersection is not a point" << std::endl;
}

View File

@ -20,8 +20,6 @@
#include <CGAL/license/Envelope_3.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Arr_segment_traits_2.h>
@ -546,9 +544,9 @@ public:
s2 != ON_ORIENTED_BOUNDARY &&
s3 != ON_ORIENTED_BOUNDARY);
*o++ = make_object(std::make_pair(A, s1));
*o++ = make_object(std::make_pair(B, s2));
*o++ = make_object(std::make_pair(C, s3));
*o++ = std::make_pair(A, s1);
*o++ = std::make_pair(B, s2);
*o++ = std::make_pair(C, s3);
}
else
{
@ -561,8 +559,8 @@ public:
b2 = parent->project(a2);
CGAL_assertion(b1 != b2);
*o++ = make_object(std::make_pair(X_monotone_curve_2(b1, b2),
ON_ORIENTED_BOUNDARY));
*o++ = std::make_pair(X_monotone_curve_2(b1, b2),
ON_ORIENTED_BOUNDARY);
}
return o;
}
@ -611,32 +609,30 @@ public:
return o;
}
Object inter_obj = parent->intersection(s1,s2);
if (inter_obj.is_empty())
std::optional<std::variant<Point_3, Segment_3>> inter_obj
= parent->intersection(s1,s2);
if (inter_obj == std::nullopt)
{
return o;
}
Point_3 point;
Segment_3 curve;
if (k.assign_3_object()(point, inter_obj))
*o++ = make_object(parent->project(point));
if (const Point_3* point = std::get_if<Point_3>(&(*inter_obj)))
*o++ = parent->project(*point);
else
{
CGAL_assertion_code(bool b = )
k.assign_3_object()(curve, inter_obj);
CGAL_assertion(b);
const Segment_3* curve = std::get_if<Segment_3>(&(*inter_obj));
CGAL_assertion(curve != nullptr);
Segment_2 proj_seg = parent->project(curve);
Segment_2 proj_seg = parent->project(*curve);
if (! k.is_degenerate_2_object() (proj_seg))
{
Intersection_curve inter_cv (proj_seg, 1);
*o++ = make_object(inter_cv);
*o++ = inter_cv;
}
else
{
const Point_2& p = k.construct_point_on_2_object() (proj_seg, 0);
*o++ = make_object(p);
*o++ = p;
}
}
@ -1044,8 +1040,9 @@ public:
// intersect two xy-monotone surfaces (3D-triangles or segments)
// if the triangles overlap, the result is empty
// the result can be a segment or a point
Object intersection(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2) const
std::optional< std::variant<Point_3, Segment_3>>
intersection(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2) const
{
CGAL_precondition(s1.is_xy_monotone());
CGAL_precondition(s2.is_xy_monotone());
@ -1054,14 +1051,13 @@ public:
// first, try to intersect the bounding boxes of the triangles,
// efficiently return empty object when the triangles are faraway
if (!CGAL::do_overlap(s1.bbox(), s2.bbox()))
return Object();
return std::nullopt;
// if intersecting two segment - alculate the intersection
// as in the case of dimension 2
if (s1.is_segment() && s2.is_segment())
{
Object res = intersection_of_segments(s1, s2);
return res;
return intersection_of_segments(s1, s2);
}
// if both triangles lie on the same (non-vertical) plane, they overlap
@ -1070,96 +1066,92 @@ public:
Plane_3 p1 = s1.plane();
Plane_3 p2 = s2.plane();
if (p1 == p2 || p1 == p2.opposite())
return Object();
return std::nullopt;
// calculate intersection between a triangle and the other triangle's
// supporting plane
// if there is no intersection - then the triangles have no intersection
// between them.
Object inter_obj = intersection(p1, s2);
auto inter_obj = intersection(p1, s2);
if (inter_obj.is_empty())
return Object();
if (inter_obj == std::nullopt)
return std::nullopt;
// otherwise, if the intersection in a point, we should check if it lies
// inside the first triangle
Assign_3 assign_obj = k.assign_3_object();
Point_3 inter_point;
if (assign_obj(inter_point, inter_obj))
if (const Point_3* inter_point = std::get_if<Point_3>(&(*inter_obj)))
{
Object res = intersection_on_plane_3(p1, s1, inter_point);
return res;
std::optional<Point_3> res = intersection_on_plane_3(p1, s1, *inter_point);
if (res != std::nullopt)
return res.value();
}
else
{
// if the intersection is a segment, we check the intersection of the
// other plane-triangle pair
Segment_3 inter_seg;
CGAL_assertion(assign_obj(inter_seg, inter_obj));
assign_obj(inter_seg, inter_obj);
const Segment_3* inter_seg = std::get_if<Segment_3>(&(*inter_obj));
CGAL_assertion(inter_seg != nullptr);
inter_obj = intersection(p2, s1);
auto inter_obj2 = intersection(p2, s1);
// if there is no intersection - then the triangles have no intersection
// between them.
if (inter_obj.is_empty())
return Object();
if (inter_obj2 == std::nullopt)
return std::nullopt;
if (assign_obj(inter_point, inter_obj))
if (const Point_3* inter_point = std::get_if<Point_3>(&(*inter_obj2)))
{
// if the intersection is a point, which lies on the segment,
// than it is the result,
// otherwise, empty result
if (k.has_on_3_object()(inter_seg, inter_point))
return make_object(inter_point);
else
return Object();
// if the intersection is a point, which lies on the segment,
// than it is the result,
// otherwise, empty result
if (k.has_on_3_object()(*inter_seg, *inter_point))
return *inter_point;
else
return std::nullopt;
}
else
{
// both plane-triangle intersections are segments, which are collinear,
// and lie on the line which is the intersection of the two supporting
// planes
Segment_3 inter_seg2;
CGAL_assertion(assign_obj(inter_seg2, inter_obj));
assign_obj(inter_seg2, inter_obj);
// both plane-triangle intersections are segments, which are collinear,
// and lie on the line which is the intersection of the two supporting
// planes
const Segment_3* inter_seg2 = std::get_if<Segment_3>(&(*inter_obj));
CGAL_assertion(inter_seg2 != nullptr);
Point_3 min1 = k.construct_min_vertex_3_object()(inter_seg),
max1 = k.construct_max_vertex_3_object()(inter_seg);
Point_3 min2 = k.construct_min_vertex_3_object()(inter_seg2),
max2 = k.construct_max_vertex_3_object()(inter_seg2);
Point_3 min1 = k.construct_min_vertex_3_object()(*inter_seg),
max1 = k.construct_max_vertex_3_object()(*inter_seg);
Point_3 min2 = k.construct_min_vertex_3_object()(*inter_seg2),
max2 = k.construct_max_vertex_3_object()(*inter_seg2);
CGAL_assertion((k.collinear_3_object()(min1, min2, max1) &&
CGAL_assertion((k.collinear_3_object()(min1, min2, max1) &&
k.collinear_3_object()(min1, max2, max1)));
// we need to find the overlapping part, if exists
Point_3 min, max;
if (k.less_xyz_3_object()(min1, min2))
min = min2;
else
min = min1;
if (k.less_xyz_3_object()(max1, max2))
max = max1;
else
max = max2;
// we need to find the overlapping part, if exists
Point_3 min, max;
if (k.less_xyz_3_object()(min1, min2))
min = min2;
else
min = min1;
if (k.less_xyz_3_object()(max1, max2))
max = max1;
else
max = max2;
Object res;
Comparison_result comp_res = k.compare_xyz_3_object()(min, max);
if (comp_res == EQUAL)
res = make_object(min);
else if (comp_res == SMALLER)
res = make_object(Segment_3(min, max));
// else - empty result
return res;
Comparison_result comp_res = k.compare_xyz_3_object()(min, max);
if (comp_res == EQUAL)
return min;
else if (comp_res == SMALLER)
return Segment_3(min, max);
// else - empty result
}
}
return std::nullopt;
}
// calculate intersection between triangle & point on the same plane plane
Object intersection_on_plane_3(const Plane_3& plane,
const Xy_monotone_surface_3& triangle,
const Point_3& point) const
std::optional<Point_3>
intersection_on_plane_3(const Plane_3& plane,
const Xy_monotone_surface_3& triangle,
const Point_3& point) const
{
Kernel k;
CGAL_precondition( triangle.is_xy_monotone() );
@ -1177,14 +1169,15 @@ public:
else
has_on = k.has_on_3_object()(static_cast<Triangle_3>(triangle), point);
if (has_on)
return make_object(point);
return point;
else
return Object();
return std::nullopt;
}
// calculate intersection between 2 segments on the same vertical plane plane
Object intersection_of_segments(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2) const
std::optional< std::variant<Point_3, Segment_3>>
intersection_of_segments(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2) const
{
Kernel k;
CGAL_precondition( s1.is_xy_monotone() && s1.is_segment());
@ -1193,14 +1186,14 @@ public:
// if the segments are not coplanar, they cannot intersect
if (!k.coplanar_3_object()(s1.vertex(0), s1.vertex(1),
s2.vertex(0), s2.vertex(1)))
return Object();
return std::nullopt;
const Plane_3& plane = s1.plane();
if (s2.plane() != plane &&
s2.plane() != plane.opposite())
// todo: this case is not needed in the algorithm,
// so we don't implement it
return Object();
return std::nullopt;
CGAL_precondition( !k.is_degenerate_3_object()(plane) );
CGAL_precondition( s2.plane() == plane ||
@ -1212,30 +1205,24 @@ public:
v2 = plane.to_2d(s1.vertex(1));
Segment_2 seg1_t(v1, v2);
Point_2 u1 = plane.to_2d(s2.vertex(0)),
Point_2 u1 = plane.to_2d(s2.vertex(0)),
u2 = plane.to_2d(s2.vertex(1));
Segment_2 seg2_t(u1, u2);
Segment_2 seg2_t(u1, u2);
Object inter_obj = k.intersect_2_object()(seg1_t, seg2_t);
Assign_2 assign_2 = k.assign_2_object();
if (inter_obj.is_empty())
return inter_obj;
auto inter_obj = k.intersect_2_object()(seg1_t, seg2_t);
if (inter_obj == std::nullopt)
return std::nullopt;
Point_2 inter_point;
Segment_2 inter_segment;
if (assign_2(inter_point, inter_obj))
return make_object(plane.to_3d(inter_point));
if (const Point_2* inter_point = std::get_if<Point_2>(&(*inter_obj)))
return plane.to_3d(*inter_point);
else
{
CGAL_assertion_code(bool b = )
assign_2(inter_segment, inter_obj);
CGAL_assertion(b);
const Segment_2* inter_segment = std::get_if<Segment_2>(&(*inter_obj));
CGAL_assertion(inter_segment!=nullptr);
return make_object
(Segment_3
(plane.to_3d(k.construct_vertex_2_object()(inter_segment, 0)),
plane.to_3d(k.construct_vertex_2_object()(inter_segment, 1))));
return Segment_3
(plane.to_3d(k.construct_vertex_2_object()(*inter_segment, 0)),
plane.to_3d(k.construct_vertex_2_object()(*inter_segment, 1)));
}
}
@ -1244,8 +1231,9 @@ public:
// and a (non degenerate) plane in 3d
// the result object can be empty, a point, a segment or the original
// triangle
Object intersection(const Plane_3& pl,
const Xy_monotone_surface_3& tri) const
std::optional<std::variant<Point_3, Segment_3>>
intersection(const Plane_3& pl,
const Xy_monotone_surface_3& tri) const
{
Kernel k;
CGAL_precondition( tri.is_xy_monotone() );
@ -1278,24 +1266,23 @@ public:
points_on_plane[n_points_on_plane++] = i;
}
CGAL_assertion(n_points_on_plane +
n_points_on_positive + n_points_on_negative == 3);
CGAL_assertion(n_points_on_plane + n_points_on_positive + n_points_on_negative == 3);
// if all vertices of tri lie on the same size (positive/negative) of pl,
// there is no intersection
if (n_points_on_positive == 3 || n_points_on_negative == 3)
return Object();
return std::nullopt;
// if all vertices of tri lie on pl then we return tri
if (n_points_on_plane == 3)
return make_object(tri);
return tri;
// if 2 vertices lie on pl, then return the segment between them
if (n_points_on_plane == 2)
{
int point_idx1 = points_on_plane[0], point_idx2 = points_on_plane[1];
return make_object (Segment_3(tri.vertex(point_idx1),
tri.vertex(point_idx2)));
return Segment_3(tri.vertex(point_idx1),
tri.vertex(point_idx2));
}
// if only 1 lie on pl, should check the segment opposite to it on tri
@ -1306,7 +1293,7 @@ public:
// if the other 2 vertices are on the same side of pl,
// then the answer is just this vertex
if (n_points_on_negative == 2 || n_points_on_positive == 2)
return make_object(tri.vertex(point_on_plane_idx));
return tri.vertex(point_on_plane_idx);
// now it is known that one vertex is on pl, and the segment of tri
// opposite to it should intersect pl
@ -1315,15 +1302,14 @@ public:
Segment_3 tri_segment(tri.vertex(point_on_plane_idx+1),
tri.vertex(point_on_plane_idx+2));
Object inter_result = k.intersect_3_object()(pl, tri_segment);
Point_3 inter_point;
CGAL_assertion( k.assign_3_object()(inter_point, inter_result) );
k.assign_3_object()(inter_point, inter_result);
auto inter_result = k.intersect_3_object()(pl, tri_segment);
const Point_3* inter_point = std::get_if<Point_3>(&(*inter_result));
CGAL_assertion( inter_point != nullptr );
// create the resulting segment
// (between tri[point_on_plane_idx] and inter_point)
return make_object(Segment_3(tri.vertex(point_on_plane_idx),
inter_point));
return Segment_3(tri.vertex(point_on_plane_idx),
*inter_point);
}
@ -1341,16 +1327,14 @@ public:
{
Segment_3 seg(tri.vertex(points_on_positive[pos_it]),
tri.vertex(points_on_negative[neg_it]));
Object inter_result = k.intersect_3_object()(pl, seg);
Point_3 inter_point;
// the result of the intersection must be a point
CGAL_assertion( k.assign_3_object()(inter_point, inter_result) );
k.assign_3_object()(inter_point, inter_result);
inter_points[n_inter_points++] = inter_point;
auto inter_result = k.intersect_3_object()(pl, seg);
const Point_3* inter_point = std::get_if<Point_3>(&(*inter_result));
CGAL_assertion( inter_point != nullptr );
inter_points[n_inter_points++] = *inter_point;
}
CGAL_assertion( n_inter_points == 2 );
return make_object(Segment_3(inter_points[0], inter_points[1]));
return Segment_3(inter_points[0], inter_points[1]);
}
// compare the value of s1 in p1 to the value of s2 in p2
@ -1394,13 +1378,12 @@ public:
Line_3 vl = k.construct_line_3_object() (point, dir);
const Plane_3& plane = s.plane();
Object res = k.intersect_3_object()(plane, vl);
CGAL_assertion(!res.is_empty());
Point_3 ip;
CGAL_assertion(k.assign_3_object()(ip, res));
k.assign_3_object()(ip, res);
auto res = k.intersect_3_object()(plane, vl);
CGAL_assertion(res != std::nullopt);
const Point_3* ip = std::get_if<Point_3>(&(*res));
CGAL_assertion(ip != nullptr);
return ip;
return *ip;
}
}
@ -1438,12 +1421,10 @@ public:
Line_2 l(tvl_point1, tvl_point2);
Segment_2 seg(t1, t2);
Object inter_obj = k.intersect_2_object()(seg, l);
Point_2 inter_point;
CGAL_assertion_code(bool is_inter_point =)
k.assign_2_object()(inter_point, inter_obj);
CGAL_assertion(is_inter_point);
return plane.to_3d(inter_point);
auto inter_obj = k.intersect_2_object()(seg, l);
const Point_2* inter_point = std::get_if<Point_2>(&(*inter_obj));
CGAL_assertion(inter_point != nullptr);
return plane.to_3d(*inter_point);
}
Point_2 construct_middle_point(const Point_2& p1, const Point_2& p2) const
@ -1495,14 +1476,11 @@ public:
typename Kernel::Line_2 vl = k.construct_line_2_object() (pt, dir);
// Compute the intersetion between the vertical line and the given curve.
Object res = k.intersect_2_object()(seg, vl);
Point_2 ip;
bool ray_shoot_successful = k.assign_2_object()(ip, res);
auto res = k.intersect_2_object()(seg, vl);
const Point_2* ip = std::get_if<Point_2>(&(*res));
CGAL_assertion (ip != nullptr);
if (! ray_shoot_successful)
CGAL_assertion (ray_shoot_successful);
return (ip);
return *ip;
}
};

View File

@ -16,65 +16,62 @@
#include <CGAL/basic.h>
#include <CGAL/Object.h>
#include <CGAL/use.h>
namespace CGAL {
template <class K>
Object plane_half_plane_proj_intersection(const typename K::Plane_3 &h1,
const typename K::Plane_3 &h2,
const typename K::Line_2 &l,
const K& k)
std::optional< std::variant<typename K::Line_2, typename K::Ray_2, typename K::Segment_2, typename K::Point_2> >
plane_half_plane_proj_intersection(const typename K::Plane_3 &h1,
const typename K::Plane_3 &h2,
const typename K::Line_2 &l,
const K& k)
{
typedef typename K::Line_3 Line_3;
typedef typename K::Line_2 Line_2;
typedef typename K::Plane_3 Plane_3;
// intersect the two planes
Object h_obj = k.intersect_3_object()(h1, h2);
if(h_obj.is_empty())
return Object(); // no intersection at all (parallel planes)
auto h_obj = k.intersect_3_object()(h1, h2);
if(h_obj == std::nullopt)
return std::nullopt; // no intersection at all (parallel planes)
Plane_3 p;
if(assign(p, h_obj))
return Object();
if(std::get_if<Plane_3>(&(*h_obj))==nullptr)
return std::nullopt;
// if two planes are not parallel they must intersect at a 3D line
Line_3 l3;
CGAL_assertion_code(bool b =)
assign(l3, h_obj);
CGAL_assertion(b);
const Line_3* l3 = std::get_if<Line_3>(&(*h_obj));
CGAL_assertion(l3!=nullptr);
const Line_2& proj_inter_line = project_xy(l3, k);
const Line_2& proj_inter_line = project_xy(*l3, k);
return line_under_linear_constraint(proj_inter_line, l, k);
return line_under_linear_constraint(proj_inter_line, l, k); //LR
}
template <class K>
Object half_plane_half_plane_proj_intersection(const typename K::Plane_3 &h1,
const typename K::Line_2 &l1,
const typename K::Plane_3 &h2,
const typename K::Line_2 &l2,
const K& k)
std::optional< std::variant<typename K::Line_2, typename K::Ray_2, typename K::Segment_2, typename K::Point_2> >
half_plane_half_plane_proj_intersection(const typename K::Plane_3 &h1,
const typename K::Line_2 &l1,
const typename K::Plane_3 &h2,
const typename K::Line_2 &l2,
const K& k)
{
typedef typename K::Ray_2 Ray_2;
typedef typename K::Line_2 Line_2;
Object obj = plane_half_plane_proj_intersection(h1, h2, l2, k);
if(obj.is_empty())
return Object();
auto obj = plane_half_plane_proj_intersection(h1, h2, l2, k);
if(obj == std::nullopt)
return std::nullopt;
Line_2 l;
if(assign(l, obj))
return line_under_linear_constraint(l, l1, k);
if(const Line_2* line = std::get_if<Line_2>(&(*obj)))
return line_under_linear_constraint(*line, l1, k);
Ray_2 ray;
if(assign(ray, obj))
return ray_under_linear_constraint(ray, l1, k);
if(const Ray_2* ray = std::get_if<Ray_2>(&(*obj)))
return ray_under_linear_constraint(*ray, l1, k);
CGAL_error(); // doesn't suppose to reach here
return Object();
return std::nullopt;
}
template <class K>
@ -97,96 +94,91 @@ typename K::Line_2 project_xy(const typename K::Line_3& l,
// l1 is a line, l2 is a linear constraint (determined by the direction
// of the line).
template <class K>
Object line_under_linear_constraint(const typename K::Line_2& l1,
const typename K::Line_2& l2,
const K& k)
std::optional< std::variant<typename K::Line_2, typename K::Ray_2, typename K::Segment_2, typename K::Point_2> >
line_under_linear_constraint(const typename K::Line_2& l1,
const typename K::Line_2& l2,
const K& k)
{
typedef typename K::Ray_2 Ray_2;
typedef typename K::Line_2 Line_2;
typedef typename K::Vector_2 Vector_2;
typedef typename K::Point_2 Point_2;
Object obj = k.intersect_2_object()(l1, l2);
Point_2 p;
if(assign(p, obj))
{
const Vector_2& vec = k.construct_vector_2_object()(l1);
const Point_2& s = k.construct_translated_point_2_object()(p, vec);
const Ray_2& ray = k.construct_ray_2_object()(p, s);
Oriented_side side = k.oriented_side_2_object()(l2, s);
if(side == ON_NEGATIVE_SIDE)
{
return make_object(k.construct_opposite_ray_2_object()(ray));
}
auto obj = k.intersect_2_object()(l1, l2);
CGAL_assertion(side == ON_POSITIVE_SIDE); //the two lines are not parallel
return make_object(ray);
}
if(obj.is_empty()) // the two lines are parallel
if(obj == std::nullopt)// the two lines are parallel
{
const Point_2& s = k.construct_point_on_2_object()(l1, 0);
Oriented_side side = k.oriented_side_2_object()(l2, s);
if(side == ON_NEGATIVE_SIDE)
return Object();
return std::nullopt;
CGAL_assertion(side == ON_POSITIVE_SIDE); // the two lines are parallel
return make_object(l1);
return l1;
}
if(const Point_2* p = std::get_if<Point_2>(&(*obj)))
{
const Vector_2& vec = k.construct_vector_2_object()(l1);
const Point_2& s = k.construct_translated_point_2_object()(*p, vec);
const Ray_2& ray = k.construct_ray_2_object()(*p, s);
Oriented_side side = k.oriented_side_2_object()(l2, s);
if(side == ON_NEGATIVE_SIDE)
{
return k.construct_opposite_ray_2_object()(ray);
}
CGAL_assertion(side == ON_POSITIVE_SIDE); //the two lines are not parallel
return ray;
}
// the two lines overlap
CGAL_USE_TYPE(Line_2);
CGAL_assertion_code(Line_2 dummy;);
CGAL_assertion_code(bool b = assign(dummy, obj););
CGAL_assertion(b);
return make_object(l1);
return l1;
}
template <class K>
Object ray_under_linear_constraint(const typename K::Ray_2& ray,
const typename K::Line_2& l,
const K& k)
std::optional< std::variant<typename K::Line_2, typename K::Ray_2, typename K::Segment_2, typename K::Point_2> >
ray_under_linear_constraint(const typename K::Ray_2& ray,
const typename K::Line_2& l,
const K& k)
{
typedef typename K::Vector_2 Vector_2;
typedef typename K::Point_2 Point_2;
const Point_2& s = k.construct_point_on_2_object()(ray, 0);
Oriented_side side = k.oriented_side_2_object()(l, s);
Object obj = k.intersect_2_object()(ray, l);
if(obj.is_empty())
auto obj = k.intersect_2_object()(ray, l);
if(obj == std::nullopt)
{
if(side == ON_NEGATIVE_SIDE)
return Object();
return std::nullopt;
CGAL_assertion(side == ON_POSITIVE_SIDE);
return make_object(ray);
return ray;
}
Point_2 p;
if(assign(p, obj))
if(const Point_2* p = std::get_if<Point_2>(&(*obj)))
{
if(side == ON_POSITIVE_SIDE)
return make_object(k.construct_segment_2_object()(s, p));
return k.construct_segment_2_object()(s, *p);
Vector_2 vec = k.construct_vector_2_object()(ray);
if(side == ON_NEGATIVE_SIDE)
return make_object(k.construct_ray_2_object()(p, vec));
return k.construct_ray_2_object()(*p, vec);
CGAL_assertion(side == ON_ORIENTED_BOUNDARY);
const Vector_2& vec_of_l = k.construct_vector_2_object()(l);
Orientation orient = k.orientation_2_object()(vec_of_l, vec);
if(orient == LEFT_TURN)
return make_object(ray);
return ray;
CGAL_assertion(orient == RIGHT_TURN);
return make_object(s);
return s;
}
// the ray and the line overlap
return make_object(ray);
return ray;
}

View File

@ -27,7 +27,6 @@
#include <map>
#include <time.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/Arr_observer.h>
#include <CGAL/Envelope_3/Envelope_base.h>
@ -307,9 +306,8 @@ protected:
void deal_with_one_surface(Xy_monotone_surface_3& surf,
Minimization_diagram_2& result)
{
typedef std::list<Object> Boundary_list;
typedef std::pair<X_monotone_curve_2, Oriented_side> Boundary_xcurve;
typedef Boundary_list::iterator Boundary_iterator;
typedef std::list<std::variant<Boundary_xcurve,Point_2>> Boundary_list;
Boundary_list boundary;
m_geom_traits->
@ -325,17 +323,15 @@ protected:
return;
}
for (Boundary_iterator boundary_it = boundary.begin();
for (auto boundary_it = boundary.begin();
boundary_it != boundary.end();
++boundary_it)
{
const Object& obj = *boundary_it;
Boundary_xcurve boundary_cv;
if (assign(boundary_cv, obj))
if (const Boundary_xcurve* boundary_cv = std::get_if<Boundary_xcurve>(&(*boundary_it)))
{
Oriented_side side = boundary_cv.second;
Oriented_side side = boundary_cv->second;
Halfedge_handle he =
insert_non_intersecting_curve(result, boundary_cv.first);
insert_non_intersecting_curve(result, boundary_cv->first);
if (side == ON_ORIENTED_BOUNDARY)
{
@ -408,10 +404,9 @@ protected:
else
{
// the xy-surface is an isolated point
Point_2 p;
CGAL_assertion(assign(p, obj));
assign(p, obj);
insert_point(result, p);
const Point_2* p = std::get_if<Point_2>(&(*boundary_it));
CGAL_assertion(p!=nullptr);
insert_point(result, *p);
}
}

View File

@ -131,7 +131,8 @@ protected:
Vertices_to_edges_map;
typedef std::pair<X_monotone_curve_2, Multiplicity> Intersection_curve;
typedef std::list<Object> Intersections_list;
typedef std::list<std::variant<Intersection_curve,
Point_2>> Intersections_list;
// this is used in the resolve edge process
typedef Triple<Point_2, bool, bool> Point_2_with_info;
@ -199,7 +200,8 @@ public:
// find the projected intersections of the surfaces. if none - we have
// a simple case:
// need only resolve non-intersecting and return
std::list<Object> inter_objs;
std::list<std::variant<Intersection_curve, Point_2>> inter_objs;
get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
if (inter_objs.size() == 0)
@ -243,11 +245,6 @@ public:
map_copied_to_orig_faces[copied_face] = face;
// insert the projected intersections into the temporary minimization diagram
Point_2 point;
Intersection_curve curve;
Object cur_obj;
// we use our zone visitor, which only inserts into the arrangement the
// points and curves which are inside the copied face
// it updates the result arrangement at the same time (action after action
@ -287,12 +284,10 @@ public:
this);
Md_point_location pl(copied_face_arr);
std::list<Object>::iterator inter_objs_it = inter_objs.begin();
for (; inter_objs_it != inter_objs.end(); ++inter_objs_it)
for (auto inter_objs_it = inter_objs.begin();
inter_objs_it != inter_objs.end(); ++inter_objs_it)
{
cur_obj = *inter_objs_it;
CGAL_assertion(!cur_obj.is_empty());
if (assign(point, cur_obj))
if (const Point_2* point = std::get_if<Point_2>(&(*inter_objs_it)))
{
// intersection can be a point when the surfaces only touch each other.
// we are only interested in the points that are inside the face or
@ -302,12 +297,12 @@ public:
// should use observer for split_edge
// if not in a sub-face of "face", shouldn't insert it
// the above information is available in zone_visitor
insert_point(copied_face_arr, point, pl, zone_visitor);
insert_point(copied_face_arr, *point, pl, zone_visitor);
}
else if (assign(curve, cur_obj))
else if (const Intersection_curve* curve = std::get_if<Intersection_curve>(&(*inter_objs_it)))
{
zone_visitor.set_current_intersection_type(curve.second);
insert(copied_face_arr, curve.first, pl, zone_visitor);
zone_visitor.set_current_intersection_type(curve->second);
insert(copied_face_arr, curve->first, pl, zone_visitor);
CGAL_assertion(copied_face_arr.is_valid());
CGAL_assertion(result.is_valid());
}
@ -485,7 +480,7 @@ public:
const Xy_monotone_surface_3& surf2 = get_aux_surface(edge, 1);
// find the projected intersections
std::list<Object> inter_objs;
std::list<std::variant<Intersection_curve, Point_2>> inter_objs;
get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
if (inter_objs.size() == 0)
@ -522,48 +517,38 @@ public:
bool is_min_end_at_inf = false;
bool is_max_end_at_inf = false;
Point_2 point;
Intersection_curve icurve;
Object cur_obj;
std::list<Object>::iterator inter_objs_it = inter_objs.begin();
for (; inter_objs_it != inter_objs.end(); ++inter_objs_it)
for (auto inter_objs_it = inter_objs.begin();
inter_objs_it != inter_objs.end(); ++inter_objs_it)
{
cur_obj = *inter_objs_it;
CGAL_assertion(!cur_obj.is_empty());
if (assign(point, cur_obj))
if (const Point_2* point = std::get_if<Point_2>(&(*inter_objs_it)))
{
// if the point is on the curve, should add it the split points
// list, otherwise, it is irrelevant and should be ignored
if (is_point_on_curve(point, original_cv))
split_points.push_back(Point_2_with_info(point, false, false));
if (is_point_on_curve(*point, original_cv))
split_points.push_back(Point_2_with_info(*point, false, false));
}
else if (assign(icurve, cur_obj))
else if (const Intersection_curve* icurve = std::get_if<Intersection_curve>(&(*inter_objs_it)))
{
const X_monotone_curve_2& x_curve = icurve.first;
const X_monotone_curve_2& x_curve = icurve->first;
// find the intersection points and overlapping segments with the
// original curve and insert them to the list of split points
// intersect the x-monotone curve with the edge's curve
typedef std::pair<Point_2, unsigned int> Intersect_point_2;
std::list<Object> intersections_list;
const Intersect_point_2* ip;
const X_monotone_curve_2* icv;
std::list<std::variant<X_monotone_curve_2, Intersect_point_2>> intersections_list;
m_traits->intersect_2_object()(x_curve, original_cv,
std::back_inserter(intersections_list));
std::list<Object>::iterator inter_it = intersections_list.begin();
for (; inter_it != intersections_list.end(); ++inter_it)
for (auto inter_it = intersections_list.begin(); inter_it != intersections_list.end(); ++inter_it)
{
ip = object_cast<Intersect_point_2>(&(*inter_it));
if (ip != nullptr)
if (const Intersect_point_2* ip = std::get_if<Intersect_point_2>(&(*inter_it)))
{
split_points.push_back(Point_2_with_info(ip->first, false, false));
}
else
{
icv = object_cast<X_monotone_curve_2>(&(*inter_it));
const X_monotone_curve_2* icv = std::get_if<X_monotone_curve_2>(&(*inter_it));
CGAL_assertion(icv != nullptr);
// we will add the *icv end points to the split_points, unless
@ -791,15 +776,15 @@ protected:
const Vertex_const_handle* vh;
Vertex_handle vh_for_p;
CGAL::Object obj = pl.locate(p);
auto obj = pl.locate(p);
visitor.init(&arr);
if ((fh = object_cast<Face_const_handle>(&obj))
if ((fh = std::get_if<Face_const_handle>(&obj))
!= nullptr)
{
vh_for_p = visitor.found_point_in_face(p, arr.non_const_handle(*fh));
}
else if ((hh = object_cast<Halfedge_const_handle>(&obj)) != nullptr)
else if ((hh = std::get_if<Halfedge_const_handle>(&obj)))
{
vh_for_p = visitor.found_point_on_edge(p , arr.non_const_handle(*hh));
}
@ -807,7 +792,7 @@ protected:
{
// In this case p lies on an existing vertex, so we just update this
// vertex.
vh = object_cast<Vertex_const_handle>(&obj);
vh = std::get_if<Vertex_const_handle>(&obj);
CGAL_assertion(vh != nullptr);
vh_for_p = visitor.found_point_on_vertex(p, arr.non_const_handle(*vh));
}

View File

@ -18,7 +18,6 @@
#include <CGAL/Envelope_3/Envelope_overlay_2.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <iostream>
@ -116,49 +115,41 @@ public:
Xy_monotone_surface_3 &cur_surface = surfaces[i];
// first insert all the projected curves of the boundary of the current surface
// collect the curve in this list, and use sweepline at the end
std::list<Object> boundary_list;
typedef std::pair<X_monotone_curve_2, Oriented_side> Boundary_xcurve;
std::list<std::variant<Boundary_xcurve, Point_2>> boundary_list;
typedef std::list<Object>::const_iterator Boundary_iterator;
traits.construct_projected_boundary_2_object()(cur_surface, std::back_inserter(boundary_list));
for(Boundary_iterator boundary_it = boundary_list.begin();
for(auto boundary_it = boundary_list.begin();
boundary_it != boundary_list.end();
++boundary_it)
{
const Object& obj = *boundary_it;
Boundary_xcurve boundary_cv;
assert(assign(boundary_cv, obj));
assign(boundary_cv, obj);
curves_col.push_back(boundary_cv.first);
const Boundary_xcurve* boundary_cv = std::get_if<Boundary_xcurve>(&(*boundary_it));
assert(boundary_cv!=nullptr);
curves_col.push_back(boundary_cv->first);
}
// second, intersect it with all surfaces before it
Object cur_obj;
for(j=0; j<i; ++j)
{
Xy_monotone_surface_3& prev_surface = surfaces[j];
std::vector<Object> inter_objs;
std::vector<std::variant<Intersection_curve,Point_2>> inter_objs;
traits.construct_projected_intersections_2_object()(cur_surface, prev_surface, std::back_inserter(inter_objs));
// we collect all intersections and use sweep to insert them
Point_2 point;
Intersection_curve curve;
for(std::size_t k=0; k<inter_objs.size(); ++k)
{
cur_obj = inter_objs[k];
assert(!cur_obj.is_empty());
if (CGAL::assign(point, cur_obj))
if (const Point_2* point = std::get_if<Point_2>(&inter_objs[k]))
{
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "intersection between surfaces is a point: " << point << std::endl;
#endif
//insert_vertex(result, point, pl);
points_col.push_back(point);
points_col.push_back(*point);
}
else if (CGAL::assign(curve, cur_obj))
else if (const Intersection_curve* curve = std::get_if<Intersection_curve>(&inter_objs[k]))
{
curves_col.push_back(curve.first);
curves_col.push_back(curve->first);
/*#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl;
#endif

View File

@ -17,7 +17,6 @@
#include <CGAL/Envelope_3/Envelope_overlay_2.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <iostream>
@ -130,48 +129,40 @@ public:
#endif
// collect the curve in this list, and use sweepline at the end
std::list<Object> boundary_list;
typedef std::pair<X_monotone_curve_2, Oriented_side> Boundary_xcurve;
std::list<std::variant<Boundary_xcurve, Point_2>> boundary_list;
traits.construct_projected_boundary_2_object()
(cur_surface, std::back_inserter(boundary_list));
std::list<Object>::const_iterator bit;
for (bit = boundary_list.begin(); bit != boundary_list.end(); ++bit) {
const Object& obj = *bit;
Boundary_xcurve boundary_cv;
assert(assign(boundary_cv, obj));
assign(boundary_cv, obj);
curves_col.push_back(boundary_cv.first);
for (auto bit = boundary_list.begin(); bit != boundary_list.end(); ++bit) {
const Boundary_xcurve* boundary_cv = std::get_if<Boundary_xcurve>(&(*bit));
assert(boundary_cv!=nullptr);
curves_col.push_back(boundary_cv->first);
}
// second, intersect it with all surfaces before it
Object cur_obj;
for (unsigned int j = 0; j < i; ++j) {
Xy_monotone_surface_3& prev_surface = surfaces[j];
std::vector<Object> inter_objs;
std::vector<std::variant<Intersection_curve,Point_2>> inter_objs;
traits.construct_projected_intersections_2_object()
(cur_surface, prev_surface, std::back_inserter(inter_objs));
// we collect all intersections and use sweep to insert them
Point_2 point;
Intersection_curve curve;
for(std::size_t k=0; k<inter_objs.size(); ++k)
{
cur_obj = inter_objs[k];
assert(!cur_obj.is_empty());
if (CGAL::assign(point, cur_obj)) {
if (const Point_2* point = std::get_if<Point_2>(&inter_objs[k])) {
#ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3
std::cout << "intersection between surfaces is a point: "
<< point << std::endl;
#endif
//insert_vertex(result, point, pl);
points_col.push_back(point);
points_col.push_back(*point);
}
else if (CGAL::assign(curve, cur_obj)) {
else if (const Intersection_curve* curve = std::get_if<Intersection_curve>(&inter_objs[k])) {
#ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3
std::cout << "intersection between surfaces is a curve: "
<< curve.first << std::endl;
#endif
curves_col.push_back(curve.first);
curves_col.push_back(curve->first);
//insert(result, curve.first, pl);
}
else
@ -262,20 +253,17 @@ public:
// foreach face in the test envelope, compute a point inside the face,
// locate it in the other envelope and compare the surfaces over the 2 faces
Md_point_location pl(env);
Object pl_obj;
Face_const_handle pl_fh;
Face_iterator fi = test_env.faces_begin();
bool eq, result = true;
for (; fi != test_env.faces_end(); ++fi) {
Face_handle fh = fi;
if (!fh->is_unbounded()) {
Point_2 inside_test = compute_point_inside_face(test_env, fh);
pl_obj = pl.locate(inside_test);
auto pl_obj = pl.locate(inside_test);
// faces of env must contain the faces of test
bool located_in_face = assign(pl_fh, pl_obj);
assert(located_in_face);
eq = fh->is_equal_data(pl_fh->begin_data(), pl_fh->end_data());
const Face_const_handle* pl_fh = std::get_if<Face_const_handle>(&pl_obj);
assert(pl_fh!=nullptr);
eq = fh->is_equal_data((*pl_fh)->begin_data(), (*pl_fh)->end_data());
assert(eq);
result &= eq;
}

View File

@ -14,6 +14,14 @@ Release date: October 2023
- **Breaking change**: The usage of `boost::optional` has been replaced by `std::optional`. Packages affected are 2D Straight Line Skeleton, 3D Fast Intersection and Distance Computation (AABB Tree), and the Kernel intersection.
- **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection.
#### 2D Arrangements
- **Breaking change**: The type of the result of point location queries changed to
`std::variant`. The support for the old macro `CGAL_ARR_POINT_LOCATION_VERSION`
has been removed.
#### Envelopes of Surfaces in 3D
- ** Breaking change**: Construct_projected_boundary_2 in `EnvelopeTraits_3` is now using `std::variant` instead of `Object`
[Release 5.6](https://github.com/CGAL/cgal/releases/tag/v5.6)
-----------

View File

@ -299,9 +299,6 @@ public:
typedef std::pair<Base_point_2, Multiplicity> Intersection_base_point;
typedef std::variant<Intersection_base_point, Base_x_monotone_curve_2>
Intersection_base_result;
typedef std::pair<Point_2, Multiplicity> Intersection_point;
typedef std::variant<Intersection_point, X_monotone_curve_2>
Intersection_result;
// In case the curves are adjacent in their curve sequence, we do
// not have to compute their intersection (we already know that they
@ -321,8 +318,7 @@ public:
if (base_pt != nullptr) {
// Attach an invalid label to an itersection point.
*oi++ = Intersection_result(std::make_pair(Point_2(base_pt->first),
base_pt->second));
*oi++ = std::make_pair(Point_2(base_pt->first), base_pt->second);
continue;
}
@ -331,10 +327,9 @@ public:
CGAL_assertion(base_xcv != nullptr);
// Attach a merged label to the overlapping curve.
*oi++ =
Intersection_result(X_monotone_curve_2(*base_xcv,
X_curve_label(cv1.label(),
cv2.label())));
*oi++ = X_monotone_curve_2(*base_xcv,
X_curve_label(cv1.label(),
cv2.label()));
}
return oi;