mirror of https://github.com/CGAL/cgal
Added new examples.
This commit is contained in:
parent
b92b88bc11
commit
8b4dea2485
|
|
@ -1044,7 +1044,14 @@ Minkowski_sum_2/doc_tex/Minkowski_sum_2/fig/onecyc_out.fig -text
|
|||
Minkowski_sum_2/doc_tex/Minkowski_sum_2/fig/sum_triangles.fig -text
|
||||
Minkowski_sum_2/doc_tex/Minkowski_sum_2/fig/sum_triangles.pstex -text
|
||||
Minkowski_sum_2/doc_tex/Minkowski_sum_2/fig/sum_triangles.pstex_t -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ex_approx_offset.C -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ex_exact_offset.C -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ex_sum_by_decomposition.C -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ex_sum_triangles.C -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ex_sum_with_holes.C -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/ms_rational_nt.h -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/rooms_star.dat -text
|
||||
Minkowski_sum_2/examples/Minkowski_sum_2/spiked.dat -text
|
||||
Modifier/doc_tex/Modifier/idraw/modifier.eps -text
|
||||
Modifier/doc_tex/Modifier/idraw/modifier.pdf -text svneol=unset#unset
|
||||
Modifier/doc_tex/Modifier/modifier.gif -text svneol=unset#unset
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
//! \file examples/Minkowski_sum_2/ex_approx_offset.C
|
||||
// Computing the approximated offset of a polygon.
|
||||
|
||||
#include "ms_rational_nt.h"
|
||||
#include <CGAL/Lazy_exact_nt.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/approximated_offset_2.h>
|
||||
#include <CGAL/offset_polygon_2.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <iostream>
|
||||
|
||||
typedef CGAL::Lazy_exact_nt<Number_type> Lazy_exact_nt;
|
||||
typedef CGAL::Cartesian<Lazy_exact_nt> Kernel;
|
||||
typedef CGAL::Polygon_2<Kernel> Polygon_2;
|
||||
|
||||
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Gps_traits_2;
|
||||
typedef Gps_traits_2::Polygon_2 Offset_polygon_2;
|
||||
typedef Gps_traits_2::Polygon_with_holes_2 Offset_polygon_with_holes_2;
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Open the input file.
|
||||
std::ifstream in_file ("spiked.dat");
|
||||
|
||||
if (! in_file.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open the input file." << std::endl;
|
||||
return (1);
|
||||
}
|
||||
|
||||
// Read the input polygon.
|
||||
Polygon_2 P;
|
||||
|
||||
in_file >> P;
|
||||
in_file.close();
|
||||
|
||||
std::cout << "Read an input polygon with "
|
||||
<< P.size() << " vertices." << std::endl;
|
||||
|
||||
// Approximate the offset polygon.
|
||||
const Number_type radius = 5;
|
||||
const double err_bound = 0.00001;
|
||||
Offset_polygon_with_holes_2 offset;
|
||||
CGAL::Timer timer;
|
||||
|
||||
timer.start();
|
||||
offset = approximated_offset_2 (P, radius, err_bound);
|
||||
timer.stop();
|
||||
|
||||
std::cout << "The offset polygon has "
|
||||
<< offset.outer_boundary().size() << " vertices, "
|
||||
<< offset.number_of_holes() << " holes." << std::endl;
|
||||
std::cout << "Offset computation took "
|
||||
<< timer.time() << " seconds." << std::endl;
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
//! \file examples/Minkowski_sum_2/ex_exact_offset.C
|
||||
// Computing the exact offset of a polygon.
|
||||
#include <CGAL/basic.h>
|
||||
|
||||
#ifndef CGAL_USE_CORE
|
||||
#include <iostream>
|
||||
int main ()
|
||||
{
|
||||
std::cout << "Sorry, this example needs CORE ..." << std::endl;
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/CORE_algebraic_number_traits.h>
|
||||
#include <CGAL/Arr_conic_traits_2.h>
|
||||
#include <CGAL/offset_polygon_2.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <iostream>
|
||||
|
||||
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
|
||||
typedef Nt_traits::Rational Rational;
|
||||
typedef Nt_traits::Algebraic Algebraic;
|
||||
typedef CGAL::Cartesian<Rational> Rat_kernel;
|
||||
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
|
||||
typedef CGAL::Arr_conic_traits_2<Rat_kernel,
|
||||
Alg_kernel,
|
||||
Nt_traits> Conic_traits_2;
|
||||
typedef CGAL::Polygon_2<Rat_kernel> Polygon_2;
|
||||
|
||||
typedef CGAL::Gps_traits_2<Conic_traits_2> Gps_traits_2;
|
||||
typedef Gps_traits_2::Polygon_2 Offset_polygon_2;
|
||||
typedef Gps_traits_2::Polygon_with_holes_2 Offset_polygon_with_holes_2;
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Open the input file.
|
||||
std::ifstream in_file ("spiked.dat");
|
||||
|
||||
if (! in_file.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open the input file." << std::endl;
|
||||
return (1);
|
||||
}
|
||||
|
||||
// Read the input polygon.
|
||||
Polygon_2 P;
|
||||
|
||||
in_file >> P;
|
||||
in_file.close();
|
||||
|
||||
std::cout << "Read an input polygon with "
|
||||
<< P.size() << " vertices." << std::endl;
|
||||
|
||||
// Compute the offset polygon.
|
||||
Conic_traits_2 traits;
|
||||
const Rational radius = 5;
|
||||
Offset_polygon_with_holes_2 offset;
|
||||
CGAL::Timer timer;
|
||||
|
||||
timer.start();
|
||||
offset = offset_polygon_2 (traits, P, radius);
|
||||
timer.stop();
|
||||
|
||||
std::cout << "The offset polygon has "
|
||||
<< offset.outer_boundary().size() << " vertices, "
|
||||
<< offset.number_of_holes() << " holes." << std::endl;
|
||||
std::cout << "Offset computation took "
|
||||
<< timer.time() << " seconds." << std::endl;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
//! \file examples/Minkowski_sum_2/ex_sum_by_decomposition.C
|
||||
// Computing the Minkowski sum of two non-convex polygons read from a file
|
||||
// using the small-side angle-bisector decomposition strategy.
|
||||
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/minkowski_sum_2.h>
|
||||
#include <CGAL/Small_side_angle_bisector_decomposition.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "print_utils.h"
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef CGAL::Polygon_2<Kernel> Polygon_2;
|
||||
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Open the input file.
|
||||
std::ifstream in_file ("rooms_star.dat");
|
||||
|
||||
if (! in_file.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open the input file." << std::endl;
|
||||
return (1);
|
||||
}
|
||||
|
||||
// Read the two polygons from the file and compute their Minkowski sum.
|
||||
Polygon_2 P, Q;
|
||||
|
||||
in_file >> P >> Q;
|
||||
in_file.close();
|
||||
|
||||
// Compute the Minkowski sum using the decomposition approach.
|
||||
CGAL::Small_side_angle_bisector_decomposition<Kernel> ssab_decomp;
|
||||
|
||||
Polygon_with_holes_2 sum = minkowski_sum_2 (P, Q, ssab_decomp);
|
||||
|
||||
std::cout << "P (+) Q = "; print_polygon_with_holes (sum);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
//! \file examples/Minkowski_sum_2/ex_sum_triangles.C
|
||||
// Computing the Minkowski sum of two triangles.
|
||||
|
||||
#include "ms_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/minkowski_sum_2.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "print_utils.h"
|
||||
|
||||
typedef int Number_type;
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef CGAL::Polygon_2<Kernel> Polygon_2;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
//! \file examples/Minkowski_sum_2/ex_sum_with_holes.C
|
||||
// Computing the Minkowski sum of two non-convex polygons read from a file.
|
||||
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/minkowski_sum_2.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "print_utils.h"
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef CGAL::Polygon_2<Kernel> Polygon_2;
|
||||
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Open the input file.
|
||||
std::ifstream in_file ("rooms_star.dat");
|
||||
|
||||
if (! in_file.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open the input file." << std::endl;
|
||||
return (1);
|
||||
}
|
||||
|
||||
// Read the two polygons from the file and compute their Minkowski sum.
|
||||
Polygon_2 P, Q;
|
||||
|
||||
in_file >> P >> Q;
|
||||
in_file.close();
|
||||
|
||||
// Compute and print the Minkowski sum.
|
||||
Polygon_with_holes_2 sum = minkowski_sum_2 (P, Q);
|
||||
|
||||
std::cout << "P (+) Q = "; print_polygon_with_holes (sum);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef CGAL_MS_RATIONAL_NT_H
|
||||
#define CGAL_MS_RATIONAL_NT_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
|
||||
// GMP is installed. Use the GMP rational number-type.
|
||||
#include <CGAL/Gmpq.h>
|
||||
|
||||
typedef CGAL::Gmpq Number_type;
|
||||
|
||||
#else
|
||||
|
||||
// GMP is not installed. Use CGAL's exact rational number-type.
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
26
|
||||
0/1 8/1
|
||||
0/1 0/1
|
||||
17/1 0/1
|
||||
17/1 18/1
|
||||
0/1 18/1
|
||||
0/1 9/1
|
||||
6/1 9/1
|
||||
6/1 10/1
|
||||
1/1 10/1
|
||||
1/1 17/1
|
||||
8/1 17/1
|
||||
8/1 14/1
|
||||
9/1 14/1
|
||||
9/1 17/1
|
||||
16/1 17/1
|
||||
16/1 10/1
|
||||
9/1 10/1
|
||||
8/1 9/1
|
||||
16/1 9/1
|
||||
16/1 1/1
|
||||
9/1 1/1
|
||||
9/1 8/1
|
||||
8/1 8/1
|
||||
8/1 1/1
|
||||
1/1 1/1
|
||||
1/1 8/1
|
||||
|
||||
8
|
||||
0/1 -3/1
|
||||
1/1 -1/1
|
||||
3/1 0/1
|
||||
1/1 1/1
|
||||
0/1 3/1
|
||||
-1/1 1/1
|
||||
-3/1 0/1
|
||||
-1/1 -1/1
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
64
|
||||
100/1 -10/1
|
||||
100/1 500/1
|
||||
500/1 498/1
|
||||
110/1 495/1
|
||||
110/1 450/1
|
||||
500/1 448/1
|
||||
110/1 445/1
|
||||
110/1 400/1
|
||||
500/1 398/1
|
||||
110/1 395/1
|
||||
110/1 350/1
|
||||
500/1 348/1
|
||||
110/1 345/1
|
||||
110/1 300/1
|
||||
500/1 298/1
|
||||
110/1 295/1
|
||||
110/1 250/1
|
||||
500/1 248/1
|
||||
110/1 245/1
|
||||
110/1 200/1
|
||||
500/1 198/1
|
||||
110/1 195/1
|
||||
110/1 150/1
|
||||
500/1 148/1
|
||||
110/1 145/1
|
||||
110/1 100/1
|
||||
500/1 98/1
|
||||
110/1 95/1
|
||||
110/1 50/1
|
||||
500/1 48/1
|
||||
110/1 45/1
|
||||
110/1 0/1
|
||||
600/1 0/1
|
||||
602/1 500/1
|
||||
605/1 0/1
|
||||
610/1 0/1
|
||||
612/1 500/1
|
||||
615/1 0/1
|
||||
620/1 0/1
|
||||
622/1 500/1
|
||||
625/1 0/1
|
||||
630/1 0/1
|
||||
632/1 500/1
|
||||
635/1 0/1
|
||||
640/1 0/1
|
||||
642/1 500/1
|
||||
645/1 0/1
|
||||
650/1 0/1
|
||||
652/1 500/1
|
||||
655/1 0/1
|
||||
660/1 0/1
|
||||
662/1 500/1
|
||||
665/1 0/1
|
||||
670/1 0/1
|
||||
672/1 500/1
|
||||
675/1 0/1
|
||||
680/1 0/1
|
||||
682/1 500/1
|
||||
685/1 0/1
|
||||
690/1 0/1
|
||||
692/1 500/1
|
||||
695/1 0/1
|
||||
700/1 0/1
|
||||
700/1 -10/1
|
||||
Loading…
Reference in New Issue