Polished docs and example programs.

This commit is contained in:
Michael Hoffmann 2003-08-28 14:18:42 +00:00
parent 9c3cba3b39
commit b172023dc0
15 changed files with 214 additions and 275 deletions

View File

@ -1,40 +1,29 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_parallelogram_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing parallelogram p_m of p
Polygon_2 p_m;
min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -1,40 +1,29 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_rectangle_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing rectangle p_m of p
Polygon_2 p_m;
min_rectangle_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_rectangle_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -1,39 +1,28 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_strip_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
cout << p << endl;
// compute the minimal enclosing strip p_m of p
Line_2 p_m[2];
min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
cout << p_m[0] << "\n" << p_m[1] << endl;
CGAL::min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
std::cout << p_m[0] << "\n" << p_m[1] << std::endl;
return 0;
}

View File

@ -12,13 +12,13 @@
\ccIndexSubitem[t]{smallest enclosing}{rectangle}
\ccIndexSubitem[t]{rectangle}{smallest enclosing}
\ccDefinition The function computes a minimum area enclosing
rectangle $R(P)$ (not necessarily axis-parallel) of a given convex
point set $P$. Note that $R(P)$ is not unique in general. The
restriction to convex sets is not really a restriction, since any
enclosing rectangle -- as a convex set -- contains the convex hull
of $P$.
\ccDefinition The function computes a minimum area enclosing rectangle
$R(P)$ of a given convex point set $P$. Note that $R(P)$ is not
necessarily axis-parallel, and it is in general not unique. The focus
on convex sets is no restriction, since any rectangle enclosing $P$
-- as a convex set -- contains the convex hull of $P$. For general
point sets one has to compute the convex hull as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
\def\ccLongParamLayout{\ccTrue}
@ -32,23 +32,22 @@
OutputIterator o,
Traits& t = Default_traits);}
computes a minimum area enclosing rectangle of the point set
described by [\ccc{points_begin}, \ccc{points_end}), writes its
vertices (counterclockwise) to \ccc{o} and returns the past-the-end
iterator
computes a minimum area enclosing rectangle of the point set described
by [\ccc{points_begin}, \ccc{points_end}), writes its vertices
(counterclockwise) to \ccc{o}, and returns the past-the-end iterator
of this sequence.\\
If the input range is empty, \ccc{o} remains unchanged.\\
If the input range consists of one element only,
exactly this point is written to \ccc{o}.
If the input range consists of one element only, this point is written
to \ccc{o} four times.
\ccPrecond The points denoted by the range [\ccc{points_begin},
\ccc{points_end}) form the boundary of a simple convex polygon $P$
in counterclockwise orientation.
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
The geometric types and operations to be used for the computation are
specified by the traits class parameter \ccc{t}. The parameter can be
omitted, if \ccc{ForwardIterator} refers to a two-dimensional point
type from one the \cgal\ Kernels. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
\ccRequire
@ -67,7 +66,7 @@
\ccRefIdfierPage{CGAL::Min_quadrilateral_default_traits_2<Kernel>}
\ccImplementation We use a rotating caliper
\ccIndexMainItem[t]{rotating caliper} algorithm \cite{t-sgprc-83}
\ccIndexMainItem[t]{rotating caliper} algorithm~\cite{t-sgprc-83}
with worst case running time linear in the number of input points.
\ccExample The following code generates a random convex polygon
@ -84,9 +83,11 @@
\ccDefinition The function computes a minimum area enclosing
parallelogram $A(P)$ of a given convex point set $P$. Note that
$A(P)$ is not unique in general. The restriction to convex sets is
not really a restriction, since any enclosing parallelogram -- as a
convex set -- contains the convex hull of $P$.
$R(P)$ is not necessarily axis-parallel, and it is in general not
unique. The focus on convex sets is no restriction, since any
parallelogram enclosing $P$ -- as a convex set -- contains the convex
hull of $P$. For general point sets one has to compute the convex hull
as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
@ -106,17 +107,17 @@
vertices (counterclockwise) to \ccc{o} and returns the past-the-end
iterator of this sequence.
If the input range is empty, \ccc{o} remains unchanged.\\
If the input range consists of one element only,
exactly this point is written to \ccc{o}.
If the input range consists of one element only, this point is written
to \ccc{o} four times.
\ccPrecond The points denoted by the range [\ccc{points_begin},
\ccc{points_end}) form the boundary of a simple convex polygon $P$
in counterclockwise orientation.
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
are specified by the traits class parameter \ccc{t}. The parameter can be
omitted, if \ccc{ForwardIterator} refers to a two-dimensional point
type from one the \cgal\ Kernels. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
\ccRequire
@ -155,9 +156,10 @@
\ccDefinition The function computes a minimum width enclosing strip
$S(P)$ of a given convex point set $P$. A strip is the closed region
bounded by two parallel lines in the plane. Note that $S(P)$ is not
unique in general. The restriction to convex sets is not really a
restriction, since any enclosing strip -- as a convex set --
contains the convex hull of $P$.
unique in general. The focus on convex sets is no restriction, since any
parallelogram enclosing $P$ -- as a convex set -- contains the convex
hull of $P$. For general point sets one has to compute the convex hull
as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
@ -173,8 +175,8 @@
Traits& t = Default_traits);}
computes a minimum enclosing strip of the point set described by
[\ccc{points_begin}, \ccc{points_end}), writes its bounding lines to
\ccc{o} and returns the past-the-end iterator of this sequence.\\
[\ccc{points_begin}, \ccc{points_end}), writes its two bounding lines
to \ccc{o} and returns the past-the-end iterator of this sequence.\\
If the input range is empty or consists of one element only, \ccc{o}
remains unchanged.
@ -184,17 +186,18 @@
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
can be omitted, if \ccc{ForwardIterator} refers to a two-dimensional
point type from one the \cgal\ Kernels. In this case, a default
traits class (\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is
used.
\ccRequire
\begin{enumerate}
\item If \ccc{Traits} is specified, it is a model for
\ccc{MinQuadrilateralTraits_2} and the value type \ccc{VT} of
\ccc{ForwardIterator} is \ccc{Traits::Point_2}. Otherwise \ccc{VT}
\ccc{ForwardIterator} is \ccc{Traits::Point_2}. Otherwise \ccc{VT}
is \ccc{CGAL::Point_2<Kernel>} for some kernel \ccc{Kernel}.
\item \ccc{OutputIterator} accepts \ccc{VT} as value type.
\item \ccc{OutputIterator} accepts \ccc{Traits::Line_2} as value type.
\end{enumerate}
\ccSeeAlso
@ -256,6 +259,8 @@
\ccNestedType{Less_yx_2}{\ccRefConceptPage{Kernel::Less_yx_2}.}
\ccNestedType{Orientation_2}{\ccRefConceptPage{Kernel::Orientation_2}.}
\ccNestedType{Has_on_negative_side_2}
{\ccRefConceptPage{Kernel::Has_on_negative_side_2}.}
@ -414,10 +419,15 @@
than the area of $p2$.}
\ccNestedType{Width_less_strip_2}{AdaptableFunctor \\\ccc{op}:
\ccc{Strip_2} $\times$ \ccc{Strip_2} $\rightarrow$ \ccc{bool}.\\
\ccc{Strip_2} $\times$ \ccc{Strip_2} $\rightarrow$ \ccc{bool}.\\
\ccc{op(s1,s2)} returns true, iff the width of $s1$ is strictly less
than the width of $s2$.}
The following type is used for expensive precondition checking only.
\ccNestedType{Orientation_2}{a model for
\ccRefConceptPage{Kernel::Orientation_2}.}
\ccHeading{Constructions}
\ccNestedType{Construct_vector_2}{a model for

View File

@ -1,40 +1,29 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_parallelogram_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing parallelogram p_m of p
Polygon_2 p_m;
min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -1,40 +1,29 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_rectangle_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing rectangle p_m of p
Polygon_2 p_m;
min_rectangle_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_rectangle_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -1,39 +1,28 @@
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_strip_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
cout << p << endl;
// compute the minimal enclosing strip p_m of p
Line_2 p_m[2];
min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
cout << p_m[0] << "\n" << p_m[1] << endl;
CGAL::min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
std::cout << p_m[0] << "\n" << p_m[1] << std::endl;
return 0;
}

