mirror of https://github.com/CGAL/cgal
Introduce wmult_hw(), a new abstraction for Homogeneous/Cartesian,
similar to wmult(), for calls .hw() on the last argument (i.e., does absolutely nothing in the Cartesian case).
This commit is contained in:
parent
6b3efb6fbb
commit
cb6639b85a
|
|
@ -42,7 +42,7 @@ intersection(const typename CGAL_WRAP(K)::Plane_3 &plane,
|
|||
const Direction_3 &line_dir = line.direction();
|
||||
|
||||
RT num = plane.a()*line_pt.hx() + plane.b()*line_pt.hy()
|
||||
+ plane.c()*line_pt.hz() + wmult((K*)0, plane.d(), line_pt.hw());
|
||||
+ plane.c()*line_pt.hz() + wmult_hw((K*)0, plane.d(), line_pt);
|
||||
RT den = plane.a()*line_dir.dx() + plane.b()*line_dir.dy()
|
||||
+ plane.c()*line_dir.dz();
|
||||
if (den == 0) {
|
||||
|
|
@ -58,7 +58,7 @@ intersection(const typename CGAL_WRAP(K)::Plane_3 &plane,
|
|||
den*line_pt.hx()-num*line_dir.dx(),
|
||||
den*line_pt.hy()-num*line_dir.dy(),
|
||||
den*line_pt.hz()-num*line_dir.dz(),
|
||||
wmult((K*)0, den, line_pt.hw())));
|
||||
wmult_hw((K*)0, den, line_pt)));
|
||||
}
|
||||
|
||||
template <class K>
|
||||
|
|
@ -172,7 +172,7 @@ do_intersect(const typename CGAL_WRAP(K)::Plane_3 &plane,
|
|||
if (den != 0)
|
||||
return true;
|
||||
RT num = plane.a()*line_pt.hx() + plane.b()*line_pt.hy()
|
||||
+ plane.c()*line_pt.hz() + wmult((K*)0, plane.d(), line_pt.hw());
|
||||
+ plane.c()*line_pt.hz() + wmult_hw((K*)0, plane.d(), line_pt);
|
||||
if (num == 0) {
|
||||
// all line
|
||||
return true;
|
||||
|
|
@ -695,36 +695,36 @@ intersection(
|
|||
} else {
|
||||
newmin = Point_3(
|
||||
min_idx[0] == 0
|
||||
? wmult((K*)0, min_points[0].hx(), min_points[1].hw())
|
||||
: wmult((K*)0, min_points[1].hx(), min_points[0].hw())
|
||||
? wmult_hw((K*)0, min_points[0].hx(), min_points[1])
|
||||
: wmult_hw((K*)0, min_points[1].hx(), min_points[0])
|
||||
,
|
||||
min_idx[1] == 0
|
||||
? wmult((K*)0, min_points[0].hy(), min_points[1].hw())
|
||||
: wmult((K*)0, min_points[1].hy(), min_points[0].hw())
|
||||
? wmult_hw((K*)0, min_points[0].hy(), min_points[1])
|
||||
: wmult_hw((K*)0, min_points[1].hy(), min_points[0])
|
||||
,
|
||||
min_idx[2] == 0
|
||||
? wmult((K*)0, min_points[0].hz(), min_points[1].hw())
|
||||
: wmult((K*)0, min_points[1].hz(), min_points[0].hw())
|
||||
? wmult_hw((K*)0, min_points[0].hz(), min_points[1])
|
||||
: wmult_hw((K*)0, min_points[1].hz(), min_points[0])
|
||||
,
|
||||
wmult((K*)0, min_points[0].hw(), min_points[1].hw()) );
|
||||
wmult_hw((K*)0, min_points[0].hw(), min_points[1]) );
|
||||
}
|
||||
if (max_idx[0] == max_idx[1] && max_idx[0] == max_idx[2]) {
|
||||
newmax = max_points[max_idx[0]];
|
||||
} else {
|
||||
newmax = Point_3(
|
||||
max_idx[0] == 0
|
||||
? wmult((K*)0, max_points[0].hx(), max_points[1].hw())
|
||||
: wmult((K*)0, max_points[1].hx(), max_points[0].hw())
|
||||
? wmult_hw((K*)0, max_points[0].hx(), max_points[1])
|
||||
: wmult_hw((K*)0, max_points[1].hx(), max_points[0])
|
||||
,
|
||||
max_idx[1] == 0
|
||||
? wmult((K*)0, max_points[0].hy(), max_points[1].hw())
|
||||
: wmult((K*)0, max_points[1].hy(), max_points[0].hw())
|
||||
? wmult_hw((K*)0, max_points[0].hy(), max_points[1])
|
||||
: wmult_hw((K*)0, max_points[1].hy(), max_points[0])
|
||||
,
|
||||
max_idx[2] == 0
|
||||
? wmult((K*)0, max_points[0].hz(), max_points[1].hw())
|
||||
: wmult((K*)0, max_points[1].hz(), max_points[0].hw())
|
||||
? wmult_hw((K*)0, max_points[0].hz(), max_points[1])
|
||||
: wmult_hw((K*)0, max_points[1].hz(), max_points[0])
|
||||
,
|
||||
wmult((K*)0, max_points[0].hw(), max_points[1].hw()) );
|
||||
wmult_hw((K*)0, max_points[0].hw(), max_points[1]) );
|
||||
}
|
||||
Object result = make_object(Iso_cuboid_3(newmin, newmax));
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -84,6 +84,56 @@ struct wmult_functor
|
|||
: public wmult_tag<typename K::Rep_tag> {};
|
||||
|
||||
|
||||
template < typename Rep_Tag > struct wmult_hw_tag;
|
||||
|
||||
template <>
|
||||
struct wmult_hw_tag<Cartesian_tag>
|
||||
{
|
||||
template < typename RT, typename T >
|
||||
const RT & operator()(const RT &a, const T &) const
|
||||
{ return a; }
|
||||
|
||||
template < typename RT, typename T >
|
||||
const RT & operator()(const RT &a, const RT &, const T &) const
|
||||
{ return a; }
|
||||
|
||||
template < typename RT, typename T >
|
||||
const RT & operator()(const RT &a, const RT &, const RT &, const T &) const
|
||||
{ return a; }
|
||||
|
||||
template < typename RT, typename T >
|
||||
const RT & operator()(const RT &a, const RT &, const RT &, const RT &,
|
||||
const T &) const
|
||||
{ return a; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct wmult_hw_tag<Homogeneous_tag>
|
||||
{
|
||||
template < typename RT, typename T >
|
||||
RT operator()(const RT &a, const T &t) const
|
||||
{ return a*t.hw(); }
|
||||
|
||||
template < typename RT, typename T >
|
||||
RT operator()(const RT &a, const RT &w1, const T &t) const
|
||||
{ return a*w1*t.hw(); }
|
||||
|
||||
template < typename RT, typename T >
|
||||
RT operator()(const RT &a, const RT &w1, const RT &w2, const T &t) const
|
||||
{ return a*w1*w2*t.hw(); }
|
||||
|
||||
template < typename RT, typename T >
|
||||
RT operator()(const RT &a, const RT &w1, const RT &w2, const RT &w3,
|
||||
const T &t) const
|
||||
{ return a*w1*w2*w3*t.hw(); }
|
||||
};
|
||||
|
||||
|
||||
template < typename K >
|
||||
struct wmult_hw_functor
|
||||
: public wmult_hw_tag<typename K::Rep_tag> {};
|
||||
|
||||
|
||||
template < typename Rep_Tag > struct wcross_tag_2;
|
||||
|
||||
template <>
|
||||
|
|
@ -166,6 +216,52 @@ struct wcross_functor_3
|
|||
} // end namespace CGALi
|
||||
|
||||
|
||||
// wmult_hw() is like wmult(), except it calls .hw() on its last argument.
|
||||
// This way, we can completely avoid creating FT(1) for Cartesian.
|
||||
|
||||
template < typename K, typename T >
|
||||
inline
|
||||
typename K::RT
|
||||
wmult_hw(K*, const typename K::RT &a,
|
||||
const T &t)
|
||||
{
|
||||
return CGALi::wmult_hw_functor<K>()(a, t);
|
||||
}
|
||||
|
||||
template < typename K, typename T >
|
||||
inline
|
||||
typename K::RT
|
||||
wmult_hw(K*, const typename K::RT &a,
|
||||
const typename K::RT &w1,
|
||||
const T &t)
|
||||
{
|
||||
return CGALi::wmult_hw_functor<K>()(a, w1, t);
|
||||
}
|
||||
|
||||
template < typename K, typename T >
|
||||
inline
|
||||
typename K::RT
|
||||
wmult_hw(K*, const typename K::RT &a,
|
||||
const typename K::RT &w1,
|
||||
const typename K::RT &w2,
|
||||
const T &t)
|
||||
{
|
||||
return CGALi::wmult_hw_functor<K>()(a, w1, w2, t);
|
||||
}
|
||||
|
||||
template < typename K, typename T >
|
||||
inline
|
||||
typename K::RT
|
||||
wmult_hw(K*, const typename K::RT &a,
|
||||
const typename K::RT &w1,
|
||||
const typename K::RT &w2,
|
||||
const typename K::RT &w3,
|
||||
const T &t)
|
||||
{
|
||||
return CGALi::wmult_hw_functor<K>()(a, w1, w2, w3, t);
|
||||
}
|
||||
|
||||
|
||||
template < typename K >
|
||||
inline
|
||||
typename K::RT
|
||||
|
|
|
|||
Loading…
Reference in New Issue