Misc code cleaning

This commit is contained in:
Mael Rouxel-Labbé 2025-03-15 00:01:43 +01:00
parent c672ed6fc1
commit 33ed6b6482
31 changed files with 1090 additions and 866 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12...3.29) cmake_minimum_required(VERSION 3.12...3.31)
project( Triangulation_on_hyperbolic_surface_2_Demo ) project( Triangulation_on_hyperbolic_surface_2_Demo )
@ -9,35 +9,25 @@ include_directories(${CMAKE_BINARY_DIR})
# Instruct CMake to run moc automatically when needed. # Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
# CGAL and its components # CGAL and its components
find_package(CGAL REQUIRED COMPONENTS Core Qt6) find_package(CGAL REQUIRED COMPONENTS Core Qt6)
find_package(Qt6 QUIET COMPONENTS Widgets) find_package(Qt6 QUIET COMPONENTS Widgets)
if ( NOT CGAL_FOUND ) if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.") message(STATUS "This project requires the CGAL library, and will not be compiled.")
return() return()
endif() endif()
if ( NOT CGAL_Qt6_FOUND OR NOT Qt6_FOUND) if ( NOT CGAL_Qt6_FOUND OR NOT Qt6_FOUND)
message(STATUS "This project requires the Qt6 library, and will not be compiled.") message(STATUS "This project requires the Qt6 library, and will not be compiled.")
return() return()
endif() endif()
# Boost and its components # Boost and its components
find_package( Boost REQUIRED ) find_package( Boost REQUIRED )
if ( NOT Boost_FOUND ) if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.") message(STATUS "This project requires the Boost library, and will not be compiled.")
return() return()
endif() endif()
# ui files, created with Qt Designer # ui files, created with Qt Designer

View File

