mirror of https://github.com/CGAL/cgal
Move Ray_2 I/O to user class level
This commit is contained in:
parent
aa9fb702a0
commit
45e65df64c
|
|
@ -65,45 +65,6 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifndef CGAL_NO_OSTREAM_INSERT_RAYC2
|
|
||||||
template < class R >
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &os, const RayC2<R> &r)
|
|
||||||
{
|
|
||||||
switch(os.iword(IO::mode)) {
|
|
||||||
case IO::ASCII :
|
|
||||||
return os << r.source() << ' ' << r.second_point();
|
|
||||||
case IO::BINARY :
|
|
||||||
return os << r.source() << r.second_point();
|
|
||||||
default:
|
|
||||||
return os << "RayC2(" << r.source() << ", " << r.second_point() << ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_OSTREAM_INSERT_RAYC2
|
|
||||||
|
|
||||||
#ifndef CGAL_NO_ISTREAM_EXTRACT_RAYC2
|
|
||||||
template < class R >
|
|
||||||
std::istream &
|
|
||||||
operator>>(std::istream &is, RayC2<R> &r)
|
|
||||||
{
|
|
||||||
typename R::Point_2 p, q;
|
|
||||||
|
|
||||||
is >> p >> q;
|
|
||||||
|
|
||||||
if (is)
|
|
||||||
r = RayC2<R>(p, q);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_ISTREAM_EXTRACT_RAYC2
|
|
||||||
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_CARTESIAN_RAY_2_H
|
#endif // CGAL_CARTESIAN_RAY_2_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,35 +147,6 @@ RayH2<R>
|
||||||
RayH2<R>::opposite() const
|
RayH2<R>::opposite() const
|
||||||
{ return RayH2<R>( start(), - direction() ); }
|
{ return RayH2<R>( start(), - direction() ); }
|
||||||
|
|
||||||
#ifndef CGAL_NO_OSTREAM_INSERT_RAYH2
|
|
||||||
template < class R >
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &os, const RayH2<R> &r)
|
|
||||||
{
|
|
||||||
switch(os.iword(IO::mode))
|
|
||||||
{
|
|
||||||
case IO::ASCII :
|
|
||||||
return os << r.source() << ' ' << r.second_point();
|
|
||||||
case IO::BINARY :
|
|
||||||
return os << r.source() << r.second_point();
|
|
||||||
default:
|
|
||||||
return os << "RayC2(" << r.source() << ", " << r.second_point() << ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_OSTREAM_INSERT_RAYH2
|
|
||||||
|
|
||||||
#ifndef CGAL_NO_ISTREAM_EXTRACT_RAYH2
|
|
||||||
template < class R >
|
|
||||||
std::istream &
|
|
||||||
operator>>(std::istream &is, RayH2<R> &r)
|
|
||||||
{
|
|
||||||
typename R::Point_2 p, q;
|
|
||||||
is >> p >> q;
|
|
||||||
r = RayH2<R>(p, q);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_ISTREAM_EXTRACT_RAYH2
|
|
||||||
|
|
||||||
template < class R >
|
template < class R >
|
||||||
CGAL_KERNEL_INLINE
|
CGAL_KERNEL_INLINE
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -188,25 +188,73 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef CGAL_NO_OSTREAM_INSERT_RAY_2
|
|
||||||
template < class R >
|
template <class R >
|
||||||
std::ostream &
|
std::ostream&
|
||||||
operator<<(std::ostream &os, const Ray_2<R> &r)
|
insert(std::ostream& os, const Ray_2<R>& r, const Cartesian_tag&)
|
||||||
{
|
{
|
||||||
return os << r.rep();
|
switch(os.iword(IO::mode)) {
|
||||||
|
case IO::ASCII :
|
||||||
|
return os << r.source() << ' ' << r.second_point();
|
||||||
|
case IO::BINARY :
|
||||||
|
return os << r.source() << r.second_point();
|
||||||
|
default:
|
||||||
|
return os << "RayC2(" << r.source() << ", " << r.second_point() << ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // CGAL_NO_OSTREAM_INSERT_RAY_2
|
|
||||||
|
|
||||||
#ifndef CGAL_NO_ISTREAM_EXTRACT_RAY_2
|
template <class R >
|
||||||
template < class R >
|
std::ostream&
|
||||||
std::istream &
|
insert(std::ostream& os, const Ray_2<R>& r, const Homogeneous_tag&)
|
||||||
operator>>(std::istream &is, Ray_2<R> &r)
|
|
||||||
{
|
{
|
||||||
return is >> r.rep();
|
switch(os.iword(IO::mode))
|
||||||
|
{
|
||||||
|
case IO::ASCII :
|
||||||
|
return os << r.source() << ' ' << r.second_point();
|
||||||
|
case IO::BINARY :
|
||||||
|
return os << r.source() << r.second_point();
|
||||||
|
default:
|
||||||
|
return os << "RayH2(" << r.source() << ", " << r.second_point() << ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template < class R >
|
||||||
|
std::ostream&
|
||||||
|
operator<<(std::ostream& os, const Ray_2<R>& r)
|
||||||
|
{
|
||||||
|
return insert(os, r, typename R::Kernel_tag() );
|
||||||
}
|
}
|
||||||
#endif // CGAL_NO_ISTREAM_EXTRACT_RAY_2
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class R >
|
||||||
|
std::istream&
|
||||||
|
extract(std::istream& is, Ray_2<R>& r, const Cartesian_tag&)
|
||||||
|
{
|
||||||
|
typename R::Point_2 p, q;
|
||||||
|
is >> p >> q;
|
||||||
|
if (is)
|
||||||
|
r = Ray_2<R>(p, q);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class R >
|
||||||
|
std::istream&
|
||||||
|
extract(std::istream& is, Ray_2<R>& r, const Homogeneous_tag&)
|
||||||
|
{
|
||||||
|
typename R::Point_2 p, q;
|
||||||
|
is >> p >> q;
|
||||||
|
if (is)
|
||||||
|
r = Ray_2<R>(p, q);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
template < class R >
|
||||||
|
std::istream&
|
||||||
|
operator>>(std::istream& is, Ray_2<R>& r)
|
||||||
|
{
|
||||||
|
return extract(is, r, typename R::Kernel_tag() );
|
||||||
|
}
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue