Do not use underscore prefixes

This commit is contained in:
Mael Rouxel-Labbé 2025-03-20 10:35:55 +01:00
parent 0ab042d358
commit f95bbbccc2
7 changed files with 291 additions and 291 deletions

View File

@ -16,16 +16,16 @@ DemoWindowItem::DemoWindowItem()
: CGAL::Qt::GraphicsItem() : CGAL::Qt::GraphicsItem()
{ {
// Clear // Clear
_edges.clear(); edges_.clear();
// Prepare the pens // Prepare the pens
_poincare_disk_pen.setStyle(Qt::SolidLine); poincare_disk_pen_.setStyle(Qt::SolidLine);
_poincare_disk_pen.setWidth(8); poincare_disk_pen_.setWidth(8);
_poincare_disk_pen.setBrush(Qt::black); poincare_disk_pen_.setBrush(Qt::black);
_edges_pen.setStyle(Qt::SolidLine); edges_pen_.setStyle(Qt::SolidLine);
_edges_pen.setWidth(6); edges_pen_.setWidth(6);
_edges_pen.setBrush(Qt::blue); edges_pen_.setBrush(Qt::blue);
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -35,27 +35,27 @@ void DemoWindowItem::paint(QPainter *painter,
QWidget *widget) QWidget *widget)
{ {
// 1. Draw the poincaré disk // 1. Draw the poincaré disk
QRectF circle_rect = QRectF(-_poincare_disk_radius_in_pixels-3, QRectF circle_rect = QRectF(-poincare_disk_radius_in_pixels_-3,
-_poincare_disk_radius_in_pixels-3, -poincare_disk_radius_in_pixels_-3,
2*_poincare_disk_radius_in_pixels+6, 2*poincare_disk_radius_in_pixels_+6,
2*_poincare_disk_radius_in_pixels+6); 2*poincare_disk_radius_in_pixels_+6);
painter->setPen(_poincare_disk_pen); painter->setPen(poincare_disk_pen_);
painter->setBrush(QBrush()); painter->setBrush(QBrush());
painter->drawEllipse(circle_rect); painter->drawEllipse(circle_rect);
// 2. Draw the edges // 2. Draw the edges
painter->setBrush(QBrush()); painter->setBrush(QBrush());
painter->setPen(_edges_pen); painter->setPen(edges_pen_);
for (std::size_t i=0; i<_edges.size(); i++) { for (std::size_t i=0; i<edges_.size(); i++) {
draw_edge(painter, _edges[i].first, _edges[i].second); draw_edge(painter, edges_[i].first, edges_[i].second);
} }
} }
QRectF DemoWindowItem::boundingRect() const { QRectF DemoWindowItem::boundingRect() const {
return QRectF(-_poincare_disk_radius_in_pixels-3, return QRectF(-poincare_disk_radius_in_pixels_-3,
-_poincare_disk_radius_in_pixels-3, -poincare_disk_radius_in_pixels_-3,
_poincare_disk_radius_in_pixels+6, poincare_disk_radius_in_pixels_+6,
_poincare_disk_radius_in_pixels+6); poincare_disk_radius_in_pixels_+6);
} }
void DemoWindowItem::modelChanged() {} // Only used by Qt : we don't need to fill it void DemoWindowItem::modelChanged() {} // Only used by Qt : we don't need to fill it
@ -76,9 +76,9 @@ void DemoWindowItem::draw_triangulation(Triangulation& triangulation)
point_2 = std::get<2>(*it); point_2 = std::get<2>(*it);
point_3 = std::get<3>(*it); point_3 = std::get<3>(*it);
_edges.push_back(std::make_pair(point_1, point_2)); edges_.push_back(std::make_pair(point_1, point_2));
_edges.push_back(std::make_pair(point_2, point_3)); edges_.push_back(std::make_pair(point_2, point_3));
_edges.push_back(std::make_pair(point_3, point_1)); edges_.push_back(std::make_pair(point_3, point_1));
} }
} }
@ -87,8 +87,8 @@ void DemoWindowItem::draw_triangulation(Triangulation& triangulation)
void DemoWindowItem::draw_point(QPainter* painter, Point position) void DemoWindowItem::draw_point(QPainter* painter, Point position)
{ {
// First convert the point in doubles, well-scaled // First convert the point in doubles, well-scaled
double point_x = _poincare_disk_radius_in_pixels * CGAL::to_double(position.x()); double point_x = poincare_disk_radius_in_pixels_ * CGAL::to_double(position.x());
double point_y = _poincare_disk_radius_in_pixels * CGAL::to_double(position.y()); double point_y = poincare_disk_radius_in_pixels_ * CGAL::to_double(position.y());
// Then draw a small circle // Then draw a small circle
QRectF circle_rect = QRectF(point_x-1, point_y-1, 3, 3); QRectF circle_rect = QRectF(point_x-1, point_y-1, 3, 3);
@ -161,10 +161,10 @@ void DemoWindowItem::draw_line(QPainter* painter,
double point_2_x, double point_2_y) double point_2_x, double point_2_y)
{ {
// Convert to doubles and scale by the radius of the poincaré disk // Convert to doubles and scale by the radius of the poincaré disk
double src_x = _poincare_disk_radius_in_pixels * point_1_x; double src_x = poincare_disk_radius_in_pixels_ * point_1_x;
double src_y = _poincare_disk_radius_in_pixels * point_1_y; double src_y = poincare_disk_radius_in_pixels_ * point_1_y;
double tar_x = _poincare_disk_radius_in_pixels * point_2_x; double tar_x = poincare_disk_radius_in_pixels_ * point_2_x;
double tar_y = _poincare_disk_radius_in_pixels * point_2_y; double tar_y = poincare_disk_radius_in_pixels_ * point_2_y;
// Actual drawing // Actual drawing
QLineF line (src_x, src_y, tar_x, tar_y); QLineF line (src_x, src_y, tar_x, tar_y);
@ -180,23 +180,23 @@ void DemoWindowItem::draw_arc(QPainter* painter,
// 1. Scale by the radius of the poincaré disk // 1. Scale by the radius of the poincaré disk
double src_x = _poincare_disk_radius_in_pixels * point_1_x; double src_x = poincare_disk_radius_in_pixels_ * point_1_x;
double src_y = _poincare_disk_radius_in_pixels * point_1_y; double src_y = poincare_disk_radius_in_pixels_ * point_1_y;
double tar_x = _poincare_disk_radius_in_pixels * point_2_x; double tar_x = poincare_disk_radius_in_pixels_ * point_2_x;
double tar_y = _poincare_disk_radius_in_pixels * point_2_y; double tar_y = poincare_disk_radius_in_pixels_ * point_2_y;
double xc = _poincare_disk_radius_in_pixels * center_x; double xc = poincare_disk_radius_in_pixels_ * center_x;
double yc = _poincare_disk_radius_in_pixels * center_y; double yc = poincare_disk_radius_in_pixels_ * center_y;
// 2. Define the radius of the circle and the box [xm, xM] \times [ym, yM] bounding the circle // 2. Define the radius of the circle and the box [xm, xM] \times [ym, yM] bounding the circle
double circle_radius = sqrt((point_1_x-center_x)*(point_1_x-center_x) + (point_1_y-center_y)*(point_1_y-center_y)); double circle_radius = sqrt((point_1_x-center_x)*(point_1_x-center_x) + (point_1_y-center_y)*(point_1_y-center_y));
double xm = _poincare_disk_radius_in_pixels * (center_x - circle_radius); double xm = poincare_disk_radius_in_pixels_ * (center_x - circle_radius);
double xM = _poincare_disk_radius_in_pixels * (center_x + circle_radius); double xM = poincare_disk_radius_in_pixels_ * (center_x + circle_radius);
double ym = _poincare_disk_radius_in_pixels * (center_y - circle_radius); double ym = poincare_disk_radius_in_pixels_ * (center_y - circle_radius);
double yM = _poincare_disk_radius_in_pixels * (center_y + circle_radius); double yM = poincare_disk_radius_in_pixels_ * (center_y + circle_radius);
// If the source and the target are too close from each other (less than 10 pixels) or if the circle is very big then just draw a line // If the source and the target are too close from each other (less than 10 pixels) or if the circle is very big then just draw a line
double dist_sq = (src_x-tar_x)*(src_x-tar_x) + (src_y - tar_y)*(src_y-tar_y); double dist_sq = (src_x-tar_x)*(src_x-tar_x) + (src_y - tar_y)*(src_y-tar_y);
@ -251,11 +251,11 @@ double DemoWindowItem::deg_angle(double x, double y)
DemoWindow::DemoWindow() : DemosMainWindow() DemoWindow::DemoWindow() : DemosMainWindow()
{ {
setupUi(this); // Method automatically generated by the ui file and here inherited from Ui::MainWindow. Builds the window and the contents for us... setupUi(this); // Method automatically generated by the ui file and here inherited from Ui::MainWindow. Builds the window and the contents for us...
this->graphicsView->setScene(&_scene); // ... in particular graphicsView is already constructed : we just put our scene in it and then do things within the scene this->graphicsView->setScene(&scene_); // ... in particular graphicsView is already constructed : we just put our scene in it and then do things within the scene
_scene.setItemIndexMethod(QGraphicsScene::NoIndex); scene_.setItemIndexMethod(QGraphicsScene::NoIndex);
_scene.setSceneRect(-600, -600, 1200, 1200); scene_.setSceneRect(-600, -600, 1200, 1200);
_item = new DemoWindowItem(); item_ = new DemoWindowItem();
_scene.addItem(_item); scene_.addItem(item_);
this->graphicsView->scale(0.5, -0.5); // Y-axis inversion this->graphicsView->scale(0.5, -0.5); // Y-axis inversion
setWindowTitle("Hyperbolic surfaces triangulation 2 Demo"); setWindowTitle("Hyperbolic surfaces triangulation 2 Demo");
@ -263,7 +263,7 @@ DemoWindow::DemoWindow() : DemosMainWindow()
DemoWindowItem& DemoWindow::item() DemoWindowItem& DemoWindow::item()
{ {
return *_item; return *item_;
} }
void DemoWindow::keyPressEvent(QKeyEvent* event) {} void DemoWindow::keyPressEvent(QKeyEvent* event) {}

View File

@ -44,14 +44,14 @@ private:
typedef CGAL::Bbox_2 Bbox_2; // "Bounding box": just a box type used for drawing typedef CGAL::Bbox_2 Bbox_2; // "Bounding box": just a box type used for drawing
// Edges to draw // Edges to draw
std::vector<std::pair<Point,Point>> _edges; std::vector<std::pair<Point,Point> > edges_;
// Pens for drawing // Pens for drawing
QPen _poincare_disk_pen; QPen poincare_disk_pen_;
QPen _edges_pen; QPen edges_pen_;
// radius of the poincaré disk // radius of the poincaré disk
const int _poincare_disk_radius_in_pixels = 600; const int poincare_disk_radius_in_pixels_ = 600;
// Approximation treshold: used to decide when to simplify a computation (ex: draw a line // Approximation treshold: used to decide when to simplify a computation (ex: draw a line
// instead of an arc if an hyperbolic segment is very small) // instead of an arc if an hyperbolic segment is very small)
@ -93,8 +93,8 @@ class DemoWindow
// (Q_OBJECT does not support templates) // (Q_OBJECT does not support templates)
private: private:
QGraphicsScene _scene; QGraphicsScene scene_;
DemoWindowItem* _item; DemoWindowItem* item_;
public: public:
DemoWindow(); DemoWindow();

View File

@ -25,19 +25,19 @@ Templated by a field FT. Represents a complex number over FT.
template <class FT> template <class FT>
class Complex_number class Complex_number
{ {
typedef Complex_number<FT> _Self; typedef Complex_number<FT> Self;
FT _real, _imag; FT real_, imag_;
public: public:
Complex_number(const FT& real_part) Complex_number(const FT& real_part)
: _real(real_part), : real_(real_part),
_imag(0) imag_(0)
{} {}
Complex_number(const FT& real_part, const FT& imaginary_part) Complex_number(const FT& real_part, const FT& imaginary_part)
: _real(real_part), : real_(real_part),
_imag(imaginary_part) imag_(imaginary_part)
{} {}
Complex_number() Complex_number()
@ -46,75 +46,75 @@ public:
template<class U,class V> template<class U,class V>
Complex_number(U&& real_part, V&& imaginary_part) Complex_number(U&& real_part, V&& imaginary_part)
: _real(std::forward<U>(real_part)), : real_(std::forward<U>(real_part)),
_imag(std::forward<V>(imaginary_part)) imag_(std::forward<V>(imaginary_part))
{} {}
void real(const FT& real_part) { void real(const FT& real_part) {
_real = real_part; real_ = real_part;
} }
void imag(const FT& imaginary_part) { void imag(const FT& imaginary_part) {
_imag = imaginary_part; imag_ = imaginary_part;
} }
FT real() const { FT real() const {
return _real; return real_;
} }
FT imag() const { FT imag() const {
return _imag; return imag_;
} }
_Self& operator+=(const _Self& other); Self& operator+=(const Self& other);
_Self& operator-=(const _Self& other); Self& operator-=(const Self& other);
_Self& operator*=(const _Self& other); Self& operator*=(const Self& other);
_Self& operator/=(const _Self& other); Self& operator/=(const Self& other);
// These member versions are not working ? // These member versions are not working ?
/* _Self operator+(const _Self& z) const; */ /* Self operator+(const Self& z) const; */
/* _Self operator-(const _Self& z) const; */ /* Self operator-(const Self& z) const; */
// Hidden friends // Hidden friends
friend _Self operator+(const _Self& z) { friend Self operator+(const Self& z) {
return z; return z;
} }
friend _Self operator-(const _Self& z) { friend Self operator-(const Self& z) {
return _Self(-z._real,-z._imag); return Self(-z.real_,-z.imag_);
} }
friend bool operator==(const _Self& z1, const _Self& z2) { friend bool operator==(const Self& z1, const Self& z2) {
return (z1._real==z2._real && z1._imag==z2._imag); return (z1.real_==z2.real_ && z1.imag_==z2.imag_);
} }
friend bool operator!=(const _Self& z1, const _Self& z2) { friend bool operator!=(const Self& z1, const Self& z2) {
return !operator==(z1, z2); return !operator==(z1, z2);
} }
friend _Self operator+(const _Self& z1, const _Self& z2) { friend Self operator+(const Self& z1, const Self& z2) {
return _Self(z1._real+z2._real, z1._imag+z2._imag); return Self(z1.real_+z2.real_, z1.imag_+z2.imag_);
} }
friend _Self operator-(const _Self& z1, const _Self& z2) { friend Self operator-(const Self& z1, const Self& z2) {
return _Self(z1._real-z2._real, z1._imag-z2._imag); return Self(z1.real_-z2.real_, z1.imag_-z2.imag_);
} }
friend _Self operator*(const _Self& z1, const _Self& z2) { friend Self operator*(const Self& z1, const Self& z2) {
return _Self(z1._real*z2._real-z1._imag*z2._imag, z1._real*z2._imag+z1._imag*z2._real); return Self(z1.real_*z2.real_-z1.imag_*z2.imag_, z1.real_*z2.imag_+z1.imag_*z2.real_);
} }
friend _Self operator/(const _Self& z1, const _Self& z2) { friend Self operator/(const Self& z1, const Self& z2) {
FT m2 = norm(z2); FT m2 = norm(z2);
return _Self(z1._real/m2, z1._imag/m2)*conj(z2); return Self(z1.real_/m2, z1.imag_/m2)*conj(z2);
} }
friend std::ostream& operator<<(std::ostream& s, const _Self& z) { friend std::ostream& operator<<(std::ostream& s, const Self& z) {
s << z._real << std::endl << z._imag << std::endl; s << z.real_ << std::endl << z.imag_ << std::endl;
return s; return s;
} }
friend void operator>>(std::istream& s, _Self& z) { friend void operator>>(std::istream& s, Self& z) {
FT ft; FT ft;
s >> ft; s >> ft;
z.real(ft); z.real(ft);
@ -127,24 +127,24 @@ public:
template<class FT> template<class FT>
Complex_number<FT>& Complex_number<FT>::operator+=(const Complex_number<FT>& other) Complex_number<FT>& Complex_number<FT>::operator+=(const Complex_number<FT>& other)
{ {
_real += other.real(); real_ += other.real();
_imag += other.imag(); imag_ += other.imag();
return *this; return *this;
} }
template<class FT> template<class FT>
Complex_number<FT>& Complex_number<FT>::operator-=(const Complex_number<FT>& other) Complex_number<FT>& Complex_number<FT>::operator-=(const Complex_number<FT>& other)
{ {
_real -= other.real(); real_ -= other.real();
_imag -= other.imag(); imag_ -= other.imag();
return *this; return *this;
} }
template<class FT> template<class FT>
Complex_number<FT>& Complex_number<FT>::operator*=(const Complex_number<FT>& other) Complex_number<FT>& Complex_number<FT>::operator*=(const Complex_number<FT>& other)
{ {
_real = _real*other.real() - _imag*other.imag(); real_ = real_*other.real() - imag_*other.imag();
_imag = _real*other.imag() + _imag*other.real(); imag_ = real_*other.imag() + imag_*other.real();
return *this; return *this;
} }
@ -152,8 +152,8 @@ template<class FT>
Complex_number<FT>& Complex_number<FT>::operator/=(const Complex_number<FT>& other) Complex_number<FT>& Complex_number<FT>::operator/=(const Complex_number<FT>& other)
{ {
FT m2 = norm(other); FT m2 = norm(other);
_real /= m2; real_ /= m2;
_imag /= m2; imag_ /= m2;
this *= conj(other); this *= conj(other);
return *this; return *this;
} }

View File

@ -42,8 +42,8 @@ public:
template<class PointRange, class PairingRange> template<class PointRange, class PairingRange>
Hyperbolic_fundamental_domain_2(PointRange & vertices, PairingRange & pairings) Hyperbolic_fundamental_domain_2(PointRange & vertices, PairingRange & pairings)
{ {
_vertices = std::vector<Point>(vertices.begin(), vertices.end()); vertices_ = std::vector<Point>(vertices.begin(), vertices.end());
_pairings = std::vector<std::size_t>(pairings.begin(), pairings.end()); pairings_ = std::vector<std::size_t>(pairings.begin(), pairings.end());
} }
// returns the number of vertices (equivalently, the number of sides) // returns the number of vertices (equivalently, the number of sides)
@ -64,8 +64,8 @@ public:
bool is_valid() const; bool is_valid() const;
private: private:
std::vector<Point> _vertices; std::vector<Point> vertices_;
std::vector<std::size_t> _pairings; std::vector<std::size_t> pairings_;
}; };
//template<class Traits> std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain); //template<class Traits> std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain);
@ -82,7 +82,7 @@ Hyperbolic_fundamental_domain_2<Traits>::
size() const size() const
{ {
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return _vertices.size(); return vertices_.size();
} }
template<class Traits> template<class Traits>
@ -91,7 +91,7 @@ Hyperbolic_fundamental_domain_2<Traits>::
vertex(std::size_t index) const vertex(std::size_t index) const
{ {
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return _vertices[index]; return vertices_[index];
} }
template<class Traits> template<class Traits>
@ -100,7 +100,7 @@ Hyperbolic_fundamental_domain_2<Traits>::
paired_side(std::size_t index) const paired_side(std::size_t index) const
{ {
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return _pairings[index]; return pairings_[index];
} }
template<class Traits> template<class Traits>
@ -148,24 +148,24 @@ std::istream&
Hyperbolic_fundamental_domain_2<Traits>:: Hyperbolic_fundamental_domain_2<Traits>::
from_stream(std::istream& s) from_stream(std::istream& s)
{ {
_vertices.clear(); vertices_.clear();
_pairings.clear(); pairings_.clear();
std::string line; std::string line;
s >> line; s >> line;
std::size_t size = std::stoi(line); std::size_t size = std::stoi(line);
_vertices.reserve(size); vertices_.reserve(size);
_pairings.reserve(size); pairings_.reserve(size);
for (std::size_t k=0; k<size; ++k) { for (std::size_t k=0; k<size; ++k) {
s >> line; s >> line;
_pairings.push_back(std::stoi(line)); pairings_.push_back(std::stoi(line));
} }
for (std::size_t k=0; k<size; ++k) { for (std::size_t k=0; k<size; ++k) {
Point p; Point p;
s >> p; s >> p;
_vertices.push_back(p); vertices_.push_back(p);
} }
return s; return s;
} }
@ -178,7 +178,7 @@ Hyperbolic_fundamental_domain_2<Traits>::
is_valid()const is_valid()const
{ {
// Get the number of vertices // Get the number of vertices
std::size_t n = _vertices.size(); std::size_t n = vertices_.size();
// Check that the number of vertices is even // Check that the number of vertices is even
if (n%2) { if (n%2) {
@ -186,17 +186,17 @@ is_valid()const
} }
// Check that there are as many side pairings as vertices // Check that there are as many side pairings as vertices
if (_pairings.size() != n) { if (pairings_.size() != n) {
return false; return false;
} }
// Check that the _pairings vector encodes a perfect matching of the set {0,1,\dots,n-1} // Check that the pairings_ vector encodes a perfect matching of the set {0,1,\dots,n-1}
std::vector<bool> already_paired(n); std::vector<bool> already_paired(n);
for (std::size_t k=0; k<n; ++k) { for (std::size_t k=0; k<n; ++k) {
already_paired[k] = false; already_paired[k] = false;
} }
for (std::size_t k=0; k<n; ++k) { for (std::size_t k=0; k<n; ++k) {
std::size_t paired_side = _pairings[k]; std::size_t paired_side = pairings_[k];
if (paired_side>=n) { if (paired_side>=n) {
return false; return false;
} }
@ -208,7 +208,7 @@ is_valid()const
// Check that the vertices all lie within the open unit disk // Check that the vertices all lie within the open unit disk
for (std::size_t k=0; k<n; ++k) { for (std::size_t k=0; k<n; ++k) {
if (norm(Complex_number(_vertices[k].x(), _vertices[k].y())) >= typename Traits::FT(1)) { if (norm(Complex_number(vertices_[k].x(), vertices_[k].y())) >= typename Traits::FT(1)) {
return false; return false;
} }
} }

View File

@ -33,11 +33,11 @@ template<class Traits>
class Hyperbolic_fundamental_domain_factory_2 class Hyperbolic_fundamental_domain_factory_2
{ {
private: private:
typedef typename Traits::FT _FT; typedef typename Traits::FT FT;
typedef typename Traits::Complex _Cmplx; typedef typename Traits::Complex Cmplx;
typedef typename Traits::Hyperbolic_point_2 _Point; typedef typename Traits::Hyperbolic_point_2 Point;
Random _random; Random random_;
public: public:
Hyperbolic_fundamental_domain_factory_2(); Hyperbolic_fundamental_domain_factory_2();
@ -48,13 +48,13 @@ private:
float random_float(); // returns number in [-1,1] float random_float(); // returns number in [-1,1]
Complex_number<float> random_complex_float(); // returns complex z such that modulus(z) < 1 and imag(z) > 0 Complex_number<float> random_complex_float(); // returns complex z such that modulus(z) < 1 and imag(z) > 0
_FT exact_number_from_float(float x); FT exact_number_from_float(float x);
_Cmplx exact_complex_from_float_complex(const Complex_number<float>& z); Cmplx exact_complex_from_float_complex(const Complex_number<float>& z);
bool try_to_compute_inexact_z0_from_z1_z2_z3(Complex_number<float>& z0, Complex_number<float>& z1, Complex_number<float>& z2, Complex_number<float>& z3); bool try_to_compute_inexact_z0_from_z1_z2_z3(Complex_number<float>& z0, Complex_number<float>& z1, Complex_number<float>& z2, Complex_number<float>& z3);
bool try_to_compute_exact_z3_from_z0_z1_z2(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3); bool try_to_compute_exact_z3_from_z0_z1_z2(Cmplx& z0, Cmplx& z1, Cmplx& z2, Cmplx& z3);
bool sanity_check(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3); bool sanity_check(Cmplx& z0, Cmplx& z1, Cmplx& z2, Cmplx& z3);
const int CGAL_DENOMINATOR_FOR_GENERATION = 10000; const int CGAL_DENOMINATOR_FOR_GENERATION = 10000;
}; };
@ -73,9 +73,9 @@ Hyperbolic_fundamental_domain_2<Traits>
Hyperbolic_fundamental_domain_factory_2<Traits>:: Hyperbolic_fundamental_domain_factory_2<Traits>::
make_hyperbolic_fundamental_domain_g2(unsigned int seed) make_hyperbolic_fundamental_domain_g2(unsigned int seed)
{ {
_random = Random(seed); random_ = Random(seed);
bool is_domain_generated = false; bool is_domain_generated = false;
_Cmplx exact_z0, exact_z1, exact_z2, exact_z3; Cmplx exact_z0, exact_z1, exact_z2, exact_z3;
while (!is_domain_generated) { while (!is_domain_generated) {
// 1. Generate inexact z0,z1,z2,z3 // 1. Generate inexact z0,z1,z2,z3
@ -103,16 +103,16 @@ make_hyperbolic_fundamental_domain_g2(unsigned int seed)
} }
} }
_Cmplx exact_zero(_FT(0), _FT(0)); Cmplx exact_zero(FT(0), FT(0));
std::vector<_Point> vertices; std::vector<Point> vertices;
vertices.push_back(_Point(exact_z0.real(), exact_z0.imag())); vertices.push_back(Point(exact_z0.real(), exact_z0.imag()));
vertices.push_back(_Point(exact_z1.real(), exact_z1.imag())); vertices.push_back(Point(exact_z1.real(), exact_z1.imag()));
vertices.push_back(_Point(exact_z2.real(), exact_z2.imag())); vertices.push_back(Point(exact_z2.real(), exact_z2.imag()));
vertices.push_back(_Point(exact_z3.real(), exact_z3.imag())); vertices.push_back(Point(exact_z3.real(), exact_z3.imag()));
vertices.push_back(_Point(-exact_z0.real(), -exact_z0.imag())); vertices.push_back(Point(-exact_z0.real(), -exact_z0.imag()));
vertices.push_back(_Point(-exact_z1.real(), -exact_z1.imag())); vertices.push_back(Point(-exact_z1.real(), -exact_z1.imag()));
vertices.push_back(_Point(-exact_z2.real(), -exact_z2.imag())); vertices.push_back(Point(-exact_z2.real(), -exact_z2.imag()));
vertices.push_back(_Point(-exact_z3.real(), -exact_z3.imag())); vertices.push_back(Point(-exact_z3.real(), -exact_z3.imag()));
std::vector<int> pairings; std::vector<int> pairings;
for (int k=0; k<8; ++k) { for (int k=0; k<8; ++k) {
@ -127,12 +127,12 @@ make_hyperbolic_fundamental_domain_g2(unsigned int seed)
template<class Traits> template<class Traits>
float Hyperbolic_fundamental_domain_factory_2<Traits>::random_positive_float() { float Hyperbolic_fundamental_domain_factory_2<Traits>::random_positive_float() {
return _random.uniform_01<float>(); return random_.uniform_01<float>();
} }
template<class Traits> template<class Traits>
float Hyperbolic_fundamental_domain_factory_2<Traits>::random_float() { float Hyperbolic_fundamental_domain_factory_2<Traits>::random_float() {
return _random.uniform_01<float>() * 2 - 1; return random_.uniform_01<float>() * 2 - 1;
} }
template<class Traits> template<class Traits>
@ -157,9 +157,9 @@ Hyperbolic_fundamental_domain_factory_2<Traits>::
exact_number_from_float(float x) exact_number_from_float(float x)
{ {
if (x < 0) { if (x < 0) {
return _FT(0)-exact_number_from_float(-x); return FT(0)-exact_number_from_float(-x);
} }
return _FT(int(x*CGAL_DENOMINATOR_FOR_GENERATION)%CGAL_DENOMINATOR_FOR_GENERATION)/_FT(CGAL_DENOMINATOR_FOR_GENERATION); return FT(int(x*CGAL_DENOMINATOR_FOR_GENERATION)%CGAL_DENOMINATOR_FOR_GENERATION)/FT(CGAL_DENOMINATOR_FOR_GENERATION);
} }
template<class Traits> template<class Traits>
@ -167,7 +167,7 @@ typename Traits::Complex
Hyperbolic_fundamental_domain_factory_2<Traits>:: Hyperbolic_fundamental_domain_factory_2<Traits>::
exact_complex_from_float_complex(const Complex_number<float>& z) exact_complex_from_float_complex(const Complex_number<float>& z)
{ {
return _Cmplx(exact_number_from_float(z.real()), exact_number_from_float(z.imag())); return Cmplx(exact_number_from_float(z.real()), exact_number_from_float(z.imag()));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -202,10 +202,10 @@ try_to_compute_inexact_z0_from_z1_z2_z3(Complex_number<float>& z0,
template<class Traits> template<class Traits>
bool bool
Hyperbolic_fundamental_domain_factory_2<Traits>:: Hyperbolic_fundamental_domain_factory_2<Traits>::
try_to_compute_exact_z3_from_z0_z1_z2(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3) try_to_compute_exact_z3_from_z0_z1_z2(Cmplx& z0, Cmplx& z1, Cmplx& z2, Cmplx& z3)
{ {
_FT zero_number (0); FT zero_number (0);
_FT one_number (1); FT one_number (1);
if ((z0.real()<=zero_number) || (z1.imag()<=zero_number) || (z2.imag()<=zero_number) || (z3.imag()<=zero_number)) { if ((z0.real()<=zero_number) || (z1.imag()<=zero_number) || (z2.imag()<=zero_number) || (z3.imag()<=zero_number)) {
return false; return false;
} }
@ -218,24 +218,24 @@ try_to_compute_exact_z3_from_z0_z1_z2(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx
return false; return false;
} }
_Cmplx one_cmplx (_FT(1), _FT(0)); Cmplx one_cmplx (FT(1), FT(0));
_Cmplx two_cmplx(_FT(2), _FT(0)); Cmplx two_cmplx(FT(2), FT(0));
_Cmplx f_of_z0 = two_cmplx * z0 / (z0*z0 + one_cmplx); Cmplx f_of_z0 = two_cmplx * z0 / (z0*z0 + one_cmplx);
_Cmplx f_of_z1 = (z0 + z1) / (z0*z1 + one_cmplx); Cmplx f_of_z1 = (z0 + z1) / (z0*z1 + one_cmplx);
_Cmplx f_of_z2 = (z0 + z2) / (z0*z2 + one_cmplx); Cmplx f_of_z2 = (z0 + z2) / (z0*z2 + one_cmplx);
_Cmplx f_of_z3 = (z0 + z3) / (z0*z3 + one_cmplx); Cmplx f_of_z3 = (z0 + z3) / (z0*z3 + one_cmplx);
_Cmplx intermediate = (one_cmplx - f_of_z0*conj(f_of_z1)) * (one_cmplx - f_of_z1*conj(f_of_z2)); Cmplx intermediate = (one_cmplx - f_of_z0*conj(f_of_z1)) * (one_cmplx - f_of_z1*conj(f_of_z2));
_FT P_of_zero = intermediate.imag(); FT P_of_zero = intermediate.imag();
_FT P_of_one = (intermediate * (one_cmplx-f_of_z2*conj(f_of_z3))).imag(); FT P_of_one = (intermediate * (one_cmplx-f_of_z2*conj(f_of_z3))).imag();
if (P_of_one == P_of_zero) { if (P_of_one == P_of_zero) {
return false; return false;
} }
_FT lbda = P_of_zero / (P_of_zero - P_of_one); FT lbda = P_of_zero / (P_of_zero - P_of_one);
_Cmplx V (lbda*(f_of_z3.real()), lbda*(f_of_z3.imag())); Cmplx V (lbda*(f_of_z3.real()), lbda*(f_of_z3.imag()));
if ((V.imag()<=zero_number) || (norm(V)>=one_number) || ((V/f_of_z2).imag()<=zero_number)) { if ((V.imag()<=zero_number) || (norm(V)>=one_number) || ((V/f_of_z2).imag()<=zero_number)) {
return false; return false;
@ -251,10 +251,10 @@ try_to_compute_exact_z3_from_z0_z1_z2(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx
template<class Traits> template<class Traits>
bool bool
Hyperbolic_fundamental_domain_factory_2<Traits>:: Hyperbolic_fundamental_domain_factory_2<Traits>::
sanity_check(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3) sanity_check(Cmplx& z0, Cmplx& z1, Cmplx& z2, Cmplx& z3)
{ {
_FT zero_number(0); FT zero_number(0);
_FT one_number(1); FT one_number(1);
// 1. Check the positions // 1. Check the positions
if ((z0.imag()!=zero_number) || (z0.real()<=zero_number) || (z1.imag()<=zero_number) || (z2.imag()<=zero_number) || (z3.imag()<=zero_number)) { if ((z0.imag()!=zero_number) || (z0.real()<=zero_number) || (z1.imag()<=zero_number) || (z2.imag()<=zero_number) || (z3.imag()<=zero_number)) {
@ -270,8 +270,8 @@ sanity_check(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3)
} }
// 2. Check the area // 2. Check the area
_Cmplx one_cmplx (one_number, zero_number); Cmplx one_cmplx (one_number, zero_number);
_Cmplx Z = (one_cmplx-z0*conj(z1)) * (one_cmplx-z1*conj(z2)) *(one_cmplx-z2*conj(z3)) *(one_cmplx+z3*conj(z0)); Cmplx Z = (one_cmplx-z0*conj(z1)) * (one_cmplx-z1*conj(z2)) *(one_cmplx-z2*conj(z3)) *(one_cmplx+z3*conj(z0));
if (Z.imag()!=zero_number) { if (Z.imag()!=zero_number) {
return false; return false;
} }

View File

@ -50,7 +50,7 @@ public:
Point operator()(const Point& point) const; Point operator()(const Point& point) const;
private: private:
Complex_number _coefficients[4]; Complex_number coefficients_[4];
}; };
// returns the composition of two isometries. // returns the composition of two isometries.
@ -131,7 +131,7 @@ void
Hyperbolic_isometry_2<Traits>:: Hyperbolic_isometry_2<Traits>::
set_coefficient(int index, const Complex_number& coefficient) set_coefficient(int index, const Complex_number& coefficient)
{ {
_coefficients[index] = coefficient; coefficients_[index] = coefficient;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -141,7 +141,7 @@ const typename Traits::Complex&
Hyperbolic_isometry_2<Traits>:: Hyperbolic_isometry_2<Traits>::
get_coefficient(int index) const get_coefficient(int index) const
{ {
return _coefficients[index]; return coefficients_[index];
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -152,8 +152,8 @@ Hyperbolic_isometry_2<Traits>::
evaluate(const Point& point) const evaluate(const Point& point) const
{ {
Complex_number z(point.x(), point.y()); Complex_number z(point.x(), point.y());
Complex_number numerator_of_the_result = _coefficients[0] * z + _coefficients[1]; Complex_number numerator_of_the_result = coefficients_[0] * z + coefficients_[1];
Complex_number denominator_of_the_result = _coefficients[2] * z + _coefficients[3]; Complex_number denominator_of_the_result = coefficients_[2] * z + coefficients_[3];
Complex_number result = numerator_of_the_result / denominator_of_the_result; Complex_number result = numerator_of_the_result / denominator_of_the_result;
return Point(result.real(), result.imag()); return Point(result.real(), result.imag());
} }

View File

@ -118,28 +118,28 @@ public:
// Wrapper around the Cmap for iterating over vertices, edges or faces. // Wrapper around the Cmap for iterating over vertices, edges or faces.
Vertex_range vertices_range() { Vertex_range vertices_range() {
return _combinatorial_map.template one_dart_per_cell<0>(); return combinatorial_map_.template one_dart_per_cell<0>();
} }
Edge_range edges_range() { Edge_range edges_range() {
return _combinatorial_map.template one_dart_per_cell<1>(); return combinatorial_map_.template one_dart_per_cell<1>();
} }
Face_range faces_range() { Face_range faces_range() {
return _combinatorial_map.template one_dart_per_cell<2>(); return combinatorial_map_.template one_dart_per_cell<2>();
} }
Vertex_const_range vertices_const_range() const { Vertex_const_range vertices_const_range() const {
return _combinatorial_map.template one_dart_per_cell<0>(); return combinatorial_map_.template one_dart_per_cell<0>();
} }
Edge_const_range edges_const_range() const { Edge_const_range edges_const_range() const {
return _combinatorial_map.template one_dart_per_cell<1>(); return combinatorial_map_.template one_dart_per_cell<1>();
} }
Face_const_range faces_const_range() const { Face_const_range faces_const_range() const {
return _combinatorial_map.template one_dart_per_cell<2>(); return combinatorial_map_.template one_dart_per_cell<2>();
} }
protected: protected:
Combinatorial_map_with_cross_ratios _combinatorial_map; Combinatorial_map_with_cross_ratios combinatorial_map_;
bool _has_anchor = false; bool has_anchor_ = false;
Anchor _anchor; Anchor anchor_;
Dart_descriptor pick_edge_to_flip(); Dart_descriptor pick_edge_to_flip();
Dart_const_descriptor pick_edge_to_flip() const; Dart_const_descriptor pick_edge_to_flip() const;
@ -160,13 +160,13 @@ Triangulation_on_hyperbolic_surface_2<Traits,Attributes>::
Triangulation_on_hyperbolic_surface_2(const Domain& domain) Triangulation_on_hyperbolic_surface_2(const Domain& domain)
{ {
// (Triangulates by adding an internal edge between domain.vertex(size-1) and the other vertices) // (Triangulates by adding an internal edge between domain.vertex(size-1) and the other vertices)
_combinatorial_map.clear(); combinatorial_map_.clear();
std::size_t size = domain.size(); std::size_t size = domain.size();
// Make the triangles // Make the triangles
std::vector<Dart_descriptor> dart_of_triangle(size-2); std::vector<Dart_descriptor> dart_of_triangle(size-2);
for (std::size_t k=0; k<size-2; ++k) { for (std::size_t k=0; k<size-2; ++k) {
dart_of_triangle[k] = _combinatorial_map.make_combinatorial_polygon(3); dart_of_triangle[k] = combinatorial_map_.make_combinatorial_polygon(3);
} }
// Sew the internal edges and set their cross ratios // Sew the internal edges and set their cross ratios
@ -182,8 +182,8 @@ Triangulation_on_hyperbolic_surface_2(const Domain& domain)
p2 = domain.vertex(k); p2 = domain.vertex(k);
p3 = domain.vertex(k+1); p3 = domain.vertex(k+1);
_combinatorial_map.template sew<2>(dart_1, dart_2); combinatorial_map_.template sew<2>(dart_1, dart_2);
_combinatorial_map.template set_attribute<1>(dart_1, _combinatorial_map.template create_attribute<1>(cross_ratio(p0,p1,p2,p3))); combinatorial_map_.template set_attribute<1>(dart_1, combinatorial_map_.template create_attribute<1>(cross_ratio(p0,p1,p2,p3)));
} }
// Sew the boundary edges and set their cross ratios // Sew the boundary edges and set their cross ratios
@ -217,18 +217,18 @@ Triangulation_on_hyperbolic_surface_2(const Domain& domain)
p3 = domain.side_pairing(k1).evaluate(p3); p3 = domain.side_pairing(k1).evaluate(p3);
if (_combinatorial_map.template is_sewable<2>(dart_1, dart_2)) { if (combinatorial_map_.template is_sewable<2>(dart_1, dart_2)) {
_combinatorial_map.template sew<2>(dart_1, dart_2); combinatorial_map_.template sew<2>(dart_1, dart_2);
_combinatorial_map.template set_attribute<1>(dart_1, _combinatorial_map.template create_attribute<1>(cross_ratio(p0,p1,p2,p3))); combinatorial_map_.template set_attribute<1>(dart_1, combinatorial_map_.template create_attribute<1>(cross_ratio(p0,p1,p2,p3)));
} }
} }
// Set the anchor // Set the anchor
_anchor.dart = dart_of_triangle[0]; anchor_.dart = dart_of_triangle[0];
_anchor.vertices[0] = domain.vertex(size-1); anchor_.vertices[0] = domain.vertex(size-1);
_anchor.vertices[1] = domain.vertex(0); anchor_.vertices[1] = domain.vertex(0);
_anchor.vertices[2] = domain.vertex(1); anchor_.vertices[2] = domain.vertex(1);
_has_anchor = true; has_anchor_ = true;
} }
/* template<class Traits, class Attributes> */ /* template<class Traits, class Attributes> */
@ -251,7 +251,7 @@ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Combinatoria
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>:: Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
combinatorial_map() combinatorial_map()
{ {
return _combinatorial_map; return combinatorial_map_;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
@ -260,7 +260,7 @@ Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
has_anchor() const has_anchor() const
{ {
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return _has_anchor; return has_anchor_;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
@ -269,7 +269,7 @@ Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
anchor() anchor()
{ {
CGAL_precondition(is_valid() && has_anchor()); CGAL_precondition(is_valid() && has_anchor());
return _anchor; return anchor_;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
@ -278,7 +278,7 @@ Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
anchor() const anchor() const
{ {
CGAL_precondition(is_valid() && has_anchor()); CGAL_precondition(is_valid() && has_anchor());
return _anchor; return anchor_;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -317,20 +317,20 @@ flip(Dart_descriptor dart)
// Modify the anchor // Modify the anchor
if (_anchor.dart == a) { if (anchor_.dart == a) {
_anchor.dart = e; anchor_.dart = e;
_anchor.vertices[1] = Point(fourth_point_from_cross_ratio(_anchor.vertices[1], _anchor.vertices[2], _anchor.vertices[0], cross_ratio_AC)); anchor_.vertices[1] = Point(fourth_point_from_cross_ratio(anchor_.vertices[1], anchor_.vertices[2], anchor_.vertices[0], cross_ratio_AC));
} else if (_anchor.dart == b) { } else if (anchor_.dart == b) {
_anchor.vertices[2] = Point(fourth_point_from_cross_ratio(_anchor.vertices[0], _anchor.vertices[1], _anchor.vertices[2], cross_ratio_AC)); anchor_.vertices[2] = Point(fourth_point_from_cross_ratio(anchor_.vertices[0], anchor_.vertices[1], anchor_.vertices[2], cross_ratio_AC));
} else if (_anchor.dart == c) { } else if (anchor_.dart == c) {
_anchor.vertices[2] = Point(fourth_point_from_cross_ratio(_anchor.vertices[2], _anchor.vertices[0], _anchor.vertices[1], cross_ratio_AC)); anchor_.vertices[2] = Point(fourth_point_from_cross_ratio(anchor_.vertices[2], anchor_.vertices[0], anchor_.vertices[1], cross_ratio_AC));
} else if (_anchor.dart == d) { } else if (anchor_.dart == d) {
_anchor.dart = b; anchor_.dart = b;
_anchor.vertices[1] = Point(fourth_point_from_cross_ratio(_anchor.vertices[1], _anchor.vertices[2], _anchor.vertices[0], cross_ratio_AC)); anchor_.vertices[1] = Point(fourth_point_from_cross_ratio(anchor_.vertices[1], anchor_.vertices[2], anchor_.vertices[0], cross_ratio_AC));
} else if (_anchor.dart == e) { } else if (anchor_.dart == e) {
_anchor.vertices[2] = Point(fourth_point_from_cross_ratio(_anchor.vertices[0], _anchor.vertices[1], _anchor.vertices[2], cross_ratio_AC)); anchor_.vertices[2] = Point(fourth_point_from_cross_ratio(anchor_.vertices[0], anchor_.vertices[1], anchor_.vertices[2], cross_ratio_AC));
} else if (_anchor.dart == f) { } else if (anchor_.dart == f) {
_anchor.vertices[2] = Point(fourth_point_from_cross_ratio(_anchor.vertices[2], _anchor.vertices[0], _anchor.vertices[1], cross_ratio_AC)); anchor_.vertices[2] = Point(fourth_point_from_cross_ratio(anchor_.vertices[2], anchor_.vertices[0], anchor_.vertices[1], cross_ratio_AC));
} }
// Compute the new cross ratios // Compute the new cross ratios
@ -344,39 +344,39 @@ flip(Dart_descriptor dart)
// Make the topological flip // Make the topological flip
_combinatorial_map.template unlink_beta<1>(a); combinatorial_map_.template unlink_beta<1>(a);
_combinatorial_map.template unlink_beta<1>(b); combinatorial_map_.template unlink_beta<1>(b);
_combinatorial_map.template unlink_beta<1>(c); combinatorial_map_.template unlink_beta<1>(c);
_combinatorial_map.template unlink_beta<1>(d); combinatorial_map_.template unlink_beta<1>(d);
_combinatorial_map.template unlink_beta<1>(e); combinatorial_map_.template unlink_beta<1>(e);
_combinatorial_map.template unlink_beta<1>(f); combinatorial_map_.template unlink_beta<1>(f);
_combinatorial_map.template link_beta<1>(b, a); combinatorial_map_.template link_beta<1>(b, a);
_combinatorial_map.template link_beta<1>(a, f); combinatorial_map_.template link_beta<1>(a, f);
_combinatorial_map.template link_beta<1>(f, b); combinatorial_map_.template link_beta<1>(f, b);
_combinatorial_map.template link_beta<1>(e, d); combinatorial_map_.template link_beta<1>(e, d);
_combinatorial_map.template link_beta<1>(d, c); combinatorial_map_.template link_beta<1>(d, c);
_combinatorial_map.template link_beta<1>(c, e); combinatorial_map_.template link_beta<1>(c, e);
// And give the new cross ratios to the edges // And give the new cross ratios to the edges
_combinatorial_map.template info<1>(a) = cross_ratio_BD; combinatorial_map_.template info<1>(a) = cross_ratio_BD;
_combinatorial_map.template info<1>(e) = cross_ratio_AB_2; combinatorial_map_.template info<1>(e) = cross_ratio_AB_2;
_combinatorial_map.template info<1>(f) = cross_ratio_BC_2; combinatorial_map_.template info<1>(f) = cross_ratio_BC_2;
_combinatorial_map.template info<1>(b) = cross_ratio_CD_2; combinatorial_map_.template info<1>(b) = cross_ratio_CD_2;
_combinatorial_map.template info<1>(c) = cross_ratio_DA_2; combinatorial_map_.template info<1>(c) = cross_ratio_DA_2;
// Take care of the particular cases where we need to "flip again" // Take care of the particular cases where we need to "flip again"
if (opposite(e) == b) { if (opposite(e) == b) {
_combinatorial_map.template info<1>(e) = one - (one - cross_ratio_AB_2) * (cross_ratio_AC); combinatorial_map_.template info<1>(e) = one - (one - cross_ratio_AB_2) * (cross_ratio_AC);
} }
if (opposite(f) == c) { if (opposite(f) == c) {
_combinatorial_map.template info<1>(f) = one - (one - cross_ratio_BC_2) / (cross_ratio_BD); combinatorial_map_.template info<1>(f) = one - (one - cross_ratio_BC_2) / (cross_ratio_BD);
} }
} }
@ -422,8 +422,8 @@ lift(bool center) const
std::vector<std::tuple<Dart_const_descriptor, Point, Point, Point> > realizations; std::vector<std::tuple<Dart_const_descriptor, Point, Point, Point> > realizations;
size_t visited_darts_mark = _combinatorial_map.get_new_mark(); size_t visited_darts_mark = combinatorial_map_.get_new_mark();
_combinatorial_map.unmark_all(visited_darts_mark); combinatorial_map_.unmark_all(visited_darts_mark);
struct Compare struct Compare
{ {
@ -439,41 +439,41 @@ lift(bool center) const
std::unordered_map<Dart_const_descriptor, Point> positions; std::unordered_map<Dart_const_descriptor, Point> positions;
Dart_const_range darts = _combinatorial_map.darts(); Dart_const_range darts = combinatorial_map_.darts();
_combinatorial_map.mark(_anchor.dart, visited_darts_mark); combinatorial_map_.mark(anchor_.dart, visited_darts_mark);
_combinatorial_map.mark(const_ccw(_anchor.dart), visited_darts_mark); combinatorial_map_.mark(const_ccw(anchor_.dart), visited_darts_mark);
_combinatorial_map.mark(const_cw(_anchor.dart), visited_darts_mark); combinatorial_map_.mark(const_cw(anchor_.dart), visited_darts_mark);
if (center) { if (center) {
Isometry center_the_drawing = hyperbolic_translation<Traits>(_anchor.vertices[0]); Isometry center_the_drawing = hyperbolic_translation<Traits>(anchor_.vertices[0]);
positions[_anchor.dart] = center_the_drawing.evaluate(_anchor.vertices[0]); positions[anchor_.dart] = center_the_drawing.evaluate(anchor_.vertices[0]);
positions[const_ccw(_anchor.dart)] = center_the_drawing.evaluate(_anchor.vertices[1]); positions[const_ccw(anchor_.dart)] = center_the_drawing.evaluate(anchor_.vertices[1]);
positions[const_cw(_anchor.dart)] = center_the_drawing.evaluate(_anchor.vertices[2]); positions[const_cw(anchor_.dart)] = center_the_drawing.evaluate(anchor_.vertices[2]);
} else { } else {
positions[_anchor.dart] = _anchor.vertices[0]; positions[anchor_.dart] = anchor_.vertices[0];
positions[const_ccw(_anchor.dart)] = _anchor.vertices[1]; positions[const_ccw(anchor_.dart)] = anchor_.vertices[1];
positions[const_cw(_anchor.dart)] = _anchor.vertices[2]; positions[const_cw(anchor_.dart)] = anchor_.vertices[2];
} }
std::tuple<Dart_const_descriptor, Point, Point, Point> value = std::tuple<Dart_const_descriptor, Point, Point, Point> value =
std::make_tuple(_anchor.dart, std::make_tuple(anchor_.dart,
positions[_anchor.dart], positions[anchor_.dart],
positions[const_ccw(_anchor.dart)], positions[const_ccw(anchor_.dart)],
positions[const_cw(_anchor.dart)]); positions[const_cw(anchor_.dart)]);
realizations.push_back(value); realizations.push_back(value);
Complex_number anchor_z0(_anchor.vertices[0].x(), _anchor.vertices[0].y()); Complex_number anchor_z0(anchor_.vertices[0].x(), anchor_.vertices[0].y());
Complex_number anchor_z1(_anchor.vertices[1].x(), _anchor.vertices[1].y()); Complex_number anchor_z1(anchor_.vertices[1].x(), anchor_.vertices[1].y());
Complex_number anchor_z2(_anchor.vertices[2].x(), _anchor.vertices[2].y()); Complex_number anchor_z2(anchor_.vertices[2].x(), anchor_.vertices[2].y());
double weight_of_anchor_dart = CGAL::to_double(norm(anchor_z0) + norm(anchor_z1)); double weight_of_anchor_dart = CGAL::to_double(norm(anchor_z0) + norm(anchor_z1));
double weight_of_ccw_anchor_dart = CGAL::to_double(norm(anchor_z1) + norm(anchor_z2)); double weight_of_ccw_anchor_dart = CGAL::to_double(norm(anchor_z1) + norm(anchor_z2));
double weight_of_cw_anchor_dart = CGAL::to_double(norm(anchor_z2) + norm(anchor_z0)); double weight_of_cw_anchor_dart = CGAL::to_double(norm(anchor_z2) + norm(anchor_z0));
queue.push(std::make_pair(_anchor.dart, weight_of_anchor_dart)); queue.push(std::make_pair(anchor_.dart, weight_of_anchor_dart));
queue.push(std::make_pair(const_ccw(_anchor.dart), weight_of_ccw_anchor_dart)); queue.push(std::make_pair(const_ccw(anchor_.dart), weight_of_ccw_anchor_dart));
queue.push(std::make_pair(const_cw(_anchor.dart), weight_of_cw_anchor_dart)); queue.push(std::make_pair(const_cw(anchor_.dart), weight_of_cw_anchor_dart));
while (! queue.empty()) { while (! queue.empty()) {
Dart_const_descriptor invader = queue.top().first; Dart_const_descriptor invader = queue.top().first;
@ -481,10 +481,10 @@ lift(bool center) const
Dart_const_descriptor invaded = const_opposite(invader); Dart_const_descriptor invaded = const_opposite(invader);
if (!_combinatorial_map.is_marked(invaded, visited_darts_mark)) { if (!combinatorial_map_.is_marked(invaded, visited_darts_mark)) {
_combinatorial_map.mark(invaded, visited_darts_mark); combinatorial_map_.mark(invaded, visited_darts_mark);
_combinatorial_map.mark(const_ccw(invaded), visited_darts_mark); combinatorial_map_.mark(const_ccw(invaded), visited_darts_mark);
_combinatorial_map.mark(const_cw(invaded), visited_darts_mark); combinatorial_map_.mark(const_cw(invaded), visited_darts_mark);
const Point& a = positions[const_ccw(invader)]; const Point& a = positions[const_ccw(invader)];
const Point& b = positions[const_cw(invader)]; const Point& b = positions[const_cw(invader)];
@ -514,7 +514,7 @@ lift(bool center) const
} }
} }
_combinatorial_map.free_mark(visited_darts_mark); combinatorial_map_.free_mark(visited_darts_mark);
return realizations; return realizations;
} }
@ -529,29 +529,29 @@ is_valid() const
// 1. Check the combinatorial map // 1. Check the combinatorial map
// Check that the combinatorial map is valid // Check that the combinatorial map is valid
if (!_combinatorial_map.is_valid()) { if (!combinatorial_map_.is_valid()) {
return false; return false;
} }
// Check that the combinatorial map has no 1,2-boundary // Check that the combinatorial map has no 1,2-boundary
for (int k=1; k<3; ++k) { for (int k=1; k<3; ++k) {
if (!_combinatorial_map.is_without_boundary(k)) { if (!combinatorial_map_.is_without_boundary(k)) {
return false; return false;
} }
} }
// 2. Check the anchor, if any // 2. Check the anchor, if any
if (_has_anchor) { if (has_anchor_) {
// Check that the dart descriptor of the anchor points to a dart of the combinatorial map // Check that the dart descriptor of the anchor points to a dart of the combinatorial map
if (!_combinatorial_map.is_dart_used(_anchor.dart)) { if (!combinatorial_map_.is_dart_used(anchor_.dart)) {
return false; return false;
} }
// Check that the three vertices of the anchor lie within the open unit disk // Check that the three vertices of the anchor lie within the open unit disk
for (int k=0; k<3; ++k) { for (int k=0; k<3; ++k) {
// if (_anchor.vertices[k].get_z() >= Number(1)) { // if (anchor_.vertices[k].get_z() >= Number(1)) {
if (norm(Complex_number(_anchor.vertices[k].x(),_anchor.vertices[k].y())) >= Number(1)) { if (norm(Complex_number(anchor_.vertices[k].x(),anchor_.vertices[k].y())) >= Number(1)) {
return false; return false;
} }
} }
@ -572,7 +572,7 @@ to_stream(std::ostream& s) const
// Give indices to the darts // Give indices to the darts
std::map<Dart_const_descriptor, int> darts_indices; std::map<Dart_const_descriptor, int> darts_indices;
int current_dart_index = 0; int current_dart_index = 0;
for (typename Dart_const_range::const_iterator it=_combinatorial_map.darts().begin(); it!=_combinatorial_map.darts().end(); ++it) { for (typename Dart_const_range::const_iterator it=combinatorial_map_.darts().begin(); it!=combinatorial_map_.darts().end(); ++it) {
darts_indices[it] = current_dart_index; darts_indices[it] = current_dart_index;
current_dart_index++; current_dart_index++;
} }
@ -581,12 +581,12 @@ to_stream(std::ostream& s) const
s << current_dart_index << std::endl; s << current_dart_index << std::endl;
// Store the anchor, if any // Store the anchor, if any
if (_has_anchor) { if (has_anchor_) {
s << "yes" << std::endl; s << "yes" << std::endl;
s << darts_indices[_anchor.dart] << std::endl; s << darts_indices[anchor_.dart] << std::endl;
s << _anchor.vertices[0] << std::endl; s << anchor_.vertices[0] << std::endl;
s << _anchor.vertices[1] << std::endl; s << anchor_.vertices[1] << std::endl;
s << _anchor.vertices[2] << std::endl; s << anchor_.vertices[2] << std::endl;
} else { } else {
s << "no" << std::endl; s << "no" << std::endl;
} }
@ -611,7 +611,7 @@ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>:: Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
from_stream(std::istream& s) from_stream(std::istream& s)
{ {
_combinatorial_map.clear(); combinatorial_map_.clear();
// Load the number of darts // Load the number of darts
std::string line; std::string line;
@ -622,23 +622,23 @@ from_stream(std::istream& s)
int anchor_dart_id = 0; int anchor_dart_id = 0;
s >> line; s >> line;
if (!line.compare("yes")) { if (!line.compare("yes")) {
_has_anchor = true; has_anchor_ = true;
s >> line; s >> line;
anchor_dart_id = std::stoi(line); // (*) _anchor.dart_id is set at the end of the function anchor_dart_id = std::stoi(line); // (*) anchor_.dart_id is set at the end of the function
s >> _anchor.vertices[0]; s >> anchor_.vertices[0];
s >> _anchor.vertices[1]; s >> anchor_.vertices[1];
s >> _anchor.vertices[2]; s >> anchor_.vertices[2];
} else { } else {
_has_anchor = false; has_anchor_ = false;
} }
// Load the triangles // Load the triangles
std::vector<Dart_descriptor> darts_by_id (nb_darts); std::vector<Dart_descriptor> darts_by_id (nb_darts);
int index1, index2, index3; int index1, index2, index3;
for (int k=0; k<nb_darts/3; ++k) { for (int k=0; k<nb_darts/3; ++k) {
Dart_descriptor triangle_dart = _combinatorial_map.make_combinatorial_polygon(3); Dart_descriptor triangle_dart = combinatorial_map_.make_combinatorial_polygon(3);
s >> line; s >> line;
index1 = std::stoi(line); index1 = std::stoi(line);
@ -662,14 +662,14 @@ from_stream(std::istream& s)
index2 = std::stoi(line); index2 = std::stoi(line);
dart_1 = darts_by_id[index1]; dart_1 = darts_by_id[index1];
dart_2 = darts_by_id[index2]; dart_2 = darts_by_id[index2];
_combinatorial_map.template sew<2>(dart_1, dart_2); combinatorial_map_.template sew<2>(dart_1, dart_2);
s >> cross_ratio; s >> cross_ratio;
_combinatorial_map.template set_attribute<1>(dart_1, _combinatorial_map.template create_attribute<1>(cross_ratio)); combinatorial_map_.template set_attribute<1>(dart_1, combinatorial_map_.template create_attribute<1>(cross_ratio));
} }
// (*) here // (*) here
if (_has_anchor) { if (has_anchor_) {
_anchor.dart = darts_by_id[anchor_dart_id]; anchor_.dart = darts_by_id[anchor_dart_id];
} }
} }
@ -677,39 +677,39 @@ from_stream(std::istream& s)
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::ccw(Dart_descriptor dart) { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::ccw(Dart_descriptor dart) {
return _combinatorial_map.beta(dart, 1); return combinatorial_map_.beta(dart, 1);
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::cw(Dart_descriptor dart) { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::cw(Dart_descriptor dart) {
return _combinatorial_map.beta(dart, 0); return combinatorial_map_.beta(dart, 0);
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::opposite(Dart_descriptor dart) { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::opposite(Dart_descriptor dart) {
return _combinatorial_map.opposite(dart); return combinatorial_map_.opposite(dart);
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_ccw(Dart_const_descriptor dart) const { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_ccw(Dart_const_descriptor dart) const {
return _combinatorial_map.beta(dart, 1); return combinatorial_map_.beta(dart, 1);
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_cw(Dart_const_descriptor dart) const { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_cw(Dart_const_descriptor dart) const {
return _combinatorial_map.beta(dart, 0); return combinatorial_map_.beta(dart, 0);
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_opposite(Dart_const_descriptor dart) const { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::const_opposite(Dart_const_descriptor dart) const {
return _combinatorial_map.opposite(dart); return combinatorial_map_.opposite(dart);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Complex_number Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::get_cross_ratio(Dart_const_descriptor dart) const { typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Complex_number Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::get_cross_ratio(Dart_const_descriptor dart) const {
return _combinatorial_map.template info_of_attribute<1>(_combinatorial_map.template attribute<1>(dart)); return combinatorial_map_.template info_of_attribute<1>(combinatorial_map_.template attribute<1>(dart));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -717,7 +717,7 @@ template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>:: typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
pick_edge_to_flip() pick_edge_to_flip()
{ {
auto& cm = _combinatorial_map.darts(); auto& cm = combinatorial_map_.darts();
for (auto it=cm.begin(); it!=cm.end(); ++it) { for (auto it=cm.begin(); it!=cm.end(); ++it) {
if (is_Delaunay_flippable(it)) { if (is_Delaunay_flippable(it)) {
return it; return it;
@ -733,7 +733,7 @@ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_d
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>:: Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
pick_edge_to_flip() const pick_edge_to_flip() const
{ {
const auto& cm = _combinatorial_map.darts(); const auto& cm = combinatorial_map_.darts();
for (auto it=cm.begin(); it!=cm.end(); ++it) { for (auto it=cm.begin(); it!=cm.end(); ++it) {
if (is_Delaunay_flippable(it) ) { if (is_Delaunay_flippable(it) ) {
return it; return it;
@ -749,9 +749,9 @@ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>:: Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
copy_from(Combinatorial_map_with_cross_ratios& cmap) copy_from(Combinatorial_map_with_cross_ratios& cmap)
{ {
//_combinatorial_map.copy_from_const(cmap); //combinatorial_map_.copy_from_const(cmap);
_combinatorial_map.copy(cmap); combinatorial_map_.copy(cmap);
_has_anchor = false; has_anchor_ = false;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
@ -761,15 +761,15 @@ copy_from(Combinatorial_map_with_cross_ratios& cmap,
const Anchor& anchor) const Anchor& anchor)
{ {
// Because of the anchor, we must operate the copy ourself // Because of the anchor, we must operate the copy ourself
_combinatorial_map.clear(); combinatorial_map_.clear();
// Copy the triangles and fill the darts conversion table // Copy the triangles and fill the darts conversion table
std::map<Dart_const_descriptor, Dart_descriptor> darts_table; std::map<Dart_const_descriptor, Dart_descriptor> darts_table;
for (typename Face_const_range::const_iterator it=cmap.template one_dart_per_cell<2>().begin(); it!=cmap.template one_dart_per_cell<2>().end(); ++it) { for (typename Face_const_range::const_iterator it=cmap.template one_dart_per_cell<2>().begin(); it!=cmap.template one_dart_per_cell<2>().end(); ++it) {
Dart_descriptor new_dart = _combinatorial_map.make_combinatorial_polygon(3); Dart_descriptor new_dart = combinatorial_map_.make_combinatorial_polygon(3);
darts_table[it] = new_dart; darts_table[it] = new_dart;
darts_table[cmap.beta(it,0)] = _combinatorial_map.beta(new_dart,0); darts_table[cmap.beta(it,0)] = combinatorial_map_.beta(new_dart,0);
darts_table[cmap.beta(it,1)] = _combinatorial_map.beta(new_dart,1); darts_table[cmap.beta(it,1)] = combinatorial_map_.beta(new_dart,1);
} }
// Sew the edges and set their cross-ratios // Sew the edges and set their cross-ratios
@ -778,18 +778,18 @@ copy_from(Combinatorial_map_with_cross_ratios& cmap,
Dart_descriptor dart_2 = darts_table[cmap.opposite(it)]; Dart_descriptor dart_2 = darts_table[cmap.opposite(it)];
Complex_number cratio = cmap.template info_of_attribute<1>(cmap.template attribute<1>(it)); Complex_number cratio = cmap.template info_of_attribute<1>(cmap.template attribute<1>(it));
_combinatorial_map.template sew<2>(dart_1, dart_2); combinatorial_map_.template sew<2>(dart_1, dart_2);
_combinatorial_map.template set_attribute<1>(dart_1, _combinatorial_map.template create_attribute<1>(cratio)); combinatorial_map_.template set_attribute<1>(dart_1, combinatorial_map_.template create_attribute<1>(cratio));
} }
cmap.opposite(anchor.dart); cmap.opposite(anchor.dart);
// Set the anchor // Set the anchor
_anchor.dart = darts_table[anchor.dart]; anchor_.dart = darts_table[anchor.dart];
for (int k=0; k<3; ++k) { for (int k=0; k<3; ++k) {
_anchor.vertices[k] = anchor.vertices[k]; anchor_.vertices[k] = anchor.vertices[k];
} }
_has_anchor = true; has_anchor_ = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////