mirror of https://github.com/CGAL/cgal
factorize the debug function helpers
This commit is contained in:
parent
f193744e66
commit
e936fcb36b
|
|
@ -34,6 +34,8 @@ typedef DT::Vertex_handle Vertex_handle;
|
||||||
typedef DT::Simplex Simplex;
|
typedef DT::Simplex Simplex;
|
||||||
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
|
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
|
||||||
|
|
||||||
|
#include "test_triangulation_simplex_3_debug.h"
|
||||||
|
|
||||||
// a function to insert without spatial sorting
|
// a function to insert without spatial sorting
|
||||||
template <typename Point_it>
|
template <typename Point_it>
|
||||||
void insert(DT& dt, Point_it first, Point_it end) {
|
void insert(DT& dt, Point_it first, Point_it end) {
|
||||||
|
|
@ -41,62 +43,6 @@ void insert(DT& dt, Point_it first, Point_it end) {
|
||||||
dt.insert(*first);
|
dt.insert(*first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto display_vert(Vertex_handle v) {
|
|
||||||
std::stringstream os;
|
|
||||||
os.precision(17);
|
|
||||||
if(v->time_stamp() == 0) {
|
|
||||||
os << "inf";
|
|
||||||
} else {
|
|
||||||
os << '#' << v->time_stamp() << "=(" << v->point() << ")";
|
|
||||||
}
|
|
||||||
return os.str();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Debug_simplex {
|
|
||||||
Simplex simplex;
|
|
||||||
|
|
||||||
template<typename CharT, typename Traits>
|
|
||||||
friend
|
|
||||||
std::basic_ostream<CharT, Traits>&
|
|
||||||
operator<<(std::basic_ostream<CharT, Traits>& os, const Debug_simplex& d) {
|
|
||||||
auto&& simplex = d.simplex;
|
|
||||||
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(DT::vertex_triple_index(index, 0))) << " - "
|
|
||||||
<< display_vert(c->vertex(DT::vertex_triple_index(index, 1))) << " - "
|
|
||||||
<< display_vert(c->vertex(DT::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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
auto debug_simplex(Simplex simplex) {
|
|
||||||
return Debug_simplex{simplex};
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::vector<Point_3> bbox_points =
|
static const std::vector<Point_3> bbox_points =
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
|
// #define CGAL_DEBUG_TRIANGULATION_SEGMENT_TRAVERSER_3 1
|
||||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||||
#include <CGAL/Delaunay_triangulation_3.h>
|
#include <CGAL/Delaunay_triangulation_3.h>
|
||||||
|
#include <CGAL/Base_with_time_stamp.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -17,14 +19,20 @@ typedef Kernel::Vector_3 Vector_3;
|
||||||
typedef Kernel::Segment_3 Segment_3;
|
typedef Kernel::Segment_3 Segment_3;
|
||||||
|
|
||||||
// Define the structure.
|
// Define the structure.
|
||||||
typedef CGAL::Delaunay_triangulation_3< Kernel > DT;
|
typedef CGAL::Base_with_time_stamp<CGAL::Triangulation_vertex_base_3<Kernel>> Vb;
|
||||||
|
typedef CGAL::Delaunay_triangulation_cell_base_3<Kernel> Cb;
|
||||||
|
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
|
||||||
|
typedef CGAL::Delaunay_triangulation_3< Kernel, Tds > DT;
|
||||||
|
|
||||||
typedef DT::Vertex_handle Vertex_handle;
|
typedef DT::Vertex_handle Vertex_handle;
|
||||||
typedef DT::Cell_handle Cell_handle;
|
typedef DT::Cell_handle Cell_handle;
|
||||||
typedef DT::Edge Edge;
|
typedef DT::Edge Edge;
|
||||||
typedef DT::Facet Facet;
|
typedef DT::Facet Facet;
|
||||||
|
typedef DT::Simplex Simplex;
|
||||||
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
|
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
|
||||||
|
|
||||||
|
#include "test_triangulation_simplex_3_debug.h"
|
||||||
|
|
||||||
void test_vertex_edge_vertex(const DT& dt, const std::size_t& nb_tests)
|
void test_vertex_edge_vertex(const DT& dt, const std::size_t& nb_tests)
|
||||||
{
|
{
|
||||||
std::cout << "* test_vertex_edge_vertex *" << std::endl;
|
std::cout << "* test_vertex_edge_vertex *" << std::endl;
|
||||||
|
|
@ -299,8 +307,8 @@ void test_triangulation_on_a_grid()
|
||||||
unsigned int nb_facets = 0, nb_edges = 0, nb_vertex = 0;
|
unsigned int nb_facets = 0, nb_edges = 0, nb_vertex = 0;
|
||||||
for (; st != st.end(); ++st)
|
for (; st != st.end(); ++st)
|
||||||
{
|
{
|
||||||
std::cout << st->dimension() << " ";
|
std::cerr << st->dimension() << " ";
|
||||||
std::cout.flush();
|
std::cerr << debug_simplex(*st) <<'\n';
|
||||||
if (st->dimension() == 3)
|
if (st->dimension() == 3)
|
||||||
{
|
{
|
||||||
if (dt.is_infinite(Cell_handle(*st))) ++inf;
|
if (dt.is_infinite(Cell_handle(*st))) ++inf;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
template <typename Vertex_handle>
|
||||||
|
auto display_vert(Vertex_handle v) {
|
||||||
|
std::stringstream os;
|
||||||
|
os.precision(17);
|
||||||
|
if(v->time_stamp() == 0) {
|
||||||
|
os << "inf";
|
||||||
|
} else {
|
||||||
|
os << '#' << v->time_stamp() << "=(" << v->point() << ")";
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename DT>
|
||||||
|
struct Debug_simplex {
|
||||||
|
using Cell_handle = typename DT::Cell_handle;
|
||||||
|
using Edge = typename DT::Edge;
|
||||||
|
using Facet = typename DT::Facet;
|
||||||
|
using Vertex_handle = typename DT::Vertex_handle;
|
||||||
|
using Simplex = typename DT::Simplex;
|
||||||
|
|
||||||
|
Simplex simplex;
|
||||||
|
|
||||||
|
template<typename Dt, typename CharT, typename Traits>
|
||||||
|
friend
|
||||||
|
std::basic_ostream<CharT, Traits>&
|
||||||
|
operator<<(std::basic_ostream<CharT, Traits>& os, const Debug_simplex<Dt>& d) {
|
||||||
|
auto&& simplex = d.simplex;
|
||||||
|
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(DT::vertex_triple_index(index, 0))) << " - "
|
||||||
|
<< display_vert(c->vertex(DT::vertex_triple_index(index, 1))) << " - "
|
||||||
|
<< display_vert(c->vertex(DT::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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#include <CGAL/Triangulation_simplex_3.h>
|
||||||
|
|
||||||
|
template <typename Triangulation>
|
||||||
|
auto debug_simplex(CGAL::Triangulation_simplex_3<Triangulation> simplex) {
|
||||||
|
return Debug_simplex<Triangulation>{simplex};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue