#ifndef __JSPHERE3D__ #define __JSPHERE3D__ #include #include #include "JGeometry3D/JPosition3D.hh" #include "JIO/JSerialisable.hh" #include "JLang/JManip.hh" /** * \author mdejong */ namespace JGEOMETRY3D {} namespace JPP { using namespace JGEOMETRY3D; } namespace JGEOMETRY3D { using JIO::JReader; using JIO::JWriter; /** * 3D sphere. */ class JSphere3D : public JPosition3D { public: /** * Default constructor. */ JSphere3D() : JPosition3D(), __r(0.0) {} /** * Constructor. * * \param pos position * \param r radius */ JSphere3D(const JVector3D& pos, const double r) : JPosition3D(pos), __r(r) {} /** * Get radius. * * \return radius */ double getRadius() const { return __r; } /** * Read sphere from input. * * \param in input stream * \param sphere sphere * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JSphere3D& sphere) { in >> static_cast(sphere); in >> sphere.__r; return in; } /** * Write sphere to output. * * \param out output stream * \param sphere sphere * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JSphere3D& sphere) { const JFormat format(out, getFormat(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos))); out << static_cast(sphere); out << ' '; out << format << sphere.__r; return out; } /** * Read sphere from input. * * \param in reader * \param sphere sphere * \return reader */ friend inline JReader& operator>>(JReader& in, JSphere3D& sphere) { in >> static_cast(sphere); in >> sphere.__r; return in; } /** * Write sphere to output. * * \param out writer * \param sphere sphere * \return writer */ friend inline JWriter& operator<<(JWriter& out, const JSphere3D& sphere) { out << static_cast(sphere); out << sphere.__r; return out; } protected: double __r; }; } #endif