mirror of https://github.com/CGAL/cgal
Allow comparison with a "correct" result in the test suite
Add tests for dangling edge/isolated vertex situations.
This commit is contained in:
parent
f0cb2e9617
commit
3dc6e24623
|
|
@ -0,0 +1,11 @@
|
||||||
|
4
|
||||||
|
-1 -1
|
||||||
|
7 -1
|
||||||
|
7 7
|
||||||
|
-1 7
|
||||||
|
1
|
||||||
|
4
|
||||||
|
2 2
|
||||||
|
2 4
|
||||||
|
4 4
|
||||||
|
4 2
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
4
|
||||||
|
-1 -1
|
||||||
|
7 -1
|
||||||
|
7 7
|
||||||
|
-1 7
|
||||||
|
|
@ -53,4 +53,13 @@ bool read_polygon (const char *filename, CGAL::Polygon_2<Kernel>& pgn)
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Kernel>
|
||||||
|
bool read_polygon_with_holes (const char *filename, CGAL::Polygon_with_holes_2<Kernel>& pgn)
|
||||||
|
{
|
||||||
|
std::ifstream ifile(filename);
|
||||||
|
ifile >> pgn;
|
||||||
|
// TODO: what can go wrong?
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
./data/rooms_part1.dat ./data/rooms_part2.dat -sohg
|
compare ./data/rooms_part1.dat ./data/rooms_part2.dat
|
||||||
./data/comb_part1.dat ./data/comb_part2.dat -sohg
|
compare ./data/comb_part1.dat ./data/comb_part2.dat
|
||||||
./data/fork_part1.dat ./data/fork_part2.dat -soh
|
compare ./data/knife_part1.dat ./data/knife_part2.dat
|
||||||
./data/knife_part1.dat ./data/knife_part2.dat -so
|
compare ./data/mchain_part1.dat ./data/mchain_part2.dat
|
||||||
./data/mchain_part1.dat ./data/mchain_part2.dat -sh
|
compare ./data/random_part1.dat ./data/random_part2.dat
|
||||||
./data/random_part1.dat ./data/random_part2.dat -sg
|
compare ./data/wheels_part1.dat ./data/wheels_part2.dat
|
||||||
./data/wheels_part1.dat ./data/wheels_part2.dat -hg
|
compare ./data/r35975_part1.dat ./data/r35975_part2.dat
|
||||||
./data/r35975_part1.dat ./data/r35975_part2.dat -sohg
|
compare ./data/r38305_part1.dat ./data/r38305_part2.dat
|
||||||
./data/r38305_part1.dat ./data/r38305_part2.dat -sohg
|
compare ./data/D.dat ./data/E.dat
|
||||||
./data/D.dat ./data/E.dat -sohg
|
compare ./data/F.dat ./data/G.dat
|
||||||
./data/F.dat ./data/G.dat -sohg
|
compare ./data/F.dat ./data/E.dat
|
||||||
./data/F.dat ./data/E.dat -sohg
|
compare ./data/F.dat ./data/D.dat
|
||||||
./data/F.dat ./data/D.dat -sohg
|
compare ./data/F.dat ./data/A.dat
|
||||||
./data/F.dat ./data/A.dat -sohg
|
compare ./data/A.dat ./data/G.dat
|
||||||
./data/A.dat ./data/G.dat -sohg
|
compare ./data/B.dat ./data/G.dat
|
||||||
./data/B.dat ./data/G.dat -sohg
|
verify ./data/dangling_edge_part1.dat ./data/dangling_edge_part2.dat ./data/dangling_edge_result.dat
|
||||||
./data/dangling_edge_part1.dat ./data/dangling_edge_part2.dat -sohg
|
verify ./data/isolated_vertex_part1.dat ./data/isolated_vertex_part2.dat ./data/isolated_vertex_result.dat
|
||||||
./data/isolated_vertex_part1.dat ./data/isolated_vertex_part2.dat -sohg
|
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,12 @@ int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Read the input file. Because of the structure of the *.cmd file
|
// Read the input file. Because of the structure of the *.cmd file
|
||||||
// (which is concatenated to the command line) we need to get all the
|
// (which is concatenated to the command line) we need to get all the
|
||||||
// inputs in one command line. This is the reason we read triplets/pairs of
|
// inputs in one command line. This is the reason we read triplets/quadruplets of
|
||||||
// arguments. Each triplet/double is one input for the program.
|
// arguments. Each triplet/quadruplet is one input for the program.
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
std::cerr << "Usage: " << argv[0] << ". The input are triplets of:"
|
std::cerr << "Usage: " << argv[0] << ". The input are triplets/quadruplets of:"
|
||||||
<< " <polygon#1> <polygon#2> [decomposition flags]"
|
<< "<compare|verify> <polygon#1> <polygon#2> [polygon#3]"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
@ -58,37 +58,35 @@ int main (int argc, char **argv)
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (i < argc)
|
while (i < argc)
|
||||||
{
|
{
|
||||||
|
bool verify = strcmp(argv[i], "verify") == 0;
|
||||||
|
|
||||||
// Read the polygons from the input files.
|
// Read the polygons from the input files.
|
||||||
Polygon_2 pgn1, pgn2;
|
Polygon_2 pgn1, pgn2;
|
||||||
|
Polygon_with_holes_2 result;
|
||||||
|
|
||||||
if (! read_polygon (argv[i], pgn1))
|
if (! read_polygon (argv[i+1], pgn1))
|
||||||
{
|
|
||||||
std::cerr << "Failed to read: <" << argv[i] << ">." << std::endl;
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! read_polygon (argv[i+1], pgn2))
|
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read: <" << argv[i+1] << ">." << std::endl;
|
std::cerr << "Failed to read: <" << argv[i+1] << ">." << std::endl;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Testing " << argv[i] << " and " << argv[i+1] << std::endl;
|
|
||||||
|
|
||||||
// Read the decomposition flags.
|
|
||||||
bool use_ssab = true;
|
|
||||||
bool use_opt = true;
|
|
||||||
bool use_hm = true;
|
|
||||||
bool use_greene = true;
|
|
||||||
|
|
||||||
if (i+2 < argc && argv[i+2][0] == '-')
|
if (! read_polygon (argv[i+2], pgn2))
|
||||||
{
|
{
|
||||||
use_ssab = (std::strchr (argv[i+2], 's') != NULL);
|
std::cerr << "Failed to read: <" << argv[i+2] << ">." << std::endl;
|
||||||
use_opt = (std::strchr (argv[i+2], 'o') != NULL);
|
return (1);
|
||||||
use_hm = (std::strchr (argv[i+2], 'h') != NULL);
|
|
||||||
use_greene = (std::strchr (argv[i+2], 'g') != NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verify)
|
||||||
|
{
|
||||||
|
if (! read_polygon_with_holes (argv[i+3], result))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to read: <" << argv[i+3] << ">." << std::endl;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Testing " << argv[i+1] << " and " << argv[i+2] << std::endl;
|
||||||
|
|
||||||
// Compute the Minkowski sum using the convolution method.
|
// Compute the Minkowski sum using the convolution method.
|
||||||
Polygon_with_holes_2 sum_conv;
|
Polygon_with_holes_2 sum_conv;
|
||||||
|
|
||||||
|
|
@ -96,17 +94,34 @@ int main (int argc, char **argv)
|
||||||
sum_conv = minkowski_sum_2 (pgn1, pgn2);
|
sum_conv = minkowski_sum_2 (pgn1, pgn2);
|
||||||
std::cout << "Done." << std::endl;
|
std::cout << "Done." << std::endl;
|
||||||
|
|
||||||
Polygon_with_holes_2 sum_conv_new;
|
if (verify)
|
||||||
std::cout << "Using the reduced convolution method ... ";
|
|
||||||
sum_conv_new = minkowski_sum_2_new (pgn1, pgn2);
|
|
||||||
if (are_equal (sum_conv, sum_conv_new))
|
|
||||||
{
|
{
|
||||||
|
if (are_equal (result, sum_conv))
|
||||||
|
{
|
||||||
std::cout << "OK." << std::endl;
|
std::cout << "OK." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "ERROR (different result)." << std::endl;
|
result = sum_conv;
|
||||||
return 1;
|
}
|
||||||
|
|
||||||
|
Polygon_with_holes_2 sum_conv_new;
|
||||||
|
std::cout << "Using the reduced convolution method ... ";
|
||||||
|
sum_conv_new = minkowski_sum_2_new (pgn1, pgn2);
|
||||||
|
if (are_equal (result, sum_conv_new))
|
||||||
|
{
|
||||||
|
std::cout << "OK." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define auxiliary polygon-decomposition objects.
|
// Define auxiliary polygon-decomposition objects.
|
||||||
|
|
@ -116,70 +131,60 @@ int main (int argc, char **argv)
|
||||||
CGAL::Greene_convex_decomposition_2<Kernel> greene_decomp;
|
CGAL::Greene_convex_decomposition_2<Kernel> greene_decomp;
|
||||||
Polygon_with_holes_2 sum_decomp;
|
Polygon_with_holes_2 sum_decomp;
|
||||||
|
|
||||||
if (use_ssab)
|
std::cout << "Using the small-side angle-bisector decomposition ... ";
|
||||||
|
sum_decomp = minkowski_sum_2 (pgn1, pgn2, ssab_decomp);
|
||||||
|
if (are_equal (result, sum_decomp))
|
||||||
{
|
{
|
||||||
std::cout << "Using the small-side angle-bisector decomposition ... ";
|
std::cout << "OK." << std::endl;
|
||||||
sum_decomp = minkowski_sum_2 (pgn1, pgn2, ssab_decomp);
|
|
||||||
if (are_equal (sum_conv, sum_decomp))
|
|
||||||
{
|
|
||||||
std::cout << "OK." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "ERROR (different result)." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_opt)
|
|
||||||
{
|
|
||||||
std::cout << "Using the optimal convex decomposition ... ";
|
|
||||||
sum_decomp = minkowski_sum_2 (pgn1, pgn2, opt_decomp);
|
|
||||||
if (are_equal (sum_conv, sum_decomp))
|
|
||||||
{
|
|
||||||
std::cout << "OK." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "ERROR (different result)." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (use_hm)
|
|
||||||
{
|
|
||||||
std::cout << "Using the Hertel--Mehlhorn decomposition ... ";
|
|
||||||
sum_decomp = minkowski_sum_2 (pgn1, pgn2, hm_approx_decomp);
|
|
||||||
if (are_equal (sum_conv, sum_decomp))
|
|
||||||
{
|
|
||||||
std::cout << "OK." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "ERROR (different result)." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (use_greene)
|
|
||||||
{
|
|
||||||
std::cout << "Using the Greene decomposition ... ";
|
|
||||||
sum_decomp = minkowski_sum_2 (pgn1, pgn2, greene_decomp);
|
|
||||||
if (are_equal (sum_conv, sum_decomp))
|
|
||||||
{
|
|
||||||
std::cout << "OK." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "ERROR (different result)." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i+2 < argc && argv[i+2][0] == '-')
|
|
||||||
i += 3;
|
|
||||||
else
|
else
|
||||||
i += 2;
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Using the optimal convex decomposition ... ";
|
||||||
|
sum_decomp = minkowski_sum_2 (pgn1, pgn2, opt_decomp);
|
||||||
|
if (are_equal (result, sum_decomp))
|
||||||
|
{
|
||||||
|
std::cout << "OK." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Using the Hertel--Mehlhorn decomposition ... ";
|
||||||
|
sum_decomp = minkowski_sum_2 (pgn1, pgn2, hm_approx_decomp);
|
||||||
|
if (are_equal (result, sum_decomp))
|
||||||
|
{
|
||||||
|
std::cout << "OK." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Using the Greene decomposition ... ";
|
||||||
|
sum_decomp = minkowski_sum_2 (pgn1, pgn2, greene_decomp);
|
||||||
|
if (are_equal (result, sum_decomp))
|
||||||
|
{
|
||||||
|
std::cout << "OK." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "ERROR (different result)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verify)
|
||||||
|
{
|
||||||
|
i += 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue