Rewrite the test-suite using:

- a single test file
- a template parameter for the kernel
- data sets and results in the source code instead of text files using diff for comparing
- no custom cgal_test script
This commit is contained in:
Sylvain Pion 2008-08-29 18:14:36 +00:00
parent f66c672caa
commit 5fda79d9fb
96 changed files with 252 additions and 849 deletions

1
.gitattributes vendored
View File

@ -1425,7 +1425,6 @@ Developers_manual/doc_tex/Developers_manual/fig/reference_counting.pdf -text svn
Developers_manual/doc_tex/Developers_manual/fig/use_real.eps -text svneol=unset#application/postscript
Developers_manual/doc_tex/Developers_manual/fig/use_real.gif -text svneol=unset#image/gif
Developers_manual/doc_tex/Developers_manual/fig/use_real.pdf -text svneol=unset#application/pdf
Distance_3/test/Distance_3/cgal_test eol=lf
Envelope_2/doc_tex/Envelope_2/fig/Envelope_2.png -text
Envelope_2/doc_tex/Envelope_2/fig/ex_circle.eps -text svneol=unset#application/postscript
Envelope_2/doc_tex/Envelope_2/fig/ex_circle.fig -text svneol=unset#application/octet-stream

View File

@ -1,2 +0,0 @@
0 1 2
-3 0 0 2 0 0

View File

@ -1,2 +0,0 @@
0 1 2
3 0 0 2 0 0

View File

@ -1,2 +0,0 @@
0 1 2
2 0 0 3 0 0

View File

@ -1,2 +0,0 @@
6 1 2
2 0 0 3 0 0

View File

@ -1,3 +0,0 @@
-8 -7 0 11 6 0
23 -27 2 -17 16 2

View File

@ -1,2 +0,0 @@
0 0 0 5 0 0
1 1 2 6 1 2

View File

@ -1,2 +0,0 @@
0 0 0 5 0 0
1 1 2 2 1 2

View File

@ -1,2 +0,0 @@
5 0 0 8 0 0
1 1 2 2 1 2

View File

@ -1,2 +0,0 @@
5 0 0 0 0 0
1 1 2 2 1 2

View File

@ -1,2 +0,0 @@
5 0 0 0 0 0
1 1 2 2 1 2

View File

@ -1,2 +0,0 @@
0 0 0 5 0 0
6 1 2 8 1 2

View File

@ -1,2 +0,0 @@
0 0 0 0 -3 0
1 4 2 1 7 2

View File

@ -1,3 +0,0 @@
0 0 0 5 0 0
8 1 2 6 1 2

View File

@ -1,2 +0,0 @@
0 0 0 0 0 0
8 1 2 6 1 2

View File

@ -1,2 +0,0 @@
0 0 0 1 0 0
2 1 2 2 -1 2

View File

@ -1,2 +0,0 @@
2 0 0 0 2 0
1 1 4 4 0 4

View File

@ -1,2 +0,0 @@
10 0 0 0 10 0
6 6 20 20 0 20

View File

@ -1,2 +0,0 @@
-10 -13 0 0 10 0
10 5 20 70 -30 20

View File

@ -1,2 +0,0 @@
0 0 0 30 -10 0
-5 20 20 40 30 20

View File

@ -1,2 +0,0 @@
4 0 0 -3 -1 0
1 1 2 2 11 2

View File

@ -1,2 +0,0 @@
3 4 0 7 7 0
7 0 2 6 5 2

View File

@ -1,2 +0,0 @@
-1 1 0 3 4 0
7 0 2 6 5 2

View File

@ -1,2 +0,0 @@
0 0 30 0 30 30
100 -100 0 200 1 0

View File

@ -1,2 +0,0 @@
1 0 0 0 0 0
1 3 3 0 0 3

View File

@ -1,2 +0,0 @@
0 0 0 1 0 0
0 0 2 -1 0 2

View File

@ -1,2 +0,0 @@
10 0 0 20 0 0
0 0 3 0 3 3

View File

