Cleaned up

This commit is contained in:
Efi Fogel 2025-10-21 14:49:00 +03:00
parent 93d5fecf1c
commit 4d85bc3e63
1 changed files with 107 additions and 119 deletions

View File

@ -45,8 +45,7 @@ namespace CGAL {
namespace draw_aos {
template <typename Arr, typename GSOptions>
class Draw_arr_tool
{
class Draw_arr_tool {
public:
using Halfedge_const_handle = typename Arr::Halfedge_const_handle;
using Vertex_const_handle = typename Arr::Vertex_const_handle;
@ -58,14 +57,15 @@ public:
using Point = typename Arr::Point_2;
using X_monotone_curve = typename Arr::X_monotone_curve_2;
/*! Construct
/*! constructs
*/
Draw_arr_tool(Arr& a_aos, CGAL::Graphics_scene& a_gs, const GSOptions& a_gso)
: m_aos(a_aos)
, m_gs(a_gs)
, m_gso(a_gso) {}
Draw_arr_tool(Arr& a_aos, CGAL::Graphics_scene& a_gs, const GSOptions& a_gso) :
m_aos(a_aos),
m_gs(a_gs),
m_gso(a_gso)
{}
/// Add a face.
//! adds a face.
void add_face(Face_const_handle face) {
// std::cout << "add_face()\n";
for (Inner_ccb_const_iterator it = face->inner_ccbs_begin(); it != face->inner_ccbs_end(); ++it) add_ccb(*it);
@ -78,7 +78,7 @@ public:
}
}
/// Add a Connected Component of the Boundary.
//! adds a Connected Component of the Boundary.
void add_ccb(Ccb_halfedge_const_circulator circ) {
// std::cout << "add_ccb()\n";
auto curr = circ;
@ -90,7 +90,7 @@ public:
} while(++curr != circ);
}
/// Draw a region.
//! draws a region.
void draw_region(Ccb_halfedge_const_circulator circ) {
// std::cout << "draw_region()\n";
/* Check whether the traits has a member function called
@ -128,21 +128,21 @@ public:
m_gs.face_end();
}
/// Compile time dispatching
//! Compile time dispatching
///
//!
template <typename T, typename A, std::enable_if_t<!has_approximate_point_v<T, A>, int> = 0>
void draw_region_impl2(const T& /* traits */, const A& /* approximate */, Halfedge_const_handle curr) {
draw_exact_region(curr);
}
///
//!
template <typename T, typename A, std::enable_if_t<has_approximate_point_v<T, A>, int> = 0>
auto draw_region_impl2(const T& /* traits */, const A& approx, Halfedge_const_handle curr) {
draw_approximate_region(curr, approx);
}
/*! Draw a region, where the traits does not has approximate_2_object.
/*! draws a region, where the traits does not has approximate_2_object.
*/
template <typename T, std::enable_if_t<!has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
void draw_region_impl1(const T& /* traits */, Halfedge_const_handle curr) {
@ -156,7 +156,7 @@ public:
draw_region_impl2(traits, traits.approximate_2_object(), curr);
}
/*! Draw a geodesic region
/*! draws a geodesic region
*/
template <typename T, std::enable_if_t<is_or_derived_from_agas_v<T>, int> = 0>
void draw_region_impl1(const T& traits, Halfedge_const_handle curr) {
@ -164,7 +164,7 @@ public:
draw_curve_impl1(traits, curr->curve(), false, CGAL::IO::Color());
}
/*! Draw a region using approximate coordinates.
/*! draws a region using approximate coordinates.
* Call this member function only if the geometry traits is equipped with
* the coordinate-approximation functionality of a curve.
* This function must be inlined (e.g., a template) to enable the
@ -183,7 +183,7 @@ public:
for (; it != polyline.end(); prev = it++) m_gs.add_point_in_face(*prev);
}
/*! Draw an exact curve.
/*! draws an exact curve.
*/
template <typename XMonotoneCurve>
void draw_exact_curve(const XMonotoneCurve& curve, bool colored, const CGAL::IO::Color& c) {
@ -197,20 +197,20 @@ public:
m_gs.add_segment(ctr_min(curve), ctr_max(curve));
}
/*! Draw a region in an exact manner.
/*! draws a region in an exact manner.
* This fallback simply draws the curve in an exact manner (and even this is not guaranteed).
*/
void draw_exact_region(Halfedge_const_handle curr) { draw_exact_curve(curr->curve(), false, CGAL::IO::Color()); }
/// Add all faces.
//! Add all faces.
template <typename Traits>
void add_faces(const Traits&) {
for (auto it = m_aos.unbounded_faces_begin(); it != m_aos.unbounded_faces_end(); ++it) add_face(it);
}
/// Compile time dispatching
//! Compile time dispatching
/*! Draw a point using approximate coordinates.
/*! draws a point using approximate coordinates.
*/
template <typename Approximate>
void draw_approximate_point(const Point& p, const Approximate& approx, bool colored, const CGAL::IO::Color& color) {
@ -220,7 +220,7 @@ public:
m_gs.add_point(approx(p));
}
///
//!
void draw_exact_point(const Point& p, bool colored, const CGAL::IO::Color& color) {
if (colored)
m_gs.add_point(p, color);
@ -228,35 +228,35 @@ public:
m_gs.add_point(p);
}
///
//!
template <typename T, typename A, std::enable_if_t<!has_approximate_point_v<T, A>, int> = 0>
void draw_point_impl2(
const T& /* traits */, const A& /* approximate */, const Point& p, bool colored, const CGAL::IO::Color& c) {
draw_exact_point(p, colored, c);
}
///
//!
template <typename T, typename A, std::enable_if_t<has_approximate_point_v<T, A>, int> = 0>
auto
draw_point_impl2(const T& /* traits */, const A& approx, const Point& p, bool colored, const CGAL::IO::Color& c) {
draw_approximate_point(p, approx, colored, c);
}
/*! Draw a point, where the traits does not has approximate_2_object.
/*! draws a point, where the traits does not has approximate_2_object.
*/
template <typename T, std::enable_if_t<!has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
void draw_point_impl1(const T& /* traits */, const Point& p, bool colored, const CGAL::IO::Color& c) {
draw_exact_point(p, colored, c);
}
/*! Draw a point, where the traits does have approximate_2_object.
/*! draws a point, where the traits does have approximate_2_object.
*/
template <typename T, std::enable_if_t<has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
auto draw_point_impl1(const T& traits, const Point& p, bool colored, const CGAL::IO::Color& c) {
draw_point_impl2(traits, traits.approximate_2_object(), p, colored, c);
}
/*! Draw a geodesic point.
/*! draws a geodesic point.
*/
template <typename T, std::enable_if_t<is_or_derived_from_agas_v<T>, int> = 0>
void draw_point_impl1(const T& traits, const Point& p, bool colored, const CGAL::IO::Color& color) {
@ -277,7 +277,7 @@ public:
m_gs.add_point(p3);
}
/// Draw a point.
//! draws a point.
void draw_point(const Point& p, bool colored, const CGAL::IO::Color& c) {
const auto* traits = m_aos.geometry_traits();
draw_point_impl1(*traits, p, colored, c);
@ -286,11 +286,10 @@ public:
///
template <typename Kernel, int AtanX, int AtanY>
Halfedge_const_handle find_smallest(Ccb_halfedge_const_circulator circ,
Arr_geodesic_arc_on_sphere_traits_2<Kernel, AtanX, AtanY> const&) {
return circ;
}
Arr_geodesic_arc_on_sphere_traits_2<Kernel, AtanX, AtanY> const&)
{ return circ; }
/*! Find the halfedge incident to the lexicographically smallest vertex
/*! finds the halfedge incident to the lexicographically smallest vertex
* along the CCB, such that there is no other halfedge underneath.
*/
template <typename Traits>
@ -302,8 +301,7 @@ public:
// Find the first halfedge directed from left to right
auto curr = circ;
do
if(curr->direction() == CGAL::ARR_LEFT_TO_RIGHT) break;
do if (curr->direction() == CGAL::ARR_LEFT_TO_RIGHT) break;
while(++curr != circ);
Halfedge_const_handle ext = curr;
@ -332,7 +330,7 @@ public:
return ext;
}
/// Add all elements to be drawn.
//! adds all elements to be drawn.
void add_elements() {
// std::cout << "add_elements()\n";
// std::cout << "ratio: " << this->pixel_ratio() << std::endl;
@ -369,7 +367,7 @@ public:
m_visited.clear();
}
/*! Draw a curve using approximate coordinates.
/*! draws a curve using approximate coordinates.
* Call this member function only of the geometry traits is equipped with
* the coordinate-aproximation functionality of a curve.
* This function must be inlined (e.g., a template) to enable the
@ -412,14 +410,14 @@ public:
draw_approximate_curve(xcv, approx, colored, c);
}
/*! Draw a curve, where the traits does not has approximate_2_object.
/*! draws a curve, where the traits does not has approximate_2_object.
*/
template <typename T, std::enable_if_t<!has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
void draw_curve_impl1(const T& /* traits */, const X_monotone_curve& xcv, bool colored, const CGAL::IO::Color& c) {
draw_exact_curve(xcv, colored, c);
}
/*! Draw a curve, where the traits does have approximate_2_object.
/*! draws a curve, where the traits does have approximate_2_object.
*/
template <typename T, std::enable_if_t<has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
auto draw_curve_impl1(const T& traits, const X_monotone_curve& xcv, bool colored, const CGAL::IO::Color& c) {
@ -427,7 +425,7 @@ public:
draw_curve_impl2(traits, traits.approximate_2_object(), xcv, colored, c);
}
/*! Draw a geodesic curve
/*! draws a geodesic curve
*/
template <typename T, std::enable_if_t<is_or_derived_from_agas_v<T>, int> = 0>
void draw_curve_impl1(const T& traits, const X_monotone_curve& xcv, bool colored, const CGAL::IO::Color& c) {
@ -462,7 +460,7 @@ public:
}
}
/// Draw a curve.
//! draws a curve.
template <typename XMonotoneCurve>
void draw_curve(const XMonotoneCurve& curve, bool colored, const CGAL::IO::Color& c) {
/* Check whether the traits has a member function called
@ -511,8 +509,7 @@ static auto map_from_pair_ranges(Range1 range1, Range2 range2) {
boost::make_transform_iterator(end, tuple_to_pair));
}
/*!
* \brief tracking changes between an arrangement and its copy that will be later inserted to.
/*! \brief tracking changes between an arrangement and its copy that will be later inserted to.
*
* \note tracks insertions only. If any other actions made(e.g. deletions, merging, etc), the state of the tracker
* instance may become invalid.
@ -520,8 +517,7 @@ static auto map_from_pair_ranges(Range1 range1, Range2 range2) {
* \tparam Arrangement
*/
template <typename Arrangement>
class Arr_insertion_tracker : Arr_observer<Arrangement>
{
class Arr_insertion_tracker : Arr_observer<Arrangement> {
using Base = Arr_observer<Arrangement>;
using Halfedge_handle = typename Arrangement::Halfedge_handle;
using Halfedge_const_handle = typename Arrangement::Halfedge_const_handle;
@ -539,8 +535,7 @@ protected:
m_halfedge_map[e->twin()] = Halfedge_const_handle(); // twin is created as well
}
virtual void before_split_edge(Halfedge_handle e,
Vertex_handle v,
virtual void before_split_edge(Halfedge_handle e, Vertex_handle v,
const X_monotone_curve_2& c1,
const X_monotone_curve_2& c2) override {
if (m_vertex_map.find(v) == m_vertex_map.end()) m_vertex_map[v] = Vertex_const_handle(); // v is newly created
@ -564,11 +559,9 @@ protected:
}
public:
Arr_insertion_tracker(Arrangement& arr)
: Base(arr) {}
Arr_insertion_tracker(Arrangement& arr) : Base(arr) {}
/*!
* \brief Query the original face of a given face.
/*! \brief Query the original face of a given face.
*
* \param fh a valid face handle in the modified arrangement.
* \return Face_const_handle
@ -579,8 +572,7 @@ public:
return it->second; // new face from splitting an existing face
}
/*!
* \brief Query the original halfedge of a given halfedge.
/*! \brief Query the original halfedge of a given halfedge.
*
* \param heh a valid halfedge handle in the modified arrangement.
* \return Halfedge_const_handle
@ -592,8 +584,7 @@ public:
return it->second;
}
/*!
* \brief Query the original vertex of a given vertex.
/*! \brief Query the original vertex of a given vertex.
*
* \param vh a valid vertex handle in the modified arrangement.
* \return Vertex_const_handle
@ -634,13 +625,12 @@ void draw_impl_planar(
}
template <typename Arrangement, typename GSOptions>
void draw_impl_agas(
const Arrangement& arr, const GSOptions& gso, const char* title, Bbox_2 initial_bbox, QApplication& app) {
void draw_impl_agas(const Arrangement& arr, const GSOptions& gso,
const char* title, Bbox_2 initial_bbox, QApplication& app) {
using Halfedge_const_handle = typename Arrangement::Halfedge_const_handle;
using Face_const_handle = typename Arrangement::Face_const_handle;
using Vertex_const_handle = typename Arrangement::Vertex_const_handle;
using Geom_traits = typename Arrangement::Geometry_traits_2;
using X_monotone_curve_2 = typename Geom_traits::X_monotone_curve_2;
using Direction_3 = typename Geom_traits::Direction_3;
using Point_2 = typename Geom_traits::Point_2;
using Agas_template_args = tmpl_args<Geom_traits>;
@ -650,14 +640,14 @@ void draw_impl_agas(
arr.vertex_handles());
auto halfedge_map = map_from_pair_ranges<Halfedge_const_handle, Halfedge_const_handle>(derived_arr.halfedge_handles(),
arr.halfedge_handles());
auto face_map =
map_from_pair_ranges<Face_const_handle, Face_const_handle>(derived_arr.face_handles(), arr.face_handles());
auto face_map = map_from_pair_ranges<Face_const_handle, Face_const_handle>(derived_arr.face_handles(),
arr.face_handles());
// setup tracker and insert the identification curve.
Arr_insertion_tracker<Arrangement> tracker(derived_arr);
X_monotone_curve_2 id_curve = arr.geometry_traits()->construct_x_monotone_curve_2_object()(
Point_2(Direction_3(0, 0, -1), Point_2::MIN_BOUNDARY_LOC),
Point_2(Direction_3(0, 0, 1), Point_2::MAX_BOUNDARY_LOC),
Direction_3(Agas_template_args::atan_y, -Agas_template_args::atan_x, 0));
Point_2 src(Direction_3(0, 0, -1), Point_2::MIN_BOUNDARY_LOC);
Point_2 trg(Direction_3(0, 0, 1), Point_2::MAX_BOUNDARY_LOC);
auto ctr_xcv = arr.geometry_traits()->construct_x_monotone_curve_2_object();
auto id_curve = ctr_xcv(src, trg, Direction_3(Agas_template_args::atan_y, -Agas_template_args::atan_x, 0));
insert(derived_arr, id_curve);
// derived_gso proxies the call to the original gso
@ -731,8 +721,7 @@ void draw(const Arrangement& arr, const GSOptions& gso, Args&&... args) {
} // namespace draw_aos
/*!
* \brief Draw an arrangement on surface.
/*! \brief draws an arrangement on surface.
*
* \tparam Arrangement
* \tparam GSOptions
@ -762,8 +751,7 @@ void draw(const Arrangement& arr,
draw_aos::draw(arr, gso, title, initial_bbox, app);
}
/*!
* \brief Draw an arrangement on surface with default graphics scene options. Faces are colored randomly.
/*! \brief draws an arrangement on surface with default graphics scene options. Faces are colored randomly.
*
* \tparam Arrangement
* \param arr the arrangement to be drawn
@ -833,7 +821,7 @@ void add_to_graphics_scene(const CGAL_ARR_TYPE& aos, CGAL::Graphics_scene& graph
add_to_graphics_scene(aos, graphics_scene, gso);
}
/// Draw an arrangement on surface.
//! draws an arrangement on surface.
template <typename GeometryTraits_2, typename TopologyTraits, class GSOptions>
void draw_old(const CGAL_ARR_TYPE& aos,
const GSOptions& gso,
@ -843,7 +831,7 @@ void draw_old(const CGAL_ARR_TYPE& aos,
draw_graphics_scene(graphics_scene, title);
}
/// Draw an arrangement on surface.
//! draws an arrangement on surface.
template <typename GeometryTraits_2, typename TopologyTraits>
void draw_old(const CGAL_ARR_TYPE& aos, const char* title = "2D Arrangement on Surface Basic Viewer") {
CGAL::Graphics_scene graphics_scene;