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