Jpp  16.0.0-rc.2
the software that should make you happy
 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 #include "JLang/JManip.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JGEOMETRY3D {}
17 namespace JPP { using namespace JGEOMETRY3D; }
18 
19 namespace JGEOMETRY3D {
20 
21  using JIO::JReader;
22  using JIO::JWriter;
23 
24 
25  /**
26  * 3D sphere.
27  */
28  class JSphere3D :
29  public JPosition3D
30  {
31  public:
32  /**
33  * Default constructor.
34  */
36  JPosition3D(),
37  __r(0.0)
38  {}
39 
40 
41  /**
42  * Constructor.
43  *
44  * \param pos position
45  * \param r radius
46  */
47  JSphere3D(const JVector3D& pos,
48  const double r) :
49  JPosition3D(pos),
50  __r(r)
51  {}
52 
53 
54  /**
55  * Get radius.
56  *
57  * \return radius
58  */
59  double getRadius() const
60  {
61  return __r;
62  }
63 
64 
65  /**
66  * Read sphere from input.
67  *
68  * \param in input stream
69  * \param sphere sphere
70  * \return input stream
71  */
72  friend inline std::istream& operator>>(std::istream& in, JSphere3D& sphere)
73  {
74  in >> static_cast<JPosition3D&>(sphere);
75  in >> sphere.__r;
76 
77  return in;
78  }
79 
80 
81  /**
82  * Write sphere to output.
83  *
84  * \param out output stream
85  * \param sphere sphere
86  * \return output stream
87  */
88  friend inline std::ostream& operator<<(std::ostream& out, const JSphere3D& sphere)
89  {
90  const JFormat format(out, getFormat<JPosition3D>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
91 
92  out << static_cast<const JPosition3D&>(sphere);
93  out << ' ';
94  out << format << sphere.__r;
95 
96  return out;
97  }
98 
99 
100  /**
101  * Read sphere from input.
102  *
103  * \param in reader
104  * \param sphere sphere
105  * \return reader
106  */
107  friend inline JReader& operator>>(JReader& in, JSphere3D& sphere)
108  {
109  in >> static_cast<JPosition3D&>(sphere);
110  in >> sphere.__r;
111 
112  return in;
113  }
114 
115 
116  /**
117  * Write sphere to output.
118  *
119  * \param out writer
120  * \param sphere sphere
121  * \return writer
122  */
123  friend inline JWriter& operator<<(JWriter& out, const JSphere3D& sphere)
124  {
125  out << static_cast<const JPosition3D&>(sphere);
126  out << sphere.__r;
127 
128  return out;
129  }
130 
131  protected:
132  double __r;
133  };
134 }
135 
136 #endif
Interface for binary output.
friend JWriter & operator<<(JWriter &out, const JSphere3D &sphere)
Write sphere to output.
Definition: JSphere3D.hh:123
friend std::istream & operator>>(std::istream &in, JSphere3D &sphere)
Read sphere from input.
Definition: JSphere3D.hh:72
friend std::ostream & operator<<(std::ostream &out, const JSphere3D &sphere)
Write sphere to output.
Definition: JSphere3D.hh:88
data_type r[M+1]
Definition: JPolint.hh:758
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
JSphere3D()
Default constructor.
Definition: JSphere3D.hh:35
Interface for binary input.
I/O manipulators.
double getRadius() const
Get radius.
Definition: JSphere3D.hh:59
friend JReader & operator>>(JReader &in, JSphere3D &sphere)
Read sphere from input.
Definition: JSphere3D.hh:107
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
JSphere3D(const JVector3D &pos, const double r)
Constructor.
Definition: JSphere3D.hh:47
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
Data structure for format specifications.
Definition: JManip.hh:522