mirror of https://github.com/CGAL/cgal
I/O factoring
This commit is contained in:
parent
7b3c05dff3
commit
a61ce2ee57
|
|
@ -0,0 +1,54 @@
|
||||||
|
namespace CGAL{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
|
||||||
|
inserts the triangulation in a stream.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
\pre <code> Triangulation_on_hyperbolic_surface_2<Traits>::is_valid() </code>
|
||||||
|
*/
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Triangulation_on_hyperbolic_surface_2<Traits>& triangulation);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
|
||||||
|
extracts the triangulation from a stream.
|
||||||
|
The format of the input should be the same as the format of the output of
|
||||||
|
the '<<' operator for Triangulation_on_hyperbolic_surface_2.
|
||||||
|
*/
|
||||||
|
std::istream& operator>>(std::istream& s, Triangulation_on_hyperbolic_surface_2<Traits>& triangulation);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
|
||||||
|
inserts the domain in a stream.
|
||||||
|
|
||||||
|
The format of the output is the following.
|
||||||
|
The first line prints the number \f$n\f$ of vertices of the domain.
|
||||||
|
For \f$ i=0 \f$ to \f$ n-1 \f$ the index of the side paired to side \f$ i \f$ is printed on a separate line.
|
||||||
|
For \f$ i=0 \f$ to \f$ n-1 \f$ the i-th vertex is printed on a separate line.
|
||||||
|
|
||||||
|
\pre <code> Hyperbolic_fundamental_domain_2< Traits >::is_valid() </code>
|
||||||
|
*/
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
|
||||||
|
extracts the domain from a stream.
|
||||||
|
|
||||||
|
The format of the input must be the same as the format of the output of
|
||||||
|
the '<<' operator for Hyperbolic_fundamental_domain_2.
|
||||||
|
*/
|
||||||
|
std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgHyperbolicSurfaceTriangulation2InputOutput
|
||||||
|
inserts the isometry in a stream.
|
||||||
|
*/
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry);
|
||||||
|
|
||||||
|
}; // namespace CGAL
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright (c) 2024
|
||||||
|
// INRIA Nancy (France), and Université Gustave Eiffel Marne-la-Vallee (France).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org)
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
#define CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H
|
||||||
|
|
||||||
|
#include <CGAL/license/Triangulation_on_hyperbolic_surface_2.h>
|
||||||
|
#include <CGAL/Triangulation_on_hyperbolic_surface_2.h>
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class Traits>
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Hyperbolic_fundamental_domain_2<Traits>& domain){
|
||||||
|
CGAL_precondition(domain.is_valid());
|
||||||
|
return domain.to_stream(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Traits>
|
||||||
|
std::istream& operator>>(std::istream& s, Hyperbolic_fundamental_domain_2<Traits>& domain){
|
||||||
|
return domain.from_stream(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class Traits>
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Hyperbolic_isometry_2<Traits>& isometry){
|
||||||
|
for (int k=0; k<4; k++){
|
||||||
|
s << isometry.get_coefficient(k);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class Traits, class Attributes>
|
||||||
|
std::ostream& operator<<(std::ostream& s, const Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation){
|
||||||
|
triangulation.to_stream(s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Traits, class Attributes>
|
||||||
|
void operator>>(std::istream& s, Triangulation_on_hyperbolic_surface_2<Traits, Attributes>& triangulation){
|
||||||
|
triangulation.from_stream(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_TRIANGULATION_ON_HYPERBOLIC_SURFACE_2_IO_H
|
||||||
Loading…
Reference in New Issue