mirror of https://github.com/CGAL/cgal
*** empty log message ***
This commit is contained in:
parent
77541a3212
commit
79160c96e0
|
|
@ -3,7 +3,7 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/rectangular_p_center_2.h>
|
||||
#include <CGAL/IO/Ostream_iterator.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
|
@ -18,33 +18,34 @@ typedef CGAL::Point_2< R > Point;
|
|||
typedef std::vector< Point > Cont;
|
||||
typedef CGAL::Creator_uniform_2< FT, Point > Creator;
|
||||
typedef CGAL::Random_points_in_square_2< Point, Creator >
|
||||
Point_generator;
|
||||
Point_generator;
|
||||
typedef CGAL::Ostream_iterator< Point, ostream > Ostream_iterator_point;
|
||||
|
||||
int main() {
|
||||
|
||||
int number_of_points( 10);
|
||||
int p( 2);
|
||||
Ostream_iterator_point cout_ip( cout);
|
||||
set_pretty_mode( cout);
|
||||
int number_of_points(10);
|
||||
int p(2);
|
||||
Ostream_iterator_point cout_ip(cout);
|
||||
set_pretty_mode(cout);
|
||||
|
||||
Cont points;
|
||||
CGAL::copy_n( Point_generator( 1),
|
||||
number_of_points,
|
||||
back_inserter( points));
|
||||
CGAL::copy_n(Point_generator(1),
|
||||
number_of_points,
|
||||
back_inserter(points));
|
||||
cout << "Generated Point Set:" << endl;
|
||||
copy( points.begin(), points.end(), cout_ip);
|
||||
copy(points.begin(), points.end(), cout_ip);
|
||||
|
||||
Cont centers;
|
||||
FT p_radius;
|
||||
rectangular_p_center_2(
|
||||
points.begin(),
|
||||
points.end(),
|
||||
back_inserter( centers),
|
||||
back_inserter(centers),
|
||||
p_radius,
|
||||
p);
|
||||
3);
|
||||
|
||||
cout << "\n\n" << p << "-centers:" << endl;
|
||||
copy( centers.begin(), centers.end(), cout_ip);
|
||||
copy(centers.begin(), centers.end(), cout_ip);
|
||||
cout << "\n\n" << p << "-radius = " << p_radius << endl;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,15 +54,14 @@ minimal distance between both sets is minimized.
|
|||
<IMG WIDTH=12 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline17"
|
||||
SRC="./MatrixSearch_pcenter1.gif" > with at most <I>p</I> points.}
|
||||
|
||||
\ccInclude{CGAL/rectangular_p_center_2.h}
|
||||
\ccInclude{CGAL/rectangular_p_center_2.h}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class
|
||||
OutputIterator, class Traits > OutputIterator
|
||||
OutputIterator, class FT > OutputIterator
|
||||
rectangular_p_center_2( ForwardIterator f, ForwardIterator l,
|
||||
OutputIterator o, Traits::FT& r, int p, const Traits& t =
|
||||
Default_traits);}
|
||||
OutputIterator o, FT& r, int p);}
|
||||
|
||||
computes rectilinear \ccc{p}-centers for the point set described by
|
||||
the range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding
|
||||
|
|
@ -71,49 +70,285 @@ minimal distance between both sets is minimized.
|
|||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item If \ccc{t} is specified explicitly, \ccc{Traits} satisfies the
|
||||
requirements stated in section
|
||||
\ref{req_RectangularP-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2}
|
||||
or -- if \ccc{t} is not specified explicitly --
|
||||
\ccc{Point_2<R>} for some representation class \ccc{R},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Point_2<R>} for some
|
||||
representation class \ccc{R} and \ccc{FT} is equivalent to \ccc{R::FT},
|
||||
\item \ccc{OutputIterator} accepts the value type of
|
||||
\ccc{ForwardIterator} as value type,
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty \textit{and}
|
||||
\item 2 $\le$ \ccc{p} $\le$ 4.
|
||||
\end{enumerate}
|
||||
|
||||
\ccHeading{Note}
|
||||
|
||||
On compilers not supporting member function templates, the parameter
|
||||
\ccc{ForwardIterator} is fixed to \ccc{vector<Point_2>::iterator}
|
||||
and \ccc{OutputIterator} is fixed to
|
||||
\ccc{back_insert_iterator<vector<Point_2>>} where \ccc{Point_2} is
|
||||
\ccc{Traits::Point_2}.
|
||||
|
||||
\ccImplementation The implementation uses sorted matrix search (see
|
||||
section \ref{secSortedMatrixSearch}) and fast algorithms for
|
||||
piercing rectangles\cite{sw-rpppp-96} which leads to a runtime
|
||||
complexity of $\mathcal{O}(n \cdot \log n)$ where $n$ is the number
|
||||
of input points.
|
||||
\ccImplementation The runtime is linear for $p \in \{2,\,3\}$ and
|
||||
$\mathcal{O}(n \cdot \log n)$ for $p = 4$ where $n$ is the number of input
|
||||
points. These runtimes are worst case optimal. The $4$-center implementation
|
||||
uses sorted matrix search (see section \ref{secSortedMatrixSearch}) and fast
|
||||
algorithms for piercing rectangles\cite{sw-rpppp-96}.
|
||||
|
||||
\ccExample The following code generates a random set of ten points
|
||||
and computes its two-centers.
|
||||
|
||||
\ccIncludeVerbatim{rectangular_p_center_2_example_noheader.C}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\subsection{$2$--$4$ Center Functions}
|
||||
|
||||
\ccHeading{$2$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class
|
||||
OutputIterator, class Traits > OutputIterator
|
||||
rectangular_2_center_2( ForwardIterator f, ForwardIterator l,
|
||||
OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{2}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $2$-radius,
|
||||
writes the at most \ccc{2} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular23-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is linear in the number of input points.
|
||||
|
||||
\ccHeading{$3$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class OutputIterator,
|
||||
class Traits > OutputIterator rectangular_3_center_2( ForwardIterator f,
|
||||
ForwardIterator l, OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{3}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $3$-radius,
|
||||
writes the at most \ccc{3} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular23-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is linear in the number of input points.
|
||||
|
||||
\ccHeading{$4$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class OutputIterator,
|
||||
class Traits > OutputIterator rectangular_4_center_2( ForwardIterator f,
|
||||
ForwardIterator l, OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{4}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $4$-radius,
|
||||
writes the at most \ccc{4} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular4-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is $\mathcal{O}(n \cdot \log n)$ where $n$
|
||||
is the number of input points which is worst case optimal. It uses sorted
|
||||
matrix search (see section \ref{secSortedMatrixSearch}) and fast
|
||||
algorithms for piercing rectangles\cite{sw-rpppp-96}.
|
||||
|
||||
\end{ccAdvanced}
|
||||
\end{ccHtmlClassFile}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc_traits}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc3_traits}
|
||||
\ccCreationVariable{t}\ccTagFullDeclarations
|
||||
|
||||
\subsection{Requirements for Rectangular $p$-center Traits Classes}
|
||||
\label{req_RectangularP-centerTraitsClasses}
|
||||
\subsection{Requirements for Rectangular $\{2,3\}$-center Traits Classes}
|
||||
\label{req_Rectangular23-centerTraitsClasses}
|
||||
|
||||
\ccDefinition A class \ccClassName\ has to provide the following
|
||||
types in order to qualify as a traits class for
|
||||
\ccc{rectangular_p_center_2}.
|
||||
\ccDefinition A class \ccClassName\ has to provide the following types in
|
||||
order to qualify as a traits class for \ccc{rectangular_2_center_2} or
|
||||
\ccc{rectangular_3_center_2}.
|
||||
|
||||
\ccTypes
|
||||
|
||||
\ccNestedType{FT}{class used for doing computations on point
|
||||
coordinates (has to fulfill field-type requirements).}
|
||||
|
||||
\ccNestedType{Point_2}{class used for representing the input
|
||||
points.}
|
||||
|
||||
\ccNestedType{Iso_rectangle_2}{class used for representing
|
||||
axis-parallel rectangles.}
|
||||
|
||||
\ccNestedType{Less_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has smaller x-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Less_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has smaller y-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Greater_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has greater x-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Greater_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has greater y-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Inf_distance_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{FT}
|
||||
returns the $||\cdot||_{\infty}$ distance of two points.}
|
||||
|
||||
\ccNestedType{Signed_inf_distance_2}{adaptable binary function
|
||||
class: \ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$
|
||||
\ccc{FT} returns the signed $||\cdot||_{\infty}$ distance of two
|
||||
points.}
|
||||
|
||||
\ccNestedType{Construct_min_2}{adaptable unary function class:
|
||||
\ccc{Iso_rectangle_2} $\rightarrow$ \ccc{Point_2} returns the
|
||||
lower-left corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_max_2}{adaptable unary function class:
|
||||
\ccc{Iso_rectangle_2} $\rightarrow$ \ccc{Point_2} returns the
|
||||
upper-right corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_corner_2}{adaptable binary function class:
|
||||
\ccc{Iso_rectangle_2} $\times$ \ccc{unsigned int} $\rightarrow$
|
||||
\ccc{Point_2} returns the i-th (starting from lower-left and then
|
||||
counterclockwise) corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_projection_onto_horizontal_implicit_line_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{Point_2}
|
||||
$\rightarrow$ \ccc{Point_2} returns the (orthogonal) projection
|
||||
of the first point onto the horizontal line through the second
|
||||
point.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2}{4-argument function
|
||||
class: \ccc{Point_2} $\times$ \ccc{Point_2} $\times$
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$
|
||||
\ccc{Iso_rectangle_2} returns the rectangle with point $i$ on
|
||||
the left, bottom, right, top resp. side.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_below_left_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as upper-right corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_below_right_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as upper-left corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_above_right_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as lower-left corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_above_left_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as lower-right corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccHeading{These can be derived from \ccc{Less} and \ccc{Greater}:}
|
||||
|
||||
\ccNestedType{Min_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with smaller x-coordinate.}
|
||||
|
||||
\ccNestedType{Max_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with greater x-coordinate.}
|
||||
|
||||
\ccNestedType{Min_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with smaller y-coordinate.}
|
||||
|
||||
\ccNestedType{Max_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with greater y-coordinate.}
|
||||
|
||||
\ccOperations
|
||||
|
||||
For every function class listed above there is a member function
|
||||
to fetch the corresponding function object.
|
||||
|
||||
\ccMemberFunction{Inf_distance_2 get_inf_distance_2() const;}{}
|
||||
\ccGlue\ccMemberFunction{Signed_inf_distance_2
|
||||
get_signed_inf_distance_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_min_2 get_construct_min_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_max_2 get_construct_max_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_corner_2 get_construct_corner_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2
|
||||
get_construct_iso_rectangle_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_projection_onto_horizontal_implicit_line_2
|
||||
get_construct_projection_onto_horizontal_implicit_line_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_below_left_point_2
|
||||
get_construct_iso_rectangle_2_below_left_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_above_left_point_2
|
||||
get_construct_iso_rectangle_2_above_left_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_below_right_point_2
|
||||
get_construct_iso_rectangle_2_below_right_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_above_right_point_2
|
||||
get_construct_iso_rectangle_2_above_right_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Min_x_2 get_min_x_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Max_x_2 get_max_x_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Min_y_2 get_min_y_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Max_y_2 get_max_y_2() const;}{}
|
||||
|
||||
\end{ccClass}
|
||||
\end{ccAdvanced}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc4_traits}
|
||||
\ccCreationVariable{t}\ccTagFullDeclarations
|
||||
|
||||
\subsection{Requirements for Rectangular $4$-center Traits Classes}
|
||||
\label{req_Rectangular4-centerTraitsClasses}
|
||||
|
||||
\ccDefinition A class \ccClassName\ has to provide the following types in
|
||||
order to qualify as a traits class for \ccc{rectangular_4_center_2}.
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/rectangular_p_center_2.h>
|
||||
#include <CGAL/IO/Ostream_iterator.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
|
@ -18,33 +18,34 @@ typedef CGAL::Point_2< R > Point;
|
|||
typedef std::vector< Point > Cont;
|
||||
typedef CGAL::Creator_uniform_2< FT, Point > Creator;
|
||||
typedef CGAL::Random_points_in_square_2< Point, Creator >
|
||||
Point_generator;
|
||||
Point_generator;
|
||||
typedef CGAL::Ostream_iterator< Point, ostream > Ostream_iterator_point;
|
||||
|
||||
int main() {
|
||||
|
||||
int number_of_points( 10);
|
||||
int p( 2);
|
||||
Ostream_iterator_point cout_ip( cout);
|
||||
set_pretty_mode( cout);
|
||||
int number_of_points(10);
|
||||
int p(2);
|
||||
Ostream_iterator_point cout_ip(cout);
|
||||
set_pretty_mode(cout);
|
||||
|
||||
Cont points;
|
||||
CGAL::copy_n( Point_generator( 1),
|
||||
number_of_points,
|
||||
back_inserter( points));
|
||||
CGAL::copy_n(Point_generator(1),
|
||||
number_of_points,
|
||||
back_inserter(points));
|
||||
cout << "Generated Point Set:" << endl;
|
||||
copy( points.begin(), points.end(), cout_ip);
|
||||
copy(points.begin(), points.end(), cout_ip);
|
||||
|
||||
Cont centers;
|
||||
FT p_radius;
|
||||
rectangular_p_center_2(
|
||||
points.begin(),
|
||||
points.end(),
|
||||
back_inserter( centers),
|
||||
back_inserter(centers),
|
||||
p_radius,
|
||||
p);
|
||||
3);
|
||||
|
||||
cout << "\n\n" << p << "-centers:" << endl;
|
||||
copy( centers.begin(), centers.end(), cout_ip);
|
||||
copy(centers.begin(), centers.end(), cout_ip);
|
||||
cout << "\n\n" << p << "-radius = " << p_radius << endl;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,15 +54,14 @@ minimal distance between both sets is minimized.
|
|||
<IMG WIDTH=12 HEIGHT=12 ALIGN=BOTTOM ALT="tex2html_wrap_inline17"
|
||||
SRC="./MatrixSearch_pcenter1.gif" > with at most <I>p</I> points.}
|
||||
|
||||
\ccInclude{CGAL/rectangular_p_center_2.h}
|
||||
\ccInclude{CGAL/rectangular_p_center_2.h}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class
|
||||
OutputIterator, class Traits > OutputIterator
|
||||
OutputIterator, class FT > OutputIterator
|
||||
rectangular_p_center_2( ForwardIterator f, ForwardIterator l,
|
||||
OutputIterator o, Traits::FT& r, int p, const Traits& t =
|
||||
Default_traits);}
|
||||
OutputIterator o, FT& r, int p);}
|
||||
|
||||
computes rectilinear \ccc{p}-centers for the point set described by
|
||||
the range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding
|
||||
|
|
@ -71,49 +70,285 @@ minimal distance between both sets is minimized.
|
|||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item If \ccc{t} is specified explicitly, \ccc{Traits} satisfies the
|
||||
requirements stated in section
|
||||
\ref{req_RectangularP-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2}
|
||||
or -- if \ccc{t} is not specified explicitly --
|
||||
\ccc{Point_2<R>} for some representation class \ccc{R},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Point_2<R>} for some
|
||||
representation class \ccc{R} and \ccc{FT} is equivalent to \ccc{R::FT},
|
||||
\item \ccc{OutputIterator} accepts the value type of
|
||||
\ccc{ForwardIterator} as value type,
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty \textit{and}
|
||||
\item 2 $\le$ \ccc{p} $\le$ 4.
|
||||
\end{enumerate}
|
||||
|
||||
\ccHeading{Note}
|
||||
|
||||
On compilers not supporting member function templates, the parameter
|
||||
\ccc{ForwardIterator} is fixed to \ccc{vector<Point_2>::iterator}
|
||||
and \ccc{OutputIterator} is fixed to
|
||||
\ccc{back_insert_iterator<vector<Point_2>>} where \ccc{Point_2} is
|
||||
\ccc{Traits::Point_2}.
|
||||
|
||||
\ccImplementation The implementation uses sorted matrix search (see
|
||||
section \ref{secSortedMatrixSearch}) and fast algorithms for
|
||||
piercing rectangles\cite{sw-rpppp-96} which leads to a runtime
|
||||
complexity of $\mathcal{O}(n \cdot \log n)$ where $n$ is the number
|
||||
of input points.
|
||||
\ccImplementation The runtime is linear for $p \in \{2,\,3\}$ and
|
||||
$\mathcal{O}(n \cdot \log n)$ for $p = 4$ where $n$ is the number of input
|
||||
points. These runtimes are worst case optimal. The $4$-center implementation
|
||||
uses sorted matrix search (see section \ref{secSortedMatrixSearch}) and fast
|
||||
algorithms for piercing rectangles\cite{sw-rpppp-96}.
|
||||
|
||||
\ccExample The following code generates a random set of ten points
|
||||
and computes its two-centers.
|
||||
|
||||
\ccIncludeVerbatim{rectangular_p_center_2_example_noheader.C}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\subsection{$2$--$4$ Center Functions}
|
||||
|
||||
\ccHeading{$2$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class
|
||||
OutputIterator, class Traits > OutputIterator
|
||||
rectangular_2_center_2( ForwardIterator f, ForwardIterator l,
|
||||
OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{2}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $2$-radius,
|
||||
writes the at most \ccc{2} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular23-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is linear in the number of input points.
|
||||
|
||||
\ccHeading{$3$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class OutputIterator,
|
||||
class Traits > OutputIterator rectangular_3_center_2( ForwardIterator f,
|
||||
ForwardIterator l, OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{3}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $3$-radius,
|
||||
writes the at most \ccc{3} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular23-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is linear in the number of input points.
|
||||
|
||||
\ccHeading{$4$-Center}
|
||||
|
||||
\def\ccLongParamLayout{\ccTrue}
|
||||
|
||||
\ccGlobalFunction{template < class ForwardIterator, class OutputIterator,
|
||||
class Traits > OutputIterator rectangular_4_center_2( ForwardIterator f,
|
||||
ForwardIterator l, OutputIterator o, Traits::FT& r, const Traits& t);}
|
||||
|
||||
computes rectilinear \ccc{4}-centers for the point set described by the
|
||||
range [\ccc{f}, \ccc{l}), sets \ccc{r} to the corresponding $4$-radius,
|
||||
writes the at most \ccc{4} center points to \ccc{o} and returns the
|
||||
past-the-end iterator of this sequence.
|
||||
|
||||
\ccHeading{Precondition}
|
||||
\begin{enumerate}
|
||||
\item \ccc{Traits} satisfies the requirements stated in section
|
||||
\ref{req_Rectangular4-centerTraitsClasses},
|
||||
\item Value type of \ccc{ForwardIterator} is \ccc{Traits::Point_2},
|
||||
\item \ccc{OutputIterator} accepts the value type of \ccc{ForwardIterator}
|
||||
as value type \textit{and}
|
||||
\item the range [\ccc{f}, \ccc{l}) is not empty.
|
||||
\end{enumerate}
|
||||
|
||||
\ccImplementation The runtime is $\mathcal{O}(n \cdot \log n)$ where $n$
|
||||
is the number of input points which is worst case optimal. It uses sorted
|
||||
matrix search (see section \ref{secSortedMatrixSearch}) and fast
|
||||
algorithms for piercing rectangles\cite{sw-rpppp-96}.
|
||||
|
||||
\end{ccAdvanced}
|
||||
\end{ccHtmlClassFile}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc_traits}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc3_traits}
|
||||
\ccCreationVariable{t}\ccTagFullDeclarations
|
||||
|
||||
\subsection{Requirements for Rectangular $p$-center Traits Classes}
|
||||
\label{req_RectangularP-centerTraitsClasses}
|
||||
\subsection{Requirements for Rectangular $\{2,3\}$-center Traits Classes}
|
||||
\label{req_Rectangular23-centerTraitsClasses}
|
||||
|
||||
\ccDefinition A class \ccClassName\ has to provide the following
|
||||
types in order to qualify as a traits class for
|
||||
\ccc{rectangular_p_center_2}.
|
||||
\ccDefinition A class \ccClassName\ has to provide the following types in
|
||||
order to qualify as a traits class for \ccc{rectangular_2_center_2} or
|
||||
\ccc{rectangular_3_center_2}.
|
||||
|
||||
\ccTypes
|
||||
|
||||
\ccNestedType{FT}{class used for doing computations on point
|
||||
coordinates (has to fulfill field-type requirements).}
|
||||
|
||||
\ccNestedType{Point_2}{class used for representing the input
|
||||
points.}
|
||||
|
||||
\ccNestedType{Iso_rectangle_2}{class used for representing
|
||||
axis-parallel rectangles.}
|
||||
|
||||
\ccNestedType{Less_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has smaller x-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Less_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has smaller y-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Greater_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has greater x-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Greater_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{bool}
|
||||
returns true, iff the first point has greater y-coordinate than
|
||||
the second.}
|
||||
|
||||
\ccNestedType{Inf_distance_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{FT}
|
||||
returns the $||\cdot||_{\infty}$ distance of two points.}
|
||||
|
||||
\ccNestedType{Signed_inf_distance_2}{adaptable binary function
|
||||
class: \ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$
|
||||
\ccc{FT} returns the signed $||\cdot||_{\infty}$ distance of two
|
||||
points.}
|
||||
|
||||
\ccNestedType{Construct_min_2}{adaptable unary function class:
|
||||
\ccc{Iso_rectangle_2} $\rightarrow$ \ccc{Point_2} returns the
|
||||
lower-left corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_max_2}{adaptable unary function class:
|
||||
\ccc{Iso_rectangle_2} $\rightarrow$ \ccc{Point_2} returns the
|
||||
upper-right corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_corner_2}{adaptable binary function class:
|
||||
\ccc{Iso_rectangle_2} $\times$ \ccc{unsigned int} $\rightarrow$
|
||||
\ccc{Point_2} returns the i-th (starting from lower-left and then
|
||||
counterclockwise) corner of a rectangle.}
|
||||
|
||||
\ccNestedType{Construct_projection_onto_horizontal_implicit_line_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{Point_2}
|
||||
$\rightarrow$ \ccc{Point_2} returns the (orthogonal) projection
|
||||
of the first point onto the horizontal line through the second
|
||||
point.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2}{4-argument function
|
||||
class: \ccc{Point_2} $\times$ \ccc{Point_2} $\times$
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$
|
||||
\ccc{Iso_rectangle_2} returns the rectangle with point $i$ on
|
||||
the left, bottom, right, top resp. side.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_below_left_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as upper-right corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_below_right_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as upper-left corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_above_right_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as lower-left corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccNestedType{Construct_iso_rectangle_2_above_left_point_2}{adaptable
|
||||
binary function class: \ccc{Point_2} $\times$ \ccc{FT}
|
||||
$\rightarrow$ \ccc{Iso_rectangle_2}. For argument $(p,\,r)$ it
|
||||
returns the rectangle with $p$ as lower-right corner and
|
||||
sidelength $r$.}
|
||||
|
||||
\ccHeading{These can be derived from \ccc{Less} and \ccc{Greater}:}
|
||||
|
||||
\ccNestedType{Min_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with smaller x-coordinate.}
|
||||
|
||||
\ccNestedType{Max_x_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with greater x-coordinate.}
|
||||
|
||||
\ccNestedType{Min_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with smaller y-coordinate.}
|
||||
|
||||
\ccNestedType{Max_y_2}{adaptable binary function class:
|
||||
\ccc{Point_2} $\times$ \ccc{Point_2} $\rightarrow$ \ccc{Point_2}
|
||||
returns the point with greater y-coordinate.}
|
||||
|
||||
\ccOperations
|
||||
|
||||
For every function class listed above there is a member function
|
||||
to fetch the corresponding function object.
|
||||
|
||||
\ccMemberFunction{Inf_distance_2 get_inf_distance_2() const;}{}
|
||||
\ccGlue\ccMemberFunction{Signed_inf_distance_2
|
||||
get_signed_inf_distance_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_min_2 get_construct_min_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_max_2 get_construct_max_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_corner_2 get_construct_corner_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2
|
||||
get_construct_iso_rectangle_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_projection_onto_horizontal_implicit_line_2
|
||||
get_construct_projection_onto_horizontal_implicit_line_2()
|
||||
const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_below_left_point_2
|
||||
get_construct_iso_rectangle_2_below_left_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_above_left_point_2
|
||||
get_construct_iso_rectangle_2_above_left_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_below_right_point_2
|
||||
get_construct_iso_rectangle_2_below_right_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Construct_iso_rectangle_2_above_right_point_2
|
||||
get_construct_iso_rectangle_2_above_right_point_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Min_x_2 get_min_x_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Max_x_2 get_max_x_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Min_y_2 get_min_y_2() const;}{}
|
||||
|
||||
\ccGlue\ccMemberFunction{Max_y_2 get_max_y_2() const;}{}
|
||||
|
||||
\end{ccClass}
|
||||
\end{ccAdvanced}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccHtmlNoClassToc\ccHtmlNoClassIndex\begin{ccClass}{Rpc4_traits}
|
||||
\ccCreationVariable{t}\ccTagFullDeclarations
|
||||
|
||||
\subsection{Requirements for Rectangular $4$-center Traits Classes}
|
||||
\label{req_Rectangular4-centerTraitsClasses}
|
||||
|
||||
\ccDefinition A class \ccClassName\ has to provide the following types in
|
||||
order to qualify as a traits class for \ccc{rectangular_4_center_2}.
|
||||
|
||||
\ccTypes
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@
|
|||
#ifndef CGAL_IO_OSTREAM_ITERATOR_H
|
||||
#include <CGAL/IO/Ostream_iterator.h>
|
||||
#endif // CGAL_IO_OSTREAM_ITERATOR_H
|
||||
#ifndef CGAL_COPY_N_H
|
||||
#include <CGAL/copy_n.h>
|
||||
#endif // CGAL_COPY_N_H
|
||||
#ifndef CGAL_ALGORITHM_H
|
||||
#include <CGAL/algorithm.h>
|
||||
#endif // CGAL_ALGORITHM_H
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
|
@ -56,33 +56,34 @@ typedef CGAL::Point_2< R > Point;
|
|||
typedef std::vector< Point > Cont;
|
||||
typedef CGAL::Creator_uniform_2< FT, Point > Creator;
|
||||
typedef CGAL::Random_points_in_square_2< Point, Creator >
|
||||
Point_generator;
|
||||
Point_generator;
|
||||
typedef CGAL::Ostream_iterator< Point, ostream > Ostream_iterator_point;
|
||||
|
||||
int main() {
|
||||
|
||||
int number_of_points( 10);
|
||||
int p( 2);
|
||||
Ostream_iterator_point cout_ip( cout);
|
||||
set_pretty_mode( cout);
|
||||
int number_of_points(10);
|
||||
int p(2);
|
||||
Ostream_iterator_point cout_ip(cout);
|
||||
set_pretty_mode(cout);
|
||||
|
||||
Cont points;
|
||||
CGAL::copy_n( Point_generator( 1),
|
||||
number_of_points,
|
||||
back_inserter( points));
|
||||
CGAL::copy_n(Point_generator(1),
|
||||
number_of_points,
|
||||
back_inserter(points));
|
||||
cout << "Generated Point Set:" << endl;
|
||||
copy( points.begin(), points.end(), cout_ip);
|
||||
copy(points.begin(), points.end(), cout_ip);
|
||||
|
||||
Cont centers;
|
||||
FT p_radius;
|
||||
rectangular_p_center_2(
|
||||
points.begin(),
|
||||
points.end(),
|
||||
back_inserter( centers),
|
||||
back_inserter(centers),
|
||||
p_radius,
|
||||
p);
|
||||
3);
|
||||
|
||||
cout << "\n\n" << p << "-centers:" << endl;
|
||||
copy( centers.begin(), centers.end(), cout_ip);
|
||||
copy(centers.begin(), centers.end(), cout_ip);
|
||||
cout << "\n\n" << p << "-radius = " << p_radius << endl;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,62 +1,13 @@
|
|||
//=====================================================================
|
||||
// Revision History for package Matrix_search
|
||||
//=====================================================================
|
||||
CHANGES:
|
||||
|
||||
1.6:
|
||||
- added package and chapter to file headers.
|
||||
- removed htmlfiles (now in Optimisation_basic).
|
||||
- changed pkg-name acc. to naming conventions.
|
||||
- minor fix in the docs.
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.17
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
DEMO: fixed for LEDA-3.8 (the point_set<I> data structure vanished)
|
||||
DEMO: Now nearest neighbor queries are done brute-force.
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.16
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
DOCS: fixed "cal" problem with html converter
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.15
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
DOCS: fixed preconditions in replace_column (reported by Mariette).
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.14
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
ALL : added std:: in a number of places where it was missing
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.13
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
ALL : Initial revision
|
||||
TEST: Added LONG_NAME_PROBLEM flags to makefile
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.12
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
ALL : use namespace std and CGAL
|
||||
ALL : use standard header files
|
||||
DOCS: fixed "cal" problem with html converter
|
||||
DOCS: fixed preconditions in replace_column (reported by Mariette).
|
||||
DOCS: Initial revision
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.11
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.10
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// revision 1.9
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
SRC : fix signed <-> unsigned comparison warning on gcc.
|
||||
1.5:
|
||||
- Now rectangular 3- and 4-centers.
|
||||
- Uses Iso_square_static_2 instead of Iso_rectangle_2
|
||||
(improved performance and robustness).
|
||||
- some fixes in the docs.
|
||||
|
|
@ -1 +1 @@
|
|||
1.17 (01 June 1999)
|
||||
1.18 (10 September 1999)
|
||||
|
|
|
|||
Loading…
Reference in New Issue