Bayeux  3.4.1
Core Foundation library for SuperNEMO
helix_3d.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Arnaud Chapon <chapon@lpccaen.in2p3.fr>
4  * Creation date: 2008-12-18
5  * Last modified: 2014-06-25
6  *
7  * License:
8  *
9  * Description:
10  *
11  * Helix 3D model (along Z axis)
12  *
13  * History:
14  *
15  */
16 
17 #ifndef GEOMTOOLS_HELIX_3D_H
18 #define GEOMTOOLS_HELIX_3D_H 1
19 
20 // Standard library:
21 #include <iostream>
22 #include <string>
23 
24 // Third party:
25 // - Bayeux/datatools:
26 #include <datatools/i_tree_dump.h>
28 #include <datatools/bit_mask.h>
29 
30 // This project:
31 #include <geomtools/i_shape_1d.h>
32 #include <geomtools/utils.h>
34 
35 namespace geomtools {
36 
38  class helix_3d : public i_shape_1d,
40  {
41  public:
42 
44  static const std::string & helix_3d_label();
45 
47  bool is_normal();
48 
50  virtual std::string get_shape_name() const;
51 
53  bool is_valid() const;
54 
56  void invalidate();
57 
59  const vector_3d & get_center() const;
60 
63 
65  void set_center(const vector_3d &);
66 
68  void set_center(double x_, double y_, double z_);
69 
71  double get_radius() const;
72 
74  void set_radius(double);
75 
77  double get_step() const;
78 
80  void set_step(double);
81 
83  double get_t1() const;
84 
86  void set_t1(double);
87 
89  double get_t2() const;
90 
92  void set_t2(double);
93 
95  void set_angle1(double);
96 
98  void set_angle2(double);
99 
101  double get_angle1() const;
102 
104  double get_angle2() const;
105 
107  virtual double get_length(uint32_t flags_ = PATH_ALL_BITS) const;
108 
110  double get_curvilinear_position(double t_) const;
111 
113  bool t_is_valid(double t_) const;
114 
116  double get_theta_from_xy(double x_, double y_) const;
117 
119  double get_t(vector_3d point_) const;
120 
122  double get_t_from_xyz(double x_, double y_, double z_) const;
123 
125  double get_t_from_z(double z_) const;
126 
128  double get_z_from_t(double t_) const;
129 
131  vector_3d get_point(double t_) const;
132 
134  vector_3d get_point_xy(double theta_) const;
135 
137  void invalidate_angles();
138 
140  bool angles_are_valid() const;
141 
143  vector_3d get_first() const;
144 
146  vector_3d get_last() const;
147 
149  helix_3d();
150 
152  virtual ~helix_3d();
153 
155  void reset();
156 
158  virtual void tree_dump(std::ostream & out_ = std::clog,
159  const std::string & title_ = "",
160  const std::string & indent_ = "",
161  bool inherit_ = false) const;
162 
164  void dump() const;
165 
167  void make_vertex_collection(basic_polyline_3d &, double angular_step_ = 0.0) const;
168 
171 
173  static double t_to_angle(double t_);
174 
176  static double angle_to_t(double angle_);
177 
182  };
183 
185  static void print_xyz(std::ostream & out_,
186  const helix_3d & helix_,
187  double step_angle_ = 0.0,
188  unsigned int flags_ = 0);
189 
191  virtual bool is_on_curve(const vector_3d & position_,
192  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
193 
195  virtual vector_3d get_direction_on_curve(const vector_3d & position_) const;
196 
202  };
203 
205  virtual void generate_wires_self(wires_type & wires_,
206  uint32_t options_ = 0) const;
207 
208 
209  protected:
210 
212  void _set_defaults();
213 
214  private:
215 
216  double _radius_;
217  vector_3d _center_;
218  double _step_;
219  double _t1_;
220  double _t2_;
221 
222  // Serialization interface:
224 
225  };
226 
227 } // end of namespace geomtools
228 
229 #include <boost/serialization/export.hpp>
230 BOOST_CLASS_EXPORT_KEY2(geomtools::helix_3d, "geomtools::helix_3d")
231 
232 // Explicit class version:
233 #include <boost/serialization/version.hpp>
234 BOOST_CLASS_VERSION(geomtools::helix_3d, 2)
235 
236 #endif // GEOMTOOLS_HELIX_3D_H
237 
238 /*
239 ** Local Variables: --
240 ** mode: c++ --
241 ** c-file-style: "gnu" --
242 ** tab-width: 2 --
243 ** End: --
244 */
The abstract base class for all 1D curves/shapes.
Definition: i_shape_1d.h:32
Definition: helix_3d.h:181
basic_polyline_3d make_vertex_collection() const
Return a collection of vertexes representing the helix.
double get_z_from_t(double t_) const
Return the z position associated to a normalized angle.
print_flags_type
Definition: helix_3d.h:178
void set_angle2(double)
Set the stop angle.
Definition: utils.h:184
bool is_normal()
Check if the shape is normal.
virtual ~helix_3d()
Destructor.
double get_step() const
Return the step.
static const uint32_t bit01
Definition: bit_mask.h:28
double get_angle1() const
Return the start angle.
vector_3d & grab_center()
Return a reference to the mutable center.
double get_t(vector_3d point_) const
Return the normalized angle associated to a position in the reference frame of the helix.
bool t_is_valid(double t_) const
Check if a given normalized angle is valid.
virtual double get_length(uint32_t flags_=PATH_ALL_BITS) const
Return the length.
virtual bool is_on_curve(const vector_3d &position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a position in on the curve.
An helix (1D shape) in a 3D space.
Definition: helix_3d.h:38
std::list< vector_3d > basic_polyline_3d
Aliases for a list of 3D vertice as a 3D-polyline.
Definition: utils.h:54
Definition: helix_3d.h:180
static double t_to_angle(double t_)
Convert parametric to angle in radian:
Rendering options bit mask.
Definition: helix_3d.h:201
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
Last defined bit.
Definition: helix_3d.h:200
static void print_xyz(std::ostream &out_, const helix_3d &helix_, double step_angle_=0.0, unsigned int flags_=0)
Print approximated data (x,y,z) triplets representing the helix.
double get_t2() const
Return the normalized stop angle.
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
void set_t2(double)
Set the normalized stop angle.
void _set_defaults()
Set the default attributes values.
double get_theta_from_xy(double x_, double y_) const
Return the angle associated to given (x,y) position in the reference frame of the helix.
void reset()
Reset.
const vector_3d & get_center() const
Return a reference to the non mutable center.
void set_step(double)
Set the step.
vector_3d get_last() const
Return the stop position on the helix.
void set_radius(double)
Set the radius.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
helix_wires_rendering_option_type
3D rendering options
Definition: helix_3d.h:198
double get_angle2() const
Return the stop angle.
virtual vector_3d get_direction_on_curve(const vector_3d &position_) const
Return the direction ar some position in on the curve.
helix_3d()
Default constructor.
static const uint32_t bit02
Definition: bit_mask.h:29
Definition: helix_3d.h:179
void set_t1(double)
Set the normalized start angle.
double get_t1() const
Return the normalized start angle.
bool angles_are_valid() const
Check if angles are valid.
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
void dump() const
Basic print.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
double get_t_from_xyz(double x_, double y_, double z_) const
Return the normalized angle associated to a (x,y,z) position triplet in the reference frame of the he...
void set_angle1(double)
Set the start angle.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
double get_t_from_z(double z_) const
Return the normalized angle associated to a z position in the reference frame of the helix.
Last defined bit.
Definition: i_wires_3d_rendering.h:62
double get_radius() const
Return the radius.
vector_3d get_first() const
Return the start position on the helix.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
vector_3d get_point(double t_) const
Return the position on the helix for a given normalized angle.
static const uint32_t bit00
Definition: bit_mask.h:27
double get_curvilinear_position(double t_) const
Return the curvilinear position from the normalized angle.
static const std::string & helix_3d_label()
Return the identifier label for the class.
void set_center(const vector_3d &)
Set the center.
void invalidate_angles()
Invalidate helix's angles.
void invalidate()
Invalidate the helix.
Do not boost angular sampling.
Definition: helix_3d.h:199
bool is_valid() const
Check if the helix is valid.
static double angle_to_t(double angle_)
Convert angle in radian to parametric:
vector_3d get_point_xy(double theta_) const
Return the position on the helix for a given angle.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39