Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
geomtools::simple_polygon Class Reference

A simple polygon in the XY plane. More...

#include <bayeux/geomtools/simple_polygon.h>

Inheritance diagram for geomtools::simple_polygon:
geomtools::i_shape_2d geomtools::i_polygon geomtools::i_object_3d geomtools::i_find_intercept geomtools::i_wires_3d_rendering datatools::i_serializable datatools::i_tree_dumpable

Classes

struct  wall_segment_type
 Data for a wall segment. More...
 

Public Types

enum  build_mode_type { BUILD_MODE_INVALID = 0, BUILD_MODE_BY_VERTICES = 1, BUILD_MODE_BY_SEGMENTS = 2 }
 Build mode. More...
 
enum  simple_polygon_wires_rendering_option_type { WR_SP_INTERNAL_EDGES = (WR_BASE_LAST << 1), WR_SP_LAST = (WR_SP_INTERNAL_EDGES), WR_SP_MASK }
 3D rendering options More...
 
typedef std::vector< wall_segment_typewall_segment_col_type
 Type alias for a collection of wall segment data. More...
 
- Public Types inherited from geomtools::i_shape_2d
enum  faces_mask_type {
  FACE_NONE = face_identifier::FACE_BITS_NONE, FACE_UNIQUE = datatools::bit_mask::bit00, FACE_UP = FACE_UNIQUE, FACE_DOWN = datatools::bit_mask::bit01,
  FACE_ALL = FACE_UNIQUE
}
 The up/down identifier of the face. More...
 
- Public Types inherited from geomtools::i_object_3d
enum  dimensional_type { DIMENSIONAL_0 = 0, DIMENSIONAL_1 = 1, DIMENSIONAL_2 = 2, DIMENSIONAL_3 = 3 }
 Known dimensions. More...
 
typedef datatools::handle< i_object_3dhandle_type
 A handle to a 3D object. More...
 
typedef std::map< std::string, object_entryhandle_dict_type
 Dictionary of handle of 3D object entries. More...
 
- Public Types inherited from datatools::i_tree_dumpable
enum  ostream_type { OSTREAM_COUT = 1, OSTREAM_CERR = 2, OSTREAM_CLOG = 3 }
 Enumeration for standard output streams. More...
 
- Public Types inherited from geomtools::i_wires_3d_rendering
enum  wires_rendering_option_type {
  WR_NONE = 0, WR_BASE_GRID = datatools::bit_mask::bit00, WR_BASE_GRID_LOW_DENSITY = (WR_BASE_GRID << 1), WR_BASE_GRID_HIGH_DENSITY = (WR_BASE_GRID << 2),
  WR_BASE_GRID_VERY_HIGH_DENSITY = (WR_BASE_GRID << 3), WR_BASE_GRID_HUGE_DENSITY = (WR_BASE_GRID << 4), WR_BASE_LOW_ANGLE_SAMPLING = (WR_BASE_GRID << 5), WR_BASE_HIGH_ANGLE_SAMPLING = (WR_BASE_GRID << 6),
  WR_BASE_VERY_HIGH_ANGLE_SAMPLING = (WR_BASE_GRID << 7), WR_BASE_HUGE_ANGLE_SAMPLING = (WR_BASE_GRID << 8), WR_BASE_UNUSED_09 = (WR_BASE_GRID << 9), WR_BASE_UNUSED_10 = (WR_BASE_GRID << 10),
  WR_BASE_UNUSED_11 = (WR_BASE_GRID << 11), WR_BASE_UNUSED_12 = (WR_BASE_GRID << 12), WR_BASE_UNUSED_13 = (WR_BASE_GRID << 13), WR_BASE_BOUNDINGS = (WR_BASE_GRID << 14),
  WR_BASE_EXPLODE = (WR_BASE_GRID << 15), WR_BASE_LAST = (WR_BASE_EXPLODE), WR_BASE_MASK = datatools::bit_mask::nbits16
}
 Wires rendering optional flags. More...
 