View File

@ -12,13 +12,13 @@
\ccIndexSubitem[t]{smallest enclosing}{rectangle}
\ccIndexSubitem[t]{rectangle}{smallest enclosing}
\ccDefinition The function computes a minimum area enclosing
rectangle $R(P)$ (not necessarily axis-parallel) of a given convex
point set $P$. Note that $R(P)$ is not unique in general. The
restriction to convex sets is not really a restriction, since any
enclosing rectangle -- as a convex set -- contains the convex hull
of $P$.
\ccDefinition The function computes a minimum area enclosing rectangle
$R(P)$ of a given convex point set $P$. Note that $R(P)$ is not
necessarily axis-parallel, and it is in general not unique. The focus
on convex sets is no restriction, since any rectangle enclosing $P$
-- as a convex set -- contains the convex hull of $P$. For general
point sets one has to compute the convex hull as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
\def\ccLongParamLayout{\ccTrue}
@ -32,23 +32,22 @@
OutputIterator o,
Traits& t = Default_traits);}
computes a minimum area enclosing rectangle of the point set
described by [\ccc{points_begin}, \ccc{points_end}), writes its
vertices (counterclockwise) to \ccc{o} and returns the past-the-end
iterator
computes a minimum area enclosing rectangle of the point set described
by [\ccc{points_begin}, \ccc{points_end}), writes its vertices
(counterclockwise) to \ccc{o}, and returns the past-the-end iterator
of this sequence.\\
If the input range is empty, \ccc{o} remains unchanged.\\
If the input range consists of one element only,
exactly this point is written to \ccc{o}.
If the input range consists of one element only, this point is written
to \ccc{o} four times.
\ccPrecond The points denoted by the range [\ccc{points_begin},
\ccc{points_end}) form the boundary of a simple convex polygon $P$
in counterclockwise orientation.
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
The geometric types and operations to be used for the computation are
specified by the traits class parameter \ccc{t}. The parameter can be
omitted, if \ccc{ForwardIterator} refers to a two-dimensional point
type from one the \cgal\ Kernels. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
\ccRequire
@ -67,7 +66,7 @@
\ccRefIdfierPage{CGAL::Min_quadrilateral_default_traits_2<Kernel>}
\ccImplementation We use a rotating caliper
\ccIndexMainItem[t]{rotating caliper} algorithm \cite{t-sgprc-83}
\ccIndexMainItem[t]{rotating caliper} algorithm~\cite{t-sgprc-83}
with worst case running time linear in the number of input points.
\ccExample The following code generates a random convex polygon
@ -84,9 +83,11 @@
\ccDefinition The function computes a minimum area enclosing
parallelogram $A(P)$ of a given convex point set $P$. Note that
$A(P)$ is not unique in general. The restriction to convex sets is
not really a restriction, since any enclosing parallelogram -- as a
convex set -- contains the convex hull of $P$.
$R(P)$ is not necessarily axis-parallel, and it is in general not
unique. The focus on convex sets is no restriction, since any
parallelogram enclosing $P$ -- as a convex set -- contains the convex
hull of $P$. For general point sets one has to compute the convex hull
as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
@ -106,17 +107,17 @@
vertices (counterclockwise) to \ccc{o} and returns the past-the-end
iterator of this sequence.
If the input range is empty, \ccc{o} remains unchanged.\\
If the input range consists of one element only,
exactly this point is written to \ccc{o}.
If the input range consists of one element only, this point is written
to \ccc{o} four times.
\ccPrecond The points denoted by the range [\ccc{points_begin},
\ccc{points_end}) form the boundary of a simple convex polygon $P$
in counterclockwise orientation.
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
are specified by the traits class parameter \ccc{t}. The parameter can be
omitted, if \ccc{ForwardIterator} refers to a two-dimensional point
type from one the \cgal\ Kernels. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
\ccRequire
@ -155,9 +156,10 @@
\ccDefinition The function computes a minimum width enclosing strip
$S(P)$ of a given convex point set $P$. A strip is the closed region
bounded by two parallel lines in the plane. Note that $S(P)$ is not
unique in general. The restriction to convex sets is not really a
restriction, since any enclosing strip -- as a convex set --
contains the convex hull of $P$.
unique in general. The focus on convex sets is no restriction, since any
parallelogram enclosing $P$ -- as a convex set -- contains the convex
hull of $P$. For general point sets one has to compute the convex hull
as a preprocessing step.
\ccInclude{CGAL/min_quadrilateral_2.h}
@ -173,8 +175,8 @@
Traits& t = Default_traits);}
computes a minimum enclosing strip of the point set described by
[\ccc{points_begin}, \ccc{points_end}), writes its bounding lines to
\ccc{o} and returns the past-the-end iterator of this sequence.\\
[\ccc{points_begin}, \ccc{points_end}), writes its two bounding lines
to \ccc{o} and returns the past-the-end iterator of this sequence.\\
If the input range is empty or consists of one element only, \ccc{o}
remains unchanged.
@ -184,17 +186,18 @@
The geometric types and operations to be used for the computation
are specified by the traits class parameter \ccc{t}. The parameter
can be omitted if \ccc{ForwardIterator} refers to a point type from
the 2D-Kernel. In this case, a default traits class
(\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is used.
can be omitted, if \ccc{ForwardIterator} refers to a two-dimensional
point type from one the \cgal\ Kernels. In this case, a default
traits class (\ccc{Min_quadrilateral_default_traits_2<Kernel>}) is
used.
\ccRequire
\begin{enumerate}
\item If \ccc{Traits} is specified, it is a model for
\ccc{MinQuadrilateralTraits_2} and the value type \ccc{VT} of
\ccc{ForwardIterator} is \ccc{Traits::Point_2}. Otherwise \ccc{VT}
\ccc{ForwardIterator} is \ccc{Traits::Point_2}. Otherwise \ccc{VT}
is \ccc{CGAL::Point_2<Kernel>} for some kernel \ccc{Kernel}.
\item \ccc{OutputIterator} accepts \ccc{VT} as value type.
\item \ccc{OutputIterator} accepts \ccc{Traits::Line_2} as value type.
\end{enumerate}
\ccSeeAlso
@ -256,6 +259,8 @@
\ccNestedType{Less_yx_2}{\ccRefConceptPage{Kernel::Less_yx_2}.}
\ccNestedType{Orientation_2}{\ccRefConceptPage{Kernel::Orientation_2}.}
\ccNestedType{Has_on_negative_side_2}
{\ccRefConceptPage{Kernel::Has_on_negative_side_2}.}
@ -414,10 +419,15 @@
than the area of $p2$.}
\ccNestedType{Width_less_strip_2}{AdaptableFunctor \\\ccc{op}:
\ccc{Strip_2} $\times$ \ccc{Strip_2} $\rightarrow$ \ccc{bool}.\\
\ccc{Strip_2} $\times$ \ccc{Strip_2} $\rightarrow$ \ccc{bool}.\\
\ccc{op(s1,s2)} returns true, iff the width of $s1$ is strictly less
than the width of $s2$.}
The following type is used for expensive precondition checking only.
\ccNestedType{Orientation_2}{a model for
\ccRefConceptPage{Kernel::Orientation_2}.}
\ccHeading{Constructions}
\ccNestedType{Construct_vector_2}{a model for

View File

@ -27,42 +27,31 @@
// ============================================================================
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_parallelogram_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing parallelogram p_m of p
Polygon_2 p_m;
min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_parallelogram_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -27,42 +27,31 @@
// ============================================================================
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_rectangle_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << p << endl;
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
std::cout << p << std::endl;
// compute the minimal enclosing rectangle p_m of p
Polygon_2 p_m;
min_rectangle_2(
p.vertices_begin(), p.vertices_end(), back_inserter(p_m));
cout << p_m << endl;
CGAL::min_rectangle_2(
p.vertices_begin(), p.vertices_end(), std::back_inserter(p_m));
std::cout << p_m << std::endl;
return 0;
}

