Give public methods more descriptive names, default one defaults to reduced conv

This commit is contained in:
Sebastian Morr 2014-08-11 12:01:12 +02:00
parent 6f609e7122
commit 55d0e7bf45
2 changed files with 49 additions and 21 deletions

View File

@ -30,21 +30,49 @@
namespace CGAL {
/*!
* Computes the Minkowski sum \f$ P \oplus Q\f$ of the two given polygons.
* The function computes the reduced convolution of the two polygons and
* extracts those loops of the convolution which are part of the Minkowsi
* sum. This method works very efficiently, regardless of whether `P` and
* `Q` are convex or non-convex.
* Note that as the input polygons may not be convex, their Minkowski
* sum may not be a simple polygon. The result is therefore represented
* as a polygon with holes.
* \pre Both `P` and `Q` are simple, counterclockwise-oriented polygons.
*/
template <class Kernel, class Container>
Polygon_with_holes_2<Kernel,Container>
minkowski_sum_by_reduced_convolution_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
{
Minkowski_sum_by_reduced_convolution_2<Kernel, Container> mink_sum;
Polygon_2<Kernel,Container> sum_bound;
std::list<Polygon_2<Kernel,Container> > sum_holes;
if (pgn1.size() > pgn2.size())
mink_sum (pgn1, pgn2, sum_bound, std::back_inserter(sum_holes));
else
mink_sum (pgn2, pgn1, sum_bound, std::back_inserter(sum_holes));
return (Polygon_with_holes_2<Kernel,Container> (sum_bound,
sum_holes.begin(),
sum_holes.end()));
}
/*!
* Compute the Minkowski sum of two simple polygons using the convolution
* method.
* Note that as the input polygons may not be convex, their Minkowski sum may
* not be a simple polygon. The result is therefore represented as a polygon
* with holes.
* \param pgn1 The first polygon.
* \param pgn2 The second polygon.
* \return The resulting polygon with holes, representing the sum.
*/
template <class Kernel, class Container>
Polygon_with_holes_2<Kernel,Container>
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
minkowski_sum_by_full_convolution_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
{
Minkowski_sum_by_convolution_2<Kernel, Container> mink_sum;
Polygon_2<Kernel,Container> sum_bound;
@ -60,23 +88,23 @@ minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
sum_holes.end()));
}
/*!
* Compute the Minkowski sum of two simple polygons using the reduced
* convolution method.
* Note that as the input polygons may not be convex, their Minkowski sum may
* not be a simple polygon. The result is therefore represented as a polygon
* with holes.
*
* \sa `CGAL::minkowski_sum_by_reduced_convolution_2()`
* \sa `CGAL::minkowski_sum_by_full_convolution_2()`
*/
template <class Kernel, class Container>
Polygon_with_holes_2<Kernel,Container>
minkowski_sum_2_new (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
minkowski_sum_2 (const Polygon_2<Kernel,Container>& pgn1,
const Polygon_2<Kernel,Container>& pgn2)
{
Minkowski_sum_by_reduced_convolution_2<Kernel, Container> mink_sum;
Polygon_2<Kernel,Container> sum_bound;
std::list<Polygon_2<Kernel,Container> > sum_holes;
if (pgn1.size() > pgn2.size())
mink_sum (pgn1, pgn2, sum_bound, std::back_inserter(sum_holes));
else
mink_sum (pgn2, pgn1, sum_bound, std::back_inserter(sum_holes));
return (Polygon_with_holes_2<Kernel,Container> (sum_bound,
sum_holes.begin(),
sum_holes.end()));
return minkowski_sum_by_reduced_convolution_2(pgn1, pgn2);
}
/*!

View File

@ -95,7 +95,7 @@ int main (int argc, char **argv)
std::cout << "Using the reduced convolution method ... ";
timer.reset();
timer.start();
sum_conv_new = minkowski_sum_2_new (pgn1, pgn2);
sum_conv_new = minkowski_sum_by_reduced_convolution_2 (pgn1, pgn2);
timer.stop();
std::cout << "Done (" << timer.time() << " s)" << std::endl;
@ -120,7 +120,7 @@ int main (int argc, char **argv)
std::cout << "Using the convolution method ... ";
timer.reset();
timer.start();
sum_conv = minkowski_sum_2 (pgn1, pgn2);
sum_conv = minkowski_sum_by_full_convolution_2 (pgn1, pgn2);
timer.stop();
if (are_equal (result, sum_conv))
{