KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
st_sphere.h
Go to the documentation of this file.
1 /* =========================================================================== *
2 |
3 | Copyright (c) 1994-2008 by Kobus Barnard (author).
4 |
5 | Personal and educational use of this code is granted, provided that this
6 | header is kept intact, and that the authorship is not misrepresented, that
7 | its use is acknowledged in publications, and relevant papers are cited.
8 |
9 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10 |
11 | Please note that the code in this file has not necessarily been adequately
12 | tested. Naturally, there is no guarantee of performance, support, or fitness
13 | for any particular task. Nonetheless, I am interested in hearing about
14 | problems that you encounter.
15 |
16 | Authors:
17 | Jinyan Guan
18 |
19 * =========================================================================== */
20 #ifndef KJB_ST_SPHERE_INCLUDED
21 #define KJB_ST_SPHERE_INCLUDED
22 
23 #include <gr_cpp/gr_sphere.h>
24 #include <m_cpp/m_vector.h>
26 #include <l_cpp/l_readable.h>
27 #include <l_cpp/l_writeable.h>
28 
29 
30 
34 namespace kjb
35 {
36 //class Perspective_camera;
37 class Parametric_sphere : public Renderable_model, public Readable, public Writeable
38 {
39  public:
41  (
42  double center_x,
43  double center_y,
44  double center_z,
45  double radius = 1.0
46  ) throw (kjb::Illegal_argument);
47 
49 
51  Parametric_sphere (const char* fname) throw (kjb::Illegal_argument,
53 
54  Parametric_sphere (std::istream& in) throw (kjb::Illegal_argument, kjb::IO_error);
55 
57 
58  virtual Parametric_sphere & operator = (const Parametric_sphere& src);
59 
60  virtual void read(std::istream& in) throw (kjb::Illegal_argument, kjb::IO_error);
61 
62  virtual void read(const char * fname)
63  {
64  Readable::read(fname);
65  }
66 
67  virtual void write(std::ostream& out) const throw (kjb::IO_error);
68  virtual void write(const char* fname) const throw (kjb::IO_error)
69  {
70  Writeable::write(fname);
71  }
72 
74  virtual void update_rendering_representation() const throw(kjb::KJB_error);
75  //Geodesic_sphere& get_triangular_mesh() {return rendering_interface; }
76 
77  virtual Parametric_sphere * clone() const {return new Parametric_sphere(*this); }
78  virtual ~Parametric_sphere() {}
79 
81  inline double get_center_x() const {return m_center_v[0]; }
82 
84  inline double get_center_y() const {return m_center_v[1]; }
85 
87  inline double get_center_z() const {return m_center_v[2]; }
88 
90  inline const Vector& get_center() const {return m_center_v;}
91 
93  inline double get_radius() const {return m_radius; }
94 
96  inline void set_center_x(double x) {m_center_v[0] = x;}
97 
99  inline void set_center_y(double y) {m_center_v[1] = y;}
100 
102  inline void set_center_z(double z) {m_center_v[2] = z;}
103 
105  inline void set_center(const Vector& center) {m_center_v = center; }
106 
108  inline void set_radius(double r) {m_radius = r; }
109 
114  (
115  const kjb::Vector & point_in_world_coordinates,
116  kjb::Vector & point_in_sphere_coordinates
117  ) const;
118 
122  (
123  const kjb::Vector & point_in_sphere_coordinates,
124  kjb::Vector & point_in_world_coordinates
125  ) const;
126 
128 
129  protected:
130  //mutable Geodesic_sphere rendering_interface;
132  double m_radius;
133 };
134 }
135 #endif
const Vector & get_center() const
Returns the center of the sphere.
Definition: st_sphere.h:90
double m_radius
Definition: st_sphere.h:132
Abstract class to write this object to an output stream.
Definition: l_writeable.h:41
void get_point_in_sphere_coordinates(const kjb::Vector &point_in_world_coordinates, kjb::Vector &point_in_sphere_coordinates) const
void set_center(const Vector &center)
Sets the center location.
Definition: st_sphere.h:105
Abstract class to read this object from an input stream.
Definition: l_readable.h:39
Definition: gr_renderable_model.h:88
Parametric_sphere()
Definition: st_sphere.h:48
virtual void read(const char *fname)
Reads this Readable from a file.
Definition: st_sphere.h:62
double get_center_z() const
Returns the center location z.
Definition: st_sphere.h:87
virtual void update_rendering_representation() const
Updates the rendering interface so that it reflects the paremeter values of this model to the renderi...
r
Definition: APPgetLargeConnectedEdges.m:127
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
virtual void write(std::ostream &out) const =0
Writes this Writeable to an output stream.
virtual Parametric_sphere * clone() const
Processes an Option from program command-line arguments.
Definition: st_sphere.h:77
virtual Abstract_renderable & get_rendering_interface() const
Returns a reference to the rendering interface used to render this model.
Definition: gr_renderable.h:151
double get_center_y() const
Returns the center location y.
Definition: st_sphere.h:84
virtual void read(std::istream &in)
Reads this Readable from an input stream.
Definition: st_sphere.cpp:68
x
Definition: APPgetLargeConnectedEdges.m:100
void get_point_in_world_coordinates(const kjb::Vector &point_in_sphere_coordinates, kjb::Vector &point_in_world_coordinates) const
Transforms a point in parapiped coordinates to world coordinates.
void set_center_z(double z)
Sets the center location z.
Definition: st_sphere.h:102
void set_center_x(double x)
Sets the center location x.
Definition: st_sphere.h:96
double get_center_x() const
Returns the center location x.
Definition: st_sphere.h:81
virtual ~Parametric_sphere()
Definition: st_sphere.h:78
Exception often thrown when wrapped C functions return error codes.
Definition: l_exception.h:262
St_renderable_model Base class for a structure model with a renderable representation.
double get_radius() const
Returns the radius.
Definition: st_sphere.h:93
void set_radius(double r)
Sets the radius.
Definition: st_sphere.h:108
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
virtual void read(std::istream &in)=0
Reads this Readable from an input stream.
virtual void write(const char *fname) const
Writes this Writeable to a file.
Definition: st_sphere.h:68
Object thrown when input or output fails.
Definition: l_exception.h:496
void set_center_y(double y)
Sets the center location y.
Definition: st_sphere.h:99
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
virtual Parametric_sphere & operator=(const Parametric_sphere &src)
Definition: st_sphere.h:37
virtual void write(std::ostream &out) const
Save the Sphere parameters into a file.
Definition: st_sphere.cpp:116
Vector m_center_v
Definition: st_sphere.h:131