From 69d42b29e6c38b016907c3bff00f88ace36cdfd7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 12:46:39 +0100 Subject: [PATCH 01/15] Triangulation on Sphere: Fix I/O --- .../Triangulation_on_sphere_2/CMakeLists.txt | 2 + .../Triangulation_on_sphere_2/issue_8200.cpp | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt index a9b9fba423d..42498d72e3f 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt @@ -4,6 +4,7 @@ project( Triangulation_on_sphere_2_Tests ) find_package(CGAL REQUIRED COMPONENTS Core) + find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) @@ -15,6 +16,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "test_dtos_illegal_points.cpp" ) create_single_source_cgal_program( "test_dtos_projection_traits.cpp" ) create_single_source_cgal_program( "test_dtos_traits.cpp" ) + create_single_source_cgal_program( "issue_8200.cpp" ) if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program( "test_dtos_dual.cpp" ) diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp new file mode 100644 index 00000000000..8c40b89385f --- /dev/null +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -0,0 +1,58 @@ +#include + +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef CGAL::Projection_on_sphere_traits_3 Traits; +typedef CGAL::Delaunay_triangulation_on_sphere_2 DToS2; + +typedef Traits::Point_3 Point_3; + +int main(int, char**) +{ + std::vector points; + points.emplace_back( 3, 1, 1); + points.emplace_back(-8, 1, 1); + points.emplace_back( 1, 2, 1); + points.emplace_back( 1, -2, 1); + points.emplace_back( 1, 1, 10); + + Traits traits(Point_3(1,1,1)); // radius is 1 by default + DToS2 dtos(traits); + + Traits::Construct_point_on_sphere_2 cst = traits.construct_point_on_sphere_2_object(); + + for(const auto& pt : points) + { + std::cout << "----- Inserting (" << pt + << ") at squared distance " << CGAL::squared_distance(pt, traits.center()) + << " from the center of the sphere" << std::endl; + dtos.insert(cst(pt)); + + std::cout << "The triangulation now has dimension: " << dtos.dimension() << " and\n"; + std::cout << dtos.number_of_vertices() << " vertices" << std::endl; + std::cout << dtos.number_of_edges() << " edges" << std::endl; + std::cout << dtos.number_of_solid_faces() << " solid faces" << std::endl; + std::cout << dtos.number_of_ghost_faces() << " ghost faces" << std::endl; + } + + std::ofstream out("dtos.txt"); + out.precision(17); + out << dtos << std::endl; + out.close(); + + CGAL::IO::write_OFF("dtos.off", dtos, CGAL::parameters::stream_precision(17)); + + DToS2 dtos2(traits); + std::ifstream in("dtos.txt"); + in >> dtos2; + in.close(); + + CGAL::IO::write_OFF("dtos2.off", dtos2, CGAL::parameters::stream_precision(17)); + + + return EXIT_SUCCESS; +} From fcdc74f7b9bb033a2c90a0f44d535dd3d326cab8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 12:56:41 +0100 Subject: [PATCH 02/15] whitespace --- .../test/Triangulation_on_sphere_2/issue_8200.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp index 8c40b89385f..2f1989622a4 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -45,14 +45,14 @@ int main(int, char**) out.close(); CGAL::IO::write_OFF("dtos.off", dtos, CGAL::parameters::stream_precision(17)); - + DToS2 dtos2(traits); std::ifstream in("dtos.txt"); in >> dtos2; in.close(); CGAL::IO::write_OFF("dtos2.off", dtos2, CGAL::parameters::stream_precision(17)); - + return EXIT_SUCCESS; } From a0cd7f8926989a0d3e6245cdb86e3d000ff2e6a0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 13:03:32 +0100 Subject: [PATCH 03/15] While we skip the first vertex when we write, we must not skip it when we read --- .../include/CGAL/Triangulation_on_sphere_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index 0de37519ad3..20af7c52e2b 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -1323,7 +1323,7 @@ Triangulation_on_sphere_2:: file_input(std::istream& is) { clear(); - Vertex_handle v = _tds.file_input(is, true); + Vertex_handle v = _tds.file_input(is, false); return v; } From 516ef8f4c4e16db5b0e8703367a32fd64c9bd6c5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 13:28:40 +0100 Subject: [PATCH 04/15] show that ghost status gets lost --- .../test/Triangulation_on_sphere_2/issue_8200.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp index 2f1989622a4..e958e6c54d8 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -51,6 +51,12 @@ int main(int, char**) in >> dtos2; in.close(); + std::cout << "After write/read triangulation has dimension: " << dtos2.dimension() << " and\n"; + std::cout << dtos2.number_of_vertices() << " vertices" << std::endl; + std::cout << dtos2.number_of_edges() << " edges" << std::endl; + std::cout << dtos2.number_of_solid_faces() << " solid faces" << std::endl; + std::cout << dtos2.number_of_ghost_faces() << " ghost faces" << std::endl; + CGAL::IO::write_OFF("dtos2.off", dtos2, CGAL::parameters::stream_precision(17)); From 4f592ed50ca53853d49c5914d72cf09c9c1845b2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 13:43:21 +0100 Subject: [PATCH 05/15] Add operator <<() and >>() for the ToS_face_base that handles the ghost status --- .../Triangulation_on_sphere_face_base_2.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h index cae6d48153b..b8afdd5f591 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h @@ -64,6 +64,27 @@ protected: bool _ghost_flag; }; +template < class Gt, class Fb > +std::ostream& +operator<<(std::ostream &os, const Triangulation_on_sphere_face_base_2 &f) +{ + // non combinatorial information. Default = point + os << static_cast(f); + os << (f.is_ghost()) ? " 0" : " 1"; + return os; +} + +template < class Gt, class Fb > +std::istream& +operator>>(std::istream &is, Triangulation_on_sphere_face_base_2 &f) +{ + int g = -1; + is >> static_cast(f); + is >> g; + f.set_ghost(g == 1); + return is; +} + } // namespace CGAL #endif //CGAL_TRIANGULATION_ON_SPHERE_FACE_BASE_2_H From 67b909cd67e13f1a343893868b3121cab2bfc627 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 May 2024 14:56:34 +0100 Subject: [PATCH 06/15] Fix assertion --- .../include/CGAL/Triangulation_on_sphere_2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index 20af7c52e2b..a2a76c65aaa 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -1281,9 +1281,9 @@ is_valid(bool verbose, std::advance(it3, 2); while(it3 != vertices_end()) { - const Orientation s = orientation(point(it1), point(it2), point(it3)); - result = result && (s == COLLINEAR); - CGAL_triangulation_assertion(result); + const Orientation s = orientation_on_sphere(point(it1), point(it2), point(it3)); + result = result && (s == COPLANAR); + CGAL_assertion(result); ++it1; ++it2; ++it3; } } From 195001267f6918910992b2f95c41a7737b98e8d4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 16 May 2024 07:00:06 +0100 Subject: [PATCH 07/15] Try to fix a warning --- .../include/CGAL/Triangulation_on_sphere_face_base_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h index b8afdd5f591..cbd76d0081a 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h @@ -70,7 +70,7 @@ operator<<(std::ostream &os, const Triangulation_on_sphere_face_base_2 & { // non combinatorial information. Default = point os << static_cast(f); - os << (f.is_ghost()) ? " 0" : " 1"; + os << f.is_ghost() ? " 0" : " 1"; return os; } From 2d455ebf57fdda8571cf84d3f98e4471e370c798 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 16 May 2024 08:04:32 +0100 Subject: [PATCH 08/15] improvement but not yet a fix --- .../include/CGAL/Triangulation_on_sphere_face_base_2.h | 2 +- .../test/Triangulation_on_sphere_2/issue_8200.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h index cbd76d0081a..84bbc11e136 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_face_base_2.h @@ -70,7 +70,7 @@ operator<<(std::ostream &os, const Triangulation_on_sphere_face_base_2 & { // non combinatorial information. Default = point os << static_cast(f); - os << f.is_ghost() ? " 0" : " 1"; + os << (f.is_ghost() ? " 1" : " 0"); return os; } diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp index e958e6c54d8..3f66eda1ff9 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -38,7 +38,7 @@ int main(int, char**) std::cout << dtos.number_of_solid_faces() << " solid faces" << std::endl; std::cout << dtos.number_of_ghost_faces() << " ghost faces" << std::endl; } - + assert(dtos.is_valid()); std::ofstream out("dtos.txt"); out.precision(17); out << dtos << std::endl; From d9249532dd4d5cbb3ff1d5cf657f6c6dfbda283b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 16:54:22 +0200 Subject: [PATCH 09/15] Fix uninitialized member --- .../include/CGAL/Projection_on_sphere_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Projection_on_sphere_traits_3.h b/Triangulation_on_sphere_2/include/CGAL/Projection_on_sphere_traits_3.h index 4f69f9bf179..f0b9110ae2f 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Projection_on_sphere_traits_3.h +++ b/Triangulation_on_sphere_2/include/CGAL/Projection_on_sphere_traits_3.h @@ -38,7 +38,7 @@ private: mutable Base_point proj_pt; public: - Point_with_scale() : Base_point() { } // vertex base wants a default constructor + Point_with_scale() : Base_point(), cached(false) { } // vertex base wants a default constructor Point_with_scale(const Base_point& p) : Base_point(p), cached(false) { } const Base_point& get_projection(const Base_point& center, From 085b6a86c8a06074d860b44fbf3d7149c94519ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 16:54:35 +0200 Subject: [PATCH 10/15] Add missing requirement for ToS2 face base IO --- .../Concepts/TriangulationOnSphereFaceBase_2.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Triangulation_on_sphere_2/doc/Triangulation_on_sphere_2/Concepts/TriangulationOnSphereFaceBase_2.h b/Triangulation_on_sphere_2/doc/Triangulation_on_sphere_2/Concepts/TriangulationOnSphereFaceBase_2.h index ab66482d9bb..00075f8e950 100644 --- a/Triangulation_on_sphere_2/doc/Triangulation_on_sphere_2/Concepts/TriangulationOnSphereFaceBase_2.h +++ b/Triangulation_on_sphere_2/doc/Triangulation_on_sphere_2/Concepts/TriangulationOnSphereFaceBase_2.h @@ -32,4 +32,16 @@ public: /// provides write access to a Boolean used to indicate if the face is a ghost face. void set_ghost(const bool b); + + /*! + inputs the non-combinatorial information given by the face: + its ghost status and other possible information. + */ + std::istream& operator>>(std::istream& is, TriangulationOnSphereFaceBase_2& v); + + /*! + outputs the non combinatorial operation given by the face: + its ghost status and other possible information. + */ + std::ostream& operator<<(std::ostream& os, const TriangulationOnSphereFaceBase_2& v); }; From 99058987d992e6a96fba147e4392489fae152b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 16:55:04 +0200 Subject: [PATCH 11/15] Factorize ToS2 DToS2 is_valid() functions --- .../CGAL/Delaunay_triangulation_on_sphere_2.h | 78 ++----------------- .../include/CGAL/Triangulation_on_sphere_2.h | 55 +++++++++---- 2 files changed, 49 insertions(+), 84 deletions(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Delaunay_triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Delaunay_triangulation_on_sphere_2.h index 53473d75515..a021358b3f0 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Delaunay_triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Delaunay_triangulation_on_sphere_2.h @@ -327,9 +327,8 @@ public: Arc_on_sphere_2 dual_on_sphere(const All_edges_iterator ei) const { return dual_on_sphere(*ei); } // Validity - bool is_plane() const; - bool is_valid(bool verbose = false, int level = 0) const; bool is_valid_face(Face_handle fh, bool verbose = false, int level = 0) const; + bool is_valid(bool verbose = false, int level = 0) const; }; // ------------------------ PREDICATES / CONSTRUCTIONS --------------------------------// @@ -1090,39 +1089,6 @@ dual_on_sphere(const Edge& e) const //-------------------------------------------CHECK------------------------------------------------// -// checks whether a given triangulation is plane (all points are coplanar) -template -bool -Delaunay_triangulation_on_sphere_2:: -is_plane() const -{ - if(number_of_vertices() <= 3) - return true; - - bool plane = true; - - Vertices_iterator it1 = vertices_begin(), it2(it1), it3(it1), it4(it1); - std::advance(it2, 1); - std::advance(it3, 2); - std::advance(it4, 3); - - while(it4 != vertices_end()) - { - Orientation s = side_of_oriented_circle(point(it1), point(it2), point(it3), point(it4)); - plane = plane && s == ON_ORIENTED_BOUNDARY; - - if(!plane) - return false; - - ++it1; - ++it2; - ++it3; - ++it4; - } - - return true; -} - template bool Delaunay_triangulation_on_sphere_2:: @@ -1154,47 +1120,19 @@ bool Delaunay_triangulation_on_sphere_2:: is_valid(bool verbose, int level) const { - bool result = true; - - if(!tds().is_valid(verbose, level)) + // in any dimension + if(verbose) { - if(verbose) - std::cerr << "invalid data structure" << std::endl; - - CGAL_triangulation_assertion(false); - return false; + std::cerr << " number of vertices " << number_of_vertices() << "\t" << std::endl; + std::cerr << " number of faces " << number_of_faces() << "\t" << std::endl; } + bool result = Base::is_valid(verbose, level); + CGAL_triangulation_assertion(result); + for(All_faces_iterator fit=all_faces_begin(); fit!=all_faces_end(); ++fit) result = result && is_valid_face(fit, verbose, level); - for(Vertices_iterator vit=vertices_begin(); vit!=vertices_end(); ++vit) - result = result && Base::is_valid_vertex(vit, verbose, level); - - switch(dimension()) - { - case 0: - break; - case 1: - CGAL_triangulation_assertion(this->is_plane()); - break; - case 2: - for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); ++it) - { - Orientation s = orientation_on_sphere(point(it, 0), point(it, 1), point(it, 2)); - result = result && (s != NEGATIVE || it->is_ghost()); - CGAL_triangulation_assertion(result); - } - - result = result && (number_of_faces() == 2 * number_of_vertices() - 4); - CGAL_triangulation_assertion(result); - break; - } - - // in any dimension - if(verbose) - std::cerr << " number of vertices " << number_of_vertices() << "\t" << std::endl; - CGAL_triangulation_assertion(result); return result; } diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index a2a76c65aaa..ddd883b38fd 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -482,7 +482,7 @@ public: //-----------------------DEBUG-------------------------------------------------------------------- void check_neighboring_faces() const; - + bool is_plane() const; bool is_valid_vertex(Vertex_handle fh, bool verbose = false, int level = 0) const; bool is_valid(bool verbose = false, int level = 0) const; @@ -1239,6 +1239,39 @@ check_neighboring_faces() const } } +// checks whether a given triangulation is plane (all points are coplanar) +template +bool +Triangulation_on_sphere_2:: +is_plane() const +{ + if(number_of_vertices() <= 3) + return true; + + bool is_plane = true; + + Vertices_iterator it1 = vertices_begin(), it2(it1), it3(it1), it4(it1); + std::advance(it2, 1); + std::advance(it3, 2); + std::advance(it4, 3); + + while(it4 != vertices_end()) + { + Orientation s = orientation(point(it1), point(it2), point(it3), point(it4)); + is_plane = is_plane && s == COLLINEAR; + + if(!is_plane) + return false; + + ++it1; + ++it2; + ++it3; + ++it4; + } + + return true; +} + template bool Triangulation_on_sphere_2:: @@ -1274,27 +1307,21 @@ is_valid(bool verbose, if(dimension() <= 0 || (dimension() == 1 && number_of_vertices() == 2)) return result; + for(Vertices_iterator vit=vertices_begin(); vit!=vertices_end(); ++vit) + result = result && is_valid_vertex(vit, verbose, level); + if(dimension() == 1) { - Vertices_iterator it1 = vertices_begin(), it2(it1), it3(it1); - std::advance(it2, 1); - std::advance(it3, 2); - while(it3 != vertices_end()) - { - const Orientation s = orientation_on_sphere(point(it1), point(it2), point(it3)); - result = result && (s == COPLANAR); - CGAL_assertion(result); - ++it1; ++it2; ++it3; - } + result = result && this->is_plane(); + CGAL_triangulation_assertion(result); } else // dimension() == 2 { for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); ++it) { const Orientation s = orientation_on_sphere(point(it, 0), point(it, 1), point(it, 2)); - CGAL_triangulation_assertion(s == LEFT_TURN || is_ghost(it)); - result = result && (s == LEFT_TURN || is_ghost(it)); + CGAL_triangulation_assertion(result); } // check number of faces. This cannot be done by the TDS, @@ -1324,6 +1351,7 @@ file_input(std::istream& is) { clear(); Vertex_handle v = _tds.file_input(is, false); + CGAL_triangulation_assertion(is_valid()); return v; } @@ -1340,7 +1368,6 @@ std::istream& operator>>(std::istream& is, Triangulation_on_sphere_2& tr) { tr.file_input(is); - CGAL_triangulation_assertion(tr.is_valid()); return is; } From de92d890711f32d3c35ad62cdcccc36a997c1dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 17:34:13 +0200 Subject: [PATCH 12/15] Also read and write the sphere's center and radius --- .../include/CGAL/Triangulation_on_sphere_2.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index ddd883b38fd..98c2949173c 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -1341,6 +1341,7 @@ void Triangulation_on_sphere_2:: file_output(std::ostream& os) const { + os << _gt.center() << " " << _gt.radius() << "\n"; _tds.file_output(os, Vertex_handle(), true); } @@ -1350,6 +1351,13 @@ Triangulation_on_sphere_2:: file_input(std::istream& is) { clear(); + + Point_3 center; + FT radius; + is >> center >> radius; + _gt.set_center(center); + _gt.set_radius(radius); + Vertex_handle v = _tds.file_input(is, false); CGAL_triangulation_assertion(is_valid()); return v; From c0f401852267256624b91c5a67bcc6717a47df5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 17:34:34 +0200 Subject: [PATCH 13/15] Modify data as to have an error with the default sphere --- .../test/Triangulation_on_sphere_2/issue_8200.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp index 3f66eda1ff9..8db4ab7cfd4 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -20,7 +20,7 @@ int main(int, char**) points.emplace_back( 1, -2, 1); points.emplace_back( 1, 1, 10); - Traits traits(Point_3(1,1,1)); // radius is 1 by default + Traits traits(Point_3(4,1,1)); // radius is 1 by default DToS2 dtos(traits); Traits::Construct_point_on_sphere_2 cst = traits.construct_point_on_sphere_2_object(); From a4a2b7d702d56610a34066b06d8dd3b178616cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 17:35:04 +0200 Subject: [PATCH 14/15] Misc clean-up --- .../Triangulation_on_sphere_2/issue_8200.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp index 8db4ab7cfd4..ae3db4f3f10 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/issue_8200.cpp @@ -38,6 +38,7 @@ int main(int, char**) std::cout << dtos.number_of_solid_faces() << " solid faces" << std::endl; std::cout << dtos.number_of_ghost_faces() << " ghost faces" << std::endl; } + assert(dtos.is_valid()); std::ofstream out("dtos.txt"); out.precision(17); @@ -46,19 +47,27 @@ int main(int, char**) CGAL::IO::write_OFF("dtos.off", dtos, CGAL::parameters::stream_precision(17)); - DToS2 dtos2(traits); + DToS2 dtos2; std::ifstream in("dtos.txt"); in >> dtos2; in.close(); + assert(dtos2.is_valid()); - std::cout << "After write/read triangulation has dimension: " << dtos2.dimension() << " and\n"; - std::cout << dtos2.number_of_vertices() << " vertices" << std::endl; - std::cout << dtos2.number_of_edges() << " edges" << std::endl; - std::cout << dtos2.number_of_solid_faces() << " solid faces" << std::endl; - std::cout << dtos2.number_of_ghost_faces() << " ghost faces" << std::endl; + std::cout << "DTOS2 center: " << dtos2.geom_traits().center() << " radius: " << dtos2.geom_traits().radius() << std::endl; + std::cout << "DTOS2 has dimension: " << dtos2.dimension() << " and\n"; + std::cout << dtos2.number_of_vertices() << " vertices" << std::endl; + std::cout << dtos2.number_of_edges() << " edges" << std::endl; + std::cout << dtos2.number_of_solid_faces() << " solid faces" << std::endl; + std::cout << dtos2.number_of_ghost_faces() << " ghost faces" << std::endl; CGAL::IO::write_OFF("dtos2.off", dtos2, CGAL::parameters::stream_precision(17)); + assert(dtos.number_of_vertices() == dtos2.number_of_vertices()); + assert(dtos.number_of_edges() == dtos2.number_of_edges()); + assert(dtos.number_of_solid_faces() == dtos2.number_of_solid_faces()); + assert(dtos.number_of_ghost_faces() == dtos2.number_of_ghost_faces()); + + std::cout << "Done." << std::endl; return EXIT_SUCCESS; } From f8abb836a05526067043d16b93b5cf94c970798a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Jun 2024 17:39:15 +0200 Subject: [PATCH 15/15] Use the correct enum value --- .../include/CGAL/Triangulation_on_sphere_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index 98c2949173c..4a7667d20bf 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -1258,7 +1258,7 @@ is_plane() const while(it4 != vertices_end()) { Orientation s = orientation(point(it1), point(it2), point(it3), point(it4)); - is_plane = is_plane && s == COLLINEAR; + is_plane = is_plane && s == COPLANAR; if(!is_plane) return false;