Skip to content

Commit

Permalink
hopefully last revision for 1st review round
Browse files Browse the repository at this point in the history
  • Loading branch information
pougetma committed Sep 9, 2024
1 parent 8f2609f commit 002b807
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ typedef Hyperbolic_surface_triangulation_2<Traits> Triangul

int main(int argc, char** argv){
// 1. Generate the triangulation
Factory factory = Factory(time(NULL));
Domain domain = factory.generate_domain_g2();
Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(time(NULL));
Triangulation triangulation = Triangulation(domain);
triangulation.make_Delaunay();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ class Hyperbolic_fundamental_domain_factory_2{
/// \name Creation
/// @{
/*!
Constructor, the seed is used for generation.
Constructor.
*/
Hyperbolic_fundamental_domain_factory_2(unsigned int seed);
Hyperbolic_fundamental_domain_factory_2();
/// @}

/// \name Generation of a domain
/// \name Generation of a domain in genus 2.
/// @{
/*!
randomly generates a convex domain of a closed orientable hyperbolic surface of genus two.
randomly generates a convex domain of a closed orientable hyperbolic surface
of genus two from a seed.
*/
Hyperbolic_fundamental_domain_2<Traits> generate_domain_g2();
Hyperbolic_fundamental_domain_2<Traits> make_hyperbolic_fundamental_domain_g2(unsigned int seed);
/// @}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,15 @@ class Hyperbolic_surface_triangulation_2{
\pre <code> is_valid() && has_anchor() </code>
*/
Anchor& anchor();
/*!
constant version of the getter.
\pre <code> is_valid() && has_anchor() </code>
*/
const Anchor& const_anchor();
/// @}


/// \name Delaunay flip algorithm
/// @{
/*!
Expand Down Expand Up @@ -190,9 +197,7 @@ class Hyperbolic_surface_triangulation_2{
/*!
reads the triangulation from a stream.
The format of the input should be the same as the format of the output of the '<<' operator.
\pre <code> is_valid() </code>
*/
*/
std::istream& operator>>(std::istream& s, Hyperbolic_surface_triangulation_2<Traits>& triangulation);
/// @}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

\page Chapter_Hyperbolic_Surface_Triangulations Triangulations of hyperbolic surfaces
\page Chapter_Hyperbolic_Surface_Triangulations Triangulations of Hyperbolic Surfaces

namespace CGAL {
/*!
Expand All @@ -19,38 +19,38 @@ Functionalities are offered such as the Delaunay flip algorithm, and the constru
A triangulation of a surface can be generated from a convex fundamental domain of the surface. A method is offered that generates such domains in genus two.


\section Section_Hyperbolic_Surface_Triangulations_Background Hyperbolic surfaces
\section Section_Hyperbolic_Surface_Triangulations_Background Hyperbolic Surfaces

We assume some familiarity with basic notions from covering space theory, and from the theory of hyperbolic surfaces.
The <b>Poincaré disk</b> \f$ \mathbb{D} \f$ is a model of the hyperbolic plane whose point set is the open unit disk of the complex plane \f$ \mathbb{C} \f$.
The <em>Poincaré disk</em> \f$ \mathbb{D} \f$ is a model of the hyperbolic plane whose point set is the open unit disk of the complex plane \f$ \mathbb{C} \f$.
In this package, every hyperbolic surface \f$ S \f$ is closed (compact, and without boundary) and orientable: this is without further mention.
The Poincaré disk \f$ \mathbb{D} \f$ is a universal covering space for \f$ S \f$, whose projection map \f$ \pi: \mathbb{D} \to S \f$ is a (local) isometry.
The pre-image set \f$ \pi^{-1}(x) \f$ of a point \f$ x \in S \f$ is infinite, its points are the <b>lifts</b> of \f$ x \f$.
The pre-image set \f$ \pi^{-1}(x) \f$ of a point \f$ x \in S \f$ is infinite, its points are the <em>lifts</em> of \f$ x \f$.
We usually denote by \f$ \widetilde x \f$ a lift of \f$ x \f$.
Paths and triangulations of \f$ S \f$ can also be lifted in \f$ \mathbb{D} \f$.

\subsection Section_Hyperbolic_Surface_Triangulations_domains Fundamental domains and triangulations
\subsection Section_Hyperbolic_Surface_Triangulations_domains Fundamental Domains and Triangulations

Let \f$ S \f$ be a hyperbolic surface. For representing \f$ S \f$ on a computer, we cut \f$ S \f$ into "manageable" pieces.
A graph \f$ G \f$ embedded on \f$ S \f$ is a <b>cellular decomposition</b> of \f$ S \f$ if every face (every connected component of \f$ S \setminus G \f$ ) is a topological disk.
A graph \f$ G \f$ embedded on \f$ S \f$ is a <em>cellular decomposition</em> of \f$ S \f$ if every face (every connected component of \f$ S \setminus G \f$ ) is a topological disk.
In this document, every edge of a graph \f$ G \f$ embedded on \f$ S \f$ is a geodesic on \f$ S \f$.
We consider two types of cellular decompositions of \f$ S \f$:

<ul>
<li>We consider cellular decompositions \f$ G \f$ of \f$ S \f$ that have only one face.
Cutting \f$ S \f$ open at the edges of \f$ G \f$ results in a hyperbolic polygon \f$ P \f$, which is a <b>fundamental domain</b> for \f$ S \f$.
Cutting \f$ S \f$ open at the edges of \f$ G \f$ results in a hyperbolic polygon \f$ P \f$, which is a <em>fundamental domain</em> for \f$ S \f$.
The edges of \f$ P \f$ are paired, so that every edge of \f$ G \f$ is cut into two edges that are paired in \f$ P \f$.
Every hyperbolic surface admits a fundamental domain \f$ P \f$ that is <b>convex</b>, in that the interior angles of \f$ P \f$ do not exceed \f$ \pi \f$.
Every hyperbolic surface admits a fundamental domain \f$ P \f$ that is <em>convex</em>, in that the interior angles of \f$ P \f$ do not exceed \f$ \pi \f$.

<li>Also, we consider <b>triangulations</b> of \f$ S \f$.
<li>Also, we consider <em>triangulations</em> of \f$ S \f$.
A cellular decomposition \f$ T \f$ of \f$ S \f$ is a triangulation if every face of \f$ T \f$ is a "triangle": it admits three incidences with edges of \f$ T \f$.
Observe that this definition allows for triangulations with only one vertex.
</ul>

A triangulation of \f$ S \f$ can be obtained from a convex fundamental domain \f$ P \f$ of \f$ S \f$ by triangulating the interior of \f$ P \f$, and by gluing back the boundary edges that are paired in \f$ P \f$.
The assumption that \f$ P \f$ is convex ensures that the interior of \f$ P \f$ can be triangulated naively by insertion of any maximal set of pairwise-disjoint arcs of \f$ P \f$.

\subsection Section_Hyperbolic_Surface_Triangulations_generation Generation of convex fundamental domains
\subsection Section_Hyperbolic_Surface_Triangulations_generation Generation of Convex Fundamental Domains

This package can generate a convex fundamental domain \f$ P \f$ of a surface of genus two, with eight vertices \f$ z_0, \dots, z_7 \in \mathbb{C} \f$, whose side pairings are \f$ A B C D \overline{A} \overline{B} \overline{C} \overline{D} \f$.
The vertices and the side pairings are in counter-clockwise order, the side between \f$ z_0 \f$ and \f$ z_1 \f$ is \f$ A \f$, and the side between \f$ z_4 \f$ and \f$ z_5 \f$ is \f$ \overline{A} \f$.
Expand All @@ -63,7 +63,7 @@ Such octagons are described in \cgalCite{aigon2005hyperbolic}.

\section Subsection_Hyperbolic_Surface_Triangulations_Representation Representation

\subsection Subsection_Hyperbolic_Surface_Triangulations_DS_Domains Data structure for domains
\subsection Subsection_Hyperbolic_Surface_Triangulations_DS_Domains Data Structure for Domains

We represent every domain as a polygon in the Poincaré disk, given by the list of its vertices, and by the list of its side pairings.
Concerning the generation of domains, in order to perform fast and exact
Expand All @@ -72,11 +72,11 @@ Under this constraint, it is not known how to generate domains of surfaces of ge
In genus two, this package generates domains whose vertices belong to \f$ \mathbb{Q} + i \mathbb{Q} \f$ (their real and imaginary parts are rational numbers).
The exact generation process can be found in \cgalCite{despre2022experimental}, together with a proof that the surfaces that can be generated in this way are dense in the space of surfaces genus two.

\subsection Subsection_Hyperbolic_Surface_Triangulations_DS_Triangulations Data structure for triangulations
\subsection Subsection_Hyperbolic_Surface_Triangulations_DS_Triangulations Data Structure for Triangulations

Let \f$ T \f$ be a triangulation of a hyperbolic surface.
We represent \f$ T \f$ by an instance of CGAL::Combinatorial_map whose edges are decorated with complex numbers.
The complex number \f$ R_T(e) \in \mathbb{C} \f$ decorating an edge \f$ e \f$ of \f$ T \f$ is the <b>cross ratio</b> of \f$ e \f$ in \f$ T \f$, defined as follows.
The complex number \f$ R_T(e) \in \mathbb{C} \f$ decorating an edge \f$ e \f$ of \f$ T \f$ is the <em>cross ratio</em> of \f$ e \f$ in \f$ T \f$, defined as follows.
Consider the lift \f$ \widetilde T \f$ of \f$ T \f$ in the Poincaré disk \f$ \mathbb{D} \f$.
In \f$ \widetilde T \f$, let \f$ \widetilde e \f$ be a lift of \f$ e \f$.
Orient \f$ \widetilde e \f$ arbitrarily, and let \f$ z_0 \in \mathbb{D} \f$ and \f$ z_2 \in \mathbb{D} \f$ be respectively the first and second vertices of \f$ \widetilde e \f$.
Expand All @@ -95,18 +95,18 @@ The anchor is used when building a portion of the lift of \f$ T \f$ in the Poinc
It contains a lift \f$ t \f$ of a triangle of \f$ T \f$ in \f$ \mathbb{D} \f$: \f$ t \f$ is represented by its three vertices in \f$ \mathbb{D} \f$, and by a dart of the corresponding triangle in the combinatorial map of \f$ T \f$.


\subsection Subsection_Hyperbolic_Surface_Triangulations_Delaunay Delaunay flip algorithm
\subsection Subsection_Hyperbolic_Surface_Triangulations_Delaunay Delaunay Flip Algorithm

Let \f$ T \f$ be a triangulation of a hyperbolic surface. An edge \f$ e \f$ of \f$ T \f$ satisfies the <b>Delaunay criterion</b> if the imaginary part of its cross ratio \f$R_T(e)\f$ is non-positive.
Let \f$ T \f$ be a triangulation of a hyperbolic surface. An edge \f$ e \f$ of \f$ T \f$ satisfies the <em>Delaunay criterion</em> if the imaginary part of its cross ratio \f$R_T(e)\f$ is non-positive.
This definition is equivalent to the usual "empty disk" formulation.
Then \f$ T \f$ is a <b>Delaunay triangulation</b> if every edge of \f$ T \f$ satisfies the Delaunay criterion.
Then \f$ T \f$ is a <em>Delaunay triangulation</em> if every edge of \f$ T \f$ satisfies the Delaunay criterion.
If an edge \f$e \f$ of \f$ T \f$ does not satisfy the Delaunay criterion, then the two triangles incident to \f$ e \f$ form a strictly convex quadrilateron, so \f$ e \f$ can be deleted from \f$ T \f$ and replaced by the other diagonal of the quadrilateron.
This operation is called a Delaunay <b>flip</b>.
This operation is called a Delaunay <em>flip</em>.
When a flip occurs, the cross ratios of the involved edges are modified via simple formulas.
The <b>Delaunay flip algorithm</b> flips edges that do not satisfy the Delaunay criterion as long as possible, with no preference on the order of the flips.
The <em>Delaunay flip algorithm</em> flips edges that do not satisfy the Delaunay criterion as long as possible, with no preference on the order of the flips.
This algorithm terminates, and outputs a Delaunay triangulation of \f$ S \f$ \cgalCite{despre2020flipping}.

\section Section_Hyperbolic_Surface_Triangulations_Software_Design Software design
\section Section_Hyperbolic_Surface_Triangulations_Software_Design Software Design


The package contains three main classes:
Expand All @@ -129,7 +129,7 @@ Also, the concept `ComplexWithoutSqrt` describes a complex number type that does
The example below generates a convex fundamental domain of a surface of genus two, triangulates the domain, applies the Delaunay flip algorithm to the resulting triangulation, saves and prints the Delaunay triangulation.
\cgalExample{Hyperbolic_surface_triangulation_2/hyperbolic_surface_triangulation.cpp}

\section Section_Hyperbolic_Surface_Implementation_History Design and implementation history
\section Section_Hyperbolic_Surface_Implementation_History Design and Implementation History

This package implements the Delaunay flip algorithm described in the hyperbolic setting by Vincent Despré, Jean-Marc Schlenker, and Monique Teillaud in \cgalCite{despre2020flipping} (with a different data structure for representing triangulations, see \cgalCite{despre2022experimental}).
It also implements the generation of domains described by Vincent Despré, Loïc Dubois, Benedikt Kolbe, and Monique Teillaud in \cgalCite{despre2022experimental}, based on results of Aline Aigon-Dupuy, Peter Buser, Michel Cibils, Alfred F Künzle, and Frank Steiner \cgalCite{aigon2005hyperbolic}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ typedef CGAL::Hyperbolic_surface_triangulation_2<Traits> Triangulati

int main(){
// Generates the domain:
Factory factory = Factory(time(NULL));
Domain domain = factory.generate_domain_g2();
Factory factory = Factory();
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(time(NULL));

// Triangulates the domain:
Triangulation triangulation = Triangulation(domain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
namespace CGAL {

/*
Factory class, whose only purpose is to construct random domains of genus 2 closed orientable hyperbolic surfaces, via its method generate_domain_g2.
Factory class, whose only purpose is to construct random fundamental domains of
closed orientable hyperbolic surfaces. The method
make_hyperbolic_fundamental_domain_g2 constructs such a domain for a surface of
genus 2.
*/
template<class Traits>
class Hyperbolic_fundamental_domain_factory_2{
Expand All @@ -36,8 +39,8 @@ class Hyperbolic_fundamental_domain_factory_2{
Random _random;

public:
Hyperbolic_fundamental_domain_factory_2(unsigned int seed);
Hyperbolic_fundamental_domain_2<Traits> generate_domain_g2();
Hyperbolic_fundamental_domain_factory_2();
Hyperbolic_fundamental_domain_2<Traits> make_hyperbolic_fundamental_domain_g2(unsigned int seed);

private:
float random_positive_float(); // returns number in [0,1]
Expand All @@ -60,15 +63,14 @@ class Hyperbolic_fundamental_domain_factory_2{
////////////////////////////////////////////////////////////////////////////////

template<class Traits>
Hyperbolic_fundamental_domain_factory_2<Traits>::Hyperbolic_fundamental_domain_factory_2(unsigned int seed){
_random = Random(seed);
}
Hyperbolic_fundamental_domain_factory_2<Traits>::Hyperbolic_fundamental_domain_factory_2(){}

////////////////////////////////////////////////////////////////////////////////

template<class Traits>
Hyperbolic_fundamental_domain_2<Traits> Hyperbolic_fundamental_domain_factory_2<Traits>::generate_domain_g2(){
Hyperbolic_fundamental_domain_2<Traits> Hyperbolic_fundamental_domain_factory_2<Traits>::make_hyperbolic_fundamental_domain_g2(unsigned int seed){

_random = Random(seed);
bool is_domain_generated = false;
_Cmplx exact_z0, exact_z1, exact_z2, exact_z3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class Hyperbolic_surface_triangulation_2{
Combinatorial_map_with_cross_ratios& combinatorial_map();
bool has_anchor() const;
Anchor& anchor();

const Anchor& const_anchor();

void to_stream(std::ostream& s) const;
void from_stream(std::istream& s);

Expand Down Expand Up @@ -241,10 +242,16 @@ bool Hyperbolic_surface_triangulation_2<Traits, Attributes>::has_anchor() const

template<class Traits, class Attributes>
typename Hyperbolic_surface_triangulation_2<Traits, Attributes>::Anchor&
Hyperbolic_surface_triangulation_2<Traits, Attributes>::anchor(){
Hyperbolic_surface_triangulation_2<Traits, Attributes>::anchor() {
return _anchor;
}

template<class Traits, class Attributes>
const typename Hyperbolic_surface_triangulation_2<Traits, Attributes>::Anchor&
Hyperbolic_surface_triangulation_2<Traits, Attributes>::const_anchor(){
return _anchor;
}

////////////////////////////////////////////////////////////////////////////////

template<class Traits, class Attributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ typedef Hyperbolic_surface_triangulation_2<Traits>
typedef typename Traits::Hyperbolic_point_2 Point;

int main() {
Factory factory (3459);
Domain domain = factory.generate_domain_g2();
Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);
Triangulation triangulation0 = Triangulation(domain);

assert( triangulation0.is_valid() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ typedef typename Traits::Complex Complex;


int main() {
Factory factory (3459);
Domain domain = factory.generate_domain_g2();
Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);

std::vector<Point> vertices;
Point z0 = Point(FT("4881/5000"),FT("0"));
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ typedef Hyperbolic_surface_triangulation_2<Traits> Triangul
typedef typename Traits::Hyperbolic_point_2 Point;

int main() {
Factory factory (3459);
Domain domain = factory.generate_domain_g2();
Factory factory;
Domain domain = factory.make_hyperbolic_fundamental_domain_g2(3459);
Triangulation triangulation0 = Triangulation(domain);

assert( triangulation0.is_valid() );
Expand Down

0 comments on commit 002b807

Please sign in to comment.