enum  sampling_level_type {
  SL_NONE = 0, SL_LOW = 1, SL_NORMAL = 2, SL_HIGH = 3,
  SL_VERY_HIGH = 4, SL_HUGE = 5
}
 Sampling levels. More...
 

Public Member Functions

bool is_valid () const
 Check the validity of the simple polygon. More...
 
virtual std::string get_shape_name () const
 Return the identifier/name of the shape. More...
 
void set_build_mode (build_mode_type)
 Set the build mode. More...
 
build_mode_type get_build_mode () const
 Return the build mode. More...
 
virtual double get_perimeter (uint32_t flags_=ALL_PIECES) const
 Return the perimeter. More...
 
virtual double get_surface (uint32_t flags_=ALL_PIECES) const
 Return the surface. More...
 
unsigned int get_number_of_vertices () const
 Return the number of vertices. More...
 
const vector_2dget_vertex (int) const
 Return the vertex by index. More...
 
bool is_convex () const
 Check if the simple polygon is convex. More...
 
void add_vertex (double x_, double y_)
 Append a vertex to the list of vertexes. More...
 
void add_vertex (const vector_2d &)
 Append a vertex to the list of vertexes. More...
 
void add_wall_segment (const vector_2d &start_, const vector_2d &stop_, double left_thickness_, double right_thickness_, double start_angle_=0.0, double stop_angle_=std::numeric_limits< double >::quiet_NaN())
 Add wall segment. More...
 
void add_wall_segment (const vector_2d &stop_, double left_thickness_, double right_thickness_, double stop_angle_=std::numeric_limits< double >::quiet_NaN())
 Add wall segment. More...
 
bool walls_are_terminated () const
 Check if walls are terminated. More...
 
 simple_polygon ()
 Default constructor. More...
 
virtual ~simple_polygon ()
 Destructor. More...
 
virtual bool is_on_surface (const vector_3d &, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
 Check is a given point belongs to the surface of the 2D shape. More...
 
virtual vector_3d get_normal_on_surface (const vector_3d &position_, bool check_=false, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
 Return the normal direction at some position on the 2D shape's path. More...
 
bool is_clockwise () const
 Check if the polygon is clockwise. More...
 
bool is_anticlockwise () const
 Check if the polygon is anticlockwise. More...
 
virtual bool find_intercept (const vector_3d &from_, const vector_3d &direction_, face_intercept_info &intercept_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
 Find the intercept of a ray with the 2D shape's surfaces. More...
 
virtual void tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
 Smart print. More...
 
virtual void generate_wires_self (wires_type &wires_, uint32_t options_=0) const
 Generate a sequence of polylines for wires 3D rendering. More...
 
virtual unsigned int compute_vertexes (vertex_col_type &vertexes_) const
 Build an ordered collection of vertexes. More...
 
unsigned int number_of_triangles () const
 Return the number of triangles. More...
 
const triangleget_triangle (int index_) const
 Return a non mutable reference to one of the inner triangles. More...
 
const mygsl::min_maxget_xrange () const
 Return the bounding interval on the X axis. More...
 
const mygsl::min_maxget_yrange () const
 Return the bounding interval on the Y axis. More...
 
bool is_initialized () const
 Check initialization. More...
 
void initialize (const datatools::properties &, const handle_dict_type *objects_=0)
 Initialization. More...
 
void reset ()
 Reset. More...
 
- Public Member Functions inherited from geomtools::i_shape_2d
virtual bool has_number_of_sides () const
 Check if the 2D shape knows its number of associated sides. More...
 
virtual unsigned int get_number_of_sides () const
 Return the number of associated sides. More...
 
virtual bool has_perimeter (uint32_t flags_=ALL_PIECES) const
 Check if the 2D shape known its perimeter. More...
 
virtual bool has_surface (uint32_t flags_=ALL_PIECES) const
 Check if the 2D shape surface is defined. More...
 
int get_dimensional () const
 Return the dimension of the object. More...
 
 i_shape_2d ()
 Default constructor. More...
 
 i_shape_2d (double tolerance_)
 Constructor. More...
 
 i_shape_2d (double tolerance_, double angular_tolerance_)
 Constructor. More...
 
virtual ~i_shape_2d ()
 Destructor. More...
 
- Public Member Functions inherited from geomtools::i_object_3d
datatools::logger::priority get_logging_priority () const
 Return the logging priority threshold. More...
 
void set_logging_priority (datatools::logger::priority)
 Set the logging priority threshold. More...
 
bool has_wires_drawer () const
 Check is a wires drawer is available. More...
 
void set_wires_drawer (i_wires_3d_rendering &wires_drawer_)
 Set a wires drawer. More...
 
void reset_wires_drawer ()
 Reset the wires drawer. More...
 
i_wires_3d_renderinggrab_wires_drawer ()
 Return a wires drawer. More...
 
const i_wires_3d_renderingget_wires_drawer () const
 Return a wires drawer. More...
 
double compute_tolerance (double tolerance_) const
 Return the distance tolerance. More...
 
double compute_angular_tolerance (double angular_tolerance_) const
 Return the angular tolerance. More...
 
double get_tolerance () const
 Return the distance tolerance. More...
 
void set_tolerance (double tolerance_)
 Set the distance tolerance. More...
 
double get_angular_tolerance () const
 Return the angular tolerance. More...
 
void set_angular_tolerance (double tolerance_)
 Set the angular tolerance. More...
 
virtual bool is_composite () const
 Check if the object is composite. More...
 
 i_object_3d ()
 Default constructor. More...
 
 i_object_3d (double tolerance_)
 Constructor on length tolerance. More...
 
 i_object_3d (double tolerance_, double angular_tolerance_)
 Constructor on length tolerance. More...
 
 i_object_3d (const i_object_3d &)
 Copy constructor. More...
 
i_object_3doperator= (const i_object_3d &)
 Assignment operator. More...
 
virtual ~i_object_3d ()
 Destructor. More...
 
void initialize_simple ()
 Initialize the 3D object. More...
 
- Public Member Functions inherited from datatools::i_serializable
 i_serializable ()
 Default constructor. More...
 
virtual ~i_serializable ()
 Destructor. More...
 
virtual const std::string & get_serial_tag () const =0
 Return the serialization string identifier of the class. More...
 
- Public Member Functions inherited from datatools::i_tree_dumpable
 i_tree_dumpable ()
 Constructor. More...
 
virtual ~i_tree_dumpable ()
 Destructor. More...
 
virtual void print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const
 Main new interface method for printing. More...
 
void print_tree_json (std::ostream &out_=std::clog, const std::string &json_options_="") const
 Printing with jsonized options. More...
 
void print_tree_json (std::ostream &out_=std::clog, const char *json_options_=nullptr) const
 Printing with jsonized options. More...
 
void tree_dump_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="", const bool inherit_=false) const
 
void tree_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="") const
 
void smart_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="") const
 
- Public Member Functions inherited from geomtools::i_find_intercept
 i_find_intercept ()
 Default constructor. More...
 
virtual ~i_find_intercept ()
 Destructor. More...
 
