mirror of https://github.com/CGAL/cgal
Cleaned up
This commit is contained in:
parent
e70cf9fa17
commit
616931594a
|
|
@ -16,7 +16,8 @@
|
||||||
#ifndef ARR_VIEWER_H
|
#ifndef ARR_VIEWER_H
|
||||||
#define ARR_VIEWER_H
|
#define ARR_VIEWER_H
|
||||||
|
|
||||||
#include "CGAL/Draw_aos/type_utils.h"
|
#include <CGAL/license/Arrangement_on_surface_2.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
@ -31,22 +32,22 @@
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QtGui/QMouseEvent>
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QtGui/QKeyEvent>
|
||||||
|
|
||||||
#include <CGAL/Qt/camera.h>
|
|
||||||
#include <CGAL/Arr_linear_traits_2.h>
|
#include <CGAL/Arr_linear_traits_2.h>
|
||||||
#include <CGAL/Arr_segment_traits_2.h>
|
#include <CGAL/Arr_segment_traits_2.h>
|
||||||
#include <CGAL/Basic_viewer.h>
|
#include <CGAL/Basic_viewer.h>
|
||||||
#include <CGAL/Bbox_2.h>
|
#include <CGAL/Bbox_2.h>
|
||||||
#include <CGAL/Graphics_scene.h>
|
#include "CGAL/Draw_aos/type_utils.h"
|
||||||
#include <CGAL/Graphics_scene_options.h>
|
|
||||||
#include <CGAL/Draw_aos/Arr_bounded_renderer.h>
|
#include <CGAL/Draw_aos/Arr_bounded_renderer.h>
|
||||||
#include <CGAL/Draw_aos/Arr_render_context.h>
|
#include <CGAL/Draw_aos/Arr_render_context.h>
|
||||||
|
#include <CGAL/Graphics_scene.h>
|
||||||
|
#include <CGAL/Graphics_scene_options.h>
|
||||||
|
#include <CGAL/Qt/camera.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace draw_aos {
|
namespace draw_aos {
|
||||||
|
|
||||||
template <typename Arrangement, typename GSOptions>
|
template <typename Arrangement, typename GSOptions>
|
||||||
class Arr_viewer : public Qt::Basic_viewer
|
class Arr_viewer : public Qt::Basic_viewer {
|
||||||
{
|
|
||||||
using Basic_viewer = Qt::Basic_viewer;
|
using Basic_viewer = Qt::Basic_viewer;
|
||||||
using Vertex_const_handle = typename Arrangement::Vertex_const_handle;
|
using Vertex_const_handle = typename Arrangement::Vertex_const_handle;
|
||||||
using Halfedge_const_handle = typename Arrangement::Halfedge_const_handle;
|
using Halfedge_const_handle = typename Arrangement::Halfedge_const_handle;
|
||||||
|
|
@ -64,9 +65,7 @@ private:
|
||||||
this->camera_->computeModelViewMatrix();
|
this->camera_->computeModelViewMatrix();
|
||||||
this->camera_->getProjectionMatrix(proj_mat.data());
|
this->camera_->getProjectionMatrix(proj_mat.data());
|
||||||
this->camera_->getModelViewMatrix(mv_mat.data());
|
this->camera_->getModelViewMatrix(mv_mat.data());
|
||||||
if(proj_mat == m_last_proj_matrix && mv_mat == m_last_modelview_matrix) {
|
if (proj_mat == m_last_proj_matrix && mv_mat == m_last_modelview_matrix) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
m_last_proj_matrix = proj_mat;
|
m_last_proj_matrix = proj_mat;
|
||||||
m_last_modelview_matrix = mv_mat;
|
m_last_modelview_matrix = mv_mat;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -85,18 +84,19 @@ private:
|
||||||
QMatrix4x4 inverse_mvp = (projection_matrix * modelview_matrix).inverted();
|
QMatrix4x4 inverse_mvp = (projection_matrix * modelview_matrix).inverted();
|
||||||
|
|
||||||
// Define 4 corners of the near plane in NDC (-1 to 1 in x and y)
|
// Define 4 corners of the near plane in NDC (-1 to 1 in x and y)
|
||||||
QVector4D clip_space_corners[] = {QVector4D(-1.0, -1.0, 0.0, 1.0), QVector4D(-1.0, 1.0, 0.0, 1.0),
|
QVector4D clip_space_corners[] = {
|
||||||
QVector4D(1.0, -1.0, 0.0, 1.0), QVector4D(1.0, 1.0, 0.0, 1.0)};
|
QVector4D(-1.0, -1.0, 0.0, 1.0), QVector4D(-1.0, 1.0, 0.0, 1.0),
|
||||||
|
QVector4D(1.0, -1.0, 0.0, 1.0), QVector4D(1.0, 1.0, 0.0, 1.0)
|
||||||
|
};
|
||||||
|
|
||||||
double xmin = std::numeric_limits<double>::max();
|
double xmin = std::numeric_limits<double>::max();
|
||||||
double xmax = std::numeric_limits<double>::lowest();
|
double xmax = std::numeric_limits<double>::lowest();
|
||||||
double ymin = std::numeric_limits<double>::max();
|
double ymin = std::numeric_limits<double>::max();
|
||||||
double ymax = std::numeric_limits<double>::lowest();
|
double ymax = std::numeric_limits<double>::lowest();
|
||||||
|
|
||||||
for(const QVector4D& corner : clip_space_corners) {
|
for (const QVector4D& corner : clip_space_corners) {
|
||||||
QVector4D world = inverse_mvp * corner;
|
QVector4D world = inverse_mvp * corner;
|
||||||
if(world.w() != 0.0)
|
if (world.w() != 0.0) world /= world.w();
|
||||||
world /= world.w();
|
|
||||||
double x = world.x();
|
double x = world.x();
|
||||||
double y = world.y();
|
double y = world.y();
|
||||||
|
|
||||||
|
|
@ -109,10 +109,11 @@ private:
|
||||||
return Bbox_2(xmin, ymin, xmax, ymax);
|
return Bbox_2(xmin, ymin, xmax, ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
double get_approx_error(const Bbox_2& bbox) const {
|
double get_approx_error(const Bbox_2& bbox) const {
|
||||||
if constexpr(Traits_adaptor<Geom_traits>::Approximation_sizing_factor == 0.0) {
|
if constexpr(Traits_adaptor<Geom_traits>::Approximation_sizing_factor == 0.0)
|
||||||
return std::numeric_limits<double>::max();
|
return std::numeric_limits<double>::max();
|
||||||
}
|
|
||||||
std::array<GLint, 4> viewport;
|
std::array<GLint, 4> viewport;
|
||||||
camera_->getViewport(viewport.data());
|
camera_->getViewport(viewport.data());
|
||||||
double viewport_width = static_cast<double>(viewport[2]);
|
double viewport_width = static_cast<double>(viewport[2]);
|
||||||
|
|
@ -121,16 +122,21 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
Arr_viewer(QWidget* parent,
|
Arr_viewer(QWidget* parent,
|
||||||
const Arrangement& arr,
|
const Arrangement& arr,
|
||||||
Graphics_scene_options options,
|
Graphics_scene_options options,
|
||||||
const char* title = "Arrangement Viewer")
|
const char* title = "Arrangement Viewer") :
|
||||||
: Basic_viewer(parent, m_scene, title)
|
Basic_viewer(parent, m_scene, title),
|
||||||
, m_scene_options(options)
|
m_scene_options(options),
|
||||||
, m_arr(arr)
|
m_arr(arr),
|
||||||
, m_feature_portals(Arr_portals<Arrangement>(*arr.geometry_traits()).create(arr))
|
m_feature_portals(Arr_portals<Arrangement>(*arr.geometry_traits()).create(arr)),
|
||||||
, m_pl(arr) {}
|
m_pl(arr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
void render_arr(const Bbox_2& bbox) {
|
void render_arr(const Bbox_2& bbox) {
|
||||||
Arr_render_context<Arrangement> ctx(m_arr, m_pl, m_feature_portals, get_approx_error(bbox));
|
Arr_render_context<Arrangement> ctx(m_arr, m_pl, m_feature_portals, get_approx_error(bbox));
|
||||||
Arr_bounded_renderer<Arrangement> renderer(ctx, bbox);
|
Arr_bounded_renderer<Arrangement> renderer(ctx, bbox);
|
||||||
|
|
@ -143,60 +149,47 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// add faces
|
// add faces
|
||||||
for(const auto& [fh, face_tris] : cache.face_cache()) {
|
for (const auto& [fh, face_tris] : cache.face_cache()) {
|
||||||
const auto& points = face_tris.points;
|
const auto& points = face_tris.points;
|
||||||
const auto& tris = face_tris.triangles;
|
const auto& tris = face_tris.triangles;
|
||||||
bool draw_face = m_scene_options.colored_face(m_arr, fh);
|
bool draw_face = m_scene_options.colored_face(m_arr, fh);
|
||||||
for(const auto& t : tris) {
|
for (const auto& t : tris) {
|
||||||
if(draw_face) {
|
if (draw_face) m_scene.face_begin(m_scene_options.face_color(m_arr, fh));
|
||||||
m_scene.face_begin(m_scene_options.face_color(m_arr, fh));
|
else m_scene.face_begin();
|
||||||
} else {
|
for (const auto idx : t) m_scene.add_point_in_face(points[idx]);
|
||||||
m_scene.face_begin();
|
|
||||||
}
|
|
||||||
for(const auto idx : t) {
|
|
||||||
m_scene.add_point_in_face(points[idx]);
|
|
||||||
}
|
|
||||||
m_scene.face_end();
|
m_scene.face_end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add edges
|
// add edges
|
||||||
for(const auto& [he, polyline] : cache.halfedge_cache()) {
|
for (const auto& [he, polyline] : cache.halfedge_cache()) {
|
||||||
if(polyline.size() < 2) {
|
if (polyline.size() < 2) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool draw_colored_edge = m_scene_options.colored_edge(m_arr, he);
|
bool draw_colored_edge = m_scene_options.colored_edge(m_arr, he);
|
||||||
auto color = draw_colored_edge ? m_scene_options.edge_color(m_arr, he) : CGAL::IO::Color();
|
auto color = draw_colored_edge ? m_scene_options.edge_color(m_arr, he) : CGAL::IO::Color();
|
||||||
for(size_t i = 0; i < polyline.size() - 1; ++i) {
|
for (size_t i = 0; i < polyline.size() - 1; ++i) {
|
||||||
const auto& cur_pt = polyline[i];
|
const auto& cur_pt = polyline[i];
|
||||||
const auto& next_pt = polyline[i + 1];
|
const auto& next_pt = polyline[i + 1];
|
||||||
auto mid_pt = CGAL::midpoint(cur_pt, next_pt);
|
auto mid_pt = CGAL::midpoint(cur_pt, next_pt);
|
||||||
if(mid_pt.x() <= bbox.xmin() || mid_pt.x() > bbox.xmax() || mid_pt.y() <= bbox.ymin() ||
|
if (mid_pt.x() <= bbox.xmin() || mid_pt.x() > bbox.xmax() || mid_pt.y() <= bbox.ymin() ||
|
||||||
mid_pt.y() > bbox.ymax())
|
mid_pt.y() > bbox.ymax())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(draw_colored_edge) {
|
if (draw_colored_edge) m_scene.add_segment(cur_pt, next_pt, color);
|
||||||
m_scene.add_segment(cur_pt, next_pt, color);
|
else m_scene.add_segment(cur_pt, next_pt);
|
||||||
} else {
|
|
||||||
m_scene.add_segment(cur_pt, next_pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add vertices
|
// add vertices
|
||||||
for(const auto& [vh, pt] : cache.vertex_cache()) {
|
for (const auto& [vh, pt] : cache.vertex_cache()) {
|
||||||
if(m_scene_options.colored_vertex(m_arr, vh)) {
|
if (m_scene_options.colored_vertex(m_arr, vh)) m_scene.add_point(pt, m_scene_options.vertex_color(m_arr, vh));
|
||||||
m_scene.add_point(pt, m_scene_options.vertex_color(m_arr, vh));
|
else m_scene.add_point(pt);
|
||||||
} else {
|
|
||||||
m_scene.add_point(pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's nothing to render, we fill the bbox with background color.
|
// If there's nothing to render, we fill the bbox with background color.
|
||||||
// This is to keep the Basic_viewer working in 2D mode.
|
// This is to keep the Basic_viewer working in 2D mode.
|
||||||
if(m_scene.empty()) {
|
if (m_scene.empty()) {
|
||||||
m_scene.face_begin(CGAL::IO::Color(255, 255, 255)); // White, by now
|
m_scene.face_begin(CGAL::IO::Color(255, 255, 255)); // White, by now
|
||||||
using Approx_point = typename Arr_approximation_geometry_traits<Geom_traits>::Approx_point;
|
using Approx_point = typename Arr_approximation_geometry_traits<Geom_traits>::Approx_point;
|
||||||
m_scene.add_point_in_face(Approx_point(bbox.xmin(), bbox.ymin()));
|
m_scene.add_point_in_face(Approx_point(bbox.xmin(), bbox.ymin()));
|
||||||
|
|
@ -207,14 +200,18 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
void rerender(Bbox_2 bbox) {
|
void rerender(Bbox_2 bbox) {
|
||||||
m_scene.clear();
|
m_scene.clear();
|
||||||
render_arr(bbox);
|
render_arr(bbox);
|
||||||
Basic_viewer::redraw();
|
Basic_viewer::redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
virtual void draw() override {
|
virtual void draw() override {
|
||||||
if(is_camera_changed()) {
|
if (is_camera_changed()) {
|
||||||
Bbox_2 bbox = view_bbox_from_camera();
|
Bbox_2 bbox = view_bbox_from_camera();
|
||||||
#if defined(CGAL_DRAW_AOS_DEBUG)
|
#if defined(CGAL_DRAW_AOS_DEBUG)
|
||||||
double dx = (bbox.xmax() - bbox.xmin()) * 0.1;
|
double dx = (bbox.xmax() - bbox.xmin()) * 0.1;
|
||||||
|
|
@ -227,6 +224,8 @@ public:
|
||||||
Basic_viewer::draw();
|
Basic_viewer::draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
virtual ~Arr_viewer() {}
|
virtual ~Arr_viewer() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,17 @@ enum class Side_of_boundary {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename, typename = std::void_t<>>
|
template <typename, typename = std::void_t<>>
|
||||||
struct has_construct_x_monotone_curve_2 : std::false_type
|
struct has_construct_x_monotone_curve_2 : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_construct_x_monotone_curve_2<T, std::void_t<typename T::Construct_x_monotone_curve_2>> : std::true_type
|
struct has_construct_x_monotone_curve_2<T, std::void_t<typename T::Construct_x_monotone_curve_2>> : std::true_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename, typename = std::void_t<>>
|
template <typename, typename = std::void_t<>>
|
||||||
struct has_approximate_2_object : std::false_type
|
struct has_approximate_2_object : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Specialization: detection succeeds if decltype(T::approximate_2_object()) is valid
|
// Specialization: detection succeeds if decltype(T::approximate_2_object()) is valid
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_approximate_2_object<T, std::void_t<decltype(std::declval<T>().approximate_2_object())>> : std::true_type
|
struct has_approximate_2_object<T, std::void_t<decltype(std::declval<T>().approximate_2_object())>> : std::true_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Convenience variable
|
// Convenience variable
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
@ -49,13 +45,12 @@ inline constexpr bool has_approximate_2_object_v = has_approximate_2_object<T>::
|
||||||
// Primary templates: detection fails by default
|
// Primary templates: detection fails by default
|
||||||
// Does a class have operator()(const Point&)?
|
// Does a class have operator()(const Point&)?
|
||||||
template <typename, typename, typename = std::void_t<>>
|
template <typename, typename, typename = std::void_t<>>
|
||||||
struct has_operator_point : std::false_type
|
struct has_operator_point : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Specialization: detection succeeds if decltype works out
|
// Specialization: detection succeeds if decltype works out
|
||||||
template <typename T, typename A>
|
template <typename T, typename A>
|
||||||
struct has_operator_point<T, A, std::void_t<decltype(std::declval<A>()(std::declval<const typename T::Point_2&>()))>>
|
struct has_operator_point<T, A, std::void_t<decltype(std::declval<A>()(std::declval<const typename T::Point_2&>()))>> :
|
||||||
: std::true_type
|
std::true_type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
// Convenience variable
|
// Convenience variable
|
||||||
|
|
@ -65,9 +60,10 @@ inline constexpr bool has_operator_point_v = has_operator_point<T, A>::value;
|
||||||
// Primary templates: detection fails by default
|
// Primary templates: detection fails by default
|
||||||
// Does a class have operator()(const X_monotone_curve&)?
|
// Does a class have operator()(const X_monotone_curve&)?
|
||||||
template <typename, typename, typename, typename = std::void_t<>>
|
template <typename, typename, typename, typename = std::void_t<>>
|
||||||
struct has_operator_xcv : std::false_type
|
struct has_operator_xcv : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename T, typename A, typename O>
|
template <typename T, typename A, typename O>
|
||||||
struct has_operator_xcv<T,
|
struct has_operator_xcv<T,
|
||||||
A,
|
A,
|
||||||
|
|
@ -82,9 +78,10 @@ struct has_operator_xcv<T,
|
||||||
template <typename T, typename A>
|
template <typename T, typename A>
|
||||||
constexpr bool has_operator_xcv_v = has_operator_xcv<T, A, void*>::value;
|
constexpr bool has_operator_xcv_v = has_operator_xcv<T, A, void*>::value;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename GeomTraits>
|
template <typename GeomTraits>
|
||||||
struct Traits_adaptor_base
|
struct Traits_adaptor_base {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
using Geom_traits = GeomTraits;
|
using Geom_traits = GeomTraits;
|
||||||
using Point_2 = typename Geom_traits::Point_2;
|
using Point_2 = typename Geom_traits::Point_2;
|
||||||
|
|
@ -94,12 +91,15 @@ public:
|
||||||
using Compare_xy_2 = typename Geom_traits::Compare_xy_2;
|
using Compare_xy_2 = typename Geom_traits::Compare_xy_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename GeomTraits>
|
template <typename GeomTraits>
|
||||||
struct Traits_adaptor;
|
struct Traits_adaptor;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
struct Traits_adaptor<Arr_segment_traits_2<Kernel>> : public Traits_adaptor_base<Arr_segment_traits_2<Kernel>>
|
struct Traits_adaptor<Arr_segment_traits_2<Kernel>> : public Traits_adaptor_base<Arr_segment_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_segment_traits_2<Kernel>;
|
using Geom_traits = Arr_segment_traits_2<Kernel>;
|
||||||
|
|
||||||
|
|
@ -113,10 +113,11 @@ public:
|
||||||
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
struct Traits_adaptor<Arr_non_caching_segment_traits_2<Kernel>>
|
struct Traits_adaptor<Arr_non_caching_segment_traits_2<Kernel>> :
|
||||||
: public Traits_adaptor_base<Arr_non_caching_segment_traits_2<Kernel>>
|
public Traits_adaptor_base<Arr_non_caching_segment_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_non_caching_segment_traits_2<Kernel>;
|
using Geom_traits = Arr_non_caching_segment_traits_2<Kernel>;
|
||||||
|
|
||||||
|
|
@ -130,10 +131,11 @@ public:
|
||||||
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename SegmentTraits>
|
template <typename SegmentTraits>
|
||||||
struct Traits_adaptor<Arr_polyline_traits_2<SegmentTraits>>
|
struct Traits_adaptor<Arr_polyline_traits_2<SegmentTraits>> :
|
||||||
: public Traits_adaptor_base<Arr_polyline_traits_2<SegmentTraits>>
|
public Traits_adaptor_base<Arr_polyline_traits_2<SegmentTraits>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_polyline_traits_2<SegmentTraits>;
|
using Geom_traits = Arr_polyline_traits_2<SegmentTraits>;
|
||||||
using Sub_traits = SegmentTraits;
|
using Sub_traits = SegmentTraits;
|
||||||
|
|
@ -149,10 +151,11 @@ public:
|
||||||
using Approximate_point_2 = typename Adapted_sub_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Adapted_sub_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename SubcurveTraits>
|
template <typename SubcurveTraits>
|
||||||
struct Traits_adaptor<Arr_polycurve_traits_2<SubcurveTraits>>
|
struct Traits_adaptor<Arr_polycurve_traits_2<SubcurveTraits>> :
|
||||||
: public Traits_adaptor_base<Arr_polycurve_traits_2<SubcurveTraits>>
|
public Traits_adaptor_base<Arr_polycurve_traits_2<SubcurveTraits>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Sub_traits = SubcurveTraits;
|
using Sub_traits = SubcurveTraits;
|
||||||
using Geom_traits = Arr_polycurve_traits_2<Sub_traits>;
|
using Geom_traits = Arr_polycurve_traits_2<Sub_traits>;
|
||||||
|
|
@ -168,9 +171,10 @@ public:
|
||||||
using Approximate_point_2 = typename Adapted_sub_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Adapted_sub_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
struct Traits_adaptor<Arr_linear_traits_2<Kernel>> : public Traits_adaptor_base<Arr_linear_traits_2<Kernel>>
|
struct Traits_adaptor<Arr_linear_traits_2<Kernel>> : public Traits_adaptor_base<Arr_linear_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_segment_traits_2<Kernel>;
|
using Geom_traits = Arr_segment_traits_2<Kernel>;
|
||||||
|
|
||||||
|
|
@ -184,10 +188,11 @@ public:
|
||||||
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename RatKernel, typename AlgKernel, typename NtTraits>
|
template <typename RatKernel, typename AlgKernel, typename NtTraits>
|
||||||
struct Traits_adaptor<Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>>
|
struct Traits_adaptor<Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>> :
|
||||||
: public Traits_adaptor_base<Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>>
|
public Traits_adaptor_base<Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>;
|
using Geom_traits = Arr_conic_traits_2<RatKernel, AlgKernel, NtTraits>;
|
||||||
|
|
||||||
|
|
@ -201,10 +206,11 @@ public:
|
||||||
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
struct Traits_adaptor<Arr_circle_segment_traits_2<Kernel>>
|
struct Traits_adaptor<Arr_circle_segment_traits_2<Kernel>> :
|
||||||
: public Traits_adaptor_base<Arr_circle_segment_traits_2<Kernel>>
|
public Traits_adaptor_base<Arr_circle_segment_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_circle_segment_traits_2<Kernel>;
|
using Geom_traits = Arr_circle_segment_traits_2<Kernel>;
|
||||||
using Base = Traits_adaptor_base<Geom_traits>;
|
using Base = Traits_adaptor_base<Geom_traits>;
|
||||||
|
|
@ -219,10 +225,11 @@ public:
|
||||||
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
using Approximate_point_2 = typename Geom_traits::Approximate_point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
struct Traits_adaptor<Arr_rational_function_traits_2<Kernel>>
|
struct Traits_adaptor<Arr_rational_function_traits_2<Kernel>> :
|
||||||
: public Traits_adaptor_base<Arr_rational_function_traits_2<Kernel>>
|
public Traits_adaptor_base<Arr_rational_function_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
using Geom_traits = Arr_rational_function_traits_2<Kernel>;
|
using Geom_traits = Arr_rational_function_traits_2<Kernel>;
|
||||||
|
|
||||||
|
|
@ -238,18 +245,20 @@ public:
|
||||||
using Approximate_point_2 = typename Approximate_kernel::Point_2;
|
using Approximate_point_2 = typename Approximate_kernel::Point_2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename GeomTraits>
|
template <typename GeomTraits>
|
||||||
class Construct_coordinate
|
class Construct_coordinate {
|
||||||
{
|
|
||||||
using FT = typename Traits_adaptor<GeomTraits>::FT;
|
using FT = typename Traits_adaptor<GeomTraits>::FT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FT operator()(double val) const { return FT(val); }
|
FT operator()(double val) const { return FT(val); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
class Construct_coordinate<Arr_rational_function_traits_2<Kernel>>
|
class Construct_coordinate<Arr_rational_function_traits_2<Kernel>> {
|
||||||
{
|
|
||||||
using FT = typename Traits_adaptor<Arr_rational_function_traits_2<Kernel>>::FT;
|
using FT = typename Traits_adaptor<Arr_rational_function_traits_2<Kernel>>::FT;
|
||||||
using Bound = typename Kernel::Bound;
|
using Bound = typename Kernel::Bound;
|
||||||
|
|
||||||
|
|
@ -257,9 +266,10 @@ public:
|
||||||
FT operator()(double val) const { return FT(Bound(val)); }
|
FT operator()(double val) const { return FT(Bound(val)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
template <typename GeomTraits>
|
template <typename GeomTraits>
|
||||||
class Arr_approximation_geometry_traits
|
class Arr_approximation_geometry_traits {
|
||||||
{
|
|
||||||
using Adapted_traits = Traits_adaptor<GeomTraits>;
|
using Adapted_traits = Traits_adaptor<GeomTraits>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -271,8 +281,7 @@ public:
|
||||||
using Polyline_geom = Apporx_point_vec;
|
using Polyline_geom = Apporx_point_vec;
|
||||||
using Triangle = std::array<std::size_t, 3>;
|
using Triangle = std::array<std::size_t, 3>;
|
||||||
using Triangle_vec = std::vector<Triangle>;
|
using Triangle_vec = std::vector<Triangle>;
|
||||||
struct Triangulated_face
|
struct Triangulated_face {
|
||||||
{
|
|
||||||
Apporx_point_vec points;
|
Apporx_point_vec points;
|
||||||
Triangle_vec triangles;
|
Triangle_vec triangles;
|
||||||
};
|
};
|
||||||
|
|
@ -281,4 +290,4 @@ public:
|
||||||
} // namespace draw_aos
|
} // namespace draw_aos
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_DRAW_AOS_TYPE_UTILS_H
|
#endif // CGAL_DRAW_AOS_TYPE_UTILS_H
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
#ifndef CGAL_DRAW_ARRANGEMENT_2_H
|
#ifndef CGAL_DRAW_ARRANGEMENT_2_H
|
||||||
#define CGAL_DRAW_ARRANGEMENT_2_H
|
#define CGAL_DRAW_ARRANGEMENT_2_H
|
||||||
|
|
||||||
|
#include <CGAL/license/Arrangement_on_surface_2.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
@ -27,7 +29,6 @@
|
||||||
#include <CGAL/Graphics_scene.h>
|
#include <CGAL/Graphics_scene.h>
|
||||||
#include <CGAL/Graphics_scene_options.h>
|
#include <CGAL/Graphics_scene_options.h>
|
||||||
#include <CGAL/Random.h>
|
#include <CGAL/Random.h>
|
||||||
#include <CGAL/license/Arrangement_on_surface_2.h>
|
|
||||||
#include <CGAL/config.h>
|
#include <CGAL/config.h>
|
||||||
#include <CGAL/Draw_aos/Arr_viewer.h>
|
#include <CGAL/Draw_aos/Arr_viewer.h>
|
||||||
|
|
||||||
|
|
@ -44,13 +45,11 @@ namespace draw_function_for_arrangement_2 {
|
||||||
// Primary templates: detection fails by default
|
// Primary templates: detection fails by default
|
||||||
// Does the traits have approximate_2_object()?
|
// Does the traits have approximate_2_object()?
|
||||||
template <typename, typename = std::void_t<>>
|
template <typename, typename = std::void_t<>>
|
||||||
struct has_approximate_2_object : std::false_type
|
struct has_approximate_2_object : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Specialization: detection succeeds if decltype(T::approximate_2_object()) is valid
|
// Specialization: detection succeeds if decltype(T::approximate_2_object()) is valid
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_approximate_2_object<T, std::void_t<decltype(std::declval<T>().approximate_2_object())>> : std::true_type
|
struct has_approximate_2_object<T, std::void_t<decltype(std::declval<T>().approximate_2_object())>> : std::true_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Convenience variable
|
// Convenience variable
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
@ -61,8 +60,7 @@ inline constexpr bool has_approximate_2_object_v = has_approximate_2_object<T>::
|
||||||
// Primary templates: detection fails by default
|
// Primary templates: detection fails by default
|
||||||
// Does a class have operator()(const Point&)?
|
// Does a class have operator()(const Point&)?
|
||||||
template <typename, typename, typename = std::void_t<>>
|
template <typename, typename, typename = std::void_t<>>
|
||||||
struct has_operator_point : std::false_type
|
struct has_operator_point : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Specialization: detection succeeds if decltype works out
|
// Specialization: detection succeeds if decltype works out
|
||||||
template <typename T, typename A>
|
template <typename T, typename A>
|
||||||
|
|
@ -79,8 +77,7 @@ inline constexpr bool has_operator_point_v = has_operator_point<T, A>::value;
|
||||||
// Primary templates: detection fails by default
|
// Primary templates: detection fails by default
|
||||||
// Does a class have operator()(const X_monotone_curve&)?
|
// Does a class have operator()(const X_monotone_curve&)?
|
||||||
template <typename, typename, typename = std::void_t<>>
|
template <typename, typename, typename = std::void_t<>>
|
||||||
struct has_operator_xcv : std::false_type
|
struct has_operator_xcv : std::false_type {};
|
||||||
{};
|
|
||||||
|
|
||||||
// Specialization: detection succeeds if decltype works out
|
// Specialization: detection succeeds if decltype works out
|
||||||
struct Dummy_output
|
struct Dummy_output
|
||||||
|
|
@ -104,8 +101,7 @@ inline constexpr bool has_operator_xcv_v = has_operator_xcv<T, A>::value;
|
||||||
|
|
||||||
// Helper: detect whether T is or derives from Arr_geodesic_arc_on_sphere_traits_2<*, *, *>
|
// Helper: detect whether T is or derives from Arr_geodesic_arc_on_sphere_traits_2<*, *, *>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_or_derived_from_agas
|
struct is_or_derived_from_agas {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
template <typename Kernel_, int AtanX, int AtanY>
|
template <typename Kernel_, int AtanX, int AtanY>
|
||||||
static std::true_type test(const Arr_geodesic_arc_on_sphere_traits_2<Kernel_, AtanX, AtanY>*);
|
static std::true_type test(const Arr_geodesic_arc_on_sphere_traits_2<Kernel_, AtanX, AtanY>*);
|
||||||
|
|
@ -123,8 +119,7 @@ inline constexpr bool is_or_derived_from_agas_v = is_or_derived_from_agas<T>::va
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename Arr, typename GSOptions>
|
template <typename Arr, typename GSOptions>
|
||||||
class Draw_arr_tool
|
class Draw_arr_tool {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
using Halfedge_const_handle = typename Arr::Halfedge_const_handle;
|
using Halfedge_const_handle = typename Arr::Halfedge_const_handle;
|
||||||
using Vertex_const_handle = typename Arr::Vertex_const_handle;
|
using Vertex_const_handle = typename Arr::Vertex_const_handle;
|
||||||
|
|
@ -138,18 +133,18 @@ public:
|
||||||
|
|
||||||
/*! Construct
|
/*! Construct
|
||||||
*/
|
*/
|
||||||
Draw_arr_tool(Arr& a_aos, CGAL::Graphics_scene& a_gs, const GSOptions& a_gso)
|
Draw_arr_tool(Arr& a_aos, CGAL::Graphics_scene& a_gs, const GSOptions& a_gso) :
|
||||||
: m_aos(a_aos)
|
m_aos(a_aos),
|
||||||
, m_gs(a_gs)
|
m_gs(a_gs),
|
||||||
, m_gso(a_gso) {}
|
m_gso(a_gso)
|
||||||
|
{}
|
||||||
|
|
||||||
/// Add a face.
|
/// Add a face.
|
||||||
void add_face(Face_const_handle face) {
|
void add_face(Face_const_handle face) {
|
||||||
// std::cout << "add_face()\n";
|
// std::cout << "add_face()\n";
|
||||||
for(Inner_ccb_const_iterator it = face->inner_ccbs_begin(); it != face->inner_ccbs_end(); ++it)
|
for (Inner_ccb_const_iterator it = face->inner_ccbs_begin(); it != face->inner_ccbs_end(); ++it) add_ccb(*it);
|
||||||
add_ccb(*it);
|
|
||||||
|
|
||||||
for(Outer_ccb_const_iterator it = face->outer_ccbs_begin(); it != face->outer_ccbs_end(); ++it) {
|
for (Outer_ccb_const_iterator it = face->outer_ccbs_begin(); it != face->outer_ccbs_end(); ++it) {
|
||||||
add_ccb(*it);
|
add_ccb(*it);
|
||||||
draw_region(*it);
|
draw_region(*it);
|
||||||
}
|
}
|
||||||
|
|
@ -161,8 +156,7 @@ public:
|
||||||
auto curr = circ;
|
auto curr = circ;
|
||||||
do {
|
do {
|
||||||
auto new_face = curr->twin()->face();
|
auto new_face = curr->twin()->face();
|
||||||
if(m_visited.find(new_face) != m_visited.end())
|
if (m_visited.find(new_face) != m_visited.end()) continue;
|
||||||
continue;
|
|
||||||
m_visited[new_face] = true;
|
m_visited[new_face] = true;
|
||||||
add_face(new_face);
|
add_face(new_face);
|
||||||
} while(++curr != circ);
|
} while(++curr != circ);
|
||||||
|
|
@ -186,10 +180,8 @@ public:
|
||||||
*
|
*
|
||||||
* For now we use C++14 features.
|
* For now we use C++14 features.
|
||||||
*/
|
*/
|
||||||
if(m_gso.colored_face(m_aos, circ->face()))
|
if (m_gso.colored_face(m_aos, circ->face())) m_gs.face_begin(m_gso.face_color(m_aos, circ->face()));
|
||||||
m_gs.face_begin(m_gso.face_color(m_aos, circ->face()));
|
else m_gs.face_begin();
|
||||||
else
|
|
||||||
m_gs.face_begin();
|
|
||||||
|
|
||||||
const auto* traits = this->m_aos.geometry_traits();
|
const auto* traits = this->m_aos.geometry_traits();
|
||||||
auto ext = find_smallest(circ, *traits);
|
auto ext = find_smallest(circ, *traits);
|
||||||
|
|
@ -197,8 +189,7 @@ public:
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// Skip halfedges that are "antenas":
|
// Skip halfedges that are "antenas":
|
||||||
while(curr->face() == curr->twin()->face())
|
while(curr->face() == curr->twin()->face()) curr = curr->twin()->next();
|
||||||
curr = curr->twin()->next();
|
|
||||||
draw_region_impl1(*traits, curr);
|
draw_region_impl1(*traits, curr);
|
||||||
curr = curr->next();
|
curr = curr->next();
|
||||||
} while(curr != ext);
|
} while(curr != ext);
|
||||||
|
|
@ -210,22 +201,19 @@ public:
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, typename A, std::enable_if_t<!has_operator_point_v<T, A>, int> = 0>
|
template <typename T, typename A, std::enable_if_t<!has_operator_point_v<T, A>, int> = 0>
|
||||||
void draw_region_impl2(const T& /* traits */, const A& /* approximate */, Halfedge_const_handle curr) {
|
void draw_region_impl2(const T& /* traits */, const A& /* approximate */, Halfedge_const_handle curr)
|
||||||
draw_exact_region(curr);
|
{ draw_exact_region(curr); }
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
||||||
auto draw_region_impl2(const T& /* traits */, const A& approx, Halfedge_const_handle curr) {
|
auto draw_region_impl2(const T& /* traits */, const A& approx, Halfedge_const_handle curr)
|
||||||
draw_approximate_region(curr, approx);
|
{ draw_approximate_region(curr, approx); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a region, where the traits does not has approximate_2_object.
|
/*! Draw 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>
|
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) {
|
void draw_region_impl1(const T& /* traits */, Halfedge_const_handle curr)
|
||||||
draw_exact_region(curr);
|
{ draw_exact_region(curr); }
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, std::enable_if_t<has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
|
template <typename T, std::enable_if_t<has_approximate_2_object_v<T> && !is_or_derived_from_agas_v<T>, int> = 0>
|
||||||
|
|
@ -255,12 +243,10 @@ public:
|
||||||
double error(0.01); // TODO? (this->pixel_ratio());
|
double error(0.01); // TODO? (this->pixel_ratio());
|
||||||
bool l2r = curr->direction() == ARR_LEFT_TO_RIGHT;
|
bool l2r = curr->direction() == ARR_LEFT_TO_RIGHT;
|
||||||
approx(curr->curve(), error, std::back_inserter(polyline), l2r);
|
approx(curr->curve(), error, std::back_inserter(polyline), l2r);
|
||||||
if(polyline.empty())
|
if (polyline.empty()) return;
|
||||||
return;
|
|
||||||
auto it = polyline.begin();
|
auto it = polyline.begin();
|
||||||
auto prev = it++;
|
auto prev = it++;
|
||||||
for(; it != polyline.end(); prev = it++)
|
for (; it != polyline.end(); prev = it++) m_gs.add_point_in_face(*prev);
|
||||||
m_gs.add_point_in_face(*prev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Draw an exact curve.
|
/*! Draw an exact curve.
|
||||||
|
|
@ -271,10 +257,8 @@ public:
|
||||||
auto ctr_min = traits->construct_min_vertex_2_object();
|
auto ctr_min = traits->construct_min_vertex_2_object();
|
||||||
auto ctr_max = traits->construct_max_vertex_2_object();
|
auto ctr_max = traits->construct_max_vertex_2_object();
|
||||||
m_gs.add_segment(ctr_min(curve), ctr_max(curve));
|
m_gs.add_segment(ctr_min(curve), ctr_max(curve));
|
||||||
if(colored)
|
if (colored) m_gs.add_segment(ctr_min(curve), ctr_max(curve), c);
|
||||||
m_gs.add_segment(ctr_min(curve), ctr_max(curve), c);
|
else m_gs.add_segment(ctr_min(curve), ctr_max(curve));
|
||||||
else
|
|
||||||
m_gs.add_segment(ctr_min(curve), ctr_max(curve));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Draw a region in an exact manner.
|
/*! Draw a region in an exact manner.
|
||||||
|
|
@ -284,10 +268,8 @@ public:
|
||||||
|
|
||||||
/// Add all faces.
|
/// Add all faces.
|
||||||
template <typename Traits>
|
template <typename Traits>
|
||||||
void add_faces(const Traits&) {
|
void add_faces(const Traits&)
|
||||||
for(auto it = m_aos.unbounded_faces_begin(); it != m_aos.unbounded_faces_end(); ++it)
|
{ for (auto it = m_aos.unbounded_faces_begin(); it != m_aos.unbounded_faces_end(); ++it) add_face(it); }
|
||||||
add_face(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compile time dispatching
|
/// Compile time dispatching
|
||||||
|
|
||||||
|
|
@ -295,47 +277,39 @@ public:
|
||||||
*/
|
*/
|
||||||
template <typename Approximate>
|
template <typename Approximate>
|
||||||
void draw_approximate_point(const Point& p, const Approximate& approx, bool colored, const CGAL::IO::Color& color) {
|
void draw_approximate_point(const Point& p, const Approximate& approx, bool colored, const CGAL::IO::Color& color) {
|
||||||
if(colored)
|
if (colored) m_gs.add_point(approx(p), color);
|
||||||
m_gs.add_point(approx(p), color);
|
else m_gs.add_point(approx(p));
|
||||||
else
|
|
||||||
m_gs.add_point(approx(p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
void draw_exact_point(const Point& p, bool colored, const CGAL::IO::Color& color) {
|
void draw_exact_point(const Point& p, bool colored, const CGAL::IO::Color& color) {
|
||||||
if(colored)
|
if (colored) m_gs.add_point(p, color);
|
||||||
m_gs.add_point(p, color);
|
else m_gs.add_point(p);
|
||||||
else
|
|
||||||
m_gs.add_point(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, typename A, std::enable_if_t<!has_operator_point_v<T, A>, int> = 0>
|
template <typename T, typename A, std::enable_if_t<!has_operator_point_v<T, A>, int> = 0>
|
||||||
void draw_point_impl2(
|
void draw_point_impl2(const T& /* traits */, const A& /* approximate */, const Point& p, bool colored,
|
||||||
const T& /* traits */, const A& /* approximate */, const Point& p, bool colored, const CGAL::IO::Color& c) {
|
const CGAL::IO::Color& c)
|
||||||
draw_exact_point(p, colored, c);
|
{ draw_exact_point(p, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
||||||
auto
|
auto
|
||||||
draw_point_impl2(const T& /* traits */, const A& approx, const Point& p, bool colored, const CGAL::IO::Color& c) {
|
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_approximate_point(p, approx, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a point, where the traits does not has approximate_2_object.
|
/*! Draw 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>
|
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) {
|
void draw_point_impl1(const T& /* traits */, const Point& p, bool colored, const CGAL::IO::Color& c)
|
||||||
draw_exact_point(p, colored, c);
|
{ draw_exact_point(p, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a point, where the traits does have approximate_2_object.
|
/*! Draw 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>
|
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) {
|
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_point_impl2(traits, traits.approximate_2_object(), p, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a geodesic point.
|
/*! Draw a geodesic point.
|
||||||
*/
|
*/
|
||||||
|
|
@ -352,10 +326,8 @@ public:
|
||||||
auto z = ap.dz();
|
auto z = ap.dz();
|
||||||
auto l = std::sqrt(x * x + y * y + z * z);
|
auto l = std::sqrt(x * x + y * y + z * z);
|
||||||
Approx_point_3 p3(x / l, y / l, z / l);
|
Approx_point_3 p3(x / l, y / l, z / l);
|
||||||
if(colored)
|
if (colored) m_gs.add_point(p3, color);
|
||||||
m_gs.add_point(p3, color);
|
else m_gs.add_point(p3);
|
||||||
else
|
|
||||||
m_gs.add_point(p3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw a point.
|
/// Draw a point.
|
||||||
|
|
@ -367,9 +339,8 @@ public:
|
||||||
///
|
///
|
||||||
template <typename Kernel, int AtanX, int AtanY>
|
template <typename Kernel, int AtanX, int AtanY>
|
||||||
Halfedge_const_handle find_smallest(Ccb_halfedge_const_circulator circ,
|
Halfedge_const_handle find_smallest(Ccb_halfedge_const_circulator circ,
|
||||||
Arr_geodesic_arc_on_sphere_traits_2<Kernel, AtanX, AtanY> const&) {
|
Arr_geodesic_arc_on_sphere_traits_2<Kernel, AtanX, AtanY> const&)
|
||||||
return circ;
|
{ return circ; }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Find the halfedge incident to the lexicographically smallest vertex
|
/*! Find the halfedge incident to the lexicographically smallest vertex
|
||||||
* along the CCB, such that there is no other halfedge underneath.
|
* along the CCB, such that there is no other halfedge underneath.
|
||||||
|
|
@ -383,9 +354,7 @@ public:
|
||||||
|
|
||||||
// Find the first halfedge directed from left to right
|
// Find the first halfedge directed from left to right
|
||||||
auto curr = circ;
|
auto curr = circ;
|
||||||
do
|
do if (curr->direction() == CGAL::ARR_LEFT_TO_RIGHT) break;
|
||||||
if(curr->direction() == CGAL::ARR_LEFT_TO_RIGHT)
|
|
||||||
break;
|
|
||||||
while(++curr != circ);
|
while(++curr != circ);
|
||||||
Halfedge_const_handle ext = curr;
|
Halfedge_const_handle ext = curr;
|
||||||
|
|
||||||
|
|
@ -393,25 +362,22 @@ public:
|
||||||
// such that there is no other halfedge underneath.
|
// such that there is no other halfedge underneath.
|
||||||
do {
|
do {
|
||||||
// Discard edges not directed from left to right:
|
// Discard edges not directed from left to right:
|
||||||
if(curr->direction() != CGAL::ARR_LEFT_TO_RIGHT)
|
if (curr->direction() != CGAL::ARR_LEFT_TO_RIGHT) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
auto res = cmp_xy(curr->source()->point(), ext->source()->point());
|
auto res = cmp_xy(curr->source()->point(), ext->source()->point());
|
||||||
|
|
||||||
// Discard the edges inciden to a point strictly larger than the point
|
// Discard the edges inciden to a point strictly larger than the point
|
||||||
// incident to the stored extreme halfedge:
|
// incident to the stored extreme halfedge:
|
||||||
if(res == LARGER)
|
if (res == LARGER) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
// Store the edge inciden to a point strictly smaller:
|
// Store the edge inciden to a point strictly smaller:
|
||||||
if(res == SMALLER) {
|
if (res == SMALLER) {
|
||||||
ext = curr;
|
ext = curr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The incident points are equal; compare the halfedges themselves:
|
// The incident points are equal; compare the halfedges themselves:
|
||||||
if(cmp_y(curr->curve(), ext->curve(), curr->source()->point()) == SMALLER)
|
if (cmp_y(curr->curve(), ext->curve(), curr->source()->point()) == SMALLER) ext = curr;
|
||||||
ext = curr;
|
|
||||||
} while(++curr != circ);
|
} while(++curr != circ);
|
||||||
|
|
||||||
return ext;
|
return ext;
|
||||||
|
|
@ -423,33 +389,28 @@ public:
|
||||||
// std::cout << "ratio: " << this->pixel_ratio() << std::endl;
|
// std::cout << "ratio: " << this->pixel_ratio() << std::endl;
|
||||||
m_visited.clear();
|
m_visited.clear();
|
||||||
|
|
||||||
if(m_aos.is_empty())
|
if (m_aos.is_empty()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if(m_gso.are_faces_enabled())
|
if (m_gso.are_faces_enabled())
|
||||||
add_faces(*(this->m_aos.geometry_traits()));
|
add_faces(*(this->m_aos.geometry_traits()));
|
||||||
|
|
||||||
// Add edges that do not separate faces.
|
// Add edges that do not separate faces.
|
||||||
if(m_gso.are_edges_enabled()) {
|
if (m_gso.are_edges_enabled()) {
|
||||||
for(auto it = m_aos.edges_begin(); it != m_aos.edges_end(); ++it) {
|
for (auto it = m_aos.edges_begin(); it != m_aos.edges_end(); ++it) {
|
||||||
if(it->face() != it->twin()->face()) {
|
if (it->face() != it->twin()->face()) {
|
||||||
if(m_gso.draw_edge(m_aos, it)) {
|
if (m_gso.draw_edge(m_aos, it)) {
|
||||||
if(m_gso.colored_edge(m_aos, it))
|
if (m_gso.colored_edge(m_aos, it)) draw_curve(it->curve(), true, m_gso.edge_color(m_aos, it));
|
||||||
draw_curve(it->curve(), true, m_gso.edge_color(m_aos, it));
|
else draw_curve(it->curve(), false, CGAL::IO::Color());
|
||||||
else
|
|
||||||
draw_curve(it->curve(), false, CGAL::IO::Color());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all points
|
// Add all points
|
||||||
if(m_gso.are_vertices_enabled()) {
|
if (m_gso.are_vertices_enabled()) {
|
||||||
for(auto it = m_aos.vertices_begin(); it != m_aos.vertices_end(); ++it) {
|
for (auto it = m_aos.vertices_begin(); it != m_aos.vertices_end(); ++it) {
|
||||||
if(m_gso.colored_vertex(m_aos, it))
|
if (m_gso.colored_vertex(m_aos, it)) draw_point(it->point(), true, m_gso.vertex_color(m_aos, it));
|
||||||
draw_point(it->point(), true, m_gso.vertex_color(m_aos, it));
|
else draw_point(it->point(), false, CGAL::IO::Color());
|
||||||
else
|
|
||||||
draw_point(it->point(), false, CGAL::IO::Color());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -471,15 +432,12 @@ public:
|
||||||
std::vector<typename Gt::Approximate_point_2> polyline;
|
std::vector<typename Gt::Approximate_point_2> polyline;
|
||||||
double error(0.01); // TODO? (this->pixel_ratio());
|
double error(0.01); // TODO? (this->pixel_ratio());
|
||||||
approx(curve, error, std::back_inserter(polyline));
|
approx(curve, error, std::back_inserter(polyline));
|
||||||
if(polyline.empty())
|
if (polyline.empty()) return;
|
||||||
return;
|
|
||||||
auto it = polyline.begin();
|
auto it = polyline.begin();
|
||||||
auto prev = it++;
|
auto prev = it++;
|
||||||
for(; it != polyline.end(); prev = it++) {
|
for (; it != polyline.end(); prev = it++) {
|
||||||
if(colored)
|
if (colored) m_gs.add_segment(*prev, *it, c);
|
||||||
m_gs.add_segment(*prev, *it, c);
|
else m_gs.add_segment(*prev, *it);
|
||||||
else
|
|
||||||
m_gs.add_segment(*prev, *it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -489,23 +447,20 @@ public:
|
||||||
const A& /* approximate */,
|
const A& /* approximate */,
|
||||||
const X_monotone_curve& xcv,
|
const X_monotone_curve& xcv,
|
||||||
bool colored,
|
bool colored,
|
||||||
const CGAL::IO::Color& c) {
|
const CGAL::IO::Color& c)
|
||||||
draw_exact_curve(xcv, colored, c);
|
{ draw_exact_curve(xcv, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
template <typename T, typename A, std::enable_if_t<has_operator_point_v<T, A>, int> = 0>
|
||||||
auto draw_curve_impl2(
|
auto draw_curve_impl2(const T& /* traits */, const A& approx, const X_monotone_curve& xcv, bool colored,
|
||||||
const T& /* traits */, const A& approx, const X_monotone_curve& xcv, bool colored, const CGAL::IO::Color& c) {
|
const CGAL::IO::Color& c)
|
||||||
draw_approximate_curve(xcv, approx, colored, c);
|
{ draw_approximate_curve(xcv, approx, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a curve, where the traits does not has approximate_2_object.
|
/*! Draw 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>
|
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) {
|
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_exact_curve(xcv, colored, c); }
|
||||||
}
|
|
||||||
|
|
||||||
/*! Draw a curve, where the traits does have approximate_2_object.
|
/*! Draw a curve, where the traits does have approximate_2_object.
|
||||||
*/
|
*/
|
||||||
|
|
@ -536,13 +491,13 @@ public:
|
||||||
auto z = it->dz();
|
auto z = it->dz();
|
||||||
auto l = std::sqrt(x * x + y * y + z * z);
|
auto l = std::sqrt(x * x + y * y + z * z);
|
||||||
Approx_point_3 prev(x / l, y / l, z / l);
|
Approx_point_3 prev(x / l, y / l, z / l);
|
||||||
for(++it; it != apoints.end(); ++it) {
|
for (++it; it != apoints.end(); ++it) {
|
||||||
auto x = it->dx();
|
auto x = it->dx();
|
||||||
auto y = it->dy();
|
auto y = it->dy();
|
||||||
auto z = it->dz();
|
auto z = it->dz();
|
||||||
auto l = std::sqrt(x * x + y * y + z * z);
|
auto l = std::sqrt(x * x + y * y + z * z);
|
||||||
Approx_point_3 next(x / l, y / l, z / l);
|
Approx_point_3 next(x / l, y / l, z / l);
|
||||||
if(colored)
|
if (colored)
|
||||||
m_gs.add_segment(prev, next, c);
|
m_gs.add_segment(prev, next, c);
|
||||||
else
|
else
|
||||||
m_gs.add_segment(prev, next);
|
m_gs.add_segment(prev, next);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue