Adde typename in places.

Also removed some spurious casts to R::FT.
This commit is contained in:
Geert-Jan Giezeman 1999-08-19 13:49:54 +00:00
parent 3609502653
commit 6f32eebe34
1 changed files with 68 additions and 74 deletions

View File

@ -179,11 +179,11 @@ Note the double occurrence of the factor@{wq@} in the latter definition.
@$@<2D squared distance general utilities@>+=@{
template <class R>
R::RT
typename R::RT
wdot(const Vector_2<R> &u,
const Vector_2<R> &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 <class R>
R::RT
typename R::RT
wcross(const Vector_2<R> &u,
const Vector_2<R> &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 <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Point_2<R> & pt1,
const Point_2<R> & pt2)
{
Vector_2<R> vec(pt1-pt2);
return (R::FT)(vec*vec);
return (typename R::FT)(vec*vec);
}
@}
@ -425,7 +425,7 @@ squared_distance(
@<Point Line distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Line_2<R> & line,
const Point_2<R> & pt)
@ -446,7 +446,7 @@ distance between the line and the point.
@$@<Point Line distance implementation@>==@{
template <class R>
R::FT
typename R::FT
squared_distance(
const Point_2<R> &pt,
const Line_2<R> &line)
@ -458,7 +458,7 @@ squared_distance(
Vector_2<R> normal(x, y);
Vector_2<R> 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(
@<Point Ray distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Ray_2<R> & ray,
const Point_2<R> & pt)
@ -493,7 +493,7 @@ point.
@$@<Point Ray distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Point_2<R> &pt,
const Ray_2<R> &ray)
@ -501,7 +501,7 @@ squared_distance(
Vector_2<R> diff = pt-ray.source();
const Vector_2<R> &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 <class R>
R::FT
typename R::FT
squared_distance_indexed(const Point_2<R> &pt,
const Ray_2<R> &ray, int ind)
{
@ -547,7 +547,7 @@ squared_distance_indexed(const Point_2<R> &pt,
@<Point Segment distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Segment_2<R> & seg,
const Point_2<R> & pt)
@ -574,7 +574,7 @@ segment is taken.
@$@<Point Segment distance implementation@>==@{
template <class R>
R::FT
typename R::FT
squared_distance(
const Point_2<R> &pt,
const Segment_2<R> &seg)
@ -585,7 +585,7 @@ squared_distance(
Vector_2<R> 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 <class R>
R::FT
typename R::FT
squared_distance_indexed(const Point_2<R> &pt,
const Segment_2<R> &seg, int ind)
{
@ -674,7 +674,7 @@ This is checked separately.
@$@<2D segment segment squared distance main routine@>+=@{
template <class R>
R::FT
typename R::FT
squared_distance(
const Segment_2<R> &seg1,
const Segment_2<R> &seg2)
@ -736,7 +736,7 @@ distance from both endpoints to the other segment and taking the minimum.
@$@<unused implementation@>@Z==@{
template <class R, class RT>
R::FT
typename R::FT
_squared_distance_of_endpoint_exact(RT start_dm, RT end_dm,
const Point_2<R> &start, const Point_2<R> &end,
const Segment<R> &seg)
@ -752,7 +752,7 @@ _squared_distance_of_endpoint_exact(RT start_dm, RT end_dm,
}
template <class R, class RT>
R::FT
typename R::FT
_squared_distance_of_endpoint_inexact<R, RT>(
const Point_2<R> &start, const Point_2<R> &end,
const Segment<R> &seg)
@ -761,11 +761,11 @@ _squared_distance_of_endpoint_inexact<R, RT>(
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 <class R, class RT>
inline R::FT
inline typename R::FT
_squared_distance_of_endpoint<false, R, RT>(RT start_dm, RT end_dm,
const Point_2<R> &start, const Point_2<R> &end,
const Segment<R> &seg)
@ -781,7 +781,7 @@ _squared_distance_of_endpoint<false, R, RT>(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 <class R>
R::FT
typename R::FT
squared_distance_parallel(
const Segment_2<R> &seg1,
const Segment_2<R> &seg2)
@ -917,7 +915,7 @@ squared_distance_parallel(
@<Segment Ray distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Ray_2<R> & ray,
const Segment_2<R> & seg)
@ -947,7 +945,7 @@ lies.
@$@<2D ray segment squared distance computation@>+=@{
template <class R>
R::FT
typename R::FT
squared_distance(
const Segment_2<R> &seg,
const Ray_2<R> &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 <class R>
R::FT
typename R::FT
squared_distance_parallel(
const Segment_2<R> &seg,
const Ray_2<R> &ray)
@ -1103,7 +1099,7 @@ const Vector_2<R> &start, const Vector_2<R> &end
@<Segment Line distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Line_2<R> & line,
const Segment_2<R> & seg)
@ -1127,7 +1123,7 @@ The boolean @{crossing1@} tells whether the segment crosses the line.
@$@<2D line segment squared distance computation@>+=@{
template <class R>
R::FT
typename R::FT
squared_distance(
const Segment_2<R> &seg,
const Line_2<R> &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 <class RT, class R>
R::FT
typename R::FT
_sqd_to_line(const Vector_2<R> &diff,
const RT & wcross, const Vector_2<R> &dir )
{
@ -1204,7 +1200,7 @@ _sqd_to_line(const Vector_2<R> &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 <class R>
R::FT
typename R::FT
squared_distance(
const Ray_2<R> &ray1,
const Ray_2<R> &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 <class R>
R::FT
typename R::FT
ray_ray_squared_distance_parallel(
const Vector_2<R> &ray1dir,
const Vector_2<R> &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(
@<Line Ray distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Ray_2<R> & ray,
const Line_2<R> & line)
@ -1382,7 +1376,7 @@ direction).
@$@<Line Ray distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Line_2<R> &line,
const Ray_2<R> &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 <class R>
R::FT
typename R::FT
squared_distance(
const Line_2<R> &line1,
const Line_2<R> &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(
@$@<Point Triangle distance implementation 2@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance_indexed(const Point_2<R> &pt,
const Triangle_2<R> &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<R> &pt,
@<Point Triangle distance implementation 3@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Triangle_2<R> & triangle,
const Point_2<R> & pt)
@ -1689,7 +1683,7 @@ squared_distance(
@$@<Point Triangle distance implementation 3@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Point_2<R> &pt,
const Triangle_2<R> &triangle)
@ -1706,7 +1700,7 @@ squared_distance(
@<Line Triangle distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Triangle_2<R> & triangle,
const Line_2<R> & line)
@ -1722,7 +1716,7 @@ squared_distance(
@$@<Line Triangle distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Line_2<R> &line,
const Triangle_2<R> &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(
@<Ray Triangle distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Triangle_2<R> & triangle,
const Ray_2<R> & ray)
@ -1768,7 +1762,7 @@ squared_distance(
@$@<Ray Triangle distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Ray_2<R> &ray,
const Triangle_2<R> &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(
@<Segment Triangle distance implementation@>
template <class R>
inline R::FT
inline typename R::FT
squared_distance(
const Triangle_2<R> & triangle,
const Segment_2<R> & seg)
@ -1838,7 +1832,7 @@ squared_distance(
@$@<Segment Triangle distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Segment_2<R> &seg,
const Triangle_2<R> &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(
@$@<Triangle Triangle distance implementation@>==@{
template <class R>
extern R::FT
extern typename R::FT
squared_distance(
const Triangle_2<R> &triangle1,
const Triangle_2<R> &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;
}
@}