Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSphere3D.hh
Go to the documentation of this file.
1 #ifndef __JSPHERE3D__
2 #define __JSPHERE3D__
3 
4 #include <istream>
5 #include <ostream>
6 
8 #include "JIO/JSerialisable.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JGEOMETRY3D {}
16 namespace JPP { using namespace JGEOMETRY3D; }
17 
18 namespace JGEOMETRY3D {
19 
20  using JIO::JReader;
21  using JIO::JWriter;
22 
23 
24  /**
25  * 3D sphere.
26  */
27  class JSphere3D :
28  public JPosition3D
29  {
30  public:
31  /**
32  * Default constructor.
33  */
35  JPosition3D(),
36  __r(0.0)
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param pos position
44  * \param r radius
45  */
46  JSphere3D(const JVector3D& pos,
47  const double r) :
48  JPosition3D(pos),
49  __r(r)
50  {}
51 
52 
53  /**
54  * Get radius.
55  *
56  * \return radius
57  */
58  double getRadius() const
59  {
60  return __r;
61  }
62 
63 
64  /**
65  * Read sphere from input.
66  *
67  * \param in input stream
68  * \param sphere sphere
69  * \return input stream
70  */
71  friend inline std::istream& operator>>(std::istream& in, JSphere3D& sphere)
72  {
73  in >> static_cast<JPosition3D&>(sphere);
74  in >> sphere.__r;
75 
76  return in;
77  }
78 
79 
80  /**
81  * Write sphere to output.
82  *
83  * \param out output stream
84  * \param sphere sphere
85  * \return output stream
86  */
87  friend inline std::ostream& operator<<(std::ostream& out, const JSphere3D& sphere)
88  {
89  out << static_cast<const JPosition3D&>(sphere);
90  out << ' ';
91  out << sphere.__r;
92 
93  return out;
94  }
95 
96 
97  /**
98  * Read sphere from input.
99  *
100  * \param in reader
101  * \param sphere sphere
102  * \return reader
103  */
104  friend inline JReader& operator>>(JReader& in, JSphere3D& sphere)
105  {
106  in >> static_cast<JPosition3D&>(sphere);
107  in >> sphere.__r;
108 
109  return in;
110  }
111 
112 
113  /**
114  * Write sphere to output.
115  *
116  * \param out writer
117  * \param sphere sphere
118  * \return writer
119  */
120  friend inline JWriter& operator<<(JWriter& out, const JSphere3D& sphere)
121  {
122  out << static_cast<const JPosition3D&>(sphere);
123  out << sphere.__r;
124 
125  return out;
126  }
127 
128  protected:
129  double __r;
130  };
131 }
132 
133 #endif
Interface for binary output.
friend JWriter & operator<<(JWriter &out, const JSphere3D &sphere)
Write sphere to output.
Definition: JSphere3D.hh:120
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
friend std::istream & operator>>(std::istream &in, JSphere3D &sphere)
Read sphere from input.
Definition: JSphere3D.hh:71
friend std::ostream & operator<<(std::ostream &out, const JSphere3D &sphere)
Write sphere to output.
Definition: JSphere3D.hh:87
data_type r[M+1]
Definition: JPolint.hh:709
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
JSphere3D()
Default constructor.
Definition: JSphere3D.hh:34
Interface for binary input.
double getRadius() const
Get radius.
Definition: JSphere3D.hh:58
friend JReader & operator>>(JReader &in, JSphere3D &sphere)
Read sphere from input.
Definition: JSphere3D.hh:104
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JSphere3D(const JVector3D &pos, const double r)
Constructor.
Definition: JSphere3D.hh:46