@ -1,3 +0,0 @@
0 0 30 0 30 30
100 -100 0 200 1 0

View File

@ -1,2 +0,0 @@
1 0 0 0 0 0
1 3 3 0 0 3

View File

@ -1,2 +0,0 @@
0 0 0 1 0 0
0 0 2 -1 0 2

View File

@ -1,2 +0,0 @@
0 1 2
2 0 0 3 0 0

View File

@ -1,2 +0,0 @@
0 0 2
0 0 0 1 2 0

View File

@ -1,2 +0,0 @@
1 0 0 0 0 0
1 3 3 0 0 3

View File

@ -1,2 +0,0 @@
-90 0 0 -10 0 0
0 0 3 0 3 3

View File

@ -1,2 +0,0 @@
0 0 0 1 0 0
0 0 2 -1 0 2

View File

@ -1,2 +0,0 @@
-10 0 0 -90 0 0
0 0 3 0 3 3

View File

@ -1,2 +0,0 @@
1 0 0 0 0 0
1 3 3 0 0 3

View File

@ -1,2 +0,0 @@
0 0 0 1 0 0
0 0 2 -1 0 2

View File

@ -1,2 +0,0 @@
2 5 3
0 1 0 0

View File

@ -1,2 +0,0 @@
2 -3 3 3 -7 4
0 1 0 0

View File

@ -1,2 +0,0 @@
2 -4 3 3 -4 4
0 1 0 0

View File

@ -1 +0,0 @@
4

View File

@ -1 +0,0 @@
14

View File

@ -1 +0,0 @@
21

View File

@ -1 +0,0 @@
41

View File

@ -1 +0,0 @@
5

View File

@ -1 +0,0 @@
16

View File

@ -1 +0,0 @@
402

View File

@ -1 +0,0 @@
524.642

View File

@ -1 +0,0 @@
824.706

View File

@ -1 +0,0 @@
6

View File

@ -1 +0,0 @@
5

View File

@ -1 +0,0 @@
13.8462

View File

@ -1 +0,0 @@
4

View File

@ -1 +0,0 @@
21

View File

@ -1 +0,0 @@
5

View File

@ -1 +0,0 @@
4

View File

@ -1 +0,0 @@
4.02

View File

@ -1 +0,0 @@
5.24642

View File

@ -1 +0,0 @@
8.24706

View File

@ -1 +0,0 @@
6

View File

@ -1 +0,0 @@
4

View File

@ -1 +0,0 @@
13.8462

View File

@ -1 +0,0 @@
5

View File

@ -1 +0,0 @@
4

View File

