mirror of https://github.com/CGAL/cgal
Move Point_3 I/O to user class level.
This commit is contained in:
parent
279d75d868
commit
c7f1f68b40
|
|
@ -172,52 +172,6 @@ PointC3<R>::bbox() const
|
||||||
return Bbox_3(xp.first, yp.first, zp.first, xp.second, yp.second, zp.second);
|
return Bbox_3(xp.first, yp.first, zp.first, xp.second, yp.second, zp.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CGAL_CARTESIAN_NO_OSTREAM_INSERT_POINTC3
|
|
||||||
template < class R >
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &os, const PointC3<R> &p)
|
|
||||||
{
|
|
||||||
switch(os.iword(IO::mode)) {
|
|
||||||
case IO::ASCII :
|
|
||||||
return os << p.x() << ' ' << p.y() << ' ' << p.z();
|
|
||||||
case IO::BINARY :
|
|
||||||
write(os, p.x());
|
|
||||||
write(os, p.y());
|
|
||||||
write(os, p.z());
|
|
||||||
return os;
|
|
||||||
default:
|
|
||||||
os << "PointC3(" << p.x() << ", " << p.y() << ", " << p.z() << ")";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // CGAL_CARTESIAN_NO_OSTREAM_INSERT_POINTC3
|
|
||||||
|
|
||||||
#ifndef CGAL_CARTESIAN_NO_ISTREAM_EXTRACT_POINTC3
|
|
||||||
template < class R >
|
|
||||||
std::istream &
|
|
||||||
operator>>(std::istream &is, PointC3<R> &p)
|
|
||||||
{
|
|
||||||
typename R::FT x, y, z;
|
|
||||||
switch(is.iword(IO::mode)) {
|
|
||||||
case IO::ASCII :
|
|
||||||
is >> x >> y >> z;
|
|
||||||
break;
|
|
||||||
case IO::BINARY :
|
|
||||||
read(is, x);
|
|
||||||
read(is, y);
|
|
||||||
read(is, z);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "" << std::endl;
|
|
||||||
std::cerr << "Stream must be in ascii or binary mode" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (is)
|
|
||||||
p = PointC3<R>(x, y, z);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
#endif // CGAL_CARTESIAN_NO_ISTREAM_EXTRACT_POINTC3
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_CARTESIAN_POINT_3_H
|
#endif // CGAL_CARTESIAN_POINT_3_H
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Stefan Schirra
|
// Author(s) : Stefan Schirra
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
PointH2() {}
|
PointH2() {}
|
||||||
|
|
||||||
PointH2(const Origin &)
|
PointH2(const Origin &)
|
||||||
: base (RT(0), RT(0), RT(1)) {}
|
: base (RT(0), RT(0), RT(1)) {}
|
||||||
|
|
||||||
PointH2(const RT& hx, const RT& hy )
|
PointH2(const RT& hx, const RT& hy )
|
||||||
|
|
@ -81,12 +81,12 @@ public:
|
||||||
FT operator[](int i) const;
|
FT operator[](int i) const;
|
||||||
const RT & homogeneous(int i) const;
|
const RT & homogeneous(int i) const;
|
||||||
|
|
||||||
Cartesian_const_iterator cartesian_begin() const
|
Cartesian_const_iterator cartesian_begin() const
|
||||||
{
|
{
|
||||||
return Cartesian_const_iterator(static_cast<const Point_2*>(this), 0);
|
return Cartesian_const_iterator(static_cast<const Point_2*>(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cartesian_const_iterator cartesian_end() const
|
Cartesian_const_iterator cartesian_end() const
|
||||||
{
|
{
|
||||||
return Cartesian_const_iterator(static_cast<const Point_2*>(this), 2);
|
return Cartesian_const_iterator(static_cast<const Point_2*>(this), 2);
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +101,7 @@ CGAL_KERNEL_INLINE
|
||||||
bool
|
bool
|
||||||
PointH2<R>::operator==( const PointH2<R>& p) const
|
PointH2<R>::operator==( const PointH2<R>& p) const
|
||||||
{ // FIXME : Predicate
|
{ // FIXME : Predicate
|
||||||
return ( (hx() * p.hw() == p.hx() * hw() )
|
return ( (hx() * p.hw() == p.hx() * hw() )
|
||||||
&&(hy() * p.hw() == p.hy() * hw() ) );
|
&&(hy() * p.hw() == p.hy() * hw() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Stefan Schirra
|
// Author(s) : Stefan Schirra
|
||||||
|
|
||||||
|
|
@ -78,12 +78,12 @@ public:
|
||||||
FT operator[](int i) const;
|
FT operator[](int i) const;
|
||||||
|
|
||||||
|
|
||||||
Cartesian_const_iterator cartesian_begin() const
|
Cartesian_const_iterator cartesian_begin() const
|
||||||
{
|
{
|
||||||
return Cartesian_const_iterator(static_cast<const Point_3*>(this), 0);
|
return Cartesian_const_iterator(static_cast<const Point_3*>(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cartesian_const_iterator cartesian_end() const
|
Cartesian_const_iterator cartesian_end() const
|
||||||
{
|
{
|
||||||
return Cartesian_const_iterator(static_cast<const Point_3*>(this), 3);
|
return Cartesian_const_iterator(static_cast<const Point_3*>(this), 3);
|
||||||
}
|
}
|
||||||
|
|
@ -204,53 +204,6 @@ bool
|
||||||
PointH3<R>::operator!=( const PointH3<R> & p) const
|
PointH3<R>::operator!=( const PointH3<R> & p) const
|
||||||
{ return !(*this == p); }
|
{ return !(*this == p); }
|
||||||
|
|
||||||
#ifndef CGAL_NO_OSTREAM_INSERT_POINTH3
|
|
||||||
template < class R >
|
|
||||||
std::ostream &operator<<(std::ostream &os, const PointH3<R> &p)
|
|
||||||
{
|
|
||||||
switch(os.iword(IO::mode)) {
|
|
||||||
case IO::ASCII :
|
|
||||||
return os << p.hx() << ' ' << p.hy() << ' ' << p.hz() << ' ' << p.hw();
|
|
||||||
case IO::BINARY :
|
|
||||||
write(os, p.hx());
|
|
||||||
write(os, p.hy());
|
|
||||||
write(os, p.hz());
|
|
||||||
write(os, p.hw());
|
|
||||||
return os;
|
|
||||||
default:
|
|
||||||
return os << "PointH3(" << p.hx() << ", "
|
|
||||||
<< p.hy() << ", "
|
|
||||||
<< p.hz() << ", "
|
|
||||||
<< p.hw() << ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_OSTREAM_INSERT_POINTH3
|
|
||||||
|
|
||||||
#ifndef CGAL_NO_ISTREAM_EXTRACT_POINTH3
|
|
||||||
template < class R >
|
|
||||||
std::istream &operator>>(std::istream &is, PointH3<R> &p)
|
|
||||||
{
|
|
||||||
typename R::RT hx, hy, hz, hw;
|
|
||||||
switch(is.iword(IO::mode)) {
|
|
||||||
case IO::ASCII :
|
|
||||||
is >> hx >> hy >> hz >> hw;
|
|
||||||
break;
|
|
||||||
case IO::BINARY :
|
|
||||||
read(is, hx);
|
|
||||||
read(is, hy);
|
|
||||||
read(is, hz);
|
|
||||||
read(is, hw);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "" << std::endl;
|
|
||||||
std::cerr << "Stream must be in ascii or binary mode" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p = PointH3<R>(hx, hy, hz, hw);
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
#endif // CGAL_NO_ISTREAM_EXTRACT_POINTH3
|
|
||||||
|
|
||||||
|
|
||||||
template < class R >
|
template < class R >
|
||||||
inline
|
inline
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#define CGAL_POINT_3_H
|
#define CGAL_POINT_3_H
|
||||||
|
|
||||||
#include <CGAL/Origin.h>
|
#include <CGAL/Origin.h>
|
||||||
|
#include <CGAL/representation_tags.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -166,22 +167,115 @@ bool
|
||||||
operator!=(const Origin& o, const Point_3<R>& p)
|
operator!=(const Origin& o, const Point_3<R>& p)
|
||||||
{ return p != o; }
|
{ return p != o; }
|
||||||
|
|
||||||
#if 0 //ndef CGAL_NO_OSTREAM_INSERT_POINT_3
|
|
||||||
|
#ifndef CGAL_NO_OSTREAM_INSERT_POINT_3
|
||||||
|
|
||||||
|
template <class R >
|
||||||
|
std::ostream&
|
||||||
|
insert(std::ostream& os, const Point_3<R>& p,const Cartesian_tag&)
|
||||||
|
{
|
||||||
|
switch(os.iword(IO::mode)) {
|
||||||
|
case IO::ASCII :
|
||||||
|
return os << p.x() << ' ' << p.y() << ' ' << p.z();
|
||||||
|
case IO::BINARY :
|
||||||
|
write(os, p.x());
|
||||||
|
write(os, p.y());
|
||||||
|
write(os, p.z());
|
||||||
|
return os;
|
||||||
|
default:
|
||||||
|
return os << "PointC3(" << p.x() << ", " << p.y()
|
||||||
|
<< ", " << p.z() << ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class R >
|
||||||
|
std::ostream&
|
||||||
|
insert(std::ostream& os, const Point_3<R>& p,const Homogeneous_tag&)
|
||||||
|
{
|
||||||
|
switch(os.iword(IO::mode))
|
||||||
|
{
|
||||||
|
case IO::ASCII :
|
||||||
|
return os << p.hx() << ' ' << p.hy() << ' ' << p.hz() << ' ' << p.hw();
|
||||||
|
case IO::BINARY :
|
||||||
|
write(os, p.hx());
|
||||||
|
write(os, p.hy());
|
||||||
|
write(os, p.hz());
|
||||||
|
write(os, p.hw());
|
||||||
|
return os;
|
||||||
|
default:
|
||||||
|
return os << "PointH3(" << p.hx() << ", "
|
||||||
|
<< p.hy() << ", "
|
||||||
|
<< p.hz() << ", "
|
||||||
|
<< p.hw() << ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template < class R >
|
template < class R >
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<<(std::ostream& os, const Point_3<R>& p)
|
operator<<(std::ostream& os, const Point_3<R>& p)
|
||||||
{
|
{
|
||||||
typedef typename R::Kernel_base::Point_3 Rep;
|
return insert(os, p, typename R::Kernel_tag() );
|
||||||
return os << static_cast<const Rep&>(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CGAL_NO_OSTREAM_INSERT_POINT_3
|
#endif // CGAL_NO_OSTREAM_INSERT_POINT_3
|
||||||
|
|
||||||
#if 0 //ndef CGAL_NO_ISTREAM_EXTRACT_POINT_3
|
#ifndef CGAL_NO_ISTREAM_EXTRACT_POINT_3
|
||||||
template < class R >
|
|
||||||
std::istream& operator>>(std::istream& is, Point_3<R>& p)
|
template <class R >
|
||||||
|
std::istream&
|
||||||
|
extract(std::istream& is, Point_3<R>& p, const Cartesian_tag&)
|
||||||
{
|
{
|
||||||
typedef typename R::Kernel_base::Point_3 Rep;
|
typename R::FT x, y, z;
|
||||||
return is >> static_cast<Rep&>(p);
|
switch(is.iword(IO::mode)) {
|
||||||
|
case IO::ASCII :
|
||||||
|
is >> x >> y >> z;
|
||||||
|
break;
|
||||||
|
case IO::BINARY :
|
||||||
|
read(is, x);
|
||||||
|
read(is, y);
|
||||||
|
read(is, z);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "" << std::endl;
|
||||||
|
std::cerr << "Stream must be in ascii or binary mode" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (is)
|
||||||
|
p = Point_3<R>(x, y, z);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class R >
|
||||||
|
std::istream&
|
||||||
|
extract(std::istream& is, Point_3<R>& p, const Homogeneous_tag&)
|
||||||
|
{
|
||||||
|
typename R::RT hx, hy, hz, hw;
|
||||||
|
switch(is.iword(IO::mode))
|
||||||
|
{
|
||||||
|
case IO::ASCII :
|
||||||
|
is >> hx >> hy >> hz >> hw;
|
||||||
|
break;
|
||||||
|
case IO::BINARY :
|
||||||
|
read(is, hx);
|
||||||
|
read(is, hy);
|
||||||
|
read(is, hz);
|
||||||
|
read(is, hw);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "" << std::endl;
|
||||||
|
std::cerr << "Stream must be in ascii or binary mode" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p = Point_3<R>(hx, hy, hz, hw);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
template < class R >
|
||||||
|
std::istream&
|
||||||
|
operator>>(std::istream& is, Point_3<R>& p)
|
||||||
|
{
|
||||||
|
return extract(is, p, typename R::Kernel_tag() );
|
||||||
}
|
}
|
||||||
#endif // CGAL_NO_ISTREAM_EXTRACT_POINT_3
|
#endif // CGAL_NO_ISTREAM_EXTRACT_POINT_3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,6 @@ public:
|
||||||
//return CGAL_NTS is_zero(squared_radius());
|
//return CGAL_NTS is_zero(squared_radius());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R_>
|
template <class R_>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue