[new traits] added test for edge conflict

This commit is contained in:
Christophe Delage 2006-07-12 17:56:41 +00:00
parent 6a79569b32
commit 9e49a15a34
1 changed files with 92 additions and 43 deletions

View File

@ -23,57 +23,99 @@ public:
: GT(), test (gt_test)
{}
struct Vertex_conflict_2 : public GT::Vertex_conflict_2
template <class Predicate, class New_predicate>
struct Checked_predicate : public Predicate
{
typename GT_test::Vertex_conflict_2 other;
New_predicate newp;
typedef typename Predicate::result_type result_type;
Vertex_conflict_2 (const typename GT::Vertex_conflict_2 &base,
const typename GT_test::Vertex_conflict_2 &test)
: GT::Vertex_conflict_2(base), other(test)
Checked_predicate (const Predicate &p, const New_predicate &np)
: Predicate (p), newp (np)
{}
Sign operator() (const Site_2 &s1, const Site_2 &s2, const Site_2 &s3,
const Site_2 &q) const
template <class T1>
result_type operator() (const T1 &t1) const
{
Sign r1 = GT::Vertex_conflict_2::operator() (s1, s2, s3, q);
Sign r2 = other (s1, s2, s3, q);
if (r1 != r2) {
std::cerr
<< "Vertex_conflict_2 "
<< "(" << s1 << ")"
<< "(" << s2 << ")"
<< "(" << s3 << ")"
<< "(" << q << ")"
<< "should be " << r1 << ", not " << r2
<< std::endl;
abort();
}
result_type r1 = Predicate::operator() (t1);
result_type r2 = newp (t1);
assert (r1 == r2);
return r1;
}
Sign operator() (const Site_2 &s1, const Site_2 &s2, const Site_2 &q) const
template <class T1, class T2>
result_type operator() (const T1 &t1, const T2 &t2) const
{
Sign r1 = GT::Vertex_conflict_2::operator() (s1, s2, q);
Sign r2 = other (s1, s2, q);
if (r1 != r2) {
std::cerr
<< "Vertex_conflict_2 "
<< "(" << s1 << ")"
<< "(" << s2 << ")"
<< "(" << q << ")"
<< "should be " << r1 << ", not " << r2
<< std::endl;
abort();
}
result_type r1 = Predicate::operator() (t1, t2);
result_type r2 = newp (t1, t2);
assert (r1 == r2);
return r1;
}
template <class T1, class T2, class T3>
result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3) const
{
result_type r1 = Predicate::operator() (t1, t2, t3);
result_type r2 = newp (t1, t2, t3);
assert (r1 == r2);
return r1;
}
template <class T1, class T2, class T3, class T4>
result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) const
{
result_type r1 = Predicate::operator() (t1, t2, t3, t4);
result_type r2 = newp (t1, t2, t3, t4);
assert (r1 == r2);
return r1;
}
template <class T1, class T2, class T3, class T4, class T5>
result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) const
{
result_type r1 = Predicate::operator() (t1, t2, t3, t4, t5);
result_type r2 = newp (t1, t2, t3, t4, t5);
assert (r1 == r2);
return r1;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) const
{
result_type r1 = Predicate::operator() (t1, t2, t3, t4, t5, t6);
result_type r2 = newp (t1, t2, t3, t4, t5, t6);
assert (r1 == r2);
return r1;
}
};
typedef Checked_predicate<typename GT::Vertex_conflict_2,
typename GT_test::Vertex_conflict_2>
Vertex_conflict_2;
typedef Checked_predicate<typename GT::Finite_edge_interior_conflict_2,
typename GT_test::Finite_edge_interior_conflict_2>
Finite_edge_interior_conflict_2;
typedef Checked_predicate<typename GT::Infinite_edge_interior_conflict_2,
typename GT_test::Infinite_edge_interior_conflict_2>
Infinite_edge_interior_conflict_2;
Vertex_conflict_2
vertex_conflict_2_object() const
{
return Vertex_conflict_2 (GT::vertex_conflict_2_object(),
test.vertex_conflict_2_object());
}
vertex_conflict_2_object() const
{
return Vertex_conflict_2 (
GT::vertex_conflict_2_object(),
test.vertex_conflict_2_object());
}
Finite_edge_interior_conflict_2
finite_edge_interior_conflict_2_object() const
{
return Finite_edge_interior_conflict_2 (
GT::finite_edge_interior_conflict_2_object(),
test.finite_edge_interior_conflict_2_object());
}
Infinite_edge_interior_conflict_2
infinite_edge_interior_conflict_2_object() const
{
return Infinite_edge_interior_conflict_2 (
GT::infinite_edge_interior_conflict_2_object(),
test.infinite_edge_interior_conflict_2_object());
}
};
typedef CGAL::MP_Float NT;
@ -85,20 +127,27 @@ typedef CGAL::Apollonius_graph_2<GT> AG;
typedef AG::Site_2 Site;
int main (void)
void test_file (const char *filename)
{
std::ifstream is ("data/algo.dat");
std::ifstream is (filename);
assert (is);
std::cout << "Apollonius diagram construction" << std::endl;
std::cout << "File " << filename << ": construction... " << std::flush;
AG ag;
Site s; while (is >> s) ag.insert (s);
std::cout << "Apollonius diagram validation" << std::endl;
std::cout << "validation... " << std::flush;
assert (ag.is_valid());
std::cout << "OK" << std::endl;
}
int main (void)
{
test_file ("data/traits.dat");
test_file ("data/algo.dat");
return 0;
}