/usr/include/CGAL/Orientation_Linf_2.h is in libcgal-dev 4.7-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | // Copyright (c) 2015 Università della Svizzera italiana.
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Panagiotis Cheilaris, Sandeep Kumar Dey, Evanthia Papadopoulou
//philaris@gmail.com, sandeep.kr.dey@gmail.com, evanthia.papadopoulou@usi.ch
#ifndef CGAL_ORIENTATION_LINF_2_H
#define CGAL_ORIENTATION_LINF_2_H
#include <CGAL/basic.h>
#include <CGAL/enum.h>
namespace CGAL {
typedef Sign OrientationLinf;
template<class K>
class Orientation_Linf_2
{
private:
typedef typename K::Point_2 Point_2;
typedef typename K::Compare_x_2 Compare_x_2;
typedef typename K::Compare_y_2 Compare_y_2;
typedef typename K::Comparison_result Comparison_result;
Compare_x_2 compare_x_2;
Compare_y_2 compare_y_2;
OrientationLinf predicate(const Point_2& p, const Point_2& q,
const Point_2& r) const
{
Comparison_result cmpxpq = compare_x_2(p, q);
Comparison_result cmpypq = compare_y_2(p, q);
Comparison_result cmpxpr = compare_x_2(p, r);
Comparison_result cmpypr = compare_y_2(p, r);
Comparison_result cmpxqr = compare_x_2(q, r);
Comparison_result cmpyqr = compare_y_2(q, r);
//std::cout << "debug Orientation_Linf_2 (p,q,r)= "
// << p << ' ' << q << ' ' << r
// << std::endl;
if ( cmpxpq == EQUAL ) {
if (cmpypq == EQUAL) {//p and q are same points
return DEGENERATE;
}
else {//pq forms a vertical line
if (cmpxpr == EQUAL) {//r lies on the vertical line formed by pq
return DEGENERATE;
}
else {
return (cmpypq == cmpxpr) ? RIGHT_TURN : LEFT_TURN ;
}
}
}
else if ( cmpypq == EQUAL ) {//p and q forms a horizontal line
// here: cmpxpq != EQUAL
if (cmpypr == EQUAL) {//r lies on the horizontal line formed by pq
return DEGENERATE;
}
else {
return (cmpxpq == cmpypr) ? LEFT_TURN : RIGHT_TURN ;
}
}
else {
// here both cmpxpq != EQUAL and cmpypq != EQUAL
bool is_monotone =
( ( ( cmpxpr == -cmpxqr ) &&
( cmpypr == -cmpyqr ) ) ||
( ( cmpxpq == cmpxpr) && ( cmpxpr == cmpxqr ) &&
( cmpypq == cmpypr) && ( cmpypr == cmpyqr ) ) ||
( (-cmpxpq == cmpxpr) && ( cmpxpr == cmpxqr) &&
(-cmpypq == cmpypr) && ( cmpypr == cmpyqr) ) ) ;
//std::cout << "debug is_monotone=" << is_monotone << std::endl;
if (is_monotone) {
//p, q, r are monotone here
//std::cout << "debug Orientation_Linf_2 are monotone"
// << std::endl;
return DEGENERATE;
}
else { // p, q, r do not form stair case
//std::cout << "debug Orientation_Linf_2 not monotone"
// << std::endl;
if ( cmpxpq == SMALLER ) {
if ( cmpypq == SMALLER ) {//CASE-I q lies in the North East of p
return (cmpyqr == SMALLER ||
cmpxpr == LARGER ||
(cmpxqr == LARGER && cmpypr == SMALLER)) ?
LEFT_TURN : RIGHT_TURN;
}//end of CASE-I
else {
// compare_y_2(p, q) == LARGER --
// CASE-II q lies in the South East of p
return (cmpxqr == SMALLER ||
cmpypr == SMALLER ||
(cmpxpr == SMALLER && cmpyqr == SMALLER)) ?
LEFT_TURN : RIGHT_TURN;
}//end of CASE-II
}
else {//cmpxpq == LARGER case III and case IV
//std::cout << "debug Orientation_Linf_2 cmpxpq LARGER"
// << std::endl;
if ( cmpypq == SMALLER ) {//CASE-III q lies in the North West of p
//std::cout << "debug Orientation_Linf_2 cmpypq SMALLER"
// << std::endl;
return (cmpxpr == SMALLER ||
cmpyqr == SMALLER ||
(cmpxqr == SMALLER && cmpypr == SMALLER)) ?
RIGHT_TURN : LEFT_TURN;
}//end of CASE-III
else {//compare_y_2(p, q) == LARGER -- CASE-IV q lies in the South West of p
//std::cout << "debug Orientation_Linf_2 cmpypq LARGER"
// << std::endl;
return (cmpypr == SMALLER ||
cmpxqr == LARGER ||
(cmpxpr == LARGER && cmpyqr == SMALLER)) ?
RIGHT_TURN : LEFT_TURN;
}//end of CASE-IV
}
}
}
}
public:
typedef OrientationLinf result_type;
typedef Point_2 argument_type;
OrientationLinf operator()(const Point_2& p, const Point_2& q,
const Point_2& r) const
{
return predicate(p, q, r);
}
};
} //namespace CGAL
#endif // CGAL_ORIENTATION_LINF_2_H
|