Bayeux  3.4.1
Core Foundation library for SuperNEMO
rectangle.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-14
4  * Last modified: 2015-02-15
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A rectangle in x-y plane
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_RECTANGLE_H
17 #define GEOMTOOLS_RECTANGLE_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 
23 // This project:
24 #include <geomtools/i_shape_2d.h>
25 #include <geomtools/i_polygon.h>
26 
27 namespace geomtools {
28 
30  class rectangle : public i_shape_2d,
31  public i_polygon
32  {
33 
34  public:
35 
37  static const std::string & rectangle_label();
38 
40  bool is_valid() const;
41 
43  double get_x() const;
44 
46  double get_y() const;
47 
49  void set_x(double);
50 
52  void set_y(double);
53 
55  void set(double x_, double y_);
56 
58  virtual double get_surface(uint32_t flags_ = ALL_PIECES) const;
59 
61  virtual double get_perimeter(uint32_t flags_ = ALL_PIECES) const;
62 
64  double get_circumference() const;
65 
66  // Return the diagonal
67  double get_diagonal() const;
68 
70  rectangle();
71 
73  rectangle(double x_, double y_);
74 
76  virtual ~rectangle();
77 
79  virtual std::string get_shape_name() const;
80 
81  virtual bool is_on_surface(const vector_3d &,
82  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
83 
84  virtual vector_3d get_normal_on_surface(const vector_3d & position_,
85  bool check_ = true,
86  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
87 
88  virtual bool find_intercept(const vector_3d & from_,
89  const vector_3d & direction_,
90  face_intercept_info & intercept_,
91  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
92 
94  virtual void tree_dump(std::ostream & out_ = std::clog,
95  const std::string & title_ = "",
96  const std::string & indent_ = "",
97  bool inherit_= false) const;
98 
110  };
111 
113  virtual void generate_wires_self(wires_type & wires_,
114  uint32_t options_ = 0) const;
115 
117  virtual unsigned int compute_vertexes(vertex_col_type & vertexes_) const;
118 
120  void initialize(const datatools::properties &, const handle_dict_type * = 0);
121 
123  void reset();
124 
125  protected:
126 
128  void _set_defaults();
129 
130  private:
131 
132  double _x_;
133  double _y_;
134 
135  // Registration interface :
137 
138  };
139 
140 } // end of namespace geomtools
141 
142 #endif // GEOMTOOLS_RECTANGLE_H
143 
144 /*
145 ** Local Variables: --
146 ** mode: c++ --
147 ** c-file-style: "gnu" --
148 ** tab-width: 2 --
149 ** End: --
150 */
void reset()
Reset.
virtual ~rectangle()
Destructor.
virtual bool find_intercept(const vector_3d &from_, const vector_3d &direction_, face_intercept_info &intercept_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
void set_x(double)
Set the X dimension.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
virtual vector_3d get_normal_on_surface(const vector_3d &position_, bool check_=true, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
double get_y() const
Return the Y dimension.
Do not render the X- side.
Definition: rectangle.h:101
double get_x() const
Return the X dimension.
Rendering options bit mask.
Definition: rectangle.h:106
double get_circumference() const
Return the circumference.
bool is_valid() const
Check if the rectangle is valid.
rectangle_wires_rendering_option_type
3D rendering options
Definition: rectangle.h:100
virtual double get_surface(uint32_t flags_=ALL_PIECES) const
Return the surface.
Last defined bit.
Definition: rectangle.h:105
rectangle()
Default constructor.
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
void set(double x_, double y_)
Set the X and Y dimensions.
static const std::string & rectangle_label()
Return the identifier label for the class.
Do not render the X+ side.
Definition: rectangle.h:102
static const uint32_t ALL_PIECES
Special flag representing all pieces composing a 2D shape.
Definition: i_shape_2d.h:53
void set_y(double)
Set the Y dimension.
Do not render the Y+ side.
Definition: rectangle.h:104
virtual unsigned int compute_vertexes(vertex_col_type &vertexes_) const
Build an ordered collection of vertexes.
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
void _set_defaults()
Set default attributes values.
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
The abstract base class for all 2D shapes/surfaces.
Definition: i_shape_2d.h:37
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
A rectangular surface (2D shape)
Definition: rectangle.h:30
Last defined bit.
Definition: i_wires_3d_rendering.h:62
double get_diagonal() const
Polygon 2D shape.
Definition: i_polygon.h:28
virtual bool is_on_surface(const vector_3d &, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
virtual double get_perimeter(uint32_t flags_=ALL_PIECES) const
Return the perimeter.
std::vector< vector_3d > vertex_col_type
Aliases for an ordered collection of 3D vertice.
Definition: utils.h:58
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
Do not render the Y- side.
Definition: rectangle.h:103
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.