BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Polygon Class Reference

Description

A polygon, for use in detector masks.

Polygon defined by two arrays with x and y coordinates of points. Sizes of arrays should coincide. If polygon is unclosed (the last point doesn't repeat the first one), it will be closed automatically.

Inheritance diagram for Polygon:

Public Member Functions

 Polygon (const PolygonPrivate *d)
 
 Polygon (std::vector< double > x, std::vector< double > y)
 
 Polygon (std::vector< std::pair< double, double >> points)
 
 ~Polygon () override
 
Polygonclone () const override
 
bool contains (const Bin1D &binx, const Bin1D &biny) const override
 Returns true if area defined by two bins is inside or on border of polygon (more precisely, if mid point of two bins satisfy this condition). More...
 
bool contains (double x, double y) const override
 Returns true if point with given coordinates is inside or on border of the shape. More...
 
double getArea () const
 
void getPoints (std::vector< double > &xpos, std::vector< double > &ypos) const
 

Protected Member Functions

void print (std::ostream &ostr) const override
 

Constructor & Destructor Documentation

◆ Polygon() [1/3]

Polygon::Polygon ( std::vector< double >  x,
std::vector< double >  y 
)

◆ Polygon() [2/3]

Polygon::Polygon ( std::vector< std::pair< double, double >>  points)

◆ Polygon() [3/3]

Polygon::Polygon ( const PolygonPrivate *  d)

◆ ~Polygon()

Polygon::~Polygon ( )
override

Member Function Documentation

◆ clone()

Polygon* Polygon::clone ( ) const
overridevirtual

Implements IShape2D.

◆ contains() [1/2]

bool Polygon::contains ( const Bin1D binx,
const Bin1D biny 
) const
overridevirtual

Returns true if area defined by two bins is inside or on border of polygon (more precisely, if mid point of two bins satisfy this condition).

Implements IShape2D.

◆ contains() [2/2]

bool Polygon::contains ( double  x,
double  y 
) const
overridevirtual

Returns true if point with given coordinates is inside or on border of the shape.

Implements IShape2D.

◆ getArea()

double Polygon::getArea ( ) const

◆ getPoints()

void Polygon::getPoints ( std::vector< double > &  xpos,
std::vector< double > &  ypos 
) const

◆ print()

void Polygon::print ( std::ostream &  ostr) const
overrideprotectedvirtual

Reimplemented from IShape2D.