Make Partition_2 work with g++

This commit is contained in:
Andreas Fabri 2017-10-30 12:55:21 +01:00
parent 1d332f5de3
commit a2fc6e1830
9 changed files with 39 additions and 26 deletions

View File

@ -71,7 +71,8 @@ between $p$ and $q$. If $p$ and $q$ are antipodal of each other then we
create any great circle that contains $p$ and $q$.}*/
{ Point_3 p1(0,0,0), p4 = CGAL::ORIGIN + ((Base*) this)->orthogonal_vector();
if ( p != q.antipode() ) {
if (R_().orientation_3_object()(p1,p,q,p4) != CGAL::POSITIVE )
if (R_().orientation_3_object()(p1,Point_3(p),
Point_3(q), p4) != CGAL::POSITIVE )
*this = Self(opposite());
} else {
/* previous method was: *this = Self(Plane_3(p1,q-p));

View File

@ -193,13 +193,18 @@ void split_halfcircle(Sphere_segment<R>& s1,
bool is_short() const
/*{\Mop a segment is short iff it is shorter than a halfcircle.}*/
{
return R().orientation_3_object()(Point_3(0,0,0), source(), target(),
CGAL::ORIGIN + this->ptr()->c_.orthogonal_vector())
return R().orientation_3_object()(Point_3(0,0,0),
Point_3(source()),
Point_3(target()),
CGAL::ORIGIN +
this->ptr()->c_.orthogonal_vector())
== CGAL::POSITIVE; }
bool is_long() const
/*{\Mop a segment is long iff it is longer than a halfcircle.}*/
{ return R().orientation_3_object()(Point_3(0,0,0), source(), target(),
{ return R().orientation_3_object()(Point_3(0,0,0),
Point_3(source()),
Point_3(target()),
CGAL::ORIGIN + this->ptr()->c_.orthogonal_vector())
== CGAL::NEGATIVE; }

View File

@ -61,13 +61,13 @@ class Indirect_edge_compare
ForwardCirculator edge_vtx_2 = edge_vtx_1;
edge_vtx_2++;
// check for horizontal edge
if(_compare_y_2((*edge_vtx_1), (*edge_vtx_2)) == EQUAL)
if(_compare_y_2(Point_2(*edge_vtx_1), Point_2(*edge_vtx_2)) == EQUAL)
{
// compare the smaller x and vertex x
if(_compare_x_2(*edge_vtx_1, *edge_vtx_2) == SMALLER)
return _compare_x_2(*edge_vtx_1, *vertex) == LARGER;
if(_compare_x_2(Point_2(*edge_vtx_1), Point_2(*edge_vtx_2)) == SMALLER)
return _compare_x_2(Point_2(*edge_vtx_1), Point_2(*vertex)) == LARGER;
else
return _compare_x_2(*edge_vtx_2, *vertex) == LARGER;
return _compare_x_2(Point_2(*edge_vtx_2), Point_2(*vertex)) == LARGER;
}
else
{
@ -110,11 +110,11 @@ class Indirect_edge_compare
{
Point_2 p_max;
Point_2 q_max;
if (_compare_x_2(*p, *after_p) == SMALLER)
if (_compare_x_2(Point_2(*p), Point_2(*after_p)) == SMALLER)
p_max = *after_p;
else
p_max = *p;
if (_compare_x_2(*q, *after_q) == SMALLER)
if (_compare_x_2(Point_2(*q), Point_2(*after_q)) == SMALLER)
q_max = *after_q;
else
q_max = *q;

View File

@ -67,7 +67,8 @@ public:
_validity = PARTITION_OPT_CVX_NOT_VALID;
Turn_reverser<Point_2_, Left_turn_2> right_turn(left_turn);
Turn_reverser<typename Traits::Point_2,
Left_turn_2> right_turn(left_turn);
if (right_turn(p1, p2, p3))
_validity = PARTITION_OPT_CVX_START_VALID;
if (right_turn(p4, p5, p6)) {

View File

@ -47,15 +47,15 @@ public:
_vertex(vertex),
_prev_v_ref(prev_ref)
{
_vertex_orientation = _orientation(*_prev_v_ref, vertex, *next_ref);
_vertex_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(vertex), Point_2(*next_ref));
}
bool
operator()(Iterator d1, Iterator d2)
{
Orientation d1_orientation = _orientation(*_prev_v_ref, _vertex, *d1);
Orientation d2_orientation = _orientation(*_prev_v_ref, _vertex, *d2);
Orientation d1_to_d2 = _orientation(*d1, _vertex, *d2);
Orientation d1_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(_vertex), Point_2(*d1));
Orientation d2_orientation = _orientation(Point_2(*_prev_v_ref), Point_2(_vertex), Point_2(*d2));
Orientation d1_to_d2 = _orientation(Point_2(*d1), Point_2(_vertex), Point_2(*d2));
// if both diagonals are on the same side of the line from previous
// vertex to this vertex then d1 comes before d2 (in CW order from

View File

@ -53,8 +53,9 @@ bool partition_appx_cvx_is_edge_through_interior(const Point_2& before_s,
{
// determine if the edge goes through the interior of the polygon or not
typedef typename Traits::Left_turn_2 Left_turn_2;
typedef typename Traits::Point_2 Bare_point_2;
Left_turn_2 left_turn = traits.left_turn_2_object();
Turn_reverser<Point_2, Left_turn_2> right_turn(left_turn);
Turn_reverser<Bare_point_2, Left_turn_2> right_turn(left_turn);
if (right_turn(before_s, source, after_s)) // concave angle
{
if (right_turn(before_s, source, target) &&

View File

@ -209,11 +209,13 @@ bool collinearly_visible(unsigned int edge_num1, unsigned int e_num,
const Traits& traits)
{
typedef typename Traits::Orientation_2 Orientation_2;
typedef typename Traits::Point_2 Point_2;
Orientation_2 orientation = traits.orientation_2_object();
if ((e_num == edge_num1+1 || e_num+1 == edge_num2) &&
edges[edge_num1][edge_num2].is_visible() &&
orientation(polygon[edge_num1], polygon[e_num], polygon[edge_num2]) ==
orientation(Point_2(polygon[edge_num1]), Point_2(polygon[e_num]),
Point_2(polygon[edge_num2])) ==
COLLINEAR)
return true;
else
@ -364,6 +366,7 @@ void make_collinear_vertices_visible(Polygon& polygon,
{
typedef typename Polygon::size_type size_type;
typedef typename Traits::Orientation_2 Orientation_2;
typedef typename Traits::Point_2 Point_2;
Orientation_2 orientation = traits.orientation_2_object();
size_type i;
@ -380,7 +383,7 @@ void make_collinear_vertices_visible(Polygon& polygon,
j = 1;
size_type start_i = 0;
while (i > 0 &&
orientation(polygon[i], polygon[prev_j], polygon[j]) == COLLINEAR)
orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) == COLLINEAR)
{
prev_j = i;
start_i = i;
@ -390,7 +393,7 @@ void make_collinear_vertices_visible(Polygon& polygon,
prev_j = 1;
j = 2;
while (j < polygon.size() &&
orientation(polygon[i], polygon[prev_j], polygon[j]) == COLLINEAR)
orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) == COLLINEAR)
{
i++;
prev_j++;
@ -419,7 +422,7 @@ void make_collinear_vertices_visible(Polygon& polygon,
prev_j = i+1;
j = i+2;
while (j < polygon.size() &&
orientation(polygon[i], polygon[prev_j], polygon[j]) ==
orientation(Point_2(polygon[i]), Point_2(polygon[prev_j]), Point_2(polygon[j])) ==
COLLINEAR)
{
j++;

View File

@ -83,8 +83,8 @@ Partition_y_mono_vertex_type partition_y_mono_vertex_type(
#endif
typename Traits::Compare_y_2 compare_y_2 = traits.compare_y_2_object();
if (compare_y_2(*previous, *c) == EQUAL &&
compare_y_2(*next, *c) == EQUAL)
if (compare_y_2(Point_2(*previous), Point_2(*c)) == EQUAL &&
compare_y_2(Point_2(*next), Point_2(*c)) == EQUAL)
return PARTITION_Y_MONO_COLLINEAR_VERTEX;
typename Traits::Less_yx_2 less_yx = traits.less_yx_2_object();
@ -300,16 +300,17 @@ template <class BidirectionalCirculator, class Traits>
bool partition_y_mono_interior_to_right(BidirectionalCirculator c,
const Traits& traits)
{
typedef typename Traits::Point_2 Point_2;
typename Traits::Compare_y_2 compare_y_2 = traits.compare_y_2_object();
BidirectionalCirculator previous = c; previous--;
Comparison_result cmp_y = compare_y_2(*previous, *c);
Comparison_result cmp_y = compare_y_2(Point_2(*previous), Point_2(*c));
if (cmp_y == LARGER) return true;
BidirectionalCirculator next = c; next++;
if (cmp_y == EQUAL && compare_y_2(*next, *c) == SMALLER) return true;
if (cmp_y == EQUAL && compare_y_2(Point_2(*next), Point_2(*c)) == SMALLER) return true;
return false;
}

View File

@ -416,7 +416,8 @@ Orientation orientation_2(ForwardIterator first,
// of the points (prev,i,next) will coincide
// return the orientation of the triple (prev,i,next)
return traits.orientation_2_object()(*prev, *i, *next);
typedef typename Traits::Point_2 Point;
return traits.orientation_2_object()(Point(*prev), Point(*i), Point(*next));
}
} //namespace CGAL