diff --git a/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/is_y_monotone_2.tex b/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/is_y_monotone_2.tex index ecd83017c4d..7d4d6679449 100644 --- a/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/is_y_monotone_2.tex +++ b/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/is_y_monotone_2.tex @@ -11,17 +11,17 @@ Function for testing the $y$-monotonicity of a sequence of points. \ccFunction{ template bool -is_y_monotone_2(InputIterator first, InputIterator last, +is_y_monotone_2(InputIterator first, InputIterator beyond, const Traits& traits); } { Determines if the sequence of points in the range -[\ccc{first}, \ccc{last}) define a $y$-monotone +[\ccc{first}, \ccc{beyond}) define a $y$-monotone polygon or not. If so, the function returns \ccc{true}, otherwise it returns \ccc{false}. } -\ccHeading{Preconditions} +\ccHeading{Requirements} \ccIndexSubitem[C]{is_y_monotone_2}{preconditions} \begin{enumerate} \item \ccc{Traits} is a model of the concept IsYMonotoneTraits\_2.% @@ -29,57 +29,31 @@ returns \ccc{false}. \item \ccc{InputIterator::value_type} should be \ccc{Traits::Point_2}. \end{enumerate} -The default traits class \ccc{Default_traits} is the \cgal\ \ccc{Kernel_traits_2} -class, +The default traits class \ccc{Default_traits} is the kernel in which the +type \ccc{InputIterator::value_type} is defined.% \ccIndexTraitsClassDefault{is_y_monotone_2} -with the representation type determined by \ccc{InputIterator::value_type}. \ccSeeAlso \ccRefIdfierPage{CGAL::Is_y_monotone_2} \\ \ccRefIdfierPage{CGAL::y_monotone_partition_2} \\ \ccRefIdfierPage{CGAL::y_monotone_partition_is_valid_2} +\ccImplementation + +This function requires $O(n)$ time for a polygon with $n$ vertices. + \ccExample -The following code fragment computes a $y$-monotone partitioning -of the simple polygon \ccc{P} using the default +The following program computes a $y$-monotone partitioning +of a polygon using the default traits class and stores the partition polygons in the list \ccc{partition_polys}. It then asserts that each of the partition -polygons is, in fact, a $y$-monotone polygon. (Note that this -assertion is superfluous unless the postcondition checking done +polygons is, in fact, a $y$-monotone polygon and that the partition +is valid. (Note that the +assertions are superfluous unless the postcondition checking done by \ccc{y_monotone_partition_2} has been turned off during compilation.) -\begin{verbatim} - #include - #include - #include - #include - #include - #include - - typedef CGAL::Cartesian R; - typedef CGAL::Polygon_traits_2 Traits; - typedef Traits::Point_2 Point_2; - typedef Traits::Polygon_2 Polygon_2 - - Polygon_2 P; - std::list partition_polys; - - // ... - // insert vertices into P to create a simple CCW-oriented polygon - // ... - CGAL::y_monotone_partition_2(P.vertices_begin(), - P.vertices_end(), - std::back_inserter(partition_polys)); - - std::list::const_iterator poly_it; - for (poly_it = partition_polys.begin(); poly_it != partition_polys.end(); - poly_it++) - { - assert(CGAL::is_y_monotone_2((*poly_it).vertices_begin(), - (*poly_it).vertices_end())); - } -\end{verbatim} +\ccIncludeExampleCode{Partition_2/y_monotone_ex.C} diff --git a/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/y_monotone_partition_2.tex b/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/y_monotone_partition_2.tex index 8b11510f422..b177f5b6632 100644 --- a/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/y_monotone_partition_2.tex +++ b/Packages/Partition_2/doc_tex/Partition_2/Partition_2_ref/y_monotone_partition_2.tex @@ -16,15 +16,17 @@ OutputIterator y_monotone_partition_2(InputIterator first, const Traits& traits = Default_traits); } { -computes a partition of the simple, counterclockwise-oriented polygon defined -by the points in the range [\ccc{first}, \ccc{last}) into $y$-monotone +computes a partition of the polygon defined +by the points in the range [\ccc{first}, \ccc{beyond}) into $y$-monotone polygons. The counterclockwise-oriented partition polygons are written to the sequence starting at position \ccc{result}. The past-the-end iterator for the resulting sequence of polygons is returned. +\ccPrecond The points in the range [\ccc{first}, \ccc{beyond}) define a +simple, counterclockwise-oriented polygon. +%\ccIndexSubitem[C]{y_monotone_partition_2}{preconditions} } \ccHeading{Requirements} -%\ccIndexSubitem[C]{y_monotone_partition_2}{preconditions} \begin{enumerate} \item \ccc{Traits} is a model of the concept YMonotonePartitionTraits\_2% \ccIndexMainItem[c]{YMonotonePartitionTraits_2} and, for the purposes @@ -36,8 +38,6 @@ the resulting sequence of polygons is returned. \item \ccc{InputIterator::value_type} should be \ccc{Traits::Point_2}, which should also be the type of the points stored in an object of type \ccc{Traits::Polygon_2}. - \item Points in the range $[first, beyond)$ must define a simple polygon - whose vertices are oriented counterclockwise. \end{enumerate} The default traits class \ccc{Default_traits} is \ccc{Partition_traits_2}, @@ -53,41 +53,22 @@ with the representation type determined by \ccc{InputIterator::value_type}. \ccImplementation -This function implements the algorithm presented by de Bert \textit{et al.} +This function implements the algorithm presented by de Berg \textit{et al.} \cite{bkos-cgaa-97} which requires $O(n \log n)$ time and $O(n)$ space for a polygon with $n$ vertices. \ccExample -The following code fragment will compute a $y$-monotone partitioning -of the simple polygon \ccc{P} using the default -traits class and store the partition polygons in the list -\ccc{partition_polys}. +The following program computes a $y$-monotone partitioning +of a polygon using the default +traits class and stores the partition polygons in the list +\ccc{partition_polys}. It then asserts that each partition polygon +produced is, in fact, $y$-monotone and that the partition is valid. +(Note that these assertions are superfluous unless the postcondition +checking for \ccc{y_monotone_partition_2} has been turned off.) -\begin{verbatim} - #include - #include - #include - #include - #include - - typedef CGAL::Cartesian R; - typedef CGAL::Polygon_traits_2 Traits; - typedef Traits::Point_2 Point_2; - typedef std::list Container; - typedef CGAL::Polygon_2 Polygon_2; - - Polygon_2 P; - std::list partition_polys; - - // ... - // insert vertices into P to create a simple CCW-oriented polygon - // ... - CGAL::y_monotone_partition_2(P.vertices_begin(), - P.vertices_end(), - std::back_inserter(partition_polys)); -\end{verbatim} +\ccIncludeExampleCode{Partition_2/y_monotone_ex.C} diff --git a/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/is_y_monotone_2.tex b/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/is_y_monotone_2.tex index ecd83017c4d..7d4d6679449 100644 --- a/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/is_y_monotone_2.tex +++ b/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/is_y_monotone_2.tex @@ -11,17 +11,17 @@ Function for testing the $y$-monotonicity of a sequence of points. \ccFunction{ template bool -is_y_monotone_2(InputIterator first, InputIterator last, +is_y_monotone_2(InputIterator first, InputIterator beyond, const Traits& traits); } { Determines if the sequence of points in the range -[\ccc{first}, \ccc{last}) define a $y$-monotone +[\ccc{first}, \ccc{beyond}) define a $y$-monotone polygon or not. If so, the function returns \ccc{true}, otherwise it returns \ccc{false}. } -\ccHeading{Preconditions} +\ccHeading{Requirements} \ccIndexSubitem[C]{is_y_monotone_2}{preconditions} \begin{enumerate} \item \ccc{Traits} is a model of the concept IsYMonotoneTraits\_2.% @@ -29,57 +29,31 @@ returns \ccc{false}. \item \ccc{InputIterator::value_type} should be \ccc{Traits::Point_2}. \end{enumerate} -The default traits class \ccc{Default_traits} is the \cgal\ \ccc{Kernel_traits_2} -class, +The default traits class \ccc{Default_traits} is the kernel in which the +type \ccc{InputIterator::value_type} is defined.% \ccIndexTraitsClassDefault{is_y_monotone_2} -with the representation type determined by \ccc{InputIterator::value_type}. \ccSeeAlso \ccRefIdfierPage{CGAL::Is_y_monotone_2} \\ \ccRefIdfierPage{CGAL::y_monotone_partition_2} \\ \ccRefIdfierPage{CGAL::y_monotone_partition_is_valid_2} +\ccImplementation + +This function requires $O(n)$ time for a polygon with $n$ vertices. + \ccExample -The following code fragment computes a $y$-monotone partitioning -of the simple polygon \ccc{P} using the default +The following program computes a $y$-monotone partitioning +of a polygon using the default traits class and stores the partition polygons in the list \ccc{partition_polys}. It then asserts that each of the partition -polygons is, in fact, a $y$-monotone polygon. (Note that this -assertion is superfluous unless the postcondition checking done +polygons is, in fact, a $y$-monotone polygon and that the partition +is valid. (Note that the +assertions are superfluous unless the postcondition checking done by \ccc{y_monotone_partition_2} has been turned off during compilation.) -\begin{verbatim} - #include - #include - #include - #include - #include - #include - - typedef CGAL::Cartesian R; - typedef CGAL::Polygon_traits_2 Traits; - typedef Traits::Point_2 Point_2; - typedef Traits::Polygon_2 Polygon_2 - - Polygon_2 P; - std::list partition_polys; - - // ... - // insert vertices into P to create a simple CCW-oriented polygon - // ... - CGAL::y_monotone_partition_2(P.vertices_begin(), - P.vertices_end(), - std::back_inserter(partition_polys)); - - std::list::const_iterator poly_it; - for (poly_it = partition_polys.begin(); poly_it != partition_polys.end(); - poly_it++) - { - assert(CGAL::is_y_monotone_2((*poly_it).vertices_begin(), - (*poly_it).vertices_end())); - } -\end{verbatim} +\ccIncludeExampleCode{Partition_2/y_monotone_ex.C} diff --git a/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/y_monotone_partition_2.tex b/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/y_monotone_partition_2.tex index 8b11510f422..b177f5b6632 100644 --- a/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/y_monotone_partition_2.tex +++ b/Packages/Partition_2/doc_tex/basic/Partition_2/Partition_2_ref/y_monotone_partition_2.tex @@ -16,15 +16,17 @@ OutputIterator y_monotone_partition_2(InputIterator first, const Traits& traits = Default_traits); } { -computes a partition of the simple, counterclockwise-oriented polygon defined -by the points in the range [\ccc{first}, \ccc{last}) into $y$-monotone +computes a partition of the polygon defined +by the points in the range [\ccc{first}, \ccc{beyond}) into $y$-monotone polygons. The counterclockwise-oriented partition polygons are written to the sequence starting at position \ccc{result}. The past-the-end iterator for the resulting sequence of polygons is returned. +\ccPrecond The points in the range [\ccc{first}, \ccc{beyond}) define a +simple, counterclockwise-oriented polygon. +%\ccIndexSubitem[C]{y_monotone_partition_2}{preconditions} } \ccHeading{Requirements} -%\ccIndexSubitem[C]{y_monotone_partition_2}{preconditions} \begin{enumerate} \item \ccc{Traits} is a model of the concept YMonotonePartitionTraits\_2% \ccIndexMainItem[c]{YMonotonePartitionTraits_2} and, for the purposes @@ -36,8 +38,6 @@ the resulting sequence of polygons is returned. \item \ccc{InputIterator::value_type} should be \ccc{Traits::Point_2}, which should also be the type of the points stored in an object of type \ccc{Traits::Polygon_2}. - \item Points in the range $[first, beyond)$ must define a simple polygon - whose vertices are oriented counterclockwise. \end{enumerate} The default traits class \ccc{Default_traits} is \ccc{Partition_traits_2}, @@ -53,41 +53,22 @@ with the representation type determined by \ccc{InputIterator::value_type}. \ccImplementation -This function implements the algorithm presented by de Bert \textit{et al.} +This function implements the algorithm presented by de Berg \textit{et al.} \cite{bkos-cgaa-97} which requires $O(n \log n)$ time and $O(n)$ space for a polygon with $n$ vertices. \ccExample -The following code fragment will compute a $y$-monotone partitioning -of the simple polygon \ccc{P} using the default -traits class and store the partition polygons in the list -\ccc{partition_polys}. +The following program computes a $y$-monotone partitioning +of a polygon using the default +traits class and stores the partition polygons in the list +\ccc{partition_polys}. It then asserts that each partition polygon +produced is, in fact, $y$-monotone and that the partition is valid. +(Note that these assertions are superfluous unless the postcondition +checking for \ccc{y_monotone_partition_2} has been turned off.) -\begin{verbatim} - #include - #include - #include - #include - #include - - typedef CGAL::Cartesian R; - typedef CGAL::Polygon_traits_2 Traits; - typedef Traits::Point_2 Point_2; - typedef std::list Container; - typedef CGAL::Polygon_2 Polygon_2; - - Polygon_2 P; - std::list partition_polys; - - // ... - // insert vertices into P to create a simple CCW-oriented polygon - // ... - CGAL::y_monotone_partition_2(P.vertices_begin(), - P.vertices_end(), - std::back_inserter(partition_polys)); -\end{verbatim} +\ccIncludeExampleCode{Partition_2/y_monotone_ex.C}