View File

@ -27,41 +27,30 @@
// ============================================================================
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/random_convex_set_2.h>
#include <CGAL/min_quadrilateral_2.h>
#include <vector>
#include <iostream>
using CGAL::Random_points_in_square_2;
using CGAL::random_convex_set_2;
using CGAL::min_strip_2;
using std::back_inserter;
using std::cout;
using std::endl;
struct Kernel : public CGAL::Cartesian<double> {};
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_traits_2<Kernel> P_traits;
typedef std::vector<Point_2> Cont;
typedef CGAL::Polygon_2<P_traits,Cont> Polygon_2;
typedef CGAL::Creator_uniform_2<double,Point_2> Creator;
typedef Random_points_in_square_2<Point_2,Creator> Point_generator;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Line_2 Line_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Random_points_in_square_2<Point_2> Generator;
int main()
{
// build a random convex 20-gon p
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
CGAL::random_convex_set_2(20, std::back_inserter(p), Generator(1.0));
cout << p << endl;
// compute the minimal enclosing strip p_m of p
Line_2 p_m[2];
min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
cout << p_m[0] << "\n" << p_m[1] << endl;
CGAL::min_strip_2(p.vertices_begin(), p.vertices_end(), p_m);
std::cout << p_m[0] << "\n" << p_m[1] << std::endl;
return 0;
}

View File

@ -94,28 +94,31 @@ namespace Optimisation {
template < class K_ >
struct Min_quadrilateral_default_traits_2 {
// types inherited from Kernel
typedef K_ Kernel;
typedef typename Kernel::RT RT;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Vector_2 Vector_2;
typedef typename Kernel::Direction_2 Direction_2;
typedef typename Kernel::Line_2 Line_2;
typedef K_ Kernel;
typedef typename Kernel::RT RT;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Vector_2 Vector_2;
typedef typename Kernel::Direction_2 Direction_2;
typedef typename Kernel::Line_2 Line_2;
// predicates and constructions inherited from Kernel
typedef typename Kernel::Equal_2 Equal_2;
typedef typename Kernel::Less_xy_2 Less_xy_2;
typedef typename Kernel::Less_yx_2 Less_yx_2;
typedef typename Kernel::Has_on_negative_side_2 Has_on_negative_side_2;
typedef typename Kernel::Equal_2 Equal_2;
typedef typename Kernel::Less_xy_2 Less_xy_2;
typedef typename Kernel::Less_yx_2 Less_yx_2;
typedef typename Kernel::Has_on_negative_side_2 Has_on_negative_side_2;
typedef typename Kernel::Compare_angle_with_x_axis_2
Compare_angle_with_x_axis_2;
typedef typename Kernel::Construct_vector_2 Construct_vector_2;
typedef typename Kernel::Construct_direction_2 Construct_direction_2;
typedef typename Kernel::Construct_line_2 Construct_line_2;
typedef typename Kernel::Construct_vector_2 Construct_vector_2;
typedef typename Kernel::Construct_direction_2 Construct_direction_2;
typedef typename Kernel::Construct_line_2 Construct_line_2;
typedef typename Kernel::Construct_perpendicular_vector_2
Construct_perpendicular_vector_2;
typedef typename Kernel::Construct_opposite_direction_2
Construct_opposite_direction_2;
// used for expensive precondition checks only:
typedef typename Kernel::Orientation_2 Orientation_2;
protected:
// used internally
Construct_line_2 line;
@ -423,6 +426,9 @@ public:
Construct_strip_2 construct_strip_2_object() const
{ return Construct_strip_2(); }
Orientation_2 orientation_2_object() const { return Orientation_2(); }
};

View File

@ -355,9 +355,9 @@ min_rectangle_2(
{
typedef Optimisation::Min_quadrilateral_traits_wrapper<BTraits> Traits;
Traits t(bt);
CGAL_optimisation_expensive_precondition(is_convex_2(f, l));
CGAL_optimisation_expensive_precondition(is_convex_2(f, l, t));
CGAL_optimisation_expensive_precondition(
orientation_2(f, l) == COUNTERCLOCKWISE);
orientation_2(f, l, t) == COUNTERCLOCKWISE);
// check for trivial cases
if (f == l) return o;
@ -457,7 +457,7 @@ min_parallelogram_2(ForwardIterator f,
{
typedef Optimisation::Min_quadrilateral_traits_wrapper<BTraits> Traits;
Traits t(bt);
CGAL_optimisation_expensive_precondition(is_convex_2(f, l));
CGAL_optimisation_expensive_precondition(is_convex_2(f, l, t));
// types from the traits class
typedef typename Traits::Direction_2 Direction_2;
@ -639,7 +639,7 @@ min_strip_2(ForwardIterator f,
{
typedef Optimisation::Min_quadrilateral_traits_wrapper<BTraits> Traits;
Traits t(bt);
CGAL_optimisation_expensive_precondition(is_convex_2(f, l));
CGAL_optimisation_expensive_precondition(is_convex_2(f, l, t));
// types from the traits class
typedef typename Traits::Direction_2 Direction_2;

View File

@ -66,6 +66,15 @@ struct MyTraits {
bool operator()(const Point_2& p, const Point_2& q) const
{ return p.yc < q.yc || p.yc == q.yc && p.xc < q.xc; }
};
struct Orientation_2 {
typedef CGAL::Orientation result_type;
typedef CGAL::Arity_tag<3> Arity;
result_type
operator()(const Point_2& p, const Point_2& q, const Point_2& r) const {
return CGAL::orientationC2(p.xc, p.yc, q.xc, q.yc, r.xc, r.yc);
}
};
struct Has_on_negative_side_2
: public std::binary_function<Line_2,Point_2,bool>
{
@ -319,6 +328,9 @@ struct MyTraits {
Construct_strip_2 construct_strip_2_object() const
{ return Construct_strip_2(); }
Orientation_2 orientation_2_object() const { return Orientation_2(); }
friend class Data;
};

View File

@ -1 +1 @@
1.25 (26 August 2003)
1.26 (28 August 2003)