Bayeux  3.4.1
Core Foundation library for SuperNEMO
quadric.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of geomtools.
7 //
8 // geomtools is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // geomtools is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with geomtools. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef GEOMTOOLS_QUADRIC_H
22 #define GEOMTOOLS_QUADRIC_H
23 
24 // This project:
25 #include <geomtools/utils.h>
26 #include <geomtools/i_shape_2d.h>
27 
28 namespace geomtools {
29 
31  class quadric : public i_shape_2d
32  {
33  public:
34 
36  static const std::string & quadric_label();
37 
39  virtual std::string get_shape_name() const;
40 
42  bool is_valid() const;
43 
45  void initialize(const datatools::properties &, const handle_dict_type * = 0);
46 
48  void reset();
49 
51  quadric();
52 
53  enum coef_index {
54  A = 9,
55  B = 8,
56  C = 7,
57  D = 6,
58  E = 5,
59  F = 4,
60  G = 3,
61  H = 2,
62  I = 1,
63  J = 0,
64  NCOEFFS = 10
65  };
66 
67  static std::string coeff_label(coef_index i_);
68 
70  void set_coefficient(coef_index, double);
71 
73  double get_coefficient(coef_index) const;
74 
76  virtual double eval_f(double x_, double y_, double z_) const;
77 
79  virtual double eval_dfdx(double x_, double y_, double z_) const;
80 
82  virtual double eval_dfdy(double x_, double y_, double z_) const;
83 
85  virtual double eval_dfdz(double x_, double y_, double z_) const;
86 
88  void eval_gradient(double x_, double y_, double z_,
89  double & dfdx_, double & dfdy_, double & dfdz_) const;
90 
92  void eval_gradient(const geomtools::vector_3d & position_,
93  geomtools::vector_3d & gradient_) const;
94 
96  double eval_f(const geomtools::vector_3d & position_) const;
97 
99  double distance(const geomtools::vector_3d & position_) const;
100 
103  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
104 
107  const geomtools::vector_3d & direction_,
108  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
109 
111  virtual bool is_on_surface(const geomtools::vector_3d & position_,
112  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
113 
114  virtual geomtools::vector_3d
116  bool check_ = true,
117  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
118 
119  virtual bool find_intercept(const geomtools::vector_3d & from_,
120  const geomtools::vector_3d & direction_,
121  face_intercept_info & intercept_,
122  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
123 
126  static void make_plane(quadric & q_, double a_, double b_, double c_, double d_);
127 
130  static void make_plane_yz(quadric & q_, double a_);
131 
134  static void make_plane_xz(quadric & q_, double b_);
135 
138  static void make_plane_xy(quadric & q_, double c_);
139 
142  static void make_parallel_planes_yz(quadric & q_, double a_);
143 
146  static void make_parallel_planes_xz(quadric & q_, double b_);
147 
150  static void make_parallel_planes_xy(quadric & q_, double c_);
151 
154  static void make_ellipsoid(quadric & q_, double a_, double b_, double c_);
155 
158  static void make_spheroid_along_z(quadric & q_, double a_, double b_);
159 
162  static void make_sphere(quadric & q_, double a_);
163 
166  static void make_elliptic_paraboloid_along_z(quadric & q_, double a_, double b_);
167 
170  static void make_circular_paraboloid_along_z(quadric & q_, double a_);
171 
174  static void make_hyperbolic_paraboloid_along_z(quadric & q_, double a_, double b_);
175 
178  static void make_elliptic_hyperbolic_one_sheet_along_z(quadric & q_, double a_, double b_, double c_);
179 
182  static void make_elliptic_hyperbolic_two_sheets_along_z(quadric & q_, double a_, double b_, double c_);
183 
186  static void make_elliptic_cone_along_z(quadric & q_, double a_, double b_, double c_);
187 
190  static void make_circular_cone_along_z(quadric & q_, double a_, double b_);
191 
194  static void make_elliptic_cylinder_along_z(quadric & q_, double a_, double b_);
195 
198  static void make_circular_cylinder_along_z(quadric & q_, double a_);
199 
202  static void make_hyperbolic_cylinder_along_z(quadric & q_, double a_, double b_);
203 
206  static void make_parabolic_cylinder_along_z(quadric & q_, double a_);
207 
209  void generate_wires_self(wires_type &, uint32_t options_ = 0) const;
210 
212  virtual void tree_dump(std::ostream & out_ = std::clog,
213  const std::string & title_ = "",
214  const std::string & indent_ = "",
215  bool inherit_= false) const;
216 
217  protected:
218 
220  void _set_defaults();
221 
222  private:
223 
224  double _coefficients_[NCOEFFS];
225 
226  // Registration interface :
228 
229  };
230 
231 } // end of namespace geomtools
232 
233 #endif // GEOMTOOLS_QUADRIC_H
234 
235 /*
236 ** Local Variables: --
237 ** mode: c++ --
238 ** c-file-style: "gnu" --
239 ** tab-width: 2 --
240 ** End: --
241 */
virtual geomtools::vector_3d get_normal_on_surface(const geomtools::vector_3d &position_, bool check_=true, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
geomtools::vector_3d orthogonal_projection(const geomtools::vector_3d &position_, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Compute the orthogonal projection from a position.
void eval_gradient(double x_, double y_, double z_, double &dfdx_, double &dfdy_, double &dfdz_) const
Compute the quadric gradient (df/dx, df/dy, df/dz) at given 3D point.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual double eval_dfdz(double x_, double y_, double z_) const
Compute the quadric df/dz derivative at given 3D point.
Definition: quadric.h:61
void reset()
Reset.
static void make_circular_paraboloid_along_z(quadric &q_, double a_)
virtual double eval_dfdy(double x_, double y_, double z_) const
Compute the quadric df/dy derivative at given 3D point.
static void make_circular_cylinder_along_z(quadric &q_, double a_)
static void make_plane_xy(quadric &q_, double c_)
static void make_plane_xz(quadric &q_, double b_)
static void make_parallel_planes_yz(quadric &q_, double a_)
static void make_circular_cone_along_z(quadric &q_, double a_, double b_)
geomtools::vector_3d projection(const geomtools::vector_3d &position_, const geomtools::vector_3d &direction_, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Compute the projection from a position along a direction.
virtual bool is_on_surface(const geomtools::vector_3d &position_, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if the point.
static void make_parabolic_cylinder_along_z(quadric &q_, double a_)
static void make_plane(quadric &q_, double a_, double b_, double c_, double d_)
Definition: quadric.h:54
static void make_elliptic_hyperbolic_one_sheet_along_z(quadric &q_, double a_, double b_, double c_)
static void make_ellipsoid(quadric &q_, double a_, double b_, double c_)
static void make_elliptic_cylinder_along_z(quadric &q_, double a_, double b_)
bool is_valid() const
Check if the plane is valid.
static void make_sphere(quadric &q_, double a_)
coef_index
Definition: quadric.h:53
virtual double eval_f(double x_, double y_, double z_) const
Compute the quadric formula f(x,y,z) at given 3D point.
void set_coefficient(coef_index, double)
Set the coefficient at given rank.
Definition: quadric.h:59
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
virtual std::string get_shape_name() const
Return the shape name.
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
double get_coefficient(coef_index) const
Return the coefficient at given rank.
Definition: quadric.h:62
static void make_hyperbolic_paraboloid_along_z(quadric &q_, double a_, double b_)
static void make_elliptic_cone_along_z(quadric &q_, double a_, double b_, double c_)
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
Definition: quadric.h:58
static std::string coeff_label(coef_index i_)
static void make_elliptic_paraboloid_along_z(quadric &q_, double a_, double b_)
static void make_hyperbolic_cylinder_along_z(quadric &q_, double a_, double b_)
quadric()
Default constructor.
static void make_plane_yz(quadric &q_, double a_)
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
Definition: quadric.h:63
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
Definition: quadric.h:60
The abstract base class for all 2D shapes/surfaces.
Definition: i_shape_2d.h:37
Definition: quadric.h:55
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
Definition: quadric.h:64
Definition: quadric.h:56
void _set_defaults()
Set default attributes values.
virtual bool find_intercept(const geomtools::vector_3d &from_, const geomtools::vector_3d &direction_, face_intercept_info &intercept_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
static void make_elliptic_hyperbolic_two_sheets_along_z(quadric &q_, double a_, double b_, double c_)
void generate_wires_self(wires_type &, uint32_t options_=0) const
Definition: quadric.h:57
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
static const std::string & quadric_label()
Return the identifier label for the class.
static void make_parallel_planes_xz(quadric &q_, double b_)
static void make_spheroid_along_z(quadric &q_, double a_, double b_)
A general quadric a 3D space.
Definition: quadric.h:31
static void make_parallel_planes_xy(quadric &q_, double c_)
virtual double eval_dfdx(double x_, double y_, double z_) const
Compute the quadric df/dx derivative at given 3D point.
double distance(const geomtools::vector_3d &position_) const
Compute the distance from a position to the plane.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125