OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
VertexList Class Reference

#include <VertexList.hh>

Collaboration diagram for VertexList:
Collaboration graph

Public Member Functions

 VertexList ()
 
 ~VertexList ()
 
void addVertex (int x, int y)
 
size_t size () const
 
int vertexX (size_t index) const
 
int vertexY (size_t index) const
 
void clear ()
 

Private Member Functions

 VertexList (const VertexList &)
 Copying forbidden. More...
 
VertexListoperator= (const VertexList &)
 Assignment forbidden. More...
 

Private Attributes

std::vector< std::pair< int, int > > vertices_
 Vector containing vertices in the list. More...
 

Detailed Description

VertexList is a class for storing x,y coordinate pairs in a list.

Definition at line 42 of file VertexList.hh.

Constructor & Destructor Documentation

◆ VertexList() [1/2]

VertexList::VertexList ( )

The Constructor

Definition at line 39 of file VertexList.cc.

39  {
40 }

◆ ~VertexList()

VertexList::~VertexList ( )

The Destructor.

Definition at line 46 of file VertexList.cc.

46  {
47 }

◆ VertexList() [2/2]

VertexList::VertexList ( const VertexList )
private

Copying forbidden.

Member Function Documentation

◆ addVertex()

void VertexList::addVertex ( int  x,
int  y 
)

Adds a vertex to the list.

Parameters
xX-coordinate of the vertex.
yY-coordinate of the vertex.

Definition at line 57 of file VertexList.cc.

57  {
58  std::pair<int, int> vertex(x, y);
59  vertices_.push_back(vertex);
60 }

References vertices_.

Referenced by EPSDC::DoDrawPolygon().

◆ clear()

void VertexList::clear ( )

Removes all vertices from the list.

Definition at line 118 of file VertexList.cc.

118  {
119  vertices_.clear();
120 }

References vertices_.

◆ operator=()

VertexList& VertexList::operator= ( const VertexList )
private

Assignment forbidden.

◆ size()

size_t VertexList::size ( ) const

Returns vertex count.

Returns
Number of vertices in the list.

Definition at line 68 of file VertexList.cc.

68  {
69  return vertices_.size();
70 }

References vertices_.

Referenced by EPSGenerator::drawFilledPolygon(), EPSGenerator::drawPolygon(), EPSGenerator::drawPolygonPath(), vertexX(), and vertexY().

◆ vertexX()

int VertexList::vertexX ( size_t  index) const

Returns x-coordinate of a vertex with given index.

Parameters
indexIndex of the vertex.
Returns
X-coordinate of the vertex.
Exceptions
OutOfRangeIf the index is out of range.

Definition at line 80 of file VertexList.cc.

80  {
81  if (index > size()) {
82  std::string error = "Vertex index out of range";
83  std::string proc = "VertexList::vertexX";
84  OutOfRange e(__FILE__, __LINE__, proc, error);
85  throw e;
86  }
87 
88  int x = vertices_[index].first;
89 
90  return x;
91 }

References size(), and vertices_.

Referenced by EPSGenerator::drawPolygonPath().

Here is the call graph for this function:

◆ vertexY()

int VertexList::vertexY ( size_t  index) const

Returns y-coordinate of a vertex with given index.

Parameters
indexIndex of the vertex.
Returns
Y-coordinate of the vertex.
Exceptions
OutOfRangeIf the index is out of range.

Definition at line 101 of file VertexList.cc.

101  {
102  if (index > size()) {
103  std::string error = "Vertex index out of range";
104  std::string proc = "VertexList::vertexY";
105  OutOfRange e(__FILE__, __LINE__, proc, error);
106  throw e;
107  }
108 
109  int y = vertices_[index].second;
110 
111  return y;
112 }

References size(), and vertices_.

Referenced by EPSGenerator::drawPolygonPath().

Here is the call graph for this function:

Member Data Documentation

◆ vertices_

std::vector<std::pair<int, int> > VertexList::vertices_
private

Vector containing vertices in the list.

Definition at line 59 of file VertexList.hh.

Referenced by addVertex(), clear(), size(), vertexX(), and vertexY().


The documentation for this class was generated from the following files:
OutOfRange
Definition: Exception.hh:320
VertexList::vertices_
std::vector< std::pair< int, int > > vertices_
Vector containing vertices in the list.
Definition: VertexList.hh:59
VertexList::size
size_t size() const
Definition: VertexList.cc:68