mirror of https://github.com/CGAL/cgal
oformat(x, tag) passed the tag value to the Output_rep
That allows to pass an integral offset to the displayed time stamps. The goal is to set it to -1, to display vertices IDs that are identical to the input vertices indices of the `Surface_mesh``.
This commit is contained in:
parent
c2fe3273ff
commit
4c75012cca
|
|
@ -1166,19 +1166,32 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct With_point_tag {};
|
||||
struct With_point_tag {
|
||||
int offset = 0;
|
||||
};
|
||||
|
||||
template <class DSC, bool Const>
|
||||
struct Output_rep<CGAL::internal::CC_iterator<DSC, Const>, With_point_tag>
|
||||
: public Output_rep<CGAL::internal::CC_iterator<DSC, Const>>
|
||||
{
|
||||
using Base = Output_rep<CGAL::internal::CC_iterator<DSC, Const>>;
|
||||
int offset = 0;
|
||||
|
||||
using CC_iterator = CGAL::internal::CC_iterator<DSC, Const>;
|
||||
using Compact_container = typename CC_iterator::CC;
|
||||
using Time_stamper = typename Compact_container::Time_stamper;
|
||||
using Base = Output_rep<CC_iterator>;
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<const void*>(pt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <class T, class F>
|
||||
Output_rep<T,F> oformat( const T& t, F) { return Output_rep<T,F>(t); }
|
||||
Output_rep<T,F> oformat( const T& t, F format) { return Output_rep<T,F>(t, format); }
|
||||
|
||||
} // namespace IO
|
||||
|
||||
|
|
|
|||
|
|
@ -280,6 +280,57 @@ operator<< (std::ostream& os,
|
|||
return os;
|
||||
}
|
||||
|
||||
template < typename TriangulationDataStructure_3, typename Tag >
|
||||
struct Output_rep<Triangulation_simplex_3<TriangulationDataStructure_3>, Tag >
|
||||
{
|
||||
using TDS = TriangulationDataStructure_3;
|
||||
using Simplex = Triangulation_simplex_3<TriangulationDataStructure_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<Vertex_handle>(simplex));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
const auto [c, index1, index2] = static_cast<Edge>(simplex);
|
||||
os << "edge "
|
||||
<< display_vert(c->vertex(index1)) << " - "
|
||||
<< display_vert(c->vertex(index2));
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const auto [c, index] = static_cast<Facet>(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<Cell_handle>(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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue