diff --git a/STL_Extension/include/CGAL/Compact_container.h b/STL_Extension/include/CGAL/Compact_container.h index 8e665e83c1e..ad10438d026 100644 --- a/STL_Extension/include/CGAL/Compact_container.h +++ b/STL_Extension/include/CGAL/Compact_container.h @@ -1166,19 +1166,32 @@ public: } }; -struct With_point_tag {}; +struct With_point_tag { + int offset = 0; +}; template struct Output_rep, With_point_tag> : public Output_rep> { - using Base = Output_rep>; + int offset = 0; + + using CC_iterator = CGAL::internal::CC_iterator; + using Compact_container = typename CC_iterator::CC; + using Time_stamper = typename Compact_container::Time_stamper; + using Base = Output_rep; using Base::Base; + Output_rep(const CC_iterator it, With_point_tag tag = {}) + : Base(it), offset(tag.offset) {} + std::ostream& operator()(std::ostream& out) const { - Base::operator()(out); - if(this->it.operator->() != nullptr) - return out << "= " << this->it->point(); + out << Time_stamper::display_id(this->it.operator->(), offset); + if(this->it.operator->() != nullptr) { + if(Time_stamper::time_stamp(this->it.operator->()) == 0) + return out << "= infinite_vertex()"; + return out << "= " << this->it->point(); + } else return out; } diff --git a/STL_Extension/include/CGAL/Time_stamper.h b/STL_Extension/include/CGAL/Time_stamper.h index 0fcee819220..a1f2d30eb36 100644 --- a/STL_Extension/include/CGAL/Time_stamper.h +++ b/STL_Extension/include/CGAL/Time_stamper.h @@ -67,12 +67,12 @@ struct Time_stamper return pt->time_stamp(); } - static auto display_id(const T* pt) + static auto display_id(const T* pt, int offset = 0) { if(pt == nullptr) return std::string("nullptr"); else - return std::string("#") + std::to_string(pt->time_stamp()); + return std::string("#") + std::to_string(pt->time_stamp() + offset); } static std::size_t hash_value(const T* p) { @@ -110,7 +110,7 @@ public: return 0; } - static auto display_id(const T* pt) + static auto display_id(const T* pt, int) { return static_cast(pt); } diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 1cbb8054ba8..71308a423c6 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -183,7 +183,7 @@ class Output_rep public: //! initialize with a const reference to \a t. - Output_rep( const T& tt) : t(tt) {} + Output_rep( const T& tt, F = {}) : t(tt) {} //! perform the output, calls \c operator\<\< by default. std::ostream& operator()( std::ostream& os) const { return (os << t); } }; @@ -248,7 +248,7 @@ Convenience function to construct an output representation (`Output_rep`) for ty Generic IO for type `T` with formatting tag. */ template -Output_rep oformat( const T& t, F) { return Output_rep(t); } +Output_rep oformat( const T& t, F format) { return Output_rep(t, format); } } // namespace IO diff --git a/TDS_3/include/CGAL/Triangulation_simplex_3.h b/TDS_3/include/CGAL/Triangulation_simplex_3.h index 0754fb021c5..91db819c098 100644 --- a/TDS_3/include/CGAL/Triangulation_simplex_3.h +++ b/TDS_3/include/CGAL/Triangulation_simplex_3.h @@ -280,6 +280,57 @@ operator<< (std::ostream& os, return os; } +template < typename TriangulationDataStructure_3, typename Tag > +struct Output_rep, Tag > +{ + using TDS = TriangulationDataStructure_3; + using Simplex = Triangulation_simplex_3; + using Vertex_handle = typename Simplex::Vertex_handle; + using Edge = typename Simplex::Edge; + using Facet = typename Simplex::Facet; + using Cell_handle = typename Simplex::Cell_handle; + + Simplex simplex; + Tag tag; + + std::ostream& operator()(std::ostream& os) const { + auto display_vert = [&](auto v) { + return CGAL::IO::oformat(v, tag); + }; + switch(simplex.dimension()) { + case 0: { + os << "vertex " << display_vert(static_cast(simplex)); + break; + } + case 1: { + const auto [c, index1, index2] = static_cast(simplex); + os << "edge " + << display_vert(c->vertex(index1)) << " - " + << display_vert(c->vertex(index2)); + break; + } + case 2: { + const auto [c, index] = static_cast(simplex); + os << "facet " + << display_vert(c->vertex(TDS::vertex_triple_index(index, 0))) << " - " + << display_vert(c->vertex(TDS::vertex_triple_index(index, 1))) << " - " + << display_vert(c->vertex(TDS::vertex_triple_index(index, 2))); + break; + } + case 3: { + const auto c = static_cast(simplex); + os << "cell " + << display_vert(c->vertex(0)) << " - " + << display_vert(c->vertex(1)) << " - " + << display_vert(c->vertex(2)) << " - " + << display_vert(c->vertex(3)); + break; + } + default: CGAL_assume(false); + } + return os; + } +}; } //namespace CGAL