bool find_intercept_self (const vector_3d &a_from, const vector_3d &a_direction, face_intercept_info &a_intercept, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
 
bool find_intercept (const vector_3d &a_from, const vector_3d &a_direction, const placement &a_placement, face_intercept_info &a_intercept, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
 
- Public Member Functions inherited from geomtools::i_wires_3d_rendering
virtual ~i_wires_3d_rendering ()
 Destructor. More...
 
void generate_wires (wires_type &wires_, const placement &positioning_, uint32_t options_=0) const
 
void generate_wires (wires_type &wires_, const geomtools::vector_3d &position_, const geomtools::rotation_3d &rotation_, uint32_t options_=0) const
 

Static Public Member Functions

static build_mode_type build_mode_from_label (const std::string &)
 Return the build mode from a label. More...
 
static std::string label_from_build_mode (build_mode_type)
 Return the label associated to a build mode. More...
 
static const std::string & simple_polygon_label ()
 Return the class label. More...
 
static bool find_segment_2d_intersection (const vector_2d &a_, const vector_2d &b_, const vector_2d &c_, const vector_2d &d_, vector_2d &intersection_)
 Find the intersection between two 2D segments. More...
 
static void triangulation (const std::vector< const vector_2d * > &vertices_, const vector_3d &normal_, std::vector< triangle > &triangles_)
 Triangulation of a simple polygon. More...
 
- Static Public Member Functions inherited from geomtools::i_shape_2d
static void init_ocd (datatools::object_configuration_description &ocd_)
 
- Static Public Member Functions inherited from geomtools::i_object_3d
static void init_ocd (datatools::object_configuration_description &)
 OCD support. More...
 
- Static Public Member Functions inherited from datatools::i_tree_dumpable
static const boost::property_tree::ptree & empty_options ()
 
static boost::property_tree::ptree make_base_print_options (const std::string &title_, const std::string &indent_="", const bool inherit_=false)
 
static std::ostream & last_skip_tag (std::ostream &out_)
 
static std::ostream & skip_tag (std::ostream &out_)
 
static std::ostream & last_tag (std::ostream &out_)
 
static std::ostream & tag (std::ostream &out_)
 
- Static Public Member Functions inherited from geomtools::i_wires_3d_rendering
static uint32_t linear_sampling (sampling_level_type)
 Return linear sampling from sampling level. More...
 
static uint32_t linear_sampling_from_options (uint32_t)
 Return linear sampling from rendering options. More...
 
static uint32_t angular_sampling (sampling_level_type)
 Return angular sampling from sampling level. More...
 
static uint32_t angular_sampling_from_options (uint32_t)
 Return angular sampling from rendering options. More...
 
static void boost_linear_sampling (uint32_t &)
 Boost the linear sampling. More...
 

Protected Member Functions

void _set_defaults ()
 Set defaults attributes. More...
 
void _build_by_vertices ()
 Build by vertices. More...
 
void _build_by_segments ()
 Build by walls. More...
 
bool _check_vertex (const vector_2d &vtx_, bool no_first_check_=false) const
 Check if a vertex can be added. More...
 
void _compute_normal ()
 Compute normal. More...
 
void _add_vertex (const vector_2d &vtx_)
 Add a new vertex. More...
 
void _add_wall_segment (const vector_2d &start_, const vector_2d &stop_, double left_thickness_, double right_thickness_, double start_angle_, double stop_angle_)
 Add wall segment. More...
 
void _at_initialize ()
 Special init operations. More...
 
- Protected Member Functions inherited from geomtools::i_object_3d
void _set_defaults ()
 Set default values for attributes. More...
 
void _initialize (const datatools::properties &, const handle_dict_type *=0)
 Initialize from properties. More...
 
void _reset ()
 Reset. More...
 

Additional Inherited Members

- Static Public Attributes inherited from geomtools::i_shape_2d
static const uint32_t ALL_PIECES = 0xFFFFFFFF
 Special flag representing all pieces composing a 2D shape. More...
 

Detailed Description

A simple polygon in the XY plane.

Member Typedef Documentation

◆ wall_segment_col_type

Type alias for a collection of wall segment data.

Member Enumeration Documentation

◆ build_mode_type

Build mode.

Enumerator
BUILD_MODE_INVALID 

Invalid build mode.

BUILD_MODE_BY_VERTICES 

Build mode by vertices.

BUILD_MODE_BY_SEGMENTS 

Build mode by segments.

◆ simple_polygon_wires_rendering_option_type

3D rendering options

Enumerator
WR_SP_INTERNAL_EDGES 

Do render the internal triangle edges.

WR_SP_LAST 

Last defined bit.

WR_SP_MASK 

Rendering options bit mask.

Constructor & Destructor Documentation

◆ simple_polygon()

geomtools::simple_polygon::simple_polygon ( )

Default constructor.

◆ ~simple_polygon()

virtual geomtools::simple_polygon::~simple_polygon ( )
virtual

Destructor.

Member Function Documentation

◆ _add_vertex()

void geomtools::simple_polygon::_add_vertex ( const vector_2d vtx_)
protected

Add a new vertex.

◆ _add_wall_segment()

void geomtools::simple_polygon::_add_wall_segment ( const vector_2d start_,
const vector_2d stop_,
double  left_thickness_,
double  right_thickness_,
double  start_angle_,
double  stop_angle_ 
)
protected

Add wall segment.

◆ _at_initialize()

void geomtools::simple_polygon::_at_initialize ( )
protected

Special init operations.

◆ _build_by_segments()

void geomtools::simple_polygon::_build_by_segments ( )
protected

Build by walls.

◆ _build_by_vertices()

void geomtools::simple_polygon::_build_by_vertices ( )
protected

Build by vertices.

◆ _check_vertex()

bool geomtools::simple_polygon::_check_vertex ( const vector_2d vtx_,
bool  no_first_check_ = false 
) const
protected

Check if a vertex can be added.

◆ _compute_normal()

void geomtools::simple_polygon::_compute_normal ( )
protected

Compute normal.

◆ _set_defaults()

void geomtools::simple_polygon::_set_defaults ( )
protected

Set defaults attributes.

◆ add_vertex() [1/2]

void geomtools::simple_polygon::add_vertex ( double  x_,
double  y_ 
)

Append a vertex to the list of vertexes.

◆ add_vertex() [2/2]

void geomtools::simple_polygon::add_vertex ( const vector_2d )

Append a vertex to the list of vertexes.

◆ add_wall_segment() [1/2]

void geomtools::simple_polygon::add_wall_segment ( const vector_2d start_,
const vector_2d stop_,
double  left_thickness_,
double  right_thickness_,
double  start_angle_ = 0.0,
double  stop_angle_ = std::numeric_limits< double >::quiet_NaN() 
)

Add wall segment.

◆ add_wall_segment() [2/2]

void geomtools::simple_polygon::add_wall_segment ( const vector_2d stop_,
double  left_thickness_,
double  right_thickness_,
double  stop_angle_ = std::numeric_limits< double >::quiet_NaN() 
)

Add wall segment.

◆ build_mode_from_label()

static build_mode_type geomtools::simple_polygon::build_mode_from_label ( const std::string &  )
static

Return the build mode from a label.

◆ compute_vertexes()

virtual unsigned int geomtools::simple_polygon::compute_vertexes ( vertex_col_type vertexes_) const
virtual

Build an ordered collection of vertexes.

Implements geomtools::i_polygon.

◆ find_intercept()

virtual bool geomtools::simple_polygon::find_intercept ( const vector_3d from_,
const vector_3d direction_,
face_intercept_info intercept_,
double  tolerance_ = GEOMTOOLS_PROPER_TOLERANCE 
) const
virtual

Find the intercept of a ray with the 2D shape's surfaces.

Implements geomtools::i_find_intercept.

◆ find_segment_2d_intersection()

static bool geomtools::simple_polygon::find_segment_2d_intersection ( const vector_2d a_,
const vector_2d b_,
const vector_2d c_,
const vector_2d d_,
vector_2d intersection_ 
)
static

Find the intersection between two 2D segments.

◆ generate_wires_self()

virtual void geomtools::simple_polygon::generate_wires_self ( wires_type wires_,
uint32_t  options_ = 0 
) const
virtual

Generate a sequence of polylines for wires 3D rendering.

Implements geomtools::i_wires_3d_rendering.

◆ get_build_mode()

build_mode_type geomtools::simple_polygon::get_build_mode ( ) const

Return the build mode.

◆ get_normal_on_surface()

virtual vector_3d geomtools::simple_polygon::get_normal_on_surface ( const vector_3d position_,
bool  check_ = false,
double  skin_ = GEOMTOOLS_PROPER_TOLERANCE 
) const
virtual

Return the normal direction at some position on the 2D shape's path.

Implements geomtools::i_shape_2d.

◆ get_number_of_vertices()

unsigned int geomtools::simple_polygon::get_number_of_vertices ( ) const

Return the number of vertices.

◆ get_perimeter()

virtual double geomtools::simple_polygon::get_perimeter ( uint32_t  flags_ = ALL_PIECES) const
virtual

Return the perimeter.

Reimplemented from geomtools::i_shape_2d.

◆ get_shape_name()

virtual std::string geomtools::simple_polygon::get_shape_name ( ) const
virtual

Return the identifier/name of the shape.

Implements geomtools::i_object_3d.

◆ get_surface()

virtual double geomtools::simple_polygon::get_surface ( uint32_t  flags_ = ALL_PIECES) const
virtual

Return the surface.

Reimplemented from geomtools::i_shape_2d.

◆ get_triangle()

const triangle& geomtools::simple_polygon::get_triangle ( int  index_) const

Return a non mutable reference to one of the inner triangles.

◆ get_vertex()

const vector_2d& geomtools::simple_polygon::get_vertex ( int  ) const

Return the vertex by index.

◆ get_xrange()

const mygsl::min_max& geomtools::simple_polygon::get_xrange ( ) const

Return the bounding interval on the X axis.

◆ get_yrange()

const mygsl::min_max& geomtools::simple_polygon::get_yrange ( ) const

Return the bounding interval on the Y axis.

◆ initialize()

void geomtools::simple_polygon::initialize ( const datatools::properties ,
const handle_dict_type objects_ = 0 
)
virtual

Initialization.

Reimplemented from geomtools::i_object_3d.

◆ is_anticlockwise()

bool geomtools::simple_polygon::is_anticlockwise ( ) const

Check if the polygon is anticlockwise.

◆ is_clockwise()

bool geomtools::simple_polygon::is_clockwise ( ) const

Check if the polygon is clockwise.

◆ is_convex()

bool geomtools::simple_polygon::is_convex ( ) const

Check if the simple polygon is convex.

◆ is_initialized()

bool geomtools::simple_polygon::is_initialized ( ) const

Check initialization.

◆ is_on_surface()

virtual bool geomtools::simple_polygon::is_on_surface ( const vector_3d ,
double  tolerance_ = GEOMTOOLS_PROPER_TOLERANCE 
) const
virtual

Check is a given point belongs to the surface of the 2D shape.

Implements geomtools::i_shape_2d.

◆ is_valid()

bool geomtools::simple_polygon::is_valid ( ) const
virtual

Check the validity of the simple polygon.

Implements geomtools::i_object_3d.

◆ label_from_build_mode()

static std::string geomtools::simple_polygon::label_from_build_mode ( build_mode_type  )
static

Return the label associated to a build mode.

◆ number_of_triangles()

unsigned int geomtools::simple_polygon::number_of_triangles ( ) const

Return the number of triangles.

◆ reset()

void geomtools::simple_polygon::reset ( )
virtual

Reset.

Reimplemented from geomtools::i_object_3d.

◆ set_build_mode()

void geomtools::simple_polygon::set_build_mode ( build_mode_type  )

Set the build mode.

◆ simple_polygon_label()

static const std::string& geomtools::simple_polygon::simple_polygon_label ( )
static

Return the class label.

◆ tree_dump()

virtual void geomtools::simple_polygon::tree_dump ( std::ostream &  out_ = std::clog,
const std::string &  title_ = "",
const std::string &  indent_ = "",
bool  inherit_ = false 
) const
virtual

Smart print.

Reimplemented from geomtools::i_object_3d.

◆ triangulation()

static void geomtools::simple_polygon::triangulation ( const std::vector< const vector_2d * > &  vertices_,
const vector_3d normal_,
std::vector< triangle > &  triangles_ 
)
static

Triangulation of a simple polygon.

◆ walls_are_terminated()

bool geomtools::simple_polygon::walls_are_terminated ( ) const

Check if walls are terminated.


The documentation for this class was generated from the following file: