mirror of https://github.com/CGAL/cgal
Redesigned version of first public release
This commit is contained in:
parent
f0c0a47ebe
commit
22196b1cc6
|
|
@ -1,31 +1,33 @@
|
||||||
% =============================================================================
|
% =============================================================================
|
||||||
% The CGAL Reference Manual
|
% The CGAL Reference Manual
|
||||||
|
% Chapter: Optimisation
|
||||||
% Section: 2D Smallest Enclosing Circle
|
% Section: 2D Smallest Enclosing Circle
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
% file : Library/spec/Min_circle_2.tex
|
% file : spec/Optimisation/Min_circle_2.tex
|
||||||
% author: Bernd Gärtner, Sven Schönherr (sven@inf.fu-berlin.de)
|
% author: Bernd Gärtner, Sven Schönherr (sven@inf.fu-berlin.de)
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
% $Revision$
|
% $Revision$
|
||||||
% $Date$
|
% $Date$
|
||||||
% =============================================================================
|
% =============================================================================
|
||||||
|
|
||||||
\begin{ccClassTemplate}{CGAL_Min_circle_2<I>}
|
\begin{ccClassTemplate}{CGAL_Min_circle_2<Traits>}
|
||||||
\ccSection{2D Smallest Enclosing Circle}
|
\ccSection{2D Smallest Enclosing Circle}
|
||||||
|
\label{sec:min_circle_2_spec}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccDefinition
|
\ccDefinition
|
||||||
|
|
||||||
An object of the class \ccClassTemplateName\ is the unique circle of
|
An object of the class \ccClassTemplateName\ is the unique circle of
|
||||||
smallest area enclosing a finite set of points in two-dimensional
|
smallest area enclosing a finite set of points in two-dimensional
|
||||||
euclidean space $\E_2$. For a point set $P$ we denote by $mc(P)$ the
|
Euclidean plane $\E_2$. For a point set $P$ we denote by $mc(P)$ the
|
||||||
smallest circle that contains all points of $P$. Note that $mc(P)$ can
|
smallest circle that contains all points of $P$. Note that $mc(P)$ can
|
||||||
be degenerate, i.e.\ $mc(P)=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$
|
be degenerate, i.e.\ $mc(P)=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$
|
||||||
if $P=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$ and $mc(P)=\{p\}$ if
|
if $P=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$ and $mc(P)=\{p\}$ if
|
||||||
$P=\{p\}$.
|
$P=\{p\}$.
|
||||||
|
|
||||||
An inclusion-minimal subset $S$ of $P$ with $mc(S)=mc(P)$ is called a
|
An inclusion-minimal subset $S$ of $P$ with $mc(S)=mc(P)$ is called a
|
||||||
{\em support set}, the points in $S$ are the {\em support points}. A
|
\emph{support set}, the points in $S$ are the \emph{support points}.
|
||||||
support set has size at most three, and all its points lie on the
|
A support set has size at most three, and all its points lie on the
|
||||||
boundary of $mc(P)$. If $mc(P)$ has more than three points on the
|
boundary of $mc(P)$. If $mc(P)$ has more than three points on the
|
||||||
boundary, neither the support set nor its size are necessarily unique.
|
boundary, neither the support set nor its size are necessarily unique.
|
||||||
|
|
||||||
|
|
@ -35,45 +37,43 @@ computes a support set $S$ which remains fixed until the next insert
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
\emph{Note:} In this release correct results are only guaranteed if
|
\emph{Note:} In this release correct results are only guaranteed if
|
||||||
exact arithmetic is used, see Section~\ref{sec:opt_I_Impl}.
|
exact arithmetic is used, see Section~\ref{sec:opt_traits_impl}.
|
||||||
|
|
||||||
\ccInclude{CGAL/Min_circle_2.h}
|
\ccInclude{CGAL/Min_circle_2.h}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Interface}
|
\ccHeading{Traits Class}
|
||||||
|
|
||||||
The template parameter \ccc{I} is the interface class for optimisation
|
The template parameter \ccc{Traits} is a traits class that defines the
|
||||||
algorithms. It is a traits class that defines the interface between
|
abstract interface between the optimisation algorithm and the
|
||||||
optimisation algorithms and the primitives they use. For example
|
primitives it uses. For example \ccc{Traits::Point} is a mapping on a
|
||||||
\ccc{I::Point} is a mapping on a point class. Think of it as 2D points
|
point class. Think of it as 2D points in the Euclidean plane.
|
||||||
in the Euclidean plane.
|
|
||||||
|
|
||||||
\cgal\ provides a ready-made implementation for the interface class as
|
We provide a traits class implementation using the \cgal\ 2D kernel as
|
||||||
described in Section~\ref{sec:opt_I_Impl}. Customizing own interface
|
described in Section~\ref{sec:opt_traits_impl}. Traits class adapters
|
||||||
classes for optimisation algorithms can be done according to the
|
to user supplied point classes are available, see
|
||||||
requirements for interface classes listed in Section~\ref{sec:opt_I_Req}.
|
Section~\ref{sec:opt_traits_adapt}. Customizing own traits classes for
|
||||||
|
optimisation algorithms can be done according to the requirements for
|
||||||
|
traits classes listed in Section~\ref{sec:opt_traits_req}.
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccTypes
|
\ccTypes
|
||||||
|
|
||||||
\ccNestedType{I}{Interface type.}
|
\ccNestedType{Traits}{}
|
||||||
|
|
||||||
\ccGlueBegin
|
\ccGlueBegin
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccTypedef{typedef I::Point Point; }{Point type.}
|
\ccTypedef{typedef Traits::Point Point; }{Point type.}
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccTypedef{typedef I::Distance Distance;}{Distance type.}
|
\ccTypedef{typedef Traits::Circle Circle;}{Circle type.}
|
||||||
\ccGlueEnd
|
\ccGlueEnd
|
||||||
|
|
||||||
\ccUnchecked
|
|
||||||
\ccTypedef{typedef I::Circle Circle; }{Circle type.}
|
|
||||||
|
|
||||||
The following types denote iterators that allow to traverse all points
|
The following types denote iterators that allow to traverse all points
|
||||||
and support points of the smallest enclosing circle, resp. The
|
and support points of the smallest enclosing circle, resp. The
|
||||||
iterators are non-mutable and their value type is \ccc{Point}. The
|
iterators are non-mutable and their value type is \ccc{Point}. The
|
||||||
iterator category is given in parentheses.
|
iterator category is given in parentheses.
|
||||||
|
|
||||||
\ccSetTwoColumns{CGAL_Min_circle_2<I>:: Support_point_iterator}{}
|
\ccSetTwoColumns{CGAL_Min_circle_2<Traits>:: Support_point_iterator}{}
|
||||||
|
|
||||||
\ccNestedType{Point_iterator}{(bidirectional).}
|
\ccNestedType{Point_iterator}{(bidirectional).}
|
||||||
|
|
||||||
|
|
@ -90,44 +90,14 @@ set $P$ and by specialized construction methods expecting no, one, two
|
||||||
or three points as arguments. The latter methods can be useful for
|
or three points as arguments. The latter methods can be useful for
|
||||||
reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to
|
|
||||||
$mc(\mbox{\ccTexHtml{$\emptyset$}{Ø}})$, the empty set.
|
|
||||||
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
|
||||||
|
|
||||||
\ccUnchecked
|
|
||||||
\ccHidden
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( CGAL_Min_circle_2<I> const&);}{
|
|
||||||
copy constructor.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p, I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p\})$, the set $\{p\}$.
|
|
||||||
\ccPostcond \ccVar\ccc{.is_degenerate()} = \ccc{true}.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
|
||||||
Point const& p2,
|
|
||||||
I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p1,p2\})$, the circle with diameter
|
|
||||||
equal to the segment connecting $p1$ and $p2$.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
|
||||||
Point const& p2,
|
|
||||||
Point const& p3,
|
|
||||||
I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p1,p2,p3\})$.}
|
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccConstructor{ template < class InputIterator >
|
\ccConstructor{ template < class InputIterator >
|
||||||
CGAL_Min_circle_2( InputIterator first,
|
CGAL_Min_circle_2( InputIterator first,
|
||||||
InputIterator last,
|
InputIterator last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName. It
|
creates a variable \ccVar\ of type \ccClassTemplateName. It
|
||||||
is initialized to $mc(P)$ with $P$ being the set of points in
|
is initialized to $mc(P)$ with $P$ being the set of points in
|
||||||
the range [\ccc{first},\ccc{last}). If \ccc{randomize} is
|
the range [\ccc{first},\ccc{last}). If \ccc{randomize} is
|
||||||
\ccc{true}, a random permutation of $P$ is computed in
|
\ccc{true}, a random permutation of $P$ is computed in
|
||||||
|
|
@ -139,17 +109,18 @@ reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
||||||
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
||||||
\ccc{Point}.}
|
\ccc{Point}.}
|
||||||
|
|
||||||
{\em Note:} Since most compilers do not support member templates yet,
|
\emph{Note:} Since most compilers do not support template member functions
|
||||||
we provide specialized constructors instead. In the current release
|
yet, we provide specialized constructors instead. In the current release
|
||||||
there are constructors for C arrays (using pointers as iterators) and
|
there are constructors for C arrays (using pointers as iterators), for the
|
||||||
for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
\stl\ sequence containers \ccc{vector<Point>} and \ccc{list<Point>} and for
|
||||||
|
the \stl\ input stream iterator \ccc{istream_iterator<Point>}.
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccConstructor{ CGAL_Min_circle_2( const Point* first,
|
\ccConstructor{ CGAL_Min_circle_2( const Point* first,
|
||||||
const Point* last,
|
const Point* last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
STL-like constructor for random access iterators.}
|
STL-like constructor for random access iterators.}
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
|
|
@ -157,17 +128,58 @@ for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
||||||
list<Point>::const_iterator last,
|
list<Point>::const_iterator last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
STL-like constructor for sequence container list<Point>.}
|
STL-like constructor for sequence container list<Point>.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( istream_iterator<Point,ptrdiff_t> first,
|
||||||
|
istream_iterator<Point,ptrdiff_t> last,
|
||||||
|
bool randomize = false,
|
||||||
|
CGAL_Random& random = CGAL_random,
|
||||||
|
Traits const& traits = Traits() );}{
|
||||||
|
STL-like constructor for input stream iterator
|
||||||
|
istream_iterator<Point,ptrdiff_t>.}
|
||||||
|
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to
|
||||||
|
$mc(\mbox{\ccTexHtml{$\emptyset$}{Ø}})$, the empty set.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p\})$, the set $\{p\}$.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_degenerate()} = \ccc{true}.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
||||||
|
Point const& p2,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p1,p2\})$, the circle with diameter
|
||||||
|
equal to the segment connecting $p1$ and $p2$.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
||||||
|
Point const& p2,
|
||||||
|
Point const& p3,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p1,p2,p3\})$.}
|
||||||
|
|
||||||
|
\ccUnchecked
|
||||||
|
\ccHidden
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( CGAL_Min_circle_2<Traits> const&);}{
|
||||||
|
copy constructor.}
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccConstructor{ ~CGAL_Min_circle_2( );}{
|
\ccConstructor{ ~CGAL_Min_circle_2( );}{
|
||||||
destructor.}
|
destructor.}
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccMemberFunction{ CGAL_Min_circle_2<I>&
|
\ccMemberFunction{ CGAL_Min_circle_2<Traits>&
|
||||||
operator = ( CGAL_Min_circle_2<I> const&);}{
|
operator = ( CGAL_Min_circle_2<Traits> const&);}{
|
||||||
assignment operator.}
|
assignment operator.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
|
|
@ -179,29 +191,32 @@ for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
||||||
\ccMemberFunction{ int number_of_support_points( ) const;}{
|
\ccMemberFunction{ int number_of_support_points( ) const;}{
|
||||||
returns the number of support points of \ccVar, i.e.\ $|S|$.}
|
returns the number of support points of \ccVar, i.e.\ $|S|$.}
|
||||||
|
|
||||||
|
\ccGlueBegin
|
||||||
\ccMemberFunction{ Point_iterator points_begin() const;}{
|
\ccMemberFunction{ Point_iterator points_begin() const;}{
|
||||||
returns an iterator referring to the first point of \ccVar.}
|
returns an iterator referring to the first point of \ccVar.}
|
||||||
|
%
|
||||||
\ccMemberFunction{ Point_iterator points_end() const;}{
|
\ccMemberFunction{ Point_iterator points_end() const;}{
|
||||||
returns the corresponding past-the-end iterator.}
|
returns the corresponding past-the-end iterator.}
|
||||||
|
\ccGlueEnd
|
||||||
|
|
||||||
|
\ccGlueBegin
|
||||||
\ccMemberFunction{ Support_point_iterator support_points_begin() const;}{
|
\ccMemberFunction{ Support_point_iterator support_points_begin() const;}{
|
||||||
returns an iterator referring to the first support point of \ccVar.}
|
returns an iterator referring to the first support point of \ccVar.}
|
||||||
|
%
|
||||||
\ccMemberFunction{ Support_point_iterator support_points_end() const;}{
|
\ccMemberFunction{ Support_point_iterator support_points_end() const;}{
|
||||||
returns the corresponding past-the-end iterator.}
|
returns the corresponding past-the-end iterator.}
|
||||||
|
\ccGlueEnd
|
||||||
|
|
||||||
\ccMemberFunction{ Point const& support_point( int i) const;}{
|
\ccMemberFunction{ Point const& support_point( int i) const;}{
|
||||||
returns the \ccc{i}-th support point of \ccVar. Between two
|
returns the \ccc{i}-th support point of \ccVar. Between two
|
||||||
insert operations any call to \ccVar\ccc{.support_point(i)}
|
modifying operations (see below) any call to
|
||||||
with the same \ccc{i} returns the same point.
|
\ccVar\ccc{.support_point(i)} with the same \ccc{i} returns
|
||||||
|
the same point.
|
||||||
\ccPrecond $0 \leq i< \mbox{\ccVar\ccc{.number_of_support_points()}}$.}
|
\ccPrecond $0 \leq i< \mbox{\ccVar\ccc{.number_of_support_points()}}$.}
|
||||||
|
|
||||||
\ccMemberFunction{ Circle circle( ) const;}{
|
\ccMemberFunction{ Circle const& circle( ) const;}{
|
||||||
returns a circle with same center and same squared radius
|
returns a circle with same center and same squared radius
|
||||||
as \ccVar, if \ccVar is not empty. Otherwise the default
|
as \ccVar.}
|
||||||
circle, i.e.\ \ccc{Circle()}, is returned.}
|
|
||||||
|
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccPredicates
|
\ccPredicates
|
||||||
|
|
@ -236,7 +251,7 @@ bounded side, i.e.\ its unbounded side equals the whole plane $\E_2$.
|
||||||
the number of support points is less than 2.}
|
the number of support points is less than 2.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Modifiers}
|
\ccModifiers
|
||||||
|
|
||||||
New points can be added to an existing \ccVar, allowing to build
|
New points can be added to an existing \ccVar, allowing to build
|
||||||
$mc(P)$ incrementally, e.g.\ if $P$ is not known in advance. Compared
|
$mc(P)$ incrementally, e.g.\ if $P$ is not known in advance. Compared
|
||||||
|
|
@ -247,6 +262,44 @@ the construction method is incremental itself.
|
||||||
inserts \ccc{p} into \ccVar\ and recomputes the smallest
|
inserts \ccc{p} into \ccVar\ and recomputes the smallest
|
||||||
enclosing circle.}
|
enclosing circle.}
|
||||||
|
|
||||||
|
\ccUnchecked
|
||||||
|
\ccMemberFunction{ template < class InputIterator >
|
||||||
|
void insert( InputIterator first,
|
||||||
|
InputIterator last );}{
|
||||||
|
inserts the points in the range [\ccc{first},\ccc{last})
|
||||||
|
into \ccVar\ and recomputes the smallest enclosing circle by
|
||||||
|
calling \ccc{insert(p)} for each point \ccc{p} in
|
||||||
|
[\ccc{first},\ccc{last}).
|
||||||
|
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
||||||
|
\ccc{Point}.}
|
||||||
|
|
||||||
|
\emph{Note:} Since most compilers do not support template member functions
|
||||||
|
yet, we provide specialized \ccc{insert} functions instead. In the current
|
||||||
|
release there are \ccc{insert} functions for C arrays (using pointers as
|
||||||
|
iterators), for the \stl\ sequence containers \ccc{vector<Point>} and
|
||||||
|
\ccc{list<Point>} and for the \stl\ input stream iterator
|
||||||
|
\ccc{istream_iterator<Point>}.
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( const Point* first,
|
||||||
|
const Point* last );}{
|
||||||
|
STL-like `insert' function for random access iterators.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( list<Point>::const_iterator first,
|
||||||
|
list<Point>::const_iterator last );}{
|
||||||
|
STL-like `insert' function for sequence container list<Point>.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( istream_iterator<Point,ptrdiff_t> first,
|
||||||
|
istream_iterator<Point,ptrdiff_t> last );}{
|
||||||
|
STL-like `insert' function for input stream iterator
|
||||||
|
istream_iterator<Point,ptrdiff_t>.}
|
||||||
|
|
||||||
|
\ccMemberFunction{ void clear( );}{
|
||||||
|
deletes all points in \ccVar\ and sets \ccVar\ to the empty set.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Validity Check}
|
\ccHeading{Validity Check}
|
||||||
|
|
||||||
|
|
@ -256,11 +309,12 @@ An object \ccVar\ is valid, iff
|
||||||
\item \ccVar\ is the smallest circle spanned by its support set $S$, and
|
\item \ccVar\ is the smallest circle spanned by its support set $S$, and
|
||||||
\item $S$ is minimal, i.e.\ no support point is redundant.
|
\item $S$ is minimal, i.e.\ no support point is redundant.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
Using the ready-made implementation for the interface class with exact
|
Using the traits class implementation for the \cgal\ kernel with exact
|
||||||
arithmetic as described in Section~\ref{sec:opt_I_Impl} guarantees
|
arithmetic as described in Section~\ref{sec:opt_traits_impl}
|
||||||
validity of \ccVar. The following function is mainly intended for
|
guarantees validity of \ccVar. The following function is mainly
|
||||||
debugging user supplied interface classes.
|
intended for debugging user supplied traits classes but also for
|
||||||
|
convincing the anxious user that the traits class implementation is
|
||||||
|
correct.
|
||||||
\begin{ccAdvanced}
|
\begin{ccAdvanced}
|
||||||
\ccMemberFunction{ bool is_valid( bool verbose = false,
|
\ccMemberFunction{ bool is_valid( bool verbose = false,
|
||||||
int level = 0 ) const;}{
|
int level = 0 ) const;}{
|
||||||
|
|
@ -271,29 +325,36 @@ debugging user supplied interface classes.
|
||||||
with interfaces of other classes.}
|
with interfaces of other classes.}
|
||||||
\end{ccAdvanced}
|
\end{ccAdvanced}
|
||||||
|
|
||||||
|
% -----------------------------------------------------------------------------
|
||||||
|
\ccHeading{Miscellaneous}
|
||||||
|
|
||||||
|
\ccMemberFunction{ Traits const& traits( ) const;}{
|
||||||
|
returns a const reference to the traits class object.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{I/O}
|
\ccHeading{I/O}
|
||||||
|
|
||||||
\ccFunction{ ostream& operator << ( ostream& os,
|
\ccFunction{ ostream& operator << ( ostream& os,
|
||||||
CGAL_Min_circle_2<I> const& min_circle);}{
|
CGAL_Min_circle_2<Traits> const&
|
||||||
|
min_circle);}{
|
||||||
writes \ccVar\ to output stream \ccc{os}.
|
writes \ccVar\ to output stream \ccc{os}.
|
||||||
\ccPrecond The output operator is defined for \ccc{I::Point}
|
\ccPrecond The output operator is defined for \ccc{Point}
|
||||||
(and for \ccc{I::Circle}, if pretty printing is used).}
|
(and for \ccc{Circle}, if pretty printing is used).}
|
||||||
|
|
||||||
\ccFunction{ istream& operator >> ( istream& is,
|
\ccFunction{ istream& operator >> ( istream& is,
|
||||||
CGAL_Min_circle_2<I> &min_circle);}{
|
CGAL_Min_circle_2<Traits> &min_circle);}{
|
||||||
reads \ccVar\ from input stream \ccc{is}.
|
reads \ccVar\ from input stream \ccc{is}.
|
||||||
\ccPrecond The input operator is defined for \ccc{I::Point}.}
|
\ccPrecond The input operator is defined for \ccc{Point}.}
|
||||||
|
|
||||||
\ccInclude{CGAL/IO/Window_stream.h}
|
\ccInclude{CGAL/IO/Window_stream.h}
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccFunction{ CGAL_Window_stream&
|
\ccFunction{ CGAL_Window_stream&
|
||||||
operator << ( CGAL_Window_stream& ws,
|
operator << ( CGAL_Window_stream& ws,
|
||||||
CGAL_Min_circle_2<I> const& min_circle);}{
|
CGAL_Min_circle_2<Traits> const& min_circle);}{
|
||||||
writes \ccVar\ to window stream \ccc{ws}.
|
writes \ccVar\ to window stream \ccc{ws}.
|
||||||
\ccPrecond The window stream output operator is defined for
|
\ccPrecond The window stream output operator is defined for
|
||||||
\ccc{I::Point} and \ccc{I::Circle}.}
|
\ccc{Point} and \ccc{Circle}.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccImplementation
|
\ccImplementation
|
||||||
|
|
@ -303,8 +364,8 @@ heuristic~\cite{w-sedbe-91a}. If randomization is chosen, the creation
|
||||||
time is almost always linear in the number of points. Access functions
|
time is almost always linear in the number of points. Access functions
|
||||||
and predicates take constant time, inserting a point might take up to
|
and predicates take constant time, inserting a point might take up to
|
||||||
linear time, but substantially less than computing the new smallest
|
linear time, but substantially less than computing the new smallest
|
||||||
enclosing circle from scratch. The check for validity takes linear
|
enclosing circle from scratch. The clear operation and the check for
|
||||||
time.
|
validity each takes linear time.
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccExample
|
\ccExample
|
||||||
|
|
@ -315,12 +376,15 @@ randomization can be useful in certain cases, we give an example.
|
||||||
\begin{cprog}
|
\begin{cprog}
|
||||||
#include <CGAL/Integer.h>
|
#include <CGAL/Integer.h>
|
||||||
#include <CGAL/Homogeneous.h>
|
#include <CGAL/Homogeneous.h>
|
||||||
|
#include <CGAL/Point_2.h>
|
||||||
|
#include <CGAL/Optimisation_traits_2.h>
|
||||||
#include <CGAL/Min_circle_2.h>
|
#include <CGAL/Min_circle_2.h>
|
||||||
|
|
||||||
typedef CGAL_Homogeneous<integer> R;
|
typedef integer NT;
|
||||||
|
typedef CGAL_Homogeneous<NT> R;
|
||||||
typedef CGAL_Point_2<R> Point;
|
typedef CGAL_Point_2<R> Point;
|
||||||
typedef CGAL_Min_circle_2< CGAL_Optimisation_default_interface<R> >
|
typedef CGAL_Optimisation_traits_2<R> Traits;
|
||||||
Min_circle;
|
typedef CGAL_Min_circle_2<Traits> Min_circle;
|
||||||
|
|
||||||
int n = 1000;
|
int n = 1000;
|
||||||
Point* P = new Point[ n];
|
Point* P = new Point[ n];
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,33 @@
|
||||||
% =============================================================================
|
% =============================================================================
|
||||||
% The CGAL Reference Manual
|
% The CGAL Reference Manual
|
||||||
|
% Chapter: Optimisation
|
||||||
% Section: 2D Smallest Enclosing Circle
|
% Section: 2D Smallest Enclosing Circle
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
% file : Library/spec/Min_circle_2.tex
|
% file : spec/Optimisation/Min_circle_2.tex
|
||||||
% author: Bernd Gärtner, Sven Schönherr (sven@inf.fu-berlin.de)
|
% author: Bernd Gärtner, Sven Schönherr (sven@inf.fu-berlin.de)
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
% $Revision$
|
% $Revision$
|
||||||
% $Date$
|
% $Date$
|
||||||
% =============================================================================
|
% =============================================================================
|
||||||
|
|
||||||
\begin{ccClassTemplate}{CGAL_Min_circle_2<I>}
|
\begin{ccClassTemplate}{CGAL_Min_circle_2<Traits>}
|
||||||
\ccSection{2D Smallest Enclosing Circle}
|
\ccSection{2D Smallest Enclosing Circle}
|
||||||
|
\label{sec:min_circle_2_spec}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccDefinition
|
\ccDefinition
|
||||||
|
|
||||||
An object of the class \ccClassTemplateName\ is the unique circle of
|
An object of the class \ccClassTemplateName\ is the unique circle of
|
||||||
smallest area enclosing a finite set of points in two-dimensional
|
smallest area enclosing a finite set of points in two-dimensional
|
||||||
euclidean space $\E_2$. For a point set $P$ we denote by $mc(P)$ the
|
Euclidean plane $\E_2$. For a point set $P$ we denote by $mc(P)$ the
|
||||||
smallest circle that contains all points of $P$. Note that $mc(P)$ can
|
smallest circle that contains all points of $P$. Note that $mc(P)$ can
|
||||||
be degenerate, i.e.\ $mc(P)=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$
|
be degenerate, i.e.\ $mc(P)=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$
|
||||||
if $P=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$ and $mc(P)=\{p\}$ if
|
if $P=\mbox{\ccTexHtml{$\;\emptyset$}{Ø}}$ and $mc(P)=\{p\}$ if
|
||||||
$P=\{p\}$.
|
$P=\{p\}$.
|
||||||
|
|
||||||
An inclusion-minimal subset $S$ of $P$ with $mc(S)=mc(P)$ is called a
|
An inclusion-minimal subset $S$ of $P$ with $mc(S)=mc(P)$ is called a
|
||||||
{\em support set}, the points in $S$ are the {\em support points}. A
|
\emph{support set}, the points in $S$ are the \emph{support points}.
|
||||||
support set has size at most three, and all its points lie on the
|
A support set has size at most three, and all its points lie on the
|
||||||
boundary of $mc(P)$. If $mc(P)$ has more than three points on the
|
boundary of $mc(P)$. If $mc(P)$ has more than three points on the
|
||||||
boundary, neither the support set nor its size are necessarily unique.
|
boundary, neither the support set nor its size are necessarily unique.
|
||||||
|
|
||||||
|
|
@ -35,45 +37,43 @@ computes a support set $S$ which remains fixed until the next insert
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
\emph{Note:} In this release correct results are only guaranteed if
|
\emph{Note:} In this release correct results are only guaranteed if
|
||||||
exact arithmetic is used, see Section~\ref{sec:opt_I_Impl}.
|
exact arithmetic is used, see Section~\ref{sec:opt_traits_impl}.
|
||||||
|
|
||||||
\ccInclude{CGAL/Min_circle_2.h}
|
\ccInclude{CGAL/Min_circle_2.h}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Interface}
|
\ccHeading{Traits Class}
|
||||||
|
|
||||||
The template parameter \ccc{I} is the interface class for optimisation
|
The template parameter \ccc{Traits} is a traits class that defines the
|
||||||
algorithms. It is a traits class that defines the interface between
|
abstract interface between the optimisation algorithm and the
|
||||||
optimisation algorithms and the primitives they use. For example
|
primitives it uses. For example \ccc{Traits::Point} is a mapping on a
|
||||||
\ccc{I::Point} is a mapping on a point class. Think of it as 2D points
|
point class. Think of it as 2D points in the Euclidean plane.
|
||||||
in the Euclidean plane.
|
|
||||||
|
|
||||||
\cgal\ provides a ready-made implementation for the interface class as
|
We provide a traits class implementation using the \cgal\ 2D kernel as
|
||||||
described in Section~\ref{sec:opt_I_Impl}. Customizing own interface
|
described in Section~\ref{sec:opt_traits_impl}. Traits class adapters
|
||||||
classes for optimisation algorithms can be done according to the
|
to user supplied point classes are available, see
|
||||||
requirements for interface classes listed in Section~\ref{sec:opt_I_Req}.
|
Section~\ref{sec:opt_traits_adapt}. Customizing own traits classes for
|
||||||
|
optimisation algorithms can be done according to the requirements for
|
||||||
|
traits classes listed in Section~\ref{sec:opt_traits_req}.
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccTypes
|
\ccTypes
|
||||||
|
|
||||||
\ccNestedType{I}{Interface type.}
|
\ccNestedType{Traits}{}
|
||||||
|
|
||||||
\ccGlueBegin
|
\ccGlueBegin
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccTypedef{typedef I::Point Point; }{Point type.}
|
\ccTypedef{typedef Traits::Point Point; }{Point type.}
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccTypedef{typedef I::Distance Distance;}{Distance type.}
|
\ccTypedef{typedef Traits::Circle Circle;}{Circle type.}
|
||||||
\ccGlueEnd
|
\ccGlueEnd
|
||||||
|
|
||||||
\ccUnchecked
|
|
||||||
\ccTypedef{typedef I::Circle Circle; }{Circle type.}
|
|
||||||
|
|
||||||
The following types denote iterators that allow to traverse all points
|
The following types denote iterators that allow to traverse all points
|
||||||
and support points of the smallest enclosing circle, resp. The
|
and support points of the smallest enclosing circle, resp. The
|
||||||
iterators are non-mutable and their value type is \ccc{Point}. The
|
iterators are non-mutable and their value type is \ccc{Point}. The
|
||||||
iterator category is given in parentheses.
|
iterator category is given in parentheses.
|
||||||
|
|
||||||
\ccSetTwoColumns{CGAL_Min_circle_2<I>:: Support_point_iterator}{}
|
\ccSetTwoColumns{CGAL_Min_circle_2<Traits>:: Support_point_iterator}{}
|
||||||
|
|
||||||
\ccNestedType{Point_iterator}{(bidirectional).}
|
\ccNestedType{Point_iterator}{(bidirectional).}
|
||||||
|
|
||||||
|
|
@ -90,44 +90,14 @@ set $P$ and by specialized construction methods expecting no, one, two
|
||||||
or three points as arguments. The latter methods can be useful for
|
or three points as arguments. The latter methods can be useful for
|
||||||
reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to
|
|
||||||
$mc(\mbox{\ccTexHtml{$\emptyset$}{Ø}})$, the empty set.
|
|
||||||
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
|
||||||
|
|
||||||
\ccUnchecked
|
|
||||||
\ccHidden
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( CGAL_Min_circle_2<I> const&);}{
|
|
||||||
copy constructor.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p, I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p\})$, the set $\{p\}$.
|
|
||||||
\ccPostcond \ccVar\ccc{.is_degenerate()} = \ccc{true}.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
|
||||||
Point const& p2,
|
|
||||||
I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p1,p2\})$, the circle with diameter
|
|
||||||
equal to the segment connecting $p1$ and $p2$.}
|
|
||||||
|
|
||||||
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
|
||||||
Point const& p2,
|
|
||||||
Point const& p3,
|
|
||||||
I const& i = I());}{
|
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName.
|
|
||||||
It is initialized to $mc(\{p1,p2,p3\})$.}
|
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccConstructor{ template < class InputIterator >
|
\ccConstructor{ template < class InputIterator >
|
||||||
CGAL_Min_circle_2( InputIterator first,
|
CGAL_Min_circle_2( InputIterator first,
|
||||||
InputIterator last,
|
InputIterator last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
introduces a variable \ccVar\ of type \ccClassTemplateName. It
|
creates a variable \ccVar\ of type \ccClassTemplateName. It
|
||||||
is initialized to $mc(P)$ with $P$ being the set of points in
|
is initialized to $mc(P)$ with $P$ being the set of points in
|
||||||
the range [\ccc{first},\ccc{last}). If \ccc{randomize} is
|
the range [\ccc{first},\ccc{last}). If \ccc{randomize} is
|
||||||
\ccc{true}, a random permutation of $P$ is computed in
|
\ccc{true}, a random permutation of $P$ is computed in
|
||||||
|
|
@ -139,17 +109,18 @@ reconstructing $mc(P)$ from a given support set $S$ of $P$.
|
||||||
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
||||||
\ccc{Point}.}
|
\ccc{Point}.}
|
||||||
|
|
||||||
{\em Note:} Since most compilers do not support member templates yet,
|
\emph{Note:} Since most compilers do not support template member functions
|
||||||
we provide specialized constructors instead. In the current release
|
yet, we provide specialized constructors instead. In the current release
|
||||||
there are constructors for C arrays (using pointers as iterators) and
|
there are constructors for C arrays (using pointers as iterators), for the
|
||||||
for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
\stl\ sequence containers \ccc{vector<Point>} and \ccc{list<Point>} and for
|
||||||
|
the \stl\ input stream iterator \ccc{istream_iterator<Point>}.
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccConstructor{ CGAL_Min_circle_2( const Point* first,
|
\ccConstructor{ CGAL_Min_circle_2( const Point* first,
|
||||||
const Point* last,
|
const Point* last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
STL-like constructor for random access iterators.}
|
STL-like constructor for random access iterators.}
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
|
|
@ -157,17 +128,58 @@ for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
||||||
list<Point>::const_iterator last,
|
list<Point>::const_iterator last,
|
||||||
bool randomize = false,
|
bool randomize = false,
|
||||||
CGAL_Random& random = CGAL_random,
|
CGAL_Random& random = CGAL_random,
|
||||||
I const& i = I() );}{
|
Traits const& traits = Traits() );}{
|
||||||
STL-like constructor for sequence container list<Point>.}
|
STL-like constructor for sequence container list<Point>.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( istream_iterator<Point,ptrdiff_t> first,
|
||||||
|
istream_iterator<Point,ptrdiff_t> last,
|
||||||
|
bool randomize = false,
|
||||||
|
CGAL_Random& random = CGAL_random,
|
||||||
|
Traits const& traits = Traits() );}{
|
||||||
|
STL-like constructor for input stream iterator
|
||||||
|
istream_iterator<Point,ptrdiff_t>.}
|
||||||
|
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to
|
||||||
|
$mc(\mbox{\ccTexHtml{$\emptyset$}{Ø}})$, the empty set.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p\})$, the set $\{p\}$.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_degenerate()} = \ccc{true}.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
||||||
|
Point const& p2,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p1,p2\})$, the circle with diameter
|
||||||
|
equal to the segment connecting $p1$ and $p2$.}
|
||||||
|
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( Point const& p1,
|
||||||
|
Point const& p2,
|
||||||
|
Point const& p3,
|
||||||
|
Traits const& traits = Traits());}{
|
||||||
|
creates a variable \ccVar\ of type \ccClassTemplateName.
|
||||||
|
It is initialized to $mc(\{p1,p2,p3\})$.}
|
||||||
|
|
||||||
|
\ccUnchecked
|
||||||
|
\ccHidden
|
||||||
|
\ccConstructor{ CGAL_Min_circle_2( CGAL_Min_circle_2<Traits> const&);}{
|
||||||
|
copy constructor.}
|
||||||
|
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccConstructor{ ~CGAL_Min_circle_2( );}{
|
\ccConstructor{ ~CGAL_Min_circle_2( );}{
|
||||||
destructor.}
|
destructor.}
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccHidden
|
\ccHidden
|
||||||
\ccMemberFunction{ CGAL_Min_circle_2<I>&
|
\ccMemberFunction{ CGAL_Min_circle_2<Traits>&
|
||||||
operator = ( CGAL_Min_circle_2<I> const&);}{
|
operator = ( CGAL_Min_circle_2<Traits> const&);}{
|
||||||
assignment operator.}
|
assignment operator.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
|
|
@ -179,29 +191,32 @@ for the STL sequence containers \ccc{vector<Point>} and \ccc{list<Point>}.
|
||||||
\ccMemberFunction{ int number_of_support_points( ) const;}{
|
\ccMemberFunction{ int number_of_support_points( ) const;}{
|
||||||
returns the number of support points of \ccVar, i.e.\ $|S|$.}
|
returns the number of support points of \ccVar, i.e.\ $|S|$.}
|
||||||
|
|
||||||
|
\ccGlueBegin
|
||||||
\ccMemberFunction{ Point_iterator points_begin() const;}{
|
\ccMemberFunction{ Point_iterator points_begin() const;}{
|
||||||
returns an iterator referring to the first point of \ccVar.}
|
returns an iterator referring to the first point of \ccVar.}
|
||||||
|
%
|
||||||
\ccMemberFunction{ Point_iterator points_end() const;}{
|
\ccMemberFunction{ Point_iterator points_end() const;}{
|
||||||
returns the corresponding past-the-end iterator.}
|
returns the corresponding past-the-end iterator.}
|
||||||
|
\ccGlueEnd
|
||||||
|
|
||||||
|
\ccGlueBegin
|
||||||
\ccMemberFunction{ Support_point_iterator support_points_begin() const;}{
|
\ccMemberFunction{ Support_point_iterator support_points_begin() const;}{
|
||||||
returns an iterator referring to the first support point of \ccVar.}
|
returns an iterator referring to the first support point of \ccVar.}
|
||||||
|
%
|
||||||
\ccMemberFunction{ Support_point_iterator support_points_end() const;}{
|
\ccMemberFunction{ Support_point_iterator support_points_end() const;}{
|
||||||
returns the corresponding past-the-end iterator.}
|
returns the corresponding past-the-end iterator.}
|
||||||
|
\ccGlueEnd
|
||||||
|
|
||||||
\ccMemberFunction{ Point const& support_point( int i) const;}{
|
\ccMemberFunction{ Point const& support_point( int i) const;}{
|
||||||
returns the \ccc{i}-th support point of \ccVar. Between two
|
returns the \ccc{i}-th support point of \ccVar. Between two
|
||||||
insert operations any call to \ccVar\ccc{.support_point(i)}
|
modifying operations (see below) any call to
|
||||||
with the same \ccc{i} returns the same point.
|
\ccVar\ccc{.support_point(i)} with the same \ccc{i} returns
|
||||||
|
the same point.
|
||||||
\ccPrecond $0 \leq i< \mbox{\ccVar\ccc{.number_of_support_points()}}$.}
|
\ccPrecond $0 \leq i< \mbox{\ccVar\ccc{.number_of_support_points()}}$.}
|
||||||
|
|
||||||
\ccMemberFunction{ Circle circle( ) const;}{
|
\ccMemberFunction{ Circle const& circle( ) const;}{
|
||||||
returns a circle with same center and same squared radius
|
returns a circle with same center and same squared radius
|
||||||
as \ccVar, if \ccVar is not empty. Otherwise the default
|
as \ccVar.}
|
||||||
circle, i.e.\ \ccc{Circle()}, is returned.}
|
|
||||||
|
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccPredicates
|
\ccPredicates
|
||||||
|
|
@ -236,7 +251,7 @@ bounded side, i.e.\ its unbounded side equals the whole plane $\E_2$.
|
||||||
the number of support points is less than 2.}
|
the number of support points is less than 2.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Modifiers}
|
\ccModifiers
|
||||||
|
|
||||||
New points can be added to an existing \ccVar, allowing to build
|
New points can be added to an existing \ccVar, allowing to build
|
||||||
$mc(P)$ incrementally, e.g.\ if $P$ is not known in advance. Compared
|
$mc(P)$ incrementally, e.g.\ if $P$ is not known in advance. Compared
|
||||||
|
|
@ -247,6 +262,44 @@ the construction method is incremental itself.
|
||||||
inserts \ccc{p} into \ccVar\ and recomputes the smallest
|
inserts \ccc{p} into \ccVar\ and recomputes the smallest
|
||||||
enclosing circle.}
|
enclosing circle.}
|
||||||
|
|
||||||
|
\ccUnchecked
|
||||||
|
\ccMemberFunction{ template < class InputIterator >
|
||||||
|
void insert( InputIterator first,
|
||||||
|
InputIterator last );}{
|
||||||
|
inserts the points in the range [\ccc{first},\ccc{last})
|
||||||
|
into \ccVar\ and recomputes the smallest enclosing circle by
|
||||||
|
calling \ccc{insert(p)} for each point \ccc{p} in
|
||||||
|
[\ccc{first},\ccc{last}).
|
||||||
|
\ccPrecond The value type of \ccc{first} and \ccc{last} is
|
||||||
|
\ccc{Point}.}
|
||||||
|
|
||||||
|
\emph{Note:} Since most compilers do not support template member functions
|
||||||
|
yet, we provide specialized \ccc{insert} functions instead. In the current
|
||||||
|
release there are \ccc{insert} functions for C arrays (using pointers as
|
||||||
|
iterators), for the \stl\ sequence containers \ccc{vector<Point>} and
|
||||||
|
\ccc{list<Point>} and for the \stl\ input stream iterator
|
||||||
|
\ccc{istream_iterator<Point>}.
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( const Point* first,
|
||||||
|
const Point* last );}{
|
||||||
|
STL-like `insert' function for random access iterators.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( list<Point>::const_iterator first,
|
||||||
|
list<Point>::const_iterator last );}{
|
||||||
|
STL-like `insert' function for sequence container list<Point>.}
|
||||||
|
|
||||||
|
\ccHidden
|
||||||
|
\ccMemberFunction{ void insert( istream_iterator<Point,ptrdiff_t> first,
|
||||||
|
istream_iterator<Point,ptrdiff_t> last );}{
|
||||||
|
STL-like `insert' function for input stream iterator
|
||||||
|
istream_iterator<Point,ptrdiff_t>.}
|
||||||
|
|
||||||
|
\ccMemberFunction{ void clear( );}{
|
||||||
|
deletes all points in \ccVar\ and sets \ccVar\ to the empty set.
|
||||||
|
\ccPostcond \ccVar\ccc{.is_empty()} = \ccc{true}.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{Validity Check}
|
\ccHeading{Validity Check}
|
||||||
|
|
||||||
|
|
@ -256,11 +309,12 @@ An object \ccVar\ is valid, iff
|
||||||
\item \ccVar\ is the smallest circle spanned by its support set $S$, and
|
\item \ccVar\ is the smallest circle spanned by its support set $S$, and
|
||||||
\item $S$ is minimal, i.e.\ no support point is redundant.
|
\item $S$ is minimal, i.e.\ no support point is redundant.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
Using the ready-made implementation for the interface class with exact
|
Using the traits class implementation for the \cgal\ kernel with exact
|
||||||
arithmetic as described in Section~\ref{sec:opt_I_Impl} guarantees
|
arithmetic as described in Section~\ref{sec:opt_traits_impl}
|
||||||
validity of \ccVar. The following function is mainly intended for
|
guarantees validity of \ccVar. The following function is mainly
|
||||||
debugging user supplied interface classes.
|
intended for debugging user supplied traits classes but also for
|
||||||
|
convincing the anxious user that the traits class implementation is
|
||||||
|
correct.
|
||||||
\begin{ccAdvanced}
|
\begin{ccAdvanced}
|
||||||
\ccMemberFunction{ bool is_valid( bool verbose = false,
|
\ccMemberFunction{ bool is_valid( bool verbose = false,
|
||||||
int level = 0 ) const;}{
|
int level = 0 ) const;}{
|
||||||
|
|
@ -271,29 +325,36 @@ debugging user supplied interface classes.
|
||||||
with interfaces of other classes.}
|
with interfaces of other classes.}
|
||||||
\end{ccAdvanced}
|
\end{ccAdvanced}
|
||||||
|
|
||||||
|
% -----------------------------------------------------------------------------
|
||||||
|
\ccHeading{Miscellaneous}
|
||||||
|
|
||||||
|
\ccMemberFunction{ Traits const& traits( ) const;}{
|
||||||
|
returns a const reference to the traits class object.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccHeading{I/O}
|
\ccHeading{I/O}
|
||||||
|
|
||||||
\ccFunction{ ostream& operator << ( ostream& os,
|
\ccFunction{ ostream& operator << ( ostream& os,
|
||||||
CGAL_Min_circle_2<I> const& min_circle);}{
|
CGAL_Min_circle_2<Traits> const&
|
||||||
|
min_circle);}{
|
||||||
writes \ccVar\ to output stream \ccc{os}.
|
writes \ccVar\ to output stream \ccc{os}.
|
||||||
\ccPrecond The output operator is defined for \ccc{I::Point}
|
\ccPrecond The output operator is defined for \ccc{Point}
|
||||||
(and for \ccc{I::Circle}, if pretty printing is used).}
|
(and for \ccc{Circle}, if pretty printing is used).}
|
||||||
|
|
||||||
\ccFunction{ istream& operator >> ( istream& is,
|
\ccFunction{ istream& operator >> ( istream& is,
|
||||||
CGAL_Min_circle_2<I> &min_circle);}{
|
CGAL_Min_circle_2<Traits> &min_circle);}{
|
||||||
reads \ccVar\ from input stream \ccc{is}.
|
reads \ccVar\ from input stream \ccc{is}.
|
||||||
\ccPrecond The input operator is defined for \ccc{I::Point}.}
|
\ccPrecond The input operator is defined for \ccc{Point}.}
|
||||||
|
|
||||||
\ccInclude{CGAL/IO/Window_stream.h}
|
\ccInclude{CGAL/IO/Window_stream.h}
|
||||||
|
|
||||||
\ccUnchecked
|
\ccUnchecked
|
||||||
\ccFunction{ CGAL_Window_stream&
|
\ccFunction{ CGAL_Window_stream&
|
||||||
operator << ( CGAL_Window_stream& ws,
|
operator << ( CGAL_Window_stream& ws,
|
||||||
CGAL_Min_circle_2<I> const& min_circle);}{
|
CGAL_Min_circle_2<Traits> const& min_circle);}{
|
||||||
writes \ccVar\ to window stream \ccc{ws}.
|
writes \ccVar\ to window stream \ccc{ws}.
|
||||||
\ccPrecond The window stream output operator is defined for
|
\ccPrecond The window stream output operator is defined for
|
||||||
\ccc{I::Point} and \ccc{I::Circle}.}
|
\ccc{Point} and \ccc{Circle}.}
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccImplementation
|
\ccImplementation
|
||||||
|
|
@ -303,8 +364,8 @@ heuristic~\cite{w-sedbe-91a}. If randomization is chosen, the creation
|
||||||
time is almost always linear in the number of points. Access functions
|
time is almost always linear in the number of points. Access functions
|
||||||
and predicates take constant time, inserting a point might take up to
|
and predicates take constant time, inserting a point might take up to
|
||||||
linear time, but substantially less than computing the new smallest
|
linear time, but substantially less than computing the new smallest
|
||||||
enclosing circle from scratch. The check for validity takes linear
|
enclosing circle from scratch. The clear operation and the check for
|
||||||
time.
|
validity each takes linear time.
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccExample
|
\ccExample
|
||||||
|
|
@ -315,12 +376,15 @@ randomization can be useful in certain cases, we give an example.
|
||||||
\begin{cprog}
|
\begin{cprog}
|
||||||
#include <CGAL/Integer.h>
|
#include <CGAL/Integer.h>
|
||||||
#include <CGAL/Homogeneous.h>
|
#include <CGAL/Homogeneous.h>
|
||||||
|
#include <CGAL/Point_2.h>
|
||||||
|
#include <CGAL/Optimisation_traits_2.h>
|
||||||
#include <CGAL/Min_circle_2.h>
|
#include <CGAL/Min_circle_2.h>
|
||||||
|
|
||||||
typedef CGAL_Homogeneous<integer> R;
|
typedef integer NT;
|
||||||
|
typedef CGAL_Homogeneous<NT> R;
|
||||||
typedef CGAL_Point_2<R> Point;
|
typedef CGAL_Point_2<R> Point;
|
||||||
typedef CGAL_Min_circle_2< CGAL_Optimisation_default_interface<R> >
|
typedef CGAL_Optimisation_traits_2<R> Traits;
|
||||||
Min_circle;
|
typedef CGAL_Min_circle_2<Traits> Min_circle;
|
||||||
|
|
||||||
int n = 1000;
|
int n = 1000;
|
||||||
Point* P = new Point[ n];
|
Point* P = new Point[ n];
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue