mirror of https://github.com/CGAL/cgal
Drew faces in the correct order (from unbounded to inner).
This commit is contained in:
parent
d1b05fd144
commit
e8eb85d5dc
|
|
@ -1,6 +1,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 <map>
|
||||||
|
|
||||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||||
#include <CGAL/Qt/init_ogl_context.h>
|
#include <CGAL/Qt/init_ogl_context.h>
|
||||||
#include <CGAL/Arrangement_2.h>
|
#include <CGAL/Arrangement_2.h>
|
||||||
|
|
@ -10,9 +12,10 @@ namespace CGAL {
|
||||||
// Viewer class for Polygon_2
|
// Viewer class for Polygon_2
|
||||||
template <typename Arrangement_2>
|
template <typename Arrangement_2>
|
||||||
class Arr_2_viewer_qt : public Basic_viewer_qt {
|
class Arr_2_viewer_qt : public Basic_viewer_qt {
|
||||||
typedef Basic_viewer_qt Base;
|
typedef Basic_viewer_qt Base;
|
||||||
typedef Arrangement_2 Arr;
|
typedef Arrangement_2 Arr;
|
||||||
typedef typename Arr::Point_2 Point;
|
typedef typename Arr::Point_2 Point;
|
||||||
|
typedef typename Arr::Face_const_handle Face_const_handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Construct the viewer.
|
/// Construct the viewer.
|
||||||
|
|
@ -26,44 +29,51 @@ public:
|
||||||
{ add_elements(); }
|
{ add_elements(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void add_ccb(typename Arr::Ccb_halfedge_const_circulator circ) {
|
//!
|
||||||
|
void add_ccb(typename Arr::Ccb_halfedge_const_circulator circ, bool has_area = true) {
|
||||||
typename Arr::Ccb_halfedge_const_circulator curr = circ;
|
typename Arr::Ccb_halfedge_const_circulator curr = circ;
|
||||||
do {
|
do {
|
||||||
typename Arr::Halfedge_const_handle e = curr;
|
typename Arr::Halfedge_const_handle e = curr;
|
||||||
add_segment(e->source()->point(), e->target()->point());
|
add_segment(e->source()->point(), e->target()->point());
|
||||||
add_point(e->source()->point());
|
add_point(e->source()->point());
|
||||||
add_point_in_face(e->source()->point());
|
if (has_area) add_point_in_face(e->source()->point());
|
||||||
} while (++curr != circ);
|
} while (++curr != circ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_face(typename Arr::Face_const_handle f, CGAL::IO::Color c) {
|
//!
|
||||||
if (! f->is_unbounded()) {
|
void add_face(Face_const_handle face, CGAL::IO::Color c) {
|
||||||
|
if (! face->is_unbounded()) {
|
||||||
face_begin(c);
|
face_begin(c);
|
||||||
add_ccb(f->outer_ccb());
|
add_ccb(face->outer_ccb());
|
||||||
for (auto iv = f->isolated_vertices_begin();
|
for (auto iv = face->isolated_vertices_begin();
|
||||||
iv != f->isolated_vertices_end(); ++iv)
|
iv != face->isolated_vertices_end(); ++iv)
|
||||||
add_point(iv->point());
|
add_point(iv->point());
|
||||||
face_end();
|
face_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = f->inner_ccbs_begin(); it != f->inner_ccbs_end(); ++it) {
|
std::map<Face_const_handle, bool> visited;
|
||||||
face_begin(c);
|
for (auto it = face->inner_ccbs_begin(); it != face->inner_ccbs_end(); ++it) {
|
||||||
add_ccb(*it);
|
auto new_face = (*it)->twin()->face();
|
||||||
for (auto iv = f->isolated_vertices_begin();
|
if (new_face == face) {
|
||||||
iv != f->isolated_vertices_end(); ++iv)
|
add_ccb(*it, false);
|
||||||
add_point(iv->point());
|
continue;
|
||||||
face_end();
|
}
|
||||||
|
if (visited.find(new_face) != visited.end()) continue;
|
||||||
|
visited[new_face] = true;
|
||||||
|
add_face(new_face, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!
|
||||||
void add_elements() {
|
void add_elements() {
|
||||||
clear();
|
clear();
|
||||||
if (m_arr.is_empty()) return;
|
if (m_arr.is_empty()) return;
|
||||||
CGAL::IO::Color c(75,160,255);
|
CGAL::IO::Color c(75,160,255);
|
||||||
for (auto fit = m_arr.faces_begin(); fit != m_arr.faces_end(); ++fit)
|
for (auto it = m_arr.unbounded_faces_begin(); it != m_arr.unbounded_faces_end(); ++it)
|
||||||
add_face(fit, c);
|
add_face(it, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!
|
||||||
virtual void keyPressEvent(QKeyEvent* e) {
|
virtual void keyPressEvent(QKeyEvent* e) {
|
||||||
// Test key pressed:
|
// Test key pressed:
|
||||||
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue