BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolygonPrivate Class Reference

The private data for polygons to hide boost dependency from the header. More...

Public Types

typedef model::d2::point_xy< double > point_t
 
typedef model::polygon< point_tpolygon_t
 

Public Member Functions

void get_points (std::vector< double > &xpos, std::vector< double > &ypos)
 
void init_from (const std::vector< double > &x, const std::vector< double > &y)
 

Public Attributes

polygon_t polygon
 

Detailed Description

The private data for polygons to hide boost dependency from the header.

Definition at line 25 of file Polygon.cpp.

Member Typedef Documentation

◆ point_t

typedef model::d2::point_xy<double> PolygonPrivate::point_t

Definition at line 27 of file Polygon.cpp.

◆ polygon_t

typedef model::polygon<point_t> PolygonPrivate::polygon_t

Definition at line 28 of file Polygon.cpp.

Member Function Documentation

◆ get_points()

void PolygonPrivate::get_points ( std::vector< double > &  xpos,
std::vector< double > &  ypos 
)

Definition at line 47 of file Polygon.cpp.

48 {
49  xpos.clear();
50  ypos.clear();
51  for (auto it = polygon.outer().begin(); it != polygon.outer().end(); ++it) {
52  // for vectors of x and y, extract the x/y from the point
53  xpos.push_back(boost::geometry::get<0>(*it));
54  ypos.push_back(boost::geometry::get<1>(*it));
55  }
56 }
polygon_t polygon
Definition: Polygon.cpp:29

Referenced by Polygon::getPoints().

◆ init_from()

void PolygonPrivate::init_from ( const std::vector< double > &  x,
const std::vector< double > &  y 
)

Definition at line 34 of file Polygon.cpp.

35 {
36  if (x.size() != y.size())
37  throw std::runtime_error(
38  "Polygon::Polygon(const std::vector<double>& x, const std::vector<double>& y) "
39  "Error. Sizes of arrays must conincide.");
40  std::vector<point_t> points;
41  for (size_t i = 0; i < x.size(); ++i)
42  points.push_back(point_t(x[i], y[i]));
43  assign_points(polygon, points);
44  correct(polygon);
45 }
model::d2::point_xy< double > point_t
Definition: Line.cpp:25

Referenced by Polygon::Polygon().

Member Data Documentation

◆ polygon

polygon_t PolygonPrivate::polygon

Definition at line 29 of file Polygon.cpp.

Referenced by Polygon::contains(), Polygon::getArea(), and Polygon::print().


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