@ -1,99 +0,0 @@
#!/bin/sh
OUTPUTFILE=error.txt
use_purify=0
one_run()
{
goodresult=RESULT/${base}/`basename ${datafile}`
if "./${base}" < ${datafile} >output
then
if [ -r ${goodresult} ]
then
if diff -b output ${goodresult} > diffoutput
then
succes=ja
else
succes=nee
cat diffoutput >> ProgramOutput.${base}.$PLATFORM
fi
else
succes=ja
fi
else
succes=nee
fi
if [ ${succes} = ja ]
then
echo "succes: ${base} < ${datafile}">> $OUTPUTFILE
else
echo "ERROR: ${base} < ${datafile}" >> $OUTPUTFILE
fi
}
make_and_execute()
{
if [ -r ii_files/${base}.ii.$1 ]
then
mv ii_files/${base}.ii.$1 ii_files/${base}.ii
fi
EXTRA_FLAGS="-DTESTR=$1"
export EXTRA_FLAGS
if make ${base} # 2>/dev/null
then
echo "succes: compiling ${file} with TESTR=$1" >> $OUTPUTFILE
if [ -r ii_files/${base}.ii ]
then
mv ii_files/${base}.ii ii_files/${base}.ii.$1
fi
if [ ${use_purify} -eq 1 ]
then
purify -log-file="%v.$1.%p.plog" ${base}
mv ${base}.pure ${base}
fi
for datafile in ${datafiles}
do
if [ -r ${datafile} ]
then
one_run
fi
done
else
echo "ERROR: compiling ${file} with TESTR=$1" >> $OUTPUTFILE
fi
make ${base}.clean
}
echo ${CGAL_LIB_DIR}
rm -f $OUTPUTFILE
touch $OUTPUTFILE
if [ $# -ne 0 ]
then
sourcefiles="$*"
else
sourcefiles="tst*.cpp"
fi
for file in ${sourcefiles}
do
base=`basename ${file} .cpp`
rm -f ProgramOutput.${base}.$PLATFORM
touch -f ProgramOutput.${base}.$PLATFORM
datafiles="ls DATA/${base}/ix*"
if [ "${datafiles}" ]
then
echo "TESTR=1" >> ProgramOutput.${base}.$PLATFORM
make_and_execute 1;
fi
if [ "${datafiles}" ]
then
echo "TESTR=2" >> ProgramOutput.${base}.$PLATFORM
make_and_execute 2;
fi
done

View File

@ -1,95 +0,0 @@
#if TESTR == 1
#include <CGAL/Cartesian.h>
inline double to_nt(int d)
{
return double(d);
}
#endif
#if TESTR == 2
#include <CGAL/Homogeneous.h>
inline double to_nt(int d)
{
return d;
}
#endif
#if TESTR == 3
#include <CGAL/test_types.h>
#include <CGAL/Cartesian.h>
inline CGAL::TestfieldC to_nt(int d)
{
unsigned char dummy1 = 'a';
signed char dummy2 = 'a';
return CGAL::TestfieldC(dummy1, dummy2, (double)d);
}
#endif
#if TESTR == 4
#include <CGAL/test_types.h>
#include <CGAL/Homogeneous.h>
inline CGAL::TestrepH to_nt(int d)
{
unsigned char dummy1 = 'a';
signed char dummy2 = 'a';
return CGAL::TestrepH(dummy1, dummy2, d);
}
#endif
#if TESTR == 5
#include <CGAL/Homogeneous.h>
#include <CGAL/Integer.h>
#if CGAL_LEDA_VERSION < 500
#include <LEDA/REDEFINE_NAMES.h>
#else
#include <LEDA/internal/REDEFINE_NAMES.h>
#endif
inline integer to_nt(int d)
{
return integer(d);
}
#if CGAL_LEDA_VERSION < 500
#include <LEDA/UNDEFINE_NAMES.h>
#else
#include <LEDA/internal/UNDEFINE_NAMES.h>
#endif
#endif
struct randomint {
randomint() ;
int get() const { return sequence[cur]; }
int next() { cur = (cur+1)%11; return get();}
private:
int sequence[11];
int cur;
};
inline randomint::randomint()
{
cur = 0;
sequence[0] = 19;
sequence[1] = 5;
sequence[2] = 17;
sequence[3] = 13;
sequence[4] = 29;
sequence[5] = 2;
sequence[6] = 23;
sequence[7] = 31;
sequence[8] = 3;
sequence[9] = 37;
sequence[10] = 11;
}

View File

@ -1,34 +0,0 @@
#if TESTR == 1
typedef double testnt;
typedef CGAL::Cartesian<testnt> TestR;
#endif
#if TESTR == 2
typedef double testnt;
typedef CGAL::Homogeneous<testnt> TestR;
#endif
#if TESTR == 3
typedef CGAL::TestfieldC testnt;
typedef CGAL::Cartesian<testnt> TestR;
#endif
#if TESTR == 4
typedef CGAL::TestrepH testnt;
typedef CGAL::Homogeneous<testnt> TestR;
#endif
#if TESTR == 5
#if CGAL_LEDA_VERSION < 500
#include <LEDA/REDEFINE_NAMES.h>
#else
#include <LEDA/internal/REDEFINE_NAMES.h>
#endif
typedef integer testnt;
#if CGAL_LEDA_VERSION < 500
#include <LEDA/UNDEFINE_NAMES.h>
#else
#include <LEDA/internal/UNDEFINE_NAMES.h>
#endif
typedef CGAL::Homogeneous<testnt> TestR;
#endif

View File

@ -0,0 +1,252 @@
// 3D distance tests.
#include <CGAL/Object.h>
#include <CGAL/Line_3.h>
#include <CGAL/Point_3.h>
#include <CGAL/Segment_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/Triangle_3.h>
#include <CGAL/Iso_cuboid_3.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Homogeneous.h>
#include <vector>
#include <iostream>
#include <cassert>
#ifdef NDEBUG
# error The test-suite needs no NDEBUG defined
#endif
const double epsilon = 0.001;
struct randomint {
randomint() ;
int get() const { return sequence[cur]; }
int next() { cur = (cur+1)%11; return get();}
private:
int sequence[11];
int cur;
};
inline randomint::randomint()
{
cur = 0;
sequence[0] = 19;
sequence[1] = 5;
sequence[2] = 17;
sequence[3] = 13;
sequence[4] = 29;
sequence[5] = 2;
sequence[6] = 23;
sequence[7] = 31;
sequence[8] = 3;
sequence[9] = 37;
sequence[10] = 11;
}
randomint ri;
inline double to_nt(int d)
{
return double(d);
}
template < typename K >
struct Test {
typedef typename K::FT FT;
typedef CGAL::Point_3< K > P;
typedef CGAL::Line_3< K > L;
typedef CGAL::Segment_3< K > S;
typedef CGAL::Ray_3< K > R;
typedef CGAL::Triangle_3< K > T;
typedef CGAL::Plane_3< K > Pl;
typedef CGAL::Iso_cuboid_3< K > Cub;
template < typename Type >
bool approx_equal_nt(const Type &t1, const Type &t2)
{
if (t1 == t2)
return true;
if (CGAL::abs(t1 - t2) / CGAL::max(CGAL::abs(t1), CGAL::abs(t2)) < epsilon)
return true;
std::cout << " Approximate comparison failed between : " << t1 << " and " << t2 << "\n";
return false;
}
template < typename O1, typename O2 >
void check_squared_distance(const O1& o1, const O2& o2, const FT& result)
{
assert(approx_equal_nt(CGAL::squared_distance(o1, o2), result));
assert(approx_equal_nt(CGAL::squared_distance(o2, o1), result));
}
P p(int x, int y, int z)
{
int w = ri.next();
return P(to_nt(x*w), to_nt(y*w), to_nt(z*w), to_nt(w));
}
Pl pl(int a, int b, int c, int d)
{
int w = ri.next();
return Pl(to_nt(a*w), to_nt(b*w), to_nt(c*w), to_nt(d*w));
}
void P_P()
{
std::cout << "Point - Point\n";
check_squared_distance (p(0, 0, 0), p(0, 0, 0), 0);
check_squared_distance (p(1, 1, 1), p(0, 0, 0), 3);
}
void P_S()
{
// Note : the values are not verified by hand
std::cout << "Point - Segment\n";
check_squared_distance (p(0, 1, 2), S(p(-3, 0, 0), p( 2, 0, 0)), 5);
check_squared_distance (p(0, 1, 2), S(p( 3, 0, 0), p( 2, 0, 0)), 9);
check_squared_distance (p(0, 1, 2), S(p( 2, 0, 0), p( 3, 0, 0)), 9);
check_squared_distance (p(6, 1, 2), S(p( 2, 0, 0), p( 3, 0, 0)), 14);
}
void S_S()
{
std::cout << "Segment - Segment\n";
check_squared_distance (S(p( -8, -7, 0), p( 11, 6, 0)), S(p(23, -27, 2), p( -17, 16, 2)), 4);
check_squared_distance (S(p( 0, 0, 0), p( 5, 0, 0)), S(p( 1, 1, 2), p( 6, 1, 2)), 5);
check_squared_distance (S(p( 0, 0, 0), p( 5, 0, 0)), S(p( 1, 1, 2), p( 2, 1, 2)), 5);
check_squared_distance (S(p( 5, 0, 0), p( 8, 0, 0)), S(p( 1, 1, 2), p( 2, 1, 2)), 14);
check_squared_distance (S(p( 5, 0, 0), p( 0, 0, 0)), S(p( 1, 1, 2), p( 2, 1, 2)), 5);
check_squared_distance (S(p( 0, 0, 0), p( 5, 0, 0)), S(p( 6, 1, 2), p( 8, 1, 2)), 6);
check_squared_distance (S(p( 0, 0, 0), p( 0,-3, 0)), S(p( 1, 4, 2), p( 1, 7, 2)), 21);
check_squared_distance (S(p( 0, 0, 0), p( 5, 0, 0)), S(p( 8, 1, 2), p( 6, 1, 2)), 6);
check_squared_distance (S(p( 0, 0, 0), p( 0, 0, 0)), S(p( 8, 1, 2), p( 6, 1, 2)), 41);
check_squared_distance (S(p( 0, 0, 0), p( 1, 0, 0)), S(p( 2, 1, 2), p( 2, -1, 2)), 5);
check_squared_distance (S(p( 2, 0, 0), p( 0, 2, 0)), S(p( 1, 1, 4), p( 4, 0, 4)), 16);
check_squared_distance (S(p( 10, 0, 0), p( 0,10, 0)), S(p( 6, 6,20), p( 20, 0,20)), 402);
check_squared_distance (S(p(-10,-13, 0), p( 0,10, 0)), S(p(10, 5,20), p( 70,-30,20)), 524.642);
check_squared_distance (S(p( 0, 0, 0), p(30,-10, 0)), S(p(-5, 20,20), p( 40, 30,20)), 824.706);
check_squared_distance (S(p( 4, 0, 0), p(-3, -1, 0)), S(p( 1, 1, 2), p( 2, 11, 2)), 6);
check_squared_distance (S(p( 3, 4, 0), p( 7, 7, 0)), S(p( 7, 0, 2), p( 6, 5, 2)), 5);
check_squared_distance (S(p( -1, 1, 0), p( 3, 4, 0)), S(p( 7, 0, 2), p( 6, 5, 2)), 13.8462);
}
void P_R()
{
// Note : the value is not verified by hand
std::cout << "Point - Ray\n";
check_squared_distance (p( -8, -7, 0), R(p(23, -27, 2), p( -17, 16, 2)), 86.3685);
}
void R_R()
{
// Note : the values are not verified by hand
std::cout << "Ray - Ray\n";
check_squared_distance (R(p( 0, 0, 30), p( 0, 30, 30)), R(p(100, -100, 0), p( 200, 1, 0)), 20899.5);
check_squared_distance (R(p( 1, 0, 0), p( 0, 0, 0)), R(p( 1, 3, 3), p( 0, 0, 3)), 9);
check_squared_distance (R(p( 0, 0, 0), p( 1, 0, 0)), R(p( 0, 0, 2), p( -1, 0, 2)), 4);
}
void S_R()
{
// Note : the values are not verified by hand
std::cout << "Segment - Ray\n";
check_squared_distance (S(p( 0, 0, 30), p( 0, 30, 30)), R(p(100, -100, 0), p( 200, 1, 0)), 20899.5);
}
void R_L()
{
// Note : the values are not verified by hand
std::cout << "Ray - Line\n";
check_squared_distance (R(p(10, 0, 0), p( 20, 0, 0)), L(p( 0, 0, 3), p( 0, 3, 3)), 109);
check_squared_distance (R(p( 0, 0, 30), p( 0, 30, 30)), L(p(100, -100, 0), p( 200, 1, 0)), 20899.5);
check_squared_distance (R(p( 1, 0, 0), p( 0, 0, 0)), L(p( 1, 3, 3), p( 0, 0, 3)), 9);
check_squared_distance (R(p( 0, 0, 0), p( 1, 0, 0)), L(p( 0, 0, 2), p( -1, 0, 2)), 4);
}
void P_L()
{
std::cout << "Point - Line\n";
check_squared_distance (p( 0, 1, 2), L(p( 2, 0, 0), p( 3, 0, 0)), 5);
check_squared_distance (p( 0, 0, 2), L(p( 0, 0, 0), p( 1, 2, 0)), 4);
}
void S_L()
{
// Note : the values are not verified by hand
std::cout << "Segment - Line\n";
check_squared_distance (S(p( 1, 0, 0), p( 0, 0, 0)), L(p( 1, 3, 3), p( 0, 0, 3)), 9);
check_squared_distance (S(p(-90, 0, 0), p(-10, 0, 0)), L(p( 0, 0, 3), p( 0, 3, 3)), 109);
check_squared_distance (S(p( 0, 0, 0), p( 1, 0, 0)), L(p( 0, 0, 2), p( -1, 0, 2)), 4);
}
void L_L()
{
// Note : the values are not verified by hand
std::cout << "Line - Line\n";
check_squared_distance (L(p(-10, 0, 0), p(-90, 0, 0)), L(p( 0, 0, 3), p( 0, 3, 3)), 9);
check_squared_distance (L(p( 1, 0, 0), p( 0, 0, 0)), L(p( 1, 3, 3), p( 0, 0, 3)), 9);
check_squared_distance (L(p( 0, 0, 0), p( 1, 0, 0)), L(p( 0, 0, 2), p( -1, 0, 2)), 4);
}
void P_Pl()
{
std::cout << "Point - Plane\n";
check_squared_distance (p(2, 5, 3), Pl(0, 1, 0, 0), 25);
}
void S_Pl()
{
std::cout << "Segment - Plane\n";
check_squared_distance (S(p(2, -3, 3), p( 3,-7, 4)), pl(0, 1, 0, 0), 9);
}
void R_Pl()
{
std::cout << "Ray - Plane\n";
check_squared_distance (R(p(2, -4, 3), p( 3,-4, 4)), Pl(0, 1, 0, 0), 16);
check_squared_distance (R(p(2, -4, 3), p( 3, 4, 4)), Pl(0, 1, 0, 0), 0);
check_squared_distance (R(p(2, -4, 3), p( 3,-8, 4)), Pl(0, 1, 0, 0), 16);
}
void L_Pl()
{
std::cout << "Line - Plane\n";
check_squared_distance (L(p(2, -4, 3), p( 3,-4, 4)), Pl(0, 1, 0, 0), 16);
check_squared_distance (L(p(2, -4, 3), p( 3, 4, 4)), Pl(0, 1, 0, 0), 0);
check_squared_distance (L(p(2, -4, 3), p( 3,-8, 4)), Pl(0, 1, 0, 0), 0);
}
void run()
{
std::cout << "3D Distance tests\n";
P_P();
P_S();
S_S();
P_R();
R_R();
S_R();
R_L();
P_L();
S_L();
L_L();
P_Pl();
S_Pl();
R_Pl();
L_Pl();
}
};
int main()
{
Test< CGAL::Cartesian<double> >().run();
Test< CGAL::Homogeneous<double> >().run();
// TODO : test more kernels.
}

View File

@ -1,35 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Segment_3< TestR > segment_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1;
if (!cin)
return 1;
w1 = ri.next();
point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
segment_t seg(tp1,tp2);
d = CGAL::squared_distance(pt, seg);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,40 +0,0 @@
#include "numrep1.h"
/*
* Squared distance between two segments.
*/
#include <CGAL/Point_3.h>
#include <CGAL/squared_distance_3.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Segment_3< TestR > segment_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
segment_t seg1(tp1,tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
segment_t seg2(tp3,tp4);
d = CGAL::squared_distance(seg1, seg2);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,36 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/squared_distance_3.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Ray_3< TestR > ray_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1;
if (!cin)
return 1;
w1 = ri.next();
point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
ray_t ray(tp1, tp2);
d = CGAL::squared_distance(pt, ray);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,40 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Ray_3< TestR > ray_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
ray_t ray1(tp1, tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
ray_t ray2(tp3, tp4);
d = CGAL::squared_distance(ray1, ray2);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,42 +0,0 @@
#include "numrep1.h"
/*
* Squared distance between two segments.
*/
#include <CGAL/Point_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/squared_distance_3.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Segment_3< TestR > segment_t;
typedef CGAL::Ray_3< TestR > ray_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
segment_t seg(tp1, tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
ray_t ray(tp3, tp4);
d = CGAL::squared_distance(seg, ray);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,41 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Line_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Line_3< TestR > line_t;
typedef CGAL::Ray_3< TestR > ray_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
ray_t ray(tp1, tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
line_t line(tp3, tp4);
d = CGAL::squared_distance(ray, line);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,36 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Line_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Line_3< TestR > line_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1;
if (!cin)
return 1;
w1 = ri.next();
point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
line_t line(tp1, tp2);
d = CGAL::squared_distance(pt, line);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,41 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Line_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Line_3< TestR > line_t;
typedef CGAL::Segment_3< TestR > seg_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
seg_t seg(tp1, tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
line_t line(tp3, tp4);
d = CGAL::squared_distance(seg, line);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,39 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Line_3.h>
#include <CGAL/squared_distance_3_1.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Line_3< TestR > line_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x1, x2, y1, y2, z1, z2, w1, w2;
TestR::FT d;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
line_t line1(tp1, tp2);
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
if (!cin)
return 1;
w1 = ri.next();
w2 = ri.next();
point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1*z1), to_nt(w1));
point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2*z2), to_nt(w2));
line_t line2(tp1, tp2);
d = CGAL::squared_distance(line1, line2);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,32 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Plane_3.h>
#include <CGAL/squared_distance_3_2.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Plane_3< TestR > plane_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x, y, z, w, w1;
TestR::FT d;
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z >> w;
if (!cin)
return 1;
plane_t plane(to_nt(x), to_nt(y), to_nt(z), to_nt(w));
d = CGAL::squared_distance(pt, plane);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,39 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Segment_3.h>
#include <CGAL/Plane_3.h>
#include <CGAL/squared_distance_3_2.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Segment_3< TestR > seg_t;
typedef CGAL::Plane_3< TestR > plane_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x, y, z, w, w1;
TestR::FT d;
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt1(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt2(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z >> w;
if (!cin)
return 1;
plane_t plane(to_nt(x), to_nt(y), to_nt(z), to_nt(w));
d = CGAL::squared_distance(seg_t(pt1, pt2), plane);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,39 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Ray_3.h>
#include <CGAL/Plane_3.h>
#include <CGAL/squared_distance_3_2.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Ray_3< TestR > ray_t;
typedef CGAL::Plane_3< TestR > plane_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x, y, z, w1, w;
TestR::FT d;
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt1(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt2(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z >> w;
if (!cin)
return 1;
plane_t plane(to_nt(x), to_nt(y), to_nt(z), to_nt(w));
d = CGAL::squared_distance(ray_t(pt1, pt2), plane);
cout << CGAL::to_double(d) << '\n';
return 0;
}

View File

@ -1,39 +0,0 @@
#include "numrep1.h"
#include <CGAL/Point_3.h>
#include <CGAL/Line_3.h>
#include <CGAL/Plane_3.h>
#include <CGAL/squared_distance_3_2.h>
#include "numrep2.h"
typedef CGAL::Point_3< TestR > point_t;
typedef CGAL::Line_3< TestR > line_t;
typedef CGAL::Plane_3< TestR > plane_t;
using std::cin;
using std::cout;
int main()
{
randomint ri;
int x, y, z, w1, w;
TestR::FT d;
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt1(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z;
if (!cin)
return 1;
w1 = ri.next();
point_t pt2(to_nt(w1*x), to_nt(w1*y), to_nt(w1*z), to_nt(w1));
cin >> x >> y >> z >> w;
if (!cin)
return 1;
plane_t plane(to_nt(x), to_nt(y), to_nt(z), to_nt(w));
d = CGAL::squared_distance(line_t(pt1, pt2), plane);
cout << CGAL::to_double(d) << '\n';
return 0;
}