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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
// Copyright (c) 1998 Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Convex_hull_2/include/CGAL/segment_intersection_points_2.h $
// $Id: include/CGAL/segment_intersection_points_2.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL_SEGMENT_INTERSECTION_POINTS_2_H
#define CGAL_SEGMENT_INTERSECTION_POINTS_2_H
#include <CGAL/license/Convex_hull_2.h>
#include <CGAL/basic.h>
#include <CGAL/algorithm.h>
#include <iterator>
namespace CGAL {
/*
#include <CGAL/Intersections_2/Segment_2_Segment_2.h>
template <class ForwardIterator, class OutputIterator, class R>
OutputIterator
si_brute_force(ForwardIterator first, ForwardIterator last,
OutputIterator result,
const R& )
{
typedef Point_2<R> Point;
ForwardIterator inner, outer;
Object i_obj;
Point p;
for ( outer = first; outer != last; ++outer)
for ( inner = successor(outer); inner != last; ++inner)
{
i_obj = intersection( *outer, *inner);
if ( assign( p, i_obj) )
result++ = p;
}
return result;
}
*/
template <class ForwardIterator, class OutputIterator, class Traits>
OutputIterator
si_brute_force_II(ForwardIterator first, ForwardIterator last,
OutputIterator result,
const Traits& traits)
{
typedef typename Traits::Point_2 Point;
typedef typename Traits::Line_2 Line;
typedef typename Traits::Orientation_2 Orientation;
Orientation orientation = traits.orientation_2_object();
for ( ForwardIterator outer = first; outer != last; ++outer)
for ( ForwardIterator inner = std::next(outer); inner != last; ++inner)
{
Point s1 = (*outer).source();
Point e1 = (*outer).target();
Point s2 = (*inner).source();
Point e2 = (*inner).target();
if ( (orientation( s1, e1, s2) != orientation( s1, e1, e2))
&&(orientation( s2, e2, s1) != orientation( s2, e2, e1)))
{
Line l1( s1, e1);
Line l2( s2, e2);
result++ = Point( l1.b()*l2.c() - l2.b()*l1.c(),
l2.a()*l1.c() - l1.a()*l2.c(),
l1.a()*l2.b() - l2.a()*l1.b());
}
}
return result;
}
template <class ForwardIterator, class OutputIterator, class Traits>
OutputIterator
segment_intersection_points_2(ForwardIterator first, ForwardIterator last,
OutputIterator result,
const Traits& traits)
{ return si_brute_force_II( first, last, result, traits); }
template <class ForwardIterator, class OutputIterator, class Traits>
OutputIterator
segment_intersection_points_2(ForwardIterator first, ForwardIterator last,
OutputIterator result)
{
typedef std::iterator_traits<ForwardIterator> ITraits;
typedef typename ITraits::value_type value_type;
typedef CGAL::Kernel_traits<value_type> KTraits;
typedef typename KTraits::Kernel Kernel;
return segment_intersection_points_2( first, last, result, Kernel());
}
} // namespace CGAL
#endif // CGAL_SEGMENT_INTERSECTION_POINTS_2_H
|