@ -2,6 +2,7 @@
#include <CGAL/Exact_rational.h> #include <CGAL/Exact_rational.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h> #include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <CGAL/Hyperbolic_surface_traits_2.h> #include <CGAL/Hyperbolic_surface_traits_2.h>
#include <CGAL/Hyperbolic_fundamental_domain_factory_2.h> #include <CGAL/Hyperbolic_fundamental_domain_factory_2.h>
@ -20,7 +21,8 @@ typedef Triangulation_on_hyperbolic_surface_2<Traits> Triangul
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char** argv){ int main(int argc, char** argv)
{
// 1. Generate the triangulation // 1. Generate the triangulation
Factory factory; Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(time(NULL)); Domain domain = factory.make_hyperbolic_fundamental_domain_g2(time(NULL));

View File

@ -12,7 +12,9 @@
#include "window.h" #include "window.h"
DemoWindowItem::DemoWindowItem() : CGAL::Qt::GraphicsItem(){ DemoWindowItem::DemoWindowItem()
: CGAL::Qt::GraphicsItem()
{
// Clear // Clear
_edges.clear(); _edges.clear();
@ -28,9 +30,15 @@ DemoWindowItem::DemoWindowItem() : CGAL::Qt::GraphicsItem(){
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DemoWindowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ void DemoWindowItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
// 1. Draw the poincaré disk // 1. Draw the poincaré disk
QRectF circle_rect = QRectF(-_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); QRectF circle_rect = QRectF(-_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);
painter->setPen(_poincare_disk_pen); painter->setPen(_poincare_disk_pen);
painter->setBrush(QBrush()); painter->setBrush(QBrush());
painter->drawEllipse(circle_rect); painter->drawEllipse(circle_rect);
@ -44,15 +52,21 @@ void DemoWindowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
} }
QRectF DemoWindowItem::boundingRect() const { QRectF DemoWindowItem::boundingRect() const {
return QRectF(-_poincare_disk_radius_in_pixels-3, -_poincare_disk_radius_in_pixels-3, _poincare_disk_radius_in_pixels+6, _poincare_disk_radius_in_pixels+6); return QRectF(-_poincare_disk_radius_in_pixels-3,
-_poincare_disk_radius_in_pixels-3,
_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
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DemoWindowItem::draw_triangulation(Triangulation& triangulation){ void DemoWindowItem::draw_triangulation(Triangulation& triangulation)
typedef std::vector<std::tuple<typename Triangulation::Combinatorial_map_with_cross_ratios::Dart_const_handle,Point,Point,Point>> RealizationVector; {
typedef std::vector<std::tuple<typename Triangulation::Combinatorial_map_with_cross_ratios::Dart_const_handle,
Point, Point, Point> > RealizationVector;
RealizationVector realized_triangles; RealizationVector realized_triangles;
realized_triangles = triangulation.lift(); realized_triangles = triangulation.lift();
@ -70,7 +84,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());
@ -78,10 +93,10 @@ void DemoWindowItem::draw_point(QPainter* painter, Point position){
// 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);
painter->drawEllipse(circle_rect); painter->drawEllipse(circle_rect);
} }
void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target){ void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target)
{
// First convert the points coordinates to doubles // First convert the points coordinates to doubles
double src_x = CGAL::to_double(source.x()); double src_x = CGAL::to_double(source.x());
@ -91,6 +106,7 @@ void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target){
double tar_y = CGAL::to_double(target.y()); double tar_y = CGAL::to_double(target.y());
// 0. If src and tar are too colinear or too close from each other then draw a line // 0. If src and tar are too colinear or too close from each other then draw a line
double determinant = src_x*tar_y - src_y*tar_x; // determinant of the matrix whose columns are the vectors src and tar : indicates colinearity double determinant = src_x*tar_y - src_y*tar_x; // determinant of the matrix whose columns are the vectors src and tar : indicates colinearity
double distance_squared = (src_x-tar_x)*(src_x-tar_x) + (src_y-tar_y)*(src_y-tar_y); double distance_squared = (src_x-tar_x)*(src_x-tar_x) + (src_y-tar_y)*(src_y-tar_y);
if ((std::abs(determinant) < computation_treshold_squared) || (distance_squared < computation_treshold_squared)) { if ((std::abs(determinant) < computation_treshold_squared) || (distance_squared < computation_treshold_squared)) {
@ -102,7 +118,7 @@ void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target){
// 1. Compute the center of the circle supporting the geodesic between src and tar // 1. Compute the center of the circle supporting the geodesic between src and tar
// 1.a Inverse src and tar with respect to the unit circle and find the euclidean midpoints of the segments between respectively // 1.a Inverse src and tar with respect to the unit circle and find the euclidean midpoints of the segments between respectively
// src and it's inversion, and tar and it's inversion // src and its inversion, and tar and its inversion
double src_norm_2 = src_x*src_x + src_y*src_y; // Can't be too close to zero because determinant was not double src_norm_2 = src_x*src_x + src_y*src_y; // Can't be too close to zero because determinant was not
double tar_norm_2 = tar_x*tar_x + tar_y*tar_y; // Can't be too close to zero because determinant was not double tar_norm_2 = tar_x*tar_x + tar_y*tar_y; // Can't be too close to zero because determinant was not
@ -121,7 +137,6 @@ void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target){
// 1.b Solve a system to find the intersection (center_x, center_y) of the bisectors of the two segments [src, src_inv] and [tar, tar_inv]: // 1.b Solve a system to find the intersection (center_x, center_y) of the bisectors of the two segments [src, src_inv] and [tar, tar_inv]:
// (center_x \\ center y) = (a & b \\ c & d)^{-1} \times (u_x \\ u_y) // (center_x \\ center y) = (a & b \\ c & d)^{-1} \times (u_x \\ u_y)
// 1.b.i define the system // 1.b.i define the system
double a = src_x; double a = src_x;
@ -141,9 +156,10 @@ void DemoWindowItem::draw_edge(QPainter* painter, Point source, Point target){
draw_arc(painter, src_x, src_y, tar_x, tar_y, center_x, center_y); draw_arc(painter, src_x, src_y, tar_x, tar_y, center_x, center_y);
} }
void DemoWindowItem::draw_line(QPainter* painter,
void DemoWindowItem::draw_line(QPainter* painter, double point_1_x, double point_1_y, double point_2_x, double point_2_y){ double point_1_x, double point_1_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;
@ -155,9 +171,11 @@ void DemoWindowItem::draw_line(QPainter* painter, double point_1_x, double point
painter->drawLine(line); painter->drawLine(line);
} }
void DemoWindowItem::draw_arc(QPainter* painter,
void DemoWindowItem::draw_arc(QPainter* painter, double point_1_x, double point_1_y, double point_1_x, double point_1_y,
double point_2_x, double point_2_y, double center_x, double center_y){ double point_2_x, double point_2_y,
double center_x, double center_y)
{
// Draws the arc supported by the circle whose center is (center_x, center_y) and whose extremities are src and tar // Draws the arc supported by the circle whose center is (center_x, center_y) and whose extremities are src and tar
// 1. Scale by the radius of the poincaré disk // 1. Scale by the radius of the poincaré disk
@ -211,7 +229,8 @@ void DemoWindowItem::draw_arc(QPainter* painter, double point_1_x, double point_
painter->drawArc(bbox_rect, src_angle*16, sweep_angle*16); painter->drawArc(bbox_rect, src_angle*16, sweep_angle*16);
} }
double DemoWindowItem::deg_angle(double x, double y){ double DemoWindowItem::deg_angle(double x, double y)
{
// To avoid problems when further division by x (ok since x^2 + y^2 not too small) : // To avoid problems when further division by x (ok since x^2 + y^2 not too small) :
if (x*x < computation_treshold_squared) { if (x*x < computation_treshold_squared) {
if (y>0) return 90; if (y>0) return 90;
@ -229,7 +248,8 @@ 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);
@ -241,7 +261,8 @@ DemoWindow::DemoWindow() : DemosMainWindow(){
setWindowTitle("Hyperbolic surfaces triangulation 2 Demo"); setWindowTitle("Hyperbolic surfaces triangulation 2 Demo");
} }
DemoWindowItem& DemoWindow::item(){ DemoWindowItem& DemoWindow::item()
{
return *_item; return *_item;
} }

View File

@ -23,6 +23,7 @@
#include <CGAL/Exact_rational.h> #include <CGAL/Exact_rational.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h> #include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <CGAL/Hyperbolic_surface_traits_2.h> #include <CGAL/Hyperbolic_surface_traits_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2.h>
@ -33,11 +34,12 @@ typedef CGAL::Hyperbolic_surface_traits_2<ParentTraits>
typedef Traits::Hyperbolic_point_2 Point; typedef Traits::Hyperbolic_point_2 Point;
typedef CGAL::Triangulation_on_hyperbolic_surface_2<Traits> Triangulation; typedef CGAL::Triangulation_on_hyperbolic_surface_2<Traits> Triangulation;
class DemoWindowItem : class DemoWindowItem
public CGAL::Qt::GraphicsItem : public CGAL::Qt::GraphicsItem
{ {
Q_OBJECT // Qt macro for Qt objects Q_OBJECT // Qt macro for Qt objects
// (Q_OBJECT does not support templates) // (Q_OBJECT does not support templates)
private: 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
@ -50,7 +52,9 @@ private:
// 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 instead of an arc if an hyperbolic segment is very small)
// 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)
const double computation_treshold = 0.001; const double computation_treshold = 0.001;
const double computation_treshold_squared = computation_treshold*computation_treshold; const double computation_treshold_squared = computation_treshold*computation_treshold;
@ -81,11 +85,13 @@ private:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class DemoWindow : class DemoWindow
public CGAL::Qt::DemosMainWindow, public Ui::MainWindow : public CGAL::Qt::DemosMainWindow,
public Ui::MainWindow
{ {
Q_OBJECT // Qt macro for Qt objects Q_OBJECT // Qt macro for Qt objects
// (Q_OBJECT does not support templates) // (Q_OBJECT does not support templates)
private: private:
QGraphicsScene _scene; QGraphicsScene _scene;
DemoWindowItem* _item; DemoWindowItem* _item;

View File

@ -11,4 +11,4 @@ template <class FT>
class Complex_number { class Complex_number {
}; };
}; // namespace CGAL } // namespace CGAL

View File

@ -14,17 +14,21 @@ The side pairings are represented by a list of integers, such that if the \f$ n
\sa `Hyperbolic_fundamental_domain_factory_2` \sa `Hyperbolic_fundamental_domain_factory_2`
*/ */
template<class Traits> template<class Traits>
class Hyperbolic_fundamental_domain_2 { class Hyperbolic_fundamental_domain_2
{
public: public:
/// \name Types /// \name Types
/// @{ /// @{
/*! /*!
Point type. Point type.
*/ */
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
/// @} /// @}
/// \name Creation /// \name Creation
/// @{ /// @{
/*! /*!
Default constructor Default constructor
*/ */
@ -32,8 +36,9 @@ public:
/*! /*!
Constructor from vertices and pairings ranges. Constructor from vertices and pairings ranges.
@tparam PointRange a model of the concepts `RandomAccessContainer` whose `value_type` is `Point`.
@tparam PairingRange a model of the concepts `RandomAccessContainer` whose `value_type` is `std::size_t`. \tparam PointRange a model of the concepts `RandomAccessContainer` whose `value_type` is `Point`.
\tparam PairingRange a model of the concepts `RandomAccessContainer` whose `value_type` is `std::size_t`.
*/ */
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);
@ -41,6 +46,7 @@ public:
/// \name Access Functions /// \name Access Functions
/// @{ /// @{
/*! /*!
returns the number of vertices (equivalently, the number of sides) of the domain. returns the number of vertices (equivalently, the number of sides) of the domain.
@ -68,24 +74,28 @@ public:
\pre <code> is_valid() </code> \pre <code> is_valid() </code>
*/ */
Hyperbolic_isometry_2<Traits> side_pairing(std::size_t i) const; Hyperbolic_isometry_2<Traits> side_pairing(std::size_t i) const;
/// @} /// @}
/// @{
/// \name Validity /// \name Validity
/// @{
/*! /*!
checks that the number of vertices is even, that there are as many side pairings as vertices, and that the vertices all lie within the open unit disk. checks that the number of vertices is even, that there are as many side pairings as vertices,
and that the vertices all lie within the open unit disk.
*/ */
bool is_valid() const; bool is_valid() const;
/// @}
/// @}
}; };
}; // namespace CGAL } // namespace CGAL
/// \name Input/Output /// \name Input/Output
/// @{ /// @{
/*! /*!
inserts the domain in a stream. \brief inserts the domain in a stream.
The format of the output is the following. The format of the output is the following.
The first line prints the number \f$n\f$ of vertices of the domain. The first line prints the number \f$n\f$ of vertices of the domain.
@ -97,9 +107,10 @@ public:
std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain); std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain);
/*! /*!
extracts the domain from a stream. \brief extracts the domain from a stream.
The format of the input must be the same as the format of the output of 'operator<<()'. The format of the input must be the same as the format of the output of 'operator<<()'.
*/ */
std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain); std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain);
/// @} /// @}

View File

@ -12,10 +12,12 @@ a surface of genus two.
\tparam Traits must be a model of `HyperbolicSurfaceTraits_2`. \tparam Traits must be a model of `HyperbolicSurfaceTraits_2`.
*/ */
template<class Traits> template<class Traits>
class Hyperbolic_fundamental_domain_factory_2{ class Hyperbolic_fundamental_domain_factory_2
{
public: public:
/// \name Creation /// \name Creation
/// @{ /// @{
/*! /*!
Constructor. Constructor.
*/ */
@ -24,13 +26,13 @@ public:
/// \name Generation of a domain in genus two. /// \name Generation of a domain in genus two.
/// @{ /// @{
/*! /*!
randomly generates a convex domain of a closed orientable hyperbolic surface randomly generates a convex domain of a closed orientable hyperbolic surface of genus two from a seed.
of genus two from a seed.
*/ */
Hyperbolic_fundamental_domain_2<Traits> make_hyperbolic_fundamental_domain_g2(unsigned int seed); Hyperbolic_fundamental_domain_2<Traits> make_hyperbolic_fundamental_domain_g2(unsigned int seed);
/// @}
/// @}
}; };
}; // namespace CGAL } // namespace CGAL

View File

@ -12,29 +12,39 @@ Functionalities are offered to compose isometries, and apply an isometry to a po
\tparam Traits must be a model of `HyperbolicSurfaceTraits_2`. \tparam Traits must be a model of `HyperbolicSurfaceTraits_2`.
*/ */
template<class Traits> template<class Traits>
class Hyperbolic_isometry_2{ class Hyperbolic_isometry_2
{
public: public:
/// \name Types /// \name Types
/// @{ /// @{
/*! /*!
Complex number type. Complex number type.
*/ */
typedef typename Traits::Complex Complex_number; typedef typename Traits::Complex Complex_number;
/*! /*!
Point type. Point type.
*/ */
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
/// @} /// @}
/// \name Creation /// \name Creation
/// @{ /// @{
/*! /*!
Default constructor to the identity. Default constructor to the identity.
*/ */
Hyperbolic_isometry_2(); Hyperbolic_isometry_2();
/*! /*!
Constructor from coefficients. Constructor from coefficients.
*/ */
Hyperbolic_isometry_2(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3); Hyperbolic_isometry_2(const Complex_number& c0,
const Complex_number& c1,
const Complex_number& c2,
const Complex_number& c3);
/// @} /// @}
/*! /*!
@ -44,47 +54,52 @@ class Hyperbolic_isometry_2{
/*! /*!
sets the coefficients of the isometry. sets the coefficients of the isometry.
\warning The implementation does not check that the
resulting transformation is an isometry.
\warning The implementation does not check that the resulting transformation is an isometry.
*/ */
void set_coefficients(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3); void set_coefficients(const Complex_number& c0,
const Complex_number& c1,
const Complex_number& c2,
const Complex_number& c3);
/*! /*!
sets a particular coefficient of the isometry. sets a particular coefficient of the isometry.
\warning The implementation does not check that the
resulting transformation is an isometry.
\warning The implementation does not check that the resulting transformation is an isometry.
*/ */
void set_coefficient(int index, const Complex_number& coefficient); void set_coefficient(int index, const Complex_number& coefficient);
/// \name Access Functions /// \name Access Functions
/// @{ /// @{
/*! /*!
returns the index-th coefficient. returns the index-th coefficient.
*/ */
const Complex_number& get_coefficient(int index) const; const Complex_number& get_coefficient(int index) const;
/// @} /// @}
/// \name Operations /// \name Operations
/// @{ /// @{
/*! /*!
evaluates the isometry at point \f$ p \f$. evaluates the isometry at point \f$ p \f$.
*/ */
Point evaluate(const Point& p) const; Point evaluate(const Point& p) const;
/*! /*!
evaluates the isometry at point \f$ p \f$. evaluates the isometry at point \f$ p \f$.
*/ */
Point operator()(const Point& p) const; Point operator()(const Point& p) const;
/// @{
/*! /*!
returns the composition of two isometries. returns the composition of two isometries.
*/ */
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> operator*(const Hyperbolic_isometry_2<Traits>& iso1, const Hyperbolic_isometry_2<Traits>& iso2); Hyperbolic_isometry_2<Traits> operator*(const Hyperbolic_isometry_2<Traits>& iso1,
/// @} const Hyperbolic_isometry_2<Traits>& iso2);
/// @}
}; };
}; // namespace CGAL } // namespace CGAL

View File

@ -10,4 +10,4 @@ namespace CGAL{
template<class HyperbolicTraits> template<class HyperbolicTraits>
class Hyperbolic_surface_traits_2 : public HyperbolicTraits {}; class Hyperbolic_surface_traits_2 : public HyperbolicTraits {};
}; // namespace CGAL } // namespace CGAL

View File

@ -3,24 +3,23 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2MainClasses \ingroup PkgHyperbolicSurfaceTriangulation2MainClasses
This item defines attributes of edges that are of type `Complex_number` reprensenting cross-ratios.
This item defines attributes of edges that are of type
`Complex_number` reprensenting cross-ratios.
\tparam Traits must be a model of `HyperbolicSurfaceTraits_2`. \tparam Traits must be a model of `HyperbolicSurfaceTraits_2`.
\cgalModels{GenericMapItems} \cgalModels{GenericMapItems}
*/ */
template<class Traits> template<class Traits>
struct Combinatorial_map_with_cross_ratios_item{ struct Combinatorial_map_with_cross_ratios_item
{
template <class CMap> template <class CMap>
struct Dart_wrapper{ struct Dart_wrapper
{
typedef Cell_attribute<CMap, Complex_number<typename Traits::FT> > Edge_attrib; typedef Cell_attribute<CMap, Complex_number<typename Traits::FT> > Edge_attrib;
typedef std::tuple<void, Edge_attrib, void> Attributes; typedef std::tuple<void, Edge_attrib, void> Attributes;
}; };
}; };
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2MainClasses \ingroup PkgHyperbolicSurfaceTriangulation2MainClasses
@ -30,7 +29,6 @@ The class provides functions such as the generation of the triangulation from a
the Delaunay flip algorithm, and the construction of a portion of the lift of the triangulation in the hyperbolic plane. the Delaunay flip algorithm, and the construction of a portion of the lift of the triangulation in the hyperbolic plane.
\tparam Traits must be a model of `HyperbolicSurfaceTraits_2`. \tparam Traits must be a model of `HyperbolicSurfaceTraits_2`.
\tparam Attributes must be a model of `GenericMapItems` whose edges are \tparam Attributes must be a model of `GenericMapItems` whose edges are
decorated with complex numbers to represent cross ratios. decorated with complex numbers to represent cross ratios.
*/ */
@ -40,58 +38,73 @@ class Triangulation_on_hyperbolic_surface_2
public: public:
/// \name Types /// \name Types
/// @{ /// @{
/*! /*!
Type of combinatorial map whose edges are decorated with complex numbers. Type of combinatorial map whose edges are decorated with complex numbers.
*/ */
typedef Combinatorial_map<2, Attributes> Combinatorial_map_with_cross_ratios; typedef Combinatorial_map<2, Attributes> Combinatorial_map_with_cross_ratios;
/*! /*!
Combinatorial map dart descriptor type. Combinatorial map dart descriptor type.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::Dart_descriptor Dart_descriptor; typedef typename Combinatorial_map_with_cross_ratios::Dart_descriptor Dart_descriptor;
/*! /*!
Combinatorial map dart const descriptor type. Combinatorial map dart const descriptor type.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::Dart_const_descriptor Dart_const_descriptor; typedef typename Combinatorial_map_with_cross_ratios::Dart_const_descriptor Dart_const_descriptor;
/*! /*!
Range of one dart for each vertex (that is 0-cell) of the combinatorial map. Range of one dart for each vertex (that is 0-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<0> Vertex_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<0> Vertex_range;
/*! /*!
Range of one dart for each edge (that is 1-cell) of the combinatorial map. Range of one dart for each edge (that is 1-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<1> Edge_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<1> Edge_range;
/*! /*!
Range of one dart for each face (that is 2-cell) of the combinatorial map. Range of one dart for each face (that is 2-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<2> Face_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_range<2> Face_range;
/*! /*!
Range of one dart for each vertex (that is 0-cell) of the combinatorial map. Range of one dart for each vertex (that is 0-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<0> Vertex_const_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<0> Vertex_const_range;
/*! /*!
Range of one dart for each edge (that is 1-cell) of the combinatorial map. Range of one dart for each edge (that is 1-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<1> Edge_const_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<1> Edge_const_range;
/*! /*!
Range of one dart for each face (that is 2-cell) of the combinatorial map. Range of one dart for each face (that is 2-cell) of the combinatorial map.
*/ */
typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<2> Face_const_range; typedef typename Combinatorial_map_with_cross_ratios::template One_dart_per_cell_const_range<2> Face_const_range;
/*! /*!
Point type. Point type.
*/ */
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
/*! /*!
stores a dart \f$ d \f$ of the combinatorial map, belonging to a triangle \f$ t \f$, and stores the three vertices of a lift of \f$ t \f$ in the hyperbolic plane. stores a dart \f$ d \f$ of the combinatorial map, belonging to a triangle \f$ t \f$,
and stores the three vertices of a lift of \f$ t \f$ in the hyperbolic plane.
*/ */
struct Anchor{ struct Anchor
{
typename Combinatorial_map_with_cross_ratios::Dart_descriptor dart; typename Combinatorial_map_with_cross_ratios::Dart_descriptor dart;
typename Traits::Hyperbolic_point_2 vertices[3]; typename Traits::Hyperbolic_point_2 vertices[3];
}; };
/// @} /// @}
/// \name Creation /// \name Creation
/// @{ /// @{
/*! /*!
Default constructor. Default constructor.
*/ */
@ -110,18 +123,22 @@ public:
Constructor from a decorated combinatorial map and an anchor. Constructor from a decorated combinatorial map and an anchor.
*/ */
Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap, Anchor& an_anchor); Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap, Anchor& an_anchor);
/// @} /// @}
/// \name Assignment /// \name Assignment
/// @{ /// @{
/*! /*!
\pre <code> other.is_valid() </code> \pre <code> other.is_valid() </code>
*/ */
Triangulation_on_hyperbolic_surface_2& operator=(Triangulation_on_hyperbolic_surface_2 other); Triangulation_on_hyperbolic_surface_2& operator=(Triangulation_on_hyperbolic_surface_2 other);
/// @} /// @}
/// \name Access Functions /// \name Access Functions
/// @{ /// @{
/*! /*!
returns the decorated combinatorial map. returns the decorated combinatorial map.
*/ */
@ -129,54 +146,60 @@ public:
/*! /*!
returns whether the triangulation has an anchor or not. returns whether the triangulation has an anchor or not.
\pre <code> is_valid() </code> \pre <code> is_valid() </code>
*/ */
bool has_anchor() const; bool has_anchor() const;
/*! /*!
returns the anchor. returns the anchor.
\pre <code> is_valid() && has_anchor() </code> \pre <code> is_valid() && has_anchor() </code>
*/ */
Anchor& anchor(); Anchor& anchor();
/*! /*!
returns the anchor. returns the anchor.
\pre <code> is_valid() && has_anchor() </code> \pre <code> is_valid() && has_anchor() </code>
*/ */
const Anchor& anchor() const; const Anchor& anchor() const;
/*! /*!
returns the range of vertices. returns the range of vertices.
*/ */
Vertex_range vertices_range(); Vertex_range vertices_range();
/*! /*!
returns the range of edges. returns the range of edges.
*/ */
Edge_range edges_range(); Edge_range edges_range();
/*! /*!
returns the range of faces. returns the range of faces.
*/ */
Face_range faces_range(); Face_range faces_range();
/*! /*!
returns the range of vertices. returns the range of vertices.
*/ */
Vertex_const_range vertices_const_range() const; Vertex_const_range vertices_const_range() const;
/*! /*!
returns the range of edges. returns the range of edges.
*/ */
Edge_const_range edges_const_range() const; Edge_const_range edges_const_range() const;
/*! /*!
returns the range of faces. returns the range of faces.
*/ */
Face_const_range faces_const_range() const; Face_const_range faces_const_range() const;
/// @}
/// @}
/// \name Delaunay Flip Algorithm /// \name Delaunay Flip Algorithm
/// @{ /// @{
/*! /*!
returns whether the edge supported by the dart is Delaunay flippable or not. An edge \f$ e \f$ is Delaunay flippable if the imaginary part of its cross ratio is positive. returns whether the edge supported by the dart is Delaunay flippable or not. An edge \f$ e \f$
is Delaunay flippable if the imaginary part of its cross ratio is positive.
\pre <code> is_valid() </code> \pre <code> is_valid() </code>
*/ */
@ -196,16 +219,18 @@ Face_const_range faces_const_range() const;
/*! /*!
applies the Delaunay flip algorithm: flips Delaunay-flippable edges until there is no such edge anymore. applies the Delaunay flip algorithm: flips Delaunay-flippable edges until there is no such edge anymore.
\pre <code> is_valid() </code> \pre <code> is_valid() </code>
*/ */
int make_Delaunay(); int make_Delaunay();
/// @} /// @}
/// \name Lifting /// \name Lifting
/// @{ /// @{
/*! /*!
lifts the triangulation in the hyperbolic plane. lifts the triangulation in the hyperbolic plane.
Returns, for every triangle \f$ t \f$ of the triangulation, one of the darts of \f$ t \f$ in the combinatorial map of the triangulation, together with a triple \f$ p,q,r \f$ of points in the hyperbolic plane. Returns, for every triangle \f$ t \f$ of the triangulation, one of the darts of \f$ t \f$ in the combinatorial map of the triangulation, together with a triple \f$ p,q,r \f$ of points in the hyperbolic plane.
The points \f$ p,q,r \f$ are the vertices of a lift of \f$ t \f$ in the hyperbolic plane. The points \f$ p,q,r \f$ are the vertices of a lift of \f$ t \f$ in the hyperbolic plane.
If the center parameter is set to true, then one of the vertices of the anchor is translated to the origin \f$ 0 \f$. If the center parameter is set to true, then one of the vertices of the anchor is translated to the origin \f$ 0 \f$.
@ -213,17 +238,21 @@ Face_const_range faces_const_range() const;
\pre <code> is_valid() && has_anchor() </code> \pre <code> is_valid() && has_anchor() </code>
*/ */
std::vector<std::tuple<Dart_const_descriptor, Point, Point, Point>> lift(bool center=true) const; std::vector<std::tuple<Dart_const_descriptor, Point, Point, Point>> lift(bool center=true) const;
/// @} /// @}
/// \name Validity /// \name Validity
/// @{ /// @{
/*! /*!
checks that the underlying combinatorial map \f$ M \f$ has no boundary and calls the is_valid method of \f$ M \f$. checks that the underlying combinatorial map \f$ M \f$ has no boundary and calls the is_valid method of \f$ M \f$.
If there is an anchor, then checks that the dart descriptor of the anchor does indeed point to a dart of \f$ M \f$, and checks that the three vertices of the anchor lie within the open unit disk.
If there is an anchor, then checks that the dart descriptor of the anchor does indeed point to a dart of \f$ M \f$,
and checks that the three vertices of the anchor lie within the open unit disk.
*/ */
bool is_valid() const; bool is_valid() const;
/// @}
/// @}
}; };
}; // namespace CGAL } // namespace CGAL

View File

@ -2,12 +2,16 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput \ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
inserts the triangulation in a stream. inserts the triangulation in a stream.
The format of the output is the following. The format of the output is the following.
Each dart of the triangulation is given an index between \f$ 0 \f$ and \f$ n-1 \f$, where \f$ n \f$ is the number of darts of the triangulation. Each dart of the triangulation is given an index between \f$ 0 \f$ and \f$ n-1 \f$, where \f$ n \f$
is the number of darts of the triangulation.
The first line contains the number \f$ n \f$ of darts. The first line contains the number \f$ n \f$ of darts.
The next line contains either 'yes' or 'no' and tells whether the triangulation has an anchor. The next line contains either 'yes' or 'no' and tells whether the triangulation has an anchor.
If the triangulation has an anchor, then the four next lines print the index of the dart of the anchor, and the three vertices of the anchor. If the triangulation has an anchor, then the four next lines print the index of the dart of the anchor,
and the three vertices of the anchor.
Then, for every triangle \f$ t \f$, the indices of the three darts of \f$ t \f$ are printed on three distinct lines. Then, for every triangle \f$ t \f$, the indices of the three darts of \f$ t \f$ are printed on three distinct lines.
Finally, for every edge \f$ e \f$, the indices of the two darts of \f$ e \f$ are printed on two distinct lines, followed by a third line on which the cross ratio of \f$ e \f$ is printed. Finally, for every edge \f$ e \f$, the indices of the two darts of \f$ e \f$ are printed on two distinct lines, followed by a third line on which the cross ratio of \f$ e \f$ is printed.
@ -17,7 +21,9 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput \ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
extracts the triangulation from a stream. extracts the triangulation from a stream.
The format of the input should be the same as the format of the output of The format of the input should be the same as the format of the output of
the '<<' operator for Triangulation_on_hyperbolic_surface_2. the '<<' operator for Triangulation_on_hyperbolic_surface_2.
*/ */
@ -25,6 +31,7 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput \ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
inserts the domain in a stream. inserts the domain in a stream.
The format of the output is the following. The format of the output is the following.
@ -38,6 +45,7 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput \ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
extracts the domain from a stream. extracts the domain from a stream.
The format of the input must be the same as the format of the output of The format of the input must be the same as the format of the output of
@ -47,8 +55,9 @@ namespace CGAL{
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput \ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
inserts the isometry in a stream. inserts the isometry in a stream.
*/ */
std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry); std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry);
}; // namespace CGAL } // namespace CGAL

View File

@ -1,12 +1,8 @@
// Copyright (c) 2024 INRIA Nancy - Grand Est (France). LIGM Marne-la-Vallée (France)
// All rights reserved.
/*! /*!
\ingroup PkgHyperbolicSurfaceTriangulation2Concepts \ingroup PkgHyperbolicSurfaceTriangulation2Concepts
\cgalConcept \cgalConcept
Describes a complex number type over a `FieldNumberType` for its real and Describes a complex number type over a `FieldNumberType` for its real and imaginary parts.
imaginary parts.
\cgalRefines{Field} \cgalRefines{Field}
@ -14,16 +10,22 @@ imaginary parts.
\cgalHasModels{CGAL::Complex_number} \cgalHasModels{CGAL::Complex_number}
\cgalHasModelsEnd \cgalHasModelsEnd
*/ */
class ComplexNumber { class ComplexNumber
{
public: public:
/// \name Types /// \name Types
/// @{ /// @{
/*! /*!
Number type for real and imaginary parts: must be a model of `FieldNumberType`. Number type for real and imaginary parts: must be a model of `FieldNumberType`.
*/ */
typedef unspecified_type FT; typedef unspecified_type FT;
/// @}
/// \name Creation /// \name Creation
/// @{ /// @{
/*! /*!
Default constructor, sets the both the real part and the imaginary part to \f$ 0 \f$. Default constructor, sets the both the real part and the imaginary part to \f$ 0 \f$.
*/ */
@ -46,10 +48,12 @@ public:
*/ */
template<class U,class V> template<class U,class V>
ComplexNumber(U&& real_part, V&& imaginary_part); ComplexNumber(U&& real_part, V&& imaginary_part);
/// @} /// @}
/// \name Get and Set /// \name Getter and Setter
/// @{ /// @{
/*! /*!
sets the real part to <code> real_part </code>. sets the real part to <code> real_part </code>.
*/ */
@ -69,86 +73,32 @@ public:
returns the imaginary part. returns the imaginary part.
*/ */
FT imag() const; FT imag() const;
/// @} /// @}
/// \name Operations /// \name Operations
/// @{ /// @{
/* /\*! */
/* returns +z. */
/* *\/ */
/* //ComplexNumber operator+(const ComplexNumber& z) const; */
/* /\*! */
/* returns -z. */
/* *\/ */
/* //ComplexNumber operator-(const ComplexNumber& z) const; */
/* /\*! */
/* Unary complex addition. */
/* *\/ */
/* //ComplexNumber operator+=(const ComplexNumber& other) const; */
/* /\*! */
/* Unary complex substraction. */
/* *\/ */
/* //ComplexNumber operator-=(const ComplexNumber& other) const; */
/* /\*! */
/* Unary complex multiplication. */
/* *\/ */
/* //ComplexNumber operator*=(const ComplexNumber& other) const; */
/* /\*! */
/* Unary complex division. */
/* *\/ */
/* //ComplexNumber operator/=(const ComplexNumber& other) const; */
/*! /*!
Copy operator. Copy operator.
*/ */
ComplexNumber operator=(const ComplexNumber& other) const; ComplexNumber operator=(const ComplexNumber& other) const;
/* /\*! */
/* Equality test. */
/* *\/ */
/* //bool operator==(const ComplexNumber& z1, const ComplexNumber& z2); */
/* /\*! */
/* Inequality test. */
/* *\/ */
/* // bool operator!=(const ComplexNumber& z1, const ComplexNumber& z2); */
/* /\*! */
/* Binary complex addition. */
/* *\/ */
/* //ComplexNumber operator+(const ComplexNumber& z1, const ComplexNumber& z2); */
/* /\*! */
/* Binary complex substraction. */
/* *\/ */
/* //ComplexNumber operator-(const ComplexNumber& z1, const ComplexNumber& z2); */
/* /\*! */
/* Binary complex multiplication. */
/* *\/ */
/* //ComplexNumber operator*(const ComplexNumber& z1, const ComplexNumber& z2); */
/* /\*! */
/* Binary complex division. */
/* *\/ */
/* //ComplexNumber operator/(const ComplexNumber& z1, const ComplexNumber& z2); */
/*! /*!
writes the complex in a stream. writes the complex in a stream.
*/ */
std::ostream& operator<<(std::ostream& s, const ComplexNumber& z); std::ostream& operator<<(std::ostream& s, const ComplexNumber& z);
/*! /*!
reads the complex from a stream. reads the complex from a stream.
*/ */
void operator>>(std::istream& s, ComplexNumber& z); void operator>>(std::istream& s, ComplexNumber& z);
/// @} /// @}
/// \relates ComplexNumber /// \relates ComplexNumber
/// @{ /// @{
/*! /*!
returns the square of the modulus. returns the square of the modulus.
*/ */
@ -158,5 +108,6 @@ public:
returns the conjugate. returns the conjugate.
*/ */
ComplexNumber conj(ComplexNumber z) const; ComplexNumber conj(ComplexNumber z) const;
/// @} /// @}
}; };

View File

@ -10,15 +10,17 @@ This traits class must have a type for complex numbers.
\cgalHasModels{CGAL::Hyperbolic_surface_traits_2} \cgalHasModels{CGAL::Hyperbolic_surface_traits_2}
\cgalHasModelsEnd \cgalHasModelsEnd
*/ */
class HyperbolicSurfaceTraits_2 { class HyperbolicSurfaceTraits_2
{
public: public:
/// \name Types /// \name Types
/// @{ /// @{
/*! /*!
represents a complex number, model of represents a complex number, model of `ComplexNumber`,
`ComplexNumber`, over the field `HyperbolicSurfaceTraits_2::FT` for its real and over the field `HyperbolicSurfaceTraits_2::FT` for its real and imaginary parts.
imaginary parts.
*/ */
typedef unspecified_type Complex; typedef unspecified_type Complex;
/// @} /// @}
}; };

View File

@ -12,7 +12,6 @@
/// \defgroup PkgHyperbolicSurfaceTriangulation2InputOutput Input/Output Functions /// \defgroup PkgHyperbolicSurfaceTriangulation2InputOutput Input/Output Functions
/// \ingroup PkgHyperbolicSurfaceTriangulation2Ref /// \ingroup PkgHyperbolicSurfaceTriangulation2Ref
/*! /*!
\addtogroup PkgHyperbolicSurfaceTriangulation2Ref \addtogroup PkgHyperbolicSurfaceTriangulation2Ref
@ -26,7 +25,7 @@
\cgalPkgSummaryEnd \cgalPkgSummaryEnd
\cgalPkgShortInfoBegin \cgalPkgShortInfoBegin
\cgalPkgSince{6} \cgalPkgSince{6.1}
\cgalPkgDependsOn{\ref PkgCombinatorialMaps} \cgalPkgDependsOn{\ref PkgCombinatorialMaps}
\cgalPkgBib{cgal:y-t2} \cgalPkgBib{cgal:y-t2}
\cgalPkgLicense{\ref licensesGPL "GPL"} \cgalPkgLicense{\ref licensesGPL "GPL"}
@ -35,7 +34,6 @@
\cgalPkgDescriptionEnd \cgalPkgDescriptionEnd
\cgalClassifedRefPages \cgalClassifedRefPages
\cgalCRPSection{Concepts} \cgalCRPSection{Concepts}

View File

@ -1,12 +1,10 @@
cmake_minimum_required(VERSION 3.12...3.29) cmake_minimum_required(VERSION 3.12...3.31)
project( Triangulation_on_hyperbolic_surface_2_Examples ) project( Triangulation_on_hyperbolic_surface_2_Examples )
# CGAL and its components # CGAL and its components
find_package( CGAL REQUIRED ) find_package( CGAL REQUIRED )
include_directories(../../include/)
# create a target per cppfile # create a target per cppfile
file( file(
GLOB cppfiles GLOB cppfiles

View File

@ -10,21 +10,23 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Complex_number
#ifndef CGAL_COMPLEX_NUMBER_H #ifndef CGAL_COMPLEX_NUMBER_H
#define CGAL_COMPLEX_NUMBER_H #define CGAL_COMPLEX_NUMBER_H
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <utility>
namespace CGAL { namespace CGAL {
/* /*
Templated by a field FT. Represents a complex number over FT. 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:
@ -33,8 +35,8 @@ public:
{} {}
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()
@ -43,8 +45,8 @@ 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) {
@ -118,33 +120,36 @@ public:
s >> ft; s >> ft;
z.imag(ft); z.imag(ft);
} }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
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;
} }
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)
{
FT m2 = norm(other); FT m2 = norm(other);
_real /= m2; _real /= m2;
_imag /= m2; _imag /= m2;
@ -153,12 +158,14 @@ Complex_number<FT>& Complex_number<FT>::operator/=(const Complex_number<FT>& oth
} }
template<class FT> template<class FT>
FT norm(const Complex_number<FT>& z) { FT norm(const Complex_number<FT>& z)
{
return z.real()*z.real() + z.imag()*z.imag(); return z.real()*z.real() + z.imag()*z.imag();
} }
template<class FT> template<class FT>
Complex_number<FT> conj(const Complex_number<FT>& z) { Complex_number<FT> conj(const Complex_number<FT>& z)
{
return Complex_number<FT>(z.real(), -z.imag()); return Complex_number<FT>(z.real(), -z.imag());
} }

View File

@ -10,18 +10,17 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Hyperbolic_fundamental_domain_2
#ifndef CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_2_H #ifndef CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_2_H
#define CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_2_H #define CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_2_H
#include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/Hyperbolic_isometry_2.h> #include <CGAL/Hyperbolic_isometry_2.h>
#include <CGAL/basic.h>
#include <vector> #include <CGAL/assertions.h>
#include <iostream> #include <iostream>
#include <vector>
namespace CGAL { namespace CGAL {
@ -33,22 +32,31 @@ identifying every two paired sides in a way that respects the orientation of P w
orientable hyperbolic surface. orientable hyperbolic surface.
*/ */
template<class Traits> template<class Traits>
class Hyperbolic_fundamental_domain_2 { class Hyperbolic_fundamental_domain_2
{
public: public:
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
Hyperbolic_fundamental_domain_2() {}; Hyperbolic_fundamental_domain_2() {};
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<int>(pairings.begin(), pairings.end()); _pairings = std::vector<int>(pairings.begin(), pairings.end());
} }
std::size_t size() const; // Returns the number of vertices (equivalently, the number of sides) // returns the number of vertices (equivalently, the number of sides)
const Point& vertex(std::size_t index) const; // Returns the index-th vertex std::size_t size() const;
std::size_t paired_side(std::size_t index) const; // Returns the index of the side paired to side A, where A is the index-th side
Hyperbolic_isometry_2<Traits> side_pairing(std::size_t index) const;// Returns the isometry that maps side A to side B, where B is the index-th side, and A is the side paired to B // returns the index-th vertex
const Point& vertex(std::size_t index) const;
// returns the index of the side paired to side A, where A is the index-th side
std::size_t paired_side(std::size_t index) const;
// returns the isometry that maps side A to side B, where B is the index-th side, and A is the side paired to B
Hyperbolic_isometry_2<Traits> side_pairing(std::size_t index) const;
std::istream& from_stream(std::istream& s); std::istream& from_stream(std::istream& s);
std::ostream& to_stream(std::ostream& s) const; std::ostream& to_stream(std::ostream& s) const;
@ -63,32 +71,43 @@ private:
//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);
//template<class Traits> std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain); //template<class Traits> std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
std::size_t Hyperbolic_fundamental_domain_2<Traits>::size() const{ std::size_t
Hyperbolic_fundamental_domain_2<Traits>::
size() const
{
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return _vertices.size(); return _vertices.size();
} }
template<class Traits> template<class Traits>
const typename Hyperbolic_fundamental_domain_2<Traits>::Point& Hyperbolic_fundamental_domain_2<Traits>::vertex(std::size_t index) const{ const typename Hyperbolic_fundamental_domain_2<Traits>::Point&
Hyperbolic_fundamental_domain_2<Traits>::
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>
std::size_t Hyperbolic_fundamental_domain_2<Traits>::paired_side(std::size_t index) const{ std::size_t
Hyperbolic_fundamental_domain_2<Traits>::
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>
Hyperbolic_isometry_2<Traits> Hyperbolic_fundamental_domain_2<Traits>::side_pairing(std::size_t index) const{ Hyperbolic_isometry_2<Traits>
Hyperbolic_fundamental_domain_2<Traits>::
side_pairing(std::size_t index) const
{
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
std::size_t n = size(); std::size_t n = size();
std::size_t paired_index = paired_side(index); std::size_t paired_index = paired_side(index);
@ -106,7 +125,10 @@ Hyperbolic_isometry_2<Traits> Hyperbolic_fundamental_domain_2<Traits>::side_pair
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
std::ostream& Hyperbolic_fundamental_domain_2<Traits>::to_stream(std::ostream& s) const{ std::ostream&
Hyperbolic_fundamental_domain_2<Traits>::
to_stream(std::ostream& s) const
{
std::size_t n = size(); std::size_t n = size();
s << std::to_string(n) << std::endl; s << std::to_string(n) << std::endl;
@ -122,7 +144,10 @@ std::ostream& Hyperbolic_fundamental_domain_2<Traits>::to_stream(std::ostream& s
} }
template<class Traits> template<class Traits>
std::istream& Hyperbolic_fundamental_domain_2<Traits>::from_stream(std::istream& s){ std::istream&
Hyperbolic_fundamental_domain_2<Traits>::
from_stream(std::istream& s)
{
_vertices.clear(); _vertices.clear();
_pairings.clear(); _pairings.clear();
@ -145,11 +170,13 @@ std::istream& Hyperbolic_fundamental_domain_2<Traits>::from_stream(std::istream&
return s; return s;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
bool Hyperbolic_fundamental_domain_2<Traits>::is_valid()const{ bool
Hyperbolic_fundamental_domain_2<Traits>::
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();

View File

@ -10,8 +10,6 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Hyperbolic_fundamental_domain_factory_2
#ifndef CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_FACTORY_2_H #ifndef CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_FACTORY_2_H
#define CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_FACTORY_2_H #define CGAL_HYPERBOLIC_FUNDAMENTAL_DOMAIN_FACTORY_2_H
@ -21,6 +19,7 @@
#include <CGAL/Random.h> #include <CGAL/Random.h>
#include <cmath> #include <cmath>
#include <vector>
namespace CGAL { namespace CGAL {
@ -31,7 +30,8 @@ closed orientable hyperbolic surfaces. The function
genus 2. genus 2.
*/ */
template<class Traits> 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;
@ -69,8 +69,10 @@ template<class Traits>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
Hyperbolic_fundamental_domain_2<Traits> Hyperbolic_fundamental_domain_factory_2<Traits>::make_hyperbolic_fundamental_domain_g2(unsigned int seed){ Hyperbolic_fundamental_domain_2<Traits>
Hyperbolic_fundamental_domain_factory_2<Traits>::
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;
@ -134,7 +136,10 @@ float Hyperbolic_fundamental_domain_factory_2<Traits>::random_float(){
} }
template<class Traits> template<class Traits>
Complex_number<float> Hyperbolic_fundamental_domain_factory_2<Traits>::random_complex_float(){ Complex_number<float>
Hyperbolic_fundamental_domain_factory_2<Traits>::
random_complex_float()
{
Complex_number<float> result (random_float(), random_positive_float()); Complex_number<float> result (random_float(), random_positive_float());
while (norm(result) >= 1) { while (norm(result) >= 1) {
result.real(random_float()); result.real(random_float());
@ -147,7 +152,10 @@ Complex_number<float> Hyperbolic_fundamental_domain_factory_2<Traits>::random_co
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
typename Traits::FT Hyperbolic_fundamental_domain_factory_2<Traits>::exact_number_from_float(float x){ typename Traits::FT
Hyperbolic_fundamental_domain_factory_2<Traits>::
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);
} }
@ -155,14 +163,22 @@ typename Traits::FT Hyperbolic_fundamental_domain_factory_2<Traits>::exact_numbe
} }
template<class Traits> template<class Traits>
typename Traits::Complex Hyperbolic_fundamental_domain_factory_2<Traits>::exact_complex_from_float_complex(const Complex_number<float>& z){ typename Traits::Complex
Hyperbolic_fundamental_domain_factory_2<Traits>::
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()));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
bool Hyperbolic_fundamental_domain_factory_2<Traits>::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 Hyperbolic_fundamental_domain_factory_2<Traits>::
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)
{
if (((z2/z1).imag()<=0) || ((z3/z2).imag()<=0)) { if (((z2/z1).imag()<=0) || ((z3/z2).imag()<=0)) {
return false; return false;
} }
@ -184,7 +200,10 @@ bool Hyperbolic_fundamental_domain_factory_2<Traits>::try_to_compute_inexact_z0_
} }
template<class Traits> template<class Traits>
bool Hyperbolic_fundamental_domain_factory_2<Traits>::try_to_compute_exact_z3_from_z0_z1_z2(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3){ bool
Hyperbolic_fundamental_domain_factory_2<Traits>::
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)) {
@ -230,7 +249,10 @@ bool Hyperbolic_fundamental_domain_factory_2<Traits>::try_to_compute_exact_z3_fr
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
bool Hyperbolic_fundamental_domain_factory_2<Traits>::sanity_check(_Cmplx& z0, _Cmplx& z1, _Cmplx& z2, _Cmplx& z3){ bool
Hyperbolic_fundamental_domain_factory_2<Traits>::
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);

View File

@ -10,8 +10,6 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Hyperbolic_isometry_2
#ifndef CGAL_HYPERBOLIC_ISOMETRY_2_H #ifndef CGAL_HYPERBOLIC_ISOMETRY_2_H
#define CGAL_HYPERBOLIC_ISOMETRY_2_H #define CGAL_HYPERBOLIC_ISOMETRY_2_H
@ -22,11 +20,13 @@
namespace CGAL { namespace CGAL {
/* /*
Represents a hyperbolic isometry in the Poincare disk model the hyperbolic plane. The isometry f is stored as list (c0, c1, c2, c3) of 4 complex numbers, Represents a hyperbolic isometry in the Poincare disk model the hyperbolic plane.
The isometry f is stored as list (c0, c1, c2, c3) of 4 complex numbers,
so that f(z) = (c0 z + c1) / (c2 z + c3) holds on every complex z in the open unit disk. so that f(z) = (c0 z + c1) / (c2 z + c3) holds on every complex z in the open unit disk.
*/ */
template<class Traits> template<class Traits>
class Hyperbolic_isometry_2{ class Hyperbolic_isometry_2
{
public: public:
typedef Hyperbolic_isometry_2<Traits> Self; typedef Hyperbolic_isometry_2<Traits> Self;
typedef typename Traits::FT FT; typedef typename Traits::FT FT;
@ -42,10 +42,10 @@ public:
void set_coefficients(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3); void set_coefficients(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3);
void set_coefficient(int index, const Complex_number& coefficient); void set_coefficient(int index, const Complex_number& coefficient);
// Returns the index-th coefficient // returns the index-th coefficient
const Complex_number& get_coefficient(int index) const; const Complex_number& get_coefficient(int index) const;
// Evaluates the isometry at point // evaluates the isometry at point
Point evaluate(const Point& point) const; Point evaluate(const Point& point) const;
Point operator()(const Point& point) const; Point operator()(const Point& point) const;
@ -59,35 +59,53 @@ template<class Traits>
// template<class Traits> std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry); // template<class Traits> std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry);
// When inverse=false, returns the hyperbolic translation that maps -p to zero, and zero to p. Otherwise, returns the hyperbolic translation that maps p to zero, and zero to -p. // When inverse is 'false', returns the hyperbolic translation that maps -p to zero, and zero to p.
// Otherwise, returns the hyperbolic translation that maps p to zero, and zero to -p.
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> hyperbolic_translation(const typename Traits::Hyperbolic_point_2& p, bool inverse=false); Hyperbolic_isometry_2<Traits> hyperbolic_translation(const typename Traits::Hyperbolic_point_2& p,
bool inverse = false);
// When inverse=false, returns the hyperbolic rotation around zero that maps p to q. Otherwise, returns the hyperbolic rotation around zero that maps q to p. // When inverse is 'false', returns the hyperbolic rotation around zero that maps p to q.
// Otherwise, returns the hyperbolic rotation around zero that maps q to p.
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> hyperbolic_rotation(const typename Traits::Hyperbolic_point_2& p, const typename Traits::Hyperbolic_point_2& q, bool inverse=false); Hyperbolic_isometry_2<Traits> hyperbolic_rotation(const typename Traits::Hyperbolic_point_2& p,
const typename Traits::Hyperbolic_point_2& q,
bool inverse = false);
// Returns the hyperbolic isometry that maps p1 to q1 and p2 to q2 // returns the hyperbolic isometry that maps p1 to q1 and p2 to q2
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> isometry_pairing_the_sides(const typename Traits::Hyperbolic_point_2& p1, const typename Traits::Hyperbolic_point_2& p2, const typename Traits::Hyperbolic_point_2& q1, const typename Traits::Hyperbolic_point_2& q2); Hyperbolic_isometry_2<Traits> isometry_pairing_the_sides(const typename Traits::Hyperbolic_point_2& p1,
const typename Traits::Hyperbolic_point_2& p2,
const typename Traits::Hyperbolic_point_2& q1,
const typename Traits::Hyperbolic_point_2& q2);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits>::Hyperbolic_isometry_2(){ Hyperbolic_isometry_2<Traits>::
Hyperbolic_isometry_2()
{
set_to_identity(); set_to_identity();
} }
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits>::Hyperbolic_isometry_2(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3){ Hyperbolic_isometry_2<Traits>::
Hyperbolic_isometry_2(const Complex_number& c0,
const Complex_number& c1,
const Complex_number& c2,
const Complex_number& c3)
{
set_coefficients(c0,c1,c2,c3); set_coefficients(c0,c1,c2,c3);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
void Hyperbolic_isometry_2<Traits>::set_to_identity(){ void
Hyperbolic_isometry_2<Traits>::
set_to_identity()
{
set_coefficients(Complex_number(FT(1)), set_coefficients(Complex_number(FT(1)),
Complex_number(FT(0)), Complex_number(FT(0)),
Complex_number(FT(0)), Complex_number(FT(0)),
@ -95,7 +113,13 @@ void Hyperbolic_isometry_2<Traits>::set_to_identity(){
} }
template<class Traits> template<class Traits>
void Hyperbolic_isometry_2<Traits>::set_coefficients(const Complex_number& c0, const Complex_number& c1, const Complex_number& c2, const Complex_number& c3){ void
Hyperbolic_isometry_2<Traits>::
set_coefficients(const Complex_number& c0,
const Complex_number& c1,
const Complex_number& c2,
const Complex_number& c3)
{
set_coefficient(0, c0); set_coefficient(0, c0);
set_coefficient(1, c1); set_coefficient(1, c1);
set_coefficient(2, c2); set_coefficient(2, c2);
@ -103,21 +127,30 @@ void Hyperbolic_isometry_2<Traits>::set_coefficients(const Complex_number& c0, c
} }
template<class Traits> template<class Traits>
void Hyperbolic_isometry_2<Traits>::set_coefficient(int index, const Complex_number& coefficient){ void
Hyperbolic_isometry_2<Traits>::
set_coefficient(int index, const Complex_number& coefficient)
{
_coefficients[index] = coefficient; _coefficients[index] = coefficient;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
const typename Traits::Complex& Hyperbolic_isometry_2<Traits>::get_coefficient(int index) const{ const typename Traits::Complex&
Hyperbolic_isometry_2<Traits>::
get_coefficient(int index) const
{
return _coefficients[index]; return _coefficients[index];
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
typename Traits::Hyperbolic_point_2 Hyperbolic_isometry_2<Traits>::evaluate(const Point& point) const{ typename Traits::Hyperbolic_point_2
Hyperbolic_isometry_2<Traits>::
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];
@ -126,13 +159,19 @@ typename Traits::Hyperbolic_point_2 Hyperbolic_isometry_2<Traits>::evaluate(cons
} }
template<class Traits> template<class Traits>
typename Traits::Hyperbolic_point_2 Hyperbolic_isometry_2<Traits>::operator()(const Point& point) const{ typename Traits::Hyperbolic_point_2
Hyperbolic_isometry_2<Traits>::
operator()(const Point& point) const
{
return evaluate(point); return evaluate(point);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> operator*(const Hyperbolic_isometry_2<Traits>& iso1, const Hyperbolic_isometry_2<Traits>& iso2) { Hyperbolic_isometry_2<Traits> operator*(const Hyperbolic_isometry_2<Traits>& iso1,
const Hyperbolic_isometry_2<Traits>& iso2)
{
Hyperbolic_isometry_2<Traits> result; Hyperbolic_isometry_2<Traits> result;
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
for (int j=0; j<2; j++) { for (int j=0; j<2; j++) {
@ -146,7 +185,9 @@ template<class Traits>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> hyperbolic_translation(const typename Traits::Hyperbolic_point_2& p, bool inverse){ Hyperbolic_isometry_2<Traits> hyperbolic_translation(const typename Traits::Hyperbolic_point_2& p,
bool inverse)
{
typename Traits::Complex one (typename Traits::FT(1)); typename Traits::Complex one (typename Traits::FT(1));
typename Traits::Complex z; typename Traits::Complex z;
if (inverse) { if (inverse) {
@ -160,8 +201,12 @@ Hyperbolic_isometry_2<Traits> hyperbolic_translation(const typename Traits::Hype
} }
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> hyperbolic_rotation(const typename Traits::Hyperbolic_point_2& p, const typename Traits::Hyperbolic_point_2& q, bool inverse){ Hyperbolic_isometry_2<Traits> hyperbolic_rotation(const typename Traits::Hyperbolic_point_2& p,
const typename Traits::Hyperbolic_point_2& q,
bool inverse)
{
typename Traits::Complex zero (typename Traits::FT(0)); typename Traits::Complex zero (typename Traits::FT(0));
Hyperbolic_isometry_2<Traits> result; Hyperbolic_isometry_2<Traits> result;
if (inverse) { if (inverse) {
result.set_coefficients(typename Traits::Complex(p.x(), p.y()), zero, zero, typename Traits::Complex(q.x(), q.y())); result.set_coefficients(typename Traits::Complex(p.x(), p.y()), zero, zero, typename Traits::Complex(q.x(), q.y()));
@ -172,7 +217,11 @@ Hyperbolic_isometry_2<Traits> hyperbolic_rotation(const typename Traits::Hyperbo
} }
template<class Traits> template<class Traits>
Hyperbolic_isometry_2<Traits> isometry_pairing_the_sides(const typename Traits::Hyperbolic_point_2& p1, const typename Traits::Hyperbolic_point_2& p2, const typename Traits::Hyperbolic_point_2& q1, const typename Traits::Hyperbolic_point_2& q2){ Hyperbolic_isometry_2<Traits> isometry_pairing_the_sides(const typename Traits::Hyperbolic_point_2& p1,
const typename Traits::Hyperbolic_point_2& p2,
const typename Traits::Hyperbolic_point_2& q1,
const typename Traits::Hyperbolic_point_2& q2)
{
Hyperbolic_isometry_2<Traits> A,B,Binv,C; Hyperbolic_isometry_2<Traits> A,B,Binv,C;
A = hyperbolic_translation<Traits>(p1); A = hyperbolic_translation<Traits>(p1);
B = hyperbolic_translation<Traits>(q1); B = hyperbolic_translation<Traits>(q1);

View File

@ -10,8 +10,6 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Hyperbolic_surface_traits_2
#ifndef CGAL_HYPERBOLIC_SURFACE_TRAITS_2 #ifndef CGAL_HYPERBOLIC_SURFACE_TRAITS_2
#define CGAL_HYPERBOLIC_SURFACE_TRAITS_2 #define CGAL_HYPERBOLIC_SURFACE_TRAITS_2
@ -19,12 +17,12 @@
#include <CGAL/Complex_number.h> #include <CGAL/Complex_number.h>
#include <iostream>
namespace CGAL { namespace CGAL {
template<class HyperbolicTraitsClass> template<class HyperbolicTraitsClass>
class Hyperbolic_surface_traits_2 : public HyperbolicTraitsClass { class Hyperbolic_surface_traits_2
: public HyperbolicTraitsClass
{
public: public:
typedef typename HyperbolicTraitsClass::FT FT; typedef typename HyperbolicTraitsClass::FT FT;
typedef typename HyperbolicTraitsClass::Hyperbolic_point_2 Hyperbolic_point_2; typedef typename HyperbolicTraitsClass::Hyperbolic_point_2 Hyperbolic_point_2;

View File

@ -10,20 +10,24 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the class Triangulation_on_hyperbolic_surface_2
#ifndef CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_H #ifndef CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_H
#define CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_H #define CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_H
#include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/Hyperbolic_fundamental_domain_2.h>
#include <CGAL/basic.h>
#include <CGAL/Combinatorial_map.h> #include <CGAL/Combinatorial_map.h>
#include <CGAL/Hyperbolic_fundamental_domain_2.h>
#include <CGAL/assertions.h>
#include <fstream>
#include <iostream>
#include <map> #include <map>
#include <vector>
#include <queue> #include <queue>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <utility>
namespace CGAL { namespace CGAL {
@ -34,11 +38,12 @@ It is also possible to specify an anchor for the triangulation. An anchor consis
2) three points A,B,C in the hyperbolic plane. The points A,B,C are the three vertices in counter-clockwise order of a triangle. This triangle is a lift 2) three points A,B,C in the hyperbolic plane. The points A,B,C are the three vertices in counter-clockwise order of a triangle. This triangle is a lift
of T, and A is a lift of V. of T, and A is a lift of V.
*/ */
template<class Traits> template<class Traits>
struct Combinatorial_map_with_cross_ratios_item{ struct Combinatorial_map_with_cross_ratios_item
{
template <class CMap> template <class CMap>
struct Dart_wrapper{ struct Dart_wrapper
{
typedef Cell_attribute<CMap, Complex_number<typename Traits::FT> > Edge_attrib; typedef Cell_attribute<CMap, Complex_number<typename Traits::FT> > Edge_attrib;
typedef std::tuple<void, Edge_attrib, void> Attributes; typedef std::tuple<void, Edge_attrib, void> Attributes;
}; };
@ -48,10 +53,10 @@ template<class Traits, class Attributes = Combinatorial_map_with_cross_ratios_it
class Triangulation_on_hyperbolic_surface_2 class Triangulation_on_hyperbolic_surface_2
{ {
public: public:
typedef Combinatorial_map<2, Attributes> Combinatorial_map_with_cross_ratios; typedef Combinatorial_map<2, Attributes> Combinatorial_map_with_cross_ratios;
struct Anchor{ struct Anchor
{
typename Combinatorial_map_with_cross_ratios::Dart_descriptor dart; typename Combinatorial_map_with_cross_ratios::Dart_descriptor dart;
typename Traits::Hyperbolic_point_2 vertices[3]; typename Traits::Hyperbolic_point_2 vertices[3];
}; };
@ -80,7 +85,6 @@ public:
// Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap); // Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap);
Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap, Anchor& anchor); Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap, Anchor& anchor);
Combinatorial_map_with_cross_ratios& combinatorial_map(); Combinatorial_map_with_cross_ratios& combinatorial_map();
bool has_anchor() const; bool has_anchor() const;
Anchor& anchor(); Anchor& anchor();
@ -98,7 +102,6 @@ public:
bool is_valid() const; bool is_valid() const;
// The following methods are not documented but they are non private for internal future use. // The following methods are not documented but they are non private for internal future use.
Dart_descriptor ccw(Dart_descriptor dart); Dart_descriptor ccw(Dart_descriptor dart);
Dart_descriptor cw(Dart_descriptor dart); Dart_descriptor cw(Dart_descriptor dart);
Dart_descriptor opposite(Dart_descriptor dart); Dart_descriptor opposite(Dart_descriptor dart);
@ -108,9 +111,9 @@ public:
Complex_number get_cross_ratio(Dart_const_descriptor dart) const; Complex_number get_cross_ratio(Dart_const_descriptor dart) const;
// Returns the cross ratio of the points a,b,c,d // returns the cross ratio of the points a,b,c,d
Complex_number cross_ratio(const Point& a, const Point& b, const Point& c, const Point& d) const; Complex_number cross_ratio(const Point& a, const Point& b, const Point& c, const Point& d) const;
// Returns the point d such that the cross ratio of a,b,c,d is cratio // returns the point d such that the cross ratio of a,b,c,d is cratio
Point fourth_point_from_cross_ratio(const Point& a, const Point& b, const Point& c, const Complex_number& cratio) const; Point fourth_point_from_cross_ratio(const Point& a, const Point& b, const Point& c, const Complex_number& cratio) const;
// Wrapper around the Cmap for iterating over vertices, edges or faces. // Wrapper around the Cmap for iterating over vertices, edges or faces.
@ -153,7 +156,9 @@ protected:
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
Triangulation_on_hyperbolic_surface_2<Traits,Attributes>::Triangulation_on_hyperbolic_surface_2(const Domain& domain){ Triangulation_on_hyperbolic_surface_2<Traits,Attributes>::
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();
int size = domain.size(); int size = domain.size();
@ -232,33 +237,46 @@ Triangulation_on_hyperbolic_surface_2<Traits,Attributes>::Triangulation_on_hyper
/* } */ /* } */
template<class Traits, class Attributes> template<class Traits, class Attributes>
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap, Anchor& anchor){ Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
Triangulation_on_hyperbolic_surface_2(Combinatorial_map_with_cross_ratios& cmap,
Anchor& anchor)
{
copy_from(cmap, anchor); copy_from(cmap, anchor);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Combinatorial_map_with_cross_ratios& Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::combinatorial_map(){ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Combinatorial_map_with_cross_ratios&
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
combinatorial_map()
{
return _combinatorial_map; return _combinatorial_map;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::has_anchor() const { bool
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Anchor& typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Anchor&
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::anchor() { Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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>
const typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Anchor& const typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Anchor&
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::anchor() const { Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
anchor() const
{
CGAL_precondition(is_valid() && has_anchor()); CGAL_precondition(is_valid() && has_anchor());
return _anchor; return _anchor;
} }
@ -266,14 +284,21 @@ Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::anchor() const {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::is_Delaunay_flippable(Dart_const_descriptor dart) const{ bool
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
is_Delaunay_flippable(Dart_const_descriptor dart) const
{
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
return (get_cross_ratio(dart).imag() > Number(0)); return (get_cross_ratio(dart).imag() > Number(0));
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::flip(Dart_descriptor dart){ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
flip(Dart_descriptor dart)
{
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
// First gather all the information needed // First gather all the information needed
Dart_descriptor a = opposite(dart); // Get a fresh descriptor Dart_descriptor a = opposite(dart); // Get a fresh descriptor
@ -356,7 +381,10 @@ void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::flip(Dart_descri
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::is_Delaunay() const{ bool
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
is_Delaunay() const
{
if (! is_valid()) { if (! is_valid()) {
return false; return false;
} }
@ -364,7 +392,10 @@ bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::is_Delaunay() co
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
int Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::make_Delaunay(){ int
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
make_Delaunay()
{
CGAL_precondition(is_valid()); CGAL_precondition(is_valid());
int number_of_flips_done = 0; int number_of_flips_done = 0;
@ -380,19 +411,31 @@ int Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::make_Delaunay(){
template<class Traits, class Attributes> template<class Traits, class Attributes>
std::vector<std::tuple<typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor, typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point, typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point, typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point>> Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::lift(bool center) const{ std::vector<std::tuple<typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor,
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point,
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point,
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point> >
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
lift(bool center) const
{
CGAL_precondition(is_valid() && has_anchor()); CGAL_precondition(is_valid() && has_anchor());
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
bool operator()(std::pair<Dart_const_descriptor,double> const & x, std::pair<Dart_const_descriptor,double> const & y) { {
bool operator()(const std::pair<Dart_const_descriptor,double>& x,
const std::pair<Dart_const_descriptor,double>& y)
{
return x.second > y.second; return x.second > y.second;
} }
}; };
std::priority_queue<std::pair<Dart_const_descriptor,double>, std::vector<std::pair<Dart_const_descriptor,double>>, Compare> queue;
std::priority_queue<std::pair<Dart_const_descriptor, double>,
std::vector<std::pair<Dart_const_descriptor, double> >, Compare> queue;
std::unordered_map<Dart_const_descriptor, Point> positions; std::unordered_map<Dart_const_descriptor, Point> positions;
@ -413,7 +456,11 @@ std::vector<std::tuple<typename Triangulation_on_hyperbolic_surface_2<Traits, At
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::make_tuple(_anchor.dart, positions[_anchor.dart], positions[const_ccw(_anchor.dart)], positions[const_cw(_anchor.dart)]); std::tuple<Dart_const_descriptor, Point, Point, Point> value =
std::make_tuple(_anchor.dart,
positions[_anchor.dart],
positions[const_ccw(_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());
@ -428,8 +475,6 @@ std::vector<std::tuple<typename Triangulation_on_hyperbolic_surface_2<Traits, At
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;
queue.pop(); queue.pop();
@ -477,7 +522,10 @@ std::vector<std::tuple<typename Triangulation_on_hyperbolic_surface_2<Traits, At
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::is_valid() const{ bool
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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
@ -515,8 +563,12 @@ bool Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::is_valid() const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::to_stream(std::ostream& s) const{ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
to_stream(std::ostream& s) const
{
CGAL_precondition(is_valid() && has_anchor()); CGAL_precondition(is_valid() && has_anchor());
// 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;
@ -555,7 +607,10 @@ void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::to_stream(std::o
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::from_stream(std::istream& s){ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
from_stream(std::istream& s)
{
_combinatorial_map.clear(); _combinatorial_map.clear();
// Load the number of darts // Load the number of darts
@ -659,7 +714,9 @@ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Complex_numb
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
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>::pick_edge_to_flip(){ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_descriptor Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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)) {
@ -672,7 +729,10 @@ template<class Traits, class Attributes>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
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>::pick_edge_to_flip() const{ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Dart_const_descriptor
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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) ) {
@ -685,14 +745,21 @@ template<class Traits, class Attributes>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::copy_from(Combinatorial_map_with_cross_ratios& cmap){ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
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>
void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::copy_from(Combinatorial_map_with_cross_ratios& cmap, const Anchor& anchor){ void
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
copy_from(Combinatorial_map_with_cross_ratios& cmap,
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();
@ -728,7 +795,10 @@ void Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::copy_from(Combin
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Traits::Complex Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::cross_ratio(const Point& a, const Point& b, const Point& c, const Point& d) const{ typename Traits::Complex
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
cross_ratio(const Point& a, const Point& b, const Point& c, const Point& d) const
{
Complex_number za (a.x(), a.y()); Complex_number za (a.x(), a.y());
Complex_number zb (b.x(), b.y()); Complex_number zb (b.x(), b.y());
Complex_number zc (c.x(), c.y()); Complex_number zc (c.x(), c.y());
@ -737,7 +807,11 @@ typename Traits::Complex Triangulation_on_hyperbolic_surface_2<Traits, Attribute
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::fourth_point_from_cross_ratio(const Point& a, const Point& b, const Point& c, const Complex_number& cratio) const{ typename Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::Point
Triangulation_on_hyperbolic_surface_2<Traits, Attributes>::
fourth_point_from_cross_ratio(const Point& a, const Point& b, const Point& c,
const Complex_number& cratio) const
{
Complex_number za (a.x(), a.y()); Complex_number za (a.x(), a.y());
Complex_number zb (b.x(), b.y()); Complex_number zb (b.x(), b.y());
Complex_number zc (c.x(), c.y()); Complex_number zc (c.x(), c.y());

View File

@ -10,34 +10,37 @@
// //
// Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud // Author(s) : Vincent Despré, Loïc Dubois, Marc Pouget, Monique Teillaud
// This file contains the declaration and the implementation of the input/output
// functions for the package Triangulation_on_hyperbolic_surface_2
#ifndef CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H #ifndef CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H
#define CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H #define CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H
#include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/basic.h>
#include <CGAL/assertions.h>
#include <iostream> #include <iostream>
namespace CGAL { namespace CGAL {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain){ std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain)
{
CGAL_precondition(domain.is_valid()); CGAL_precondition(domain.is_valid());
return domain.to_stream(s); return domain.to_stream(s);
} }
template<class Traits> template<class Traits>
std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain){ std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain)
{
return domain.from_stream(s); return domain.from_stream(s);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits> template<class Traits>
std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry){ std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry)
{
for (int k=0; k<4; ++k) { for (int k=0; k<4; ++k) {
s << isometry.get_coefficient(k); s << isometry.get_coefficient(k);
} }
@ -46,13 +49,15 @@ std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& i
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<class Traits, class Attributes> template<class Traits, class Attributes>
std::ostream& operator<<(std::ostream& s, const Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation){ std::ostream& operator<<(std::ostream& s, const Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation)
{
triangulation.to_stream(s); triangulation.to_stream(s);
return s; return s;
} }
template<class Traits, class Attributes> template<class Traits, class Attributes>
void operator>>(std::istream& s, Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation){ void operator>>(std::istream& s, Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation)
{
triangulation.from_stream(s); triangulation.from_stream(s);
} }

View File

@ -1,15 +1,11 @@
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.12...3.29) cmake_minimum_required(VERSION 3.12...3.31)
project(Triangulation_on_hyperbolic_surface_2_Tests) project(Triangulation_on_hyperbolic_surface_2_Tests)
find_package(CGAL REQUIRED) find_package(CGAL REQUIRED)
set(CMAKE_BUILD_TYPE "Debug")
include_directories(../../include/)
# create a target per cppfile # create a target per cppfile
file( file(
GLOB cppfiles GLOB cppfiles

View File

@ -12,6 +12,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector>
typedef CGAL::Circular_kernel_2<CGAL::Cartesian<CGAL::Exact_rational>,CGAL::Algebraic_kernel_for_circles_2_2<CGAL::Exact_rational>> Kernel; typedef CGAL::Circular_kernel_2<CGAL::Cartesian<CGAL::Exact_rational>,CGAL::Algebraic_kernel_for_circles_2_2<CGAL::Exact_rational>> Kernel;
typedef CGAL::Hyperbolic_Delaunay_triangulation_CK_traits_2<Kernel> ParentTraits; typedef CGAL::Hyperbolic_Delaunay_triangulation_CK_traits_2<Kernel> ParentTraits;
@ -22,7 +23,8 @@ typedef CGAL::Triangulation_on_hyperbolic_surface_2<Traits> Tria
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
int main() { int main()
{
Factory factory; Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459); Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);
Triangulation triangulation0 = Triangulation(domain); Triangulation triangulation0 = Triangulation(domain);

View File

@ -10,7 +10,8 @@ typedef CGAL::Interval_nt<> Interval;
typedef CGAL::Complex_number<Exact_rational> Complex_rational; typedef CGAL::Complex_number<Exact_rational> Complex_rational;
typedef CGAL::Complex_number<Interval> Complex_interval; typedef CGAL::Complex_number<Interval> Complex_interval;
int main() { int main()
{
// Complex_rational tests : // Complex_rational tests :
Complex_rational zero_rational = Complex_rational (); Complex_rational zero_rational = Complex_rational ();
assert(zero_rational == Complex_rational(Exact_rational(0), Exact_rational(0))); assert(zero_rational == Complex_rational(Exact_rational(0), Exact_rational(0)));

View File

@ -7,6 +7,7 @@
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h> #include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <iostream> #include <iostream>
#include <vector>
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel; typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits; typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits;
@ -18,7 +19,8 @@ typedef typename Traits::Hyperbolic_point_2 Point;
typedef typename Traits::Complex Complex; typedef typename Traits::Complex Complex;
int main() { int main()
{
std::vector<Point> vertices; std::vector<Point> vertices;
Point z0 = Point(FT("4881/5000"),FT("0")); Point z0 = Point(FT("4881/5000"),FT("0"));
Point z1 = Point(FT("9211/10000"),FT("2733/10000")); Point z1 = Point(FT("9211/10000"),FT("2733/10000"));

View File

@ -6,6 +6,7 @@
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h> #include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <iostream> #include <iostream>
#include <vector>
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel; typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits; typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits;
@ -17,8 +18,8 @@ typedef typename Traits::FT FT;
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
typedef typename Traits::Complex Complex; typedef typename Traits::Complex Complex;
int main()
int main() { {
Factory factory; Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459); Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);

View File

@ -17,8 +17,8 @@ typedef typename Traits::FT FT;
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
typedef typename Traits::Complex Complex; typedef typename Traits::Complex Complex;
int main()
int main() { {
Isometry identity_1 = Isometry (); Isometry identity_1 = Isometry ();
assert(identity_1.get_coefficient(0)==Complex(FT(1))); assert(identity_1.get_coefficient(0)==Complex(FT(1)));
assert(identity_1.get_coefficient(1)==Complex(FT(0))); assert(identity_1.get_coefficient(1)==Complex(FT(0)));

View File

@ -2,13 +2,16 @@
#include <CGAL/Hyperbolic_fundamental_domain_factory_2.h> #include <CGAL/Hyperbolic_fundamental_domain_factory_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2_IO.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2_IO.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <iostream>
#include <sstream>
#include <CGAL/Exact_rational.h> #include <CGAL/Exact_rational.h>
#include <CGAL/Lazy_exact_nt.h> #include <CGAL/Lazy_exact_nt.h>
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <iostream>
#include <sstream>
#include <tuple>
#include <vector>
typedef CGAL::Cartesian<CGAL::Lazy_exact_nt<CGAL::Exact_rational>> Kernel; typedef CGAL::Cartesian<CGAL::Lazy_exact_nt<CGAL::Exact_rational>> Kernel;
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits; typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits;
@ -19,7 +22,8 @@ typedef CGAL::Triangulation_on_hyperbolic_surface_2<Traits> Tr
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
int main() { int main()
{
Factory factory; Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459); Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);
Triangulation triangulation0 = Triangulation(domain); Triangulation triangulation0 = Triangulation(domain);
@ -49,7 +53,6 @@ int main() {
output_not_centered = triangulation.lift(false); output_not_centered = triangulation.lift(false);
output_centered = triangulation.lift(); output_centered = triangulation.lift();
Triangulation::Combinatorial_map_with_cross_ratios& cmap = triangulation.combinatorial_map(); Triangulation::Combinatorial_map_with_cross_ratios& cmap = triangulation.combinatorial_map();
Triangulation::Anchor& anchor = triangulation.anchor(); Triangulation::Anchor& anchor = triangulation.anchor();
assert(cmap.is_dart_used(anchor.dart)); assert(cmap.is_dart_used(anchor.dart));

View File

@ -1,13 +1,14 @@
#include <CGAL/Hyperbolic_surface_traits_2.h> #include <CGAL/Hyperbolic_surface_traits_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2.h>
#include <CGAL/Triangulation_on_hyperbolic_surface_2_IO.h> #include <CGAL/Triangulation_on_hyperbolic_surface_2_IO.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <CGAL/Exact_rational.h> #include <CGAL/Exact_rational.h>
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector>
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel; typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits; typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2<Kernel> ParentTraits;
@ -19,7 +20,8 @@ typedef typename Traits::FT FT;
typedef typename Traits::Hyperbolic_point_2 Point; typedef typename Traits::Hyperbolic_point_2 Point;
typedef typename Traits::Complex Complex; typedef typename Traits::Complex Complex;
Domain build_domain(){ Domain build_domain()
{
std::vector<Point> vertices; std::vector<Point> vertices;
vertices.push_back( Point(FT(809,10000),FT(0))); vertices.push_back( Point(FT(809,10000),FT(0)));
vertices.push_back( Point(FT(7359,10000),FT(1877,10000))); vertices.push_back( Point(FT(7359,10000),FT(1877,10000)));
@ -38,7 +40,8 @@ Domain build_domain(){
return Domain(vertices, pairings); return Domain(vertices, pairings);
} }
int main() { int main()
{
Domain domain = build_domain(); Domain domain = build_domain();
Triangulation triangulation0 = Triangulation(domain); Triangulation triangulation0 = Triangulation(domain);