1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
// Copyright (c) 2005,2006,2007,2008,2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1.1/Set_movable_separability_2/include/CGAL/Set_movable_separability_2/internal/Utils.h $
// $Id: include/CGAL/Set_movable_separability_2/internal/Utils.h 08b27d3db14 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Shahar <shasha94@gmail.com>
// Efi Fogel <efif@gmail.com>
#ifndef CGAL_SET_MOVABLE_SEPARABILITY_2_INTERNAL_UTILS_H
#define CGAL_SET_MOVABLE_SEPARABILITY_2_INTERNAL_UTILS_H
#include <CGAL/license/Set_movable_separability_2.h>
#include <CGAL/enum.h>
#include <CGAL/Polygon_2.h>
namespace CGAL {
namespace Set_movable_separability_2 {
namespace internal {
/*! \fn std::pair<typename Kernel::Direction_2,typename Kernel::Direction_2> get_segment_outer_circle(typename Kernel::Segment_2 seg, CGAL::Orientation orientation)
* \param[in] seg the polygon segment
* \param[in] orientation the orientation of the segment (and the polygon).
* if CLOCKWISE then the outer half circle is to the left.
* \return the open outer half-circle of the edge.
*/
template <typename Kernel>
inline std::pair<typename Kernel::Direction_2, typename Kernel::Direction_2>
get_segment_outer_circle(const typename Kernel::Segment_2 seg,
const CGAL::Orientation orientation)
{
typename Kernel::Direction_2 forward( seg);
typename Kernel::Direction_2 backward(-forward);
return (orientation == CGAL::CLOCKWISE) ?
std::make_pair(backward, forward) : std::make_pair(forward, backward);
}
template <typename Kernel>
bool is_any_edge_collinear(const CGAL::Polygon_2<Kernel>& pgn, Kernel& kernel)
{
typedef typename Kernel::Point_2 Point_2;
typedef typename CGAL::Polygon_2<Kernel> Polygon_2;
typedef typename Polygon_2::Vertex_const_iterator Vertex_const_iterator;
auto collinear = kernel.collinear_2_object();
Vertex_const_iterator vci = pgn.vertices_begin();
Point_2 firstVar = *(vci++);
Point_2 secondVar = *(vci++);
Point_2 thirdVar = *(vci++);
for (; vci != pgn.vertices_end(); ++vci) {
firstVar = secondVar;
secondVar = thirdVar;
thirdVar = *vci;
if (collinear(firstVar, secondVar, thirdVar)) return true;
}
vci = pgn.vertices_begin();
firstVar = secondVar;
secondVar = thirdVar;
thirdVar = *(vci++);
if(collinear(firstVar, secondVar, thirdVar)) return true;
firstVar = secondVar;
secondVar = thirdVar;
thirdVar = *(vci++);
if (collinear(firstVar, secondVar, thirdVar)) return true;
return false;
}
} // namespace internal
} // namespace Set_movable_separability_2
} // namespace CGAL
#endif
|