Skip to content

Commit cce7014

Browse files
committed
Use functor to compute squared distance
1 parent fe59612 commit cce7014

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,25 +1199,13 @@ template<class R_> struct Compare_squared_distance : private Store_kernel<R_> {
11991199
typedef R_ R;
12001200
typedef typename Get_type<R, RT_tag>::type RT;
12011201
typedef typename Get_type<R, Comparison_result_tag>::type result_type;
1202-
typedef typename Get_functor<R, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CI;
1202+
typedef typename Get_functor<R, Squared_distance_tag>::type CSD;
12031203

12041204
template<class V,class W>
12051205
result_type operator()(V const&a, V const&b, W const&c)const{ // Point, Point. FT
1206-
CI ci(this->kernel());
1207-
1208-
auto a_begin=ci(a,Begin_tag());
1209-
auto b_begin=ci(b,Begin_tag());
1210-
auto a_end=ci(a,End_tag());
1211-
RT sqdist(0);
1212-
result_type res;
1213-
// can't we do slightly better for Uncertain<*> ?
1214-
// after res=...; if(is_uncertain(res))return indeterminate<result_type>();
1215-
do{
1216-
RT d = (*a_begin++ - *b_begin++);
1217-
sqdist += d*d;
1218-
}while(a_begin!=a_end);
1219-
res=CGAL_NTS compare(sqdist,c);
1220-
return res;
1206+
CSD csd(this->kernel());
1207+
RT sqdist = csd(a,b);
1208+
return compare(sqdist,c);
12211209
}
12221210
};
12231211
}

0 commit comments

Comments
 (0)