// ============================================================================ // // Copyright (c) 1997 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------------- // // release : $CGAL_Revision: CGAL-0.9-I-06 $ // release_date : $CGAL_Date: 1998/03/11 $ // // file : include/CGAL/Polygon_2_algorithms.h // source : // revision : 1.8a // revision_date : 13 Mar 1998 // author(s) : Wieger Wesselink // // coordinator : Utrecht University // // ============================================================================ #ifndef CGAL_POLYGON_2_ALGORITHMS_H #define CGAL_POLYGON_2_ALGORITHMS_H #include #include #include #include #ifdef CGAL_REP_CLASS_DEFINED #include #endif // CGAL_REP_CLASS_DEFINED CGAL_BEGIN_NAMESPACE //-----------------------------------------------------------------------// // algorithms for sequences of 2D points //-----------------------------------------------------------------------// template ForwardIterator left_vertex_2(ForwardIterator first, ForwardIterator last, const Traits& traits); template ForwardIterator right_vertex_2(ForwardIterator first, ForwardIterator last, const Traits& traits); template ForwardIterator top_vertex_2(ForwardIterator first, ForwardIterator last, const Traits& traits); template ForwardIterator bottom_vertex_2(ForwardIterator first, ForwardIterator last, const Traits& traits); template Bbox_2 bbox_2(InputIterator first, InputIterator last); template void area_2( ForwardIterator first, ForwardIterator last, typename std::iterator_traits::value_type::FT& result, const Traits& traits) { typedef typename std::iterator_traits::value_type::FT FT; result = FT(0); // check if the polygon is empty if (first == last) return; ForwardIterator second = first; ++second; // check if the polygon has only one point if (second == last) return; ForwardIterator third = second; while (++third != last) { result = result + traits.determinant_2(*first, *second, *third); second = third; } result = result / FT(2); } template bool is_convex_2(ForwardIterator first, ForwardIterator last, const Traits& traits); template bool is_simple_2(ForwardIterator first, ForwardIterator last, const Traits& traits); // In the following two functions we would like to use Traits::Point_2 instead // of Point, but this is not allowed by g++ 2.7.2. template Oriented_side oriented_side_2(ForwardIterator first, ForwardIterator last, const Point& point, const Traits& traits); template Bounded_side bounded_side_2(ForwardIterator first, ForwardIterator last, const Point& point, const Traits& traits); template Orientation orientation_2(ForwardIterator first, ForwardIterator last, const Traits& traits); //-----------------------------------------------------------------------// // implementation //-----------------------------------------------------------------------// #ifdef CGAL_REP_CLASS_DEFINED template inline ForwardIterator left_vertex_2_aux(ForwardIterator first, ForwardIterator last, const Point_2) { return left_vertex_2(first, last, Polygon_traits_2()); } template inline ForwardIterator left_vertex_2(ForwardIterator first, ForwardIterator last) { return left_vertex_2_aux(first, last, *first); } template inline ForwardIterator right_vertex_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return right_vertex_2(first, last, Polygon_traits_2()); } template inline ForwardIterator right_vertex_2(ForwardIterator first, ForwardIterator last) { return right_vertex_2_aux(first, last, *first); } template inline ForwardIterator top_vertex_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return top_vertex_2(first, last, Polygon_traits_2()); } template inline ForwardIterator top_vertex_2(ForwardIterator first, ForwardIterator last) { return top_vertex_2_aux(first, last, *first); } template inline ForwardIterator bottom_vertex_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return bottom_vertex_2(first, last, Polygon_traits_2()); } template inline ForwardIterator bottom_vertex_2(ForwardIterator first, ForwardIterator last) { return bottom_vertex_2_aux(first, last, *first); } template inline void area_2_aux(ForwardIterator first, ForwardIterator last, Numbertype& result, const Point_2&) { area_2(first, last, result, Polygon_traits_2()); } template inline void area_2(ForwardIterator first, ForwardIterator last, Numbertype& result) { area_2_aux(first, last, result, *first); } template inline bool is_convex_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return is_convex_2(first, last, Polygon_traits_2()); } template inline bool is_convex_2(ForwardIterator first, ForwardIterator last) { return is_convex_2_aux(first, last, *first); } template inline bool is_simple_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return is_simple_2(first, last, Polygon_traits_2()); } template inline bool is_simple_2(ForwardIterator first, ForwardIterator last) { return is_simple_2_aux(first, last, *first); } template inline Oriented_side oriented_side_2(ForwardIterator first, ForwardIterator last, const Point_2& point) { return oriented_side_2(first, last, point, Polygon_traits_2()); } template inline Bounded_side bounded_side_2(ForwardIterator first, ForwardIterator last, const Point_2& point) { return bounded_side_2(first, last, point, Polygon_traits_2()); } template inline Orientation orientation_2_aux(ForwardIterator first, ForwardIterator last, const Point_2&) { return orientation_2(first, last, Polygon_traits_2()); } template inline Orientation orientation_2(ForwardIterator first, ForwardIterator last) { return orientation_2_aux(first, last, *first); } #endif // CGAL_REP_CLASS_DEFINED CGAL_END_NAMESPACE #ifdef CGAL_CFG_NO_AUTOMATIC_TEMPLATE_INCLUSION #include #endif // CGAL_CFG_NO_AUTOMATIC_TEMPLATE_INCLUSION #endif // CGAL_POLYGON_2_ALGORITHMS_H