diff --git a/Packages/Distance_2/web/sqdistance_2.fw b/Packages/Distance_2/web/sqdistance_2.fw index b5a32ebe270..dd95604ddb4 100644 --- a/Packages/Distance_2/web/sqdistance_2.fw +++ b/Packages/Distance_2/web/sqdistance_2.fw @@ -179,11 +179,11 @@ Note the double occurrence of the factor@{wq@} in the latter definition. @$@<2D squared distance general utilities@>+=@{ template -R::RT +typename R::RT wdot(const Vector_2 &u, const Vector_2 &v) { - return (R::RT)(u.hx()*v.hx() + u.hy()*v.hy()); + return (u.hx()*v.hx() + u.hy()*v.hy()); } #ifdef CGAL_HOMOGENEOUS_H @@ -231,11 +231,11 @@ definition of the wcross product for points. template -R::RT +typename R::RT wcross(const Vector_2 &u, const Vector_2 &v) { - return (R::RT)(u.hx()*v.hy() - u.hy()*v.hx()); + return (typename R::RT)(u.hx()*v.hy() - u.hy()*v.hx()); } #ifdef CGAL_HOMOGENEOUS_H @@ -406,13 +406,13 @@ of the difference vector. @$@<2D squared distance header declarations 1@>+=@{@- template -inline R::FT +inline typename R::FT squared_distance( const Point_2 & pt1, const Point_2 & pt2) { Vector_2 vec(pt1-pt2); - return (R::FT)(vec*vec); + return (typename R::FT)(vec*vec); } @} @@ -425,7 +425,7 @@ squared_distance( @ template -inline R::FT +inline typename R::FT squared_distance( const Line_2 & line, const Point_2 & pt) @@ -446,7 +446,7 @@ distance between the line and the point. @$@==@{ template -R::FT +typename R::FT squared_distance( const Point_2 &pt, const Line_2 &line) @@ -458,7 +458,7 @@ squared_distance( Vector_2 normal(x, y); Vector_2 diff = pt - line.point(); FT signdist = diff * normal; - return (R::FT)((signdist*signdist)/FT(x*x+y*y)); + return (typename R::FT)((signdist*signdist)/FT(x*x+y*y)); } @} @@ -471,7 +471,7 @@ squared_distance( @ template -inline R::FT +inline typename R::FT squared_distance( const Ray_2 & ray, const Point_2 & pt) @@ -493,7 +493,7 @@ point. @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Point_2 &pt, const Ray_2 &ray) @@ -501,7 +501,7 @@ squared_distance( Vector_2 diff = pt-ray.source(); const Vector_2 &dir = ray.direction().vector(); if (!is_acute_angle(dir,diff) ) - return (R::FT)(diff*diff); + return (typename R::FT)(diff*diff); return squared_distance(pt, ray.supporting_line()); } @} @@ -531,7 +531,7 @@ distance_index( } template -R::FT +typename R::FT squared_distance_indexed(const Point_2 &pt, const Ray_2 &ray, int ind) { @@ -547,7 +547,7 @@ squared_distance_indexed(const Point_2 &pt, @ template -inline R::FT +inline typename R::FT squared_distance( const Segment_2 & seg, const Point_2 & pt) @@ -574,7 +574,7 @@ segment is taken. @$@==@{ template -R::FT +typename R::FT squared_distance( const Point_2 &pt, const Segment_2 &seg) @@ -585,7 +585,7 @@ squared_distance( Vector_2 segvec = seg.target()-seg.source(); RT d = wdot(diff,segvec); if (d <= (RT)0) - return (R::FT)(diff*diff); + return (typename R::FT)(diff*diff); RT e = wdot(segvec,segvec); if (wmult((R*)0 ,d, segvec.hw()) > wmult((R*)0, e, diff.hw())) return squared_distance(pt, seg.target()); @@ -623,7 +623,7 @@ distance_index( } template -R::FT +typename R::FT squared_distance_indexed(const Point_2 &pt, const Segment_2 &seg, int ind) { @@ -674,7 +674,7 @@ This is checked separately. @$@<2D segment segment squared distance main routine@>+=@{ template -R::FT +typename R::FT squared_distance( const Segment_2 &seg1, const Segment_2 &seg2) @@ -736,7 +736,7 @@ distance from both endpoints to the other segment and taking the minimum. @$@@Z==@{ template -R::FT +typename R::FT _squared_distance_of_endpoint_exact(RT start_dm, RT end_dm, const Point_2 &start, const Point_2 &end, const Segment &seg) @@ -752,7 +752,7 @@ _squared_distance_of_endpoint_exact(RT start_dm, RT end_dm, } template -R::FT +typename R::FT _squared_distance_of_endpoint_inexact( const Point_2 &start, const Point_2 &end, const Segment &seg) @@ -761,11 +761,11 @@ _squared_distance_of_endpoint_inexact( RT d1, d2; d1 = squared_distance(start, seg); d2 = squared_distance(end, seg); - return (d1 < d2) ? (R::FT)(d1) : (R::FT)(d2); + return (d1 < d2) ? (typename R::FT)(d1) : (typename_R::FT)(d2); } template -inline R::FT +inline typename R::FT _squared_distance_of_endpoint(RT start_dm, RT end_dm, const Point_2 &start, const Point_2 &end, const Segment &seg) @@ -781,7 +781,7 @@ _squared_distance_of_endpoint(RT start_dm, RT end_dm, @$@<2D segment segment squared distance main routine@>+=@{ if (crossing1) { if (crossing2) - return (R::FT)((FT)0); + return (FT)0; RT dm; dm = _distance_measure_sub(c2s,c2e, seg2.source(), seg2.target()); if (dm < RT(0)) { @@ -833,9 +833,7 @@ segment and take the minimum. min2 = (dm < RT(0)) ? squared_distance(seg2.source(), seg1): squared_distance(seg2.target(), seg1); - return (min1 < min2) - ? (R::FT)(min1) - : (R::FT)(min2); + return (min1 < min2) ? min1 : min2; } } } @@ -875,7 +873,7 @@ to make the necessary decisions. @$@<2D segment segment squared distance parallel case@>+=@{ template -R::FT +typename R::FT squared_distance_parallel( const Segment_2 &seg1, const Segment_2 &seg2) @@ -917,7 +915,7 @@ squared_distance_parallel( @ template -inline R::FT +inline typename R::FT squared_distance( const Ray_2 & ray, const Segment_2 & seg) @@ -947,7 +945,7 @@ lies. @$@<2D ray segment squared distance computation@>+=@{ template -R::FT +typename R::FT squared_distance( const Segment_2 &seg, const Ray_2 &ray) @@ -1009,7 +1007,7 @@ product, first corrected by homogenising factors). @$@<2D ray segment squared distance computation@>+=@{ if (crossing1) { if (crossing2) - return (R::FT)(FT(0)); + return FT(0); return squared_distance(ray.source(), seg); } else { if (crossing2) { @@ -1043,9 +1041,7 @@ segment and take the minimum. ? squared_distance(seg.source(), ray) : squared_distance(seg.target(), ray); min2 = squared_distance(ray.source(), seg); - return (min1 < min2) - ? (R::FT)(min1) - : (R::FT)(min2); + return (min1 < min2) ? min1 : min2; } } } @@ -1053,7 +1049,7 @@ segment and take the minimum. @$@<2D ray segment squared distance parallel case@>==@{ template -R::FT +typename R::FT squared_distance_parallel( const Segment_2 &seg, const Ray_2 &ray) @@ -1103,7 +1099,7 @@ const Vector_2 &start, const Vector_2 &end @ template -inline R::FT +inline typename R::FT squared_distance( const Line_2 & line, const Segment_2 & seg) @@ -1127,7 +1123,7 @@ The boolean @{crossing1@} tells whether the segment crosses the line. @$@<2D line segment squared distance computation@>+=@{ template -R::FT +typename R::FT squared_distance( const Segment_2 &seg, const Line_2 &line) @@ -1169,7 +1165,7 @@ factors). @$@<2D line segment squared distance computation@>+=@{ if (crossing1) { - return (R::FT)((FT)0); + return (FT)0; } else { RT dm; dm = _distance_measure_sub(c1s, c1e, startvec, endvec); @@ -1195,7 +1191,7 @@ with hw factors. The hw factors of @{dir@} cancel. @$@<2D line segment squared distance helper routine@>==@{ template -R::FT +typename R::FT _sqd_to_line(const Vector_2 &diff, const RT & wcross, const Vector_2 &dir ) { @@ -1204,7 +1200,7 @@ _sqd_to_line(const Vector_2 &diff, RT denominator = wmult((R*)0, RT(wdot(dir,dir)), diff.hw(), diff.hw()); FT result = R::make_FT(numerator, denominator); - return (R::FT)(result); + return result; } @} @@ -1237,7 +1233,7 @@ We look at the direction of the ray and on which side its starting point lies. @$@<2D ray ray squared distance computation@>+=@{ template -R::FT +typename R::FT squared_distance( const Ray_2 &ray1, const Ray_2 &ray2) @@ -1277,7 +1273,7 @@ ray. @$@<2D ray ray squared distance computation@>+=@{ if (crossing1) { if (crossing2) - return (R::FT)((FT)0); + return (FT)0; return squared_distance(ray2.source(), ray1); } else { if (crossing2) { @@ -1294,9 +1290,7 @@ ray and take the minimum. FT min1, min2; min1 = squared_distance(ray1.source(), ray2); min2 = squared_distance(ray2.source(), ray1); - return (min1 < min2) - ? (R::FT)(min1) - : (R::FT)(min2); + return (min1 < min2) ? min1 : min2; } } } @@ -1314,7 +1308,7 @@ line of the other. @$@<2D ray ray squared distance parallel case@>==@{ template -R::FT +typename R::FT ray_ray_squared_distance_parallel( const Vector_2 &ray1dir, const Vector_2 &ray2dir, @@ -1332,12 +1326,12 @@ ray_ray_squared_distance_parallel( (sign(ray1dir.hy()) == sign(ray2dir.hy())); } if (!same_direction) - return (R::FT)(from1to2*from1to2); + return (typename R::FT)(from1to2*from1to2); } RT wcr, w; wcr = wcross(ray1dir, from1to2); w = from1to2.hw(); - return (R::FT)(FT(wcr*wcr) + return (typename R::FT)(FT(wcr*wcr) / FT(wmult((R*)0, RT(wdot(ray1dir, ray1dir)), w, w))); } @} @@ -1353,7 +1347,7 @@ ray_ray_squared_distance_parallel( @ template -inline R::FT +inline typename R::FT squared_distance( const Ray_2 & ray, const Line_2 & line) @@ -1382,7 +1376,7 @@ direction). @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Line_2 &line, const Ray_2 &ray) @@ -1393,12 +1387,12 @@ squared_distance( FT sign_dist = diff*normalvec; if (sign_dist < FT(0)) { if (is_acute_angle(normalvec, ray.direction().vector()) ) - return (R::FT)((FT)0); + return (FT)0; } else { if (is_obtuse_angle(normalvec, ray.direction().vector()) ) - return (R::FT)((FT)0); + return (FT)0; } - return (R::FT)((sign_dist*sign_dist)/(normalvec*normalvec)); + return (typename R::FT)((sign_dist*sign_dist)/(normalvec*normalvec)); } @} @@ -1427,7 +1421,7 @@ _are_parallel( } template -R::FT +typename R::FT squared_distance( const Line_2 &line1, const Line_2 &line2) @@ -1436,7 +1430,7 @@ squared_distance( if (_are_parallel(line1,line2)) return squared_distance(line1.point(), line2); else - return (R::FT)((FT)0); + return (FT)0; } @} @@ -1652,13 +1646,13 @@ distance_index( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance_indexed(const Point_2 &pt, const Triangle_2 &triangle, int ind1, int ind2) { typedef typename R::FT FT; if (ind1 == -1) - return (R::FT)(FT(0)); + return FT(0); if (ind2 == -1) return squared_distance(pt, triangle.vertex(ind1)); return squared_distance(pt, @@ -1673,7 +1667,7 @@ squared_distance_indexed(const Point_2 &pt, @ template -inline R::FT +inline typename R::FT squared_distance( const Triangle_2 & triangle, const Point_2 & pt) @@ -1689,7 +1683,7 @@ squared_distance( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Point_2 &pt, const Triangle_2 &triangle) @@ -1706,7 +1700,7 @@ squared_distance( @ template -inline R::FT +inline typename R::FT squared_distance( const Triangle_2 & triangle, const Line_2 & line) @@ -1722,7 +1716,7 @@ squared_distance( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Line_2 &line, const Triangle_2 &triangle) @@ -1731,9 +1725,9 @@ squared_distance( Oriented_side side0; side0 = line.oriented_side(triangle.vertex(0)); if (line.oriented_side(triangle.vertex(1)) != side0) - return (R::FT)(FT(0)); + return FT(0); if (line.oriented_side(triangle.vertex(2)) != side0) - return (R::FT)(FT(0)); + return FT(0); FT mindist, dist; int i; mindist = squared_distance(triangle.vertex(0),line); @@ -1742,7 +1736,7 @@ squared_distance( if (dist < mindist) mindist = dist; } - return (R::FT)(mindist); + return mindist; } @} @@ -1752,7 +1746,7 @@ squared_distance( @ template -inline R::FT +inline typename R::FT squared_distance( const Triangle_2 & triangle, const Ray_2 & ray) @@ -1768,7 +1762,7 @@ squared_distance( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Ray_2 &ray, const Triangle_2 &triangle) @@ -1792,7 +1786,7 @@ squared_distance( // now check if all vertices are on the right side of the separating line. // In case of vertex-vertex smallest distance this is the case. if (ind_tr2 == -1 && ind_ray != -1) - return (R::FT)(mindist); + return mindist; if (ind_tr2 != -1) { // Check if all the segment vertices lie at the same side of // the triangle segment. @@ -1812,7 +1806,7 @@ squared_distance( } } } - return (R::FT)(mindist); + return mindist; } @} @@ -1822,7 +1816,7 @@ squared_distance( @ template -inline R::FT +inline typename R::FT squared_distance( const Triangle_2 & triangle, const Segment_2 & seg) @@ -1838,7 +1832,7 @@ squared_distance( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Segment_2 &seg, const Triangle_2 &triangle) @@ -1870,7 +1864,7 @@ squared_distance( // now check if all vertices are on the right side of the separating line. // In case of vertex-vertex smallest distance this is the case. if (ind_tr2 == -1 && ind_seg != -1) - return (R::FT)(mindist); + return mindist; if (ind_tr2 != -1) { // Check if all the segment vertices lie at the same side of @@ -1893,7 +1887,7 @@ squared_distance( } } } - return (R::FT)(mindist); + return mindist; } @} @@ -1910,7 +1904,7 @@ squared_distance( @$@==@{ template -extern R::FT +extern typename R::FT squared_distance( const Triangle_2 &triangle1, const Triangle_2 &triangle2) @@ -1942,7 +1936,7 @@ squared_distance( } // now check if all vertices are on the right side of the separating line. if (ind1_2 == -1 && ind2_2 == -1) - return (R::FT)(mindist); + return mindist; // In case of point-segment closest distance, there is still the possibility // of overlapping triangles. // Check if all the vertices lie at the same side of the segment. @@ -1967,7 +1961,7 @@ squared_distance( } } } - return (R::FT)(mindist); + return mindist; } @}