CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
2di_shape.cpp
Go to the documentation of this file.
1
12
13/*===============================================================================================================================
14
15This file is part of CoastalME, the Coastal Modelling Environment.
16
17CoastalME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
18
19This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23===============================================================================================================================*/
24#include <vector>
25
26#include "2di_shape.h"
27
32
37
40{
41 // TODO 055 Maybe add a safety check?
42 return m_VPoints[n];
43}
44
47{
48 return m_VPoints.back();
49}
50
52vector<CGeom2DIPoint>* CA2DIShape::pPtiVGetPoints(void)
53{
54 return &m_VPoints;
55}
56
59{
60 m_VPoints.clear();
61}
62
64void CA2DIShape::Resize(const int nSize)
65{
66 m_VPoints.resize(nSize);
67}
68
70int CA2DIShape::nGetSize(void) const
71{
72 return static_cast<int>(m_VPoints.size());
73}
74
75// void CA2DIShape::InsertAtFront(int const nX, int const nY)
76// {
77// m_VPoints.insert(m_VPoints.begin(), CGeom2DIPoint(nX, nY));
78// }
79
82{
83 m_VPoints.push_back(*pPtiNew);
84}
85
87void CA2DIShape::Append(int const nX, int const nY)
88{
89 m_VPoints.push_back(CGeom2DIPoint(nX, nY));
90}
91
93void CA2DIShape::AppendIfNotAlready(int const nX, int const nY)
94{
95 CGeom2DIPoint PtiIn(nX, nY);
96
97 if (m_VPoints.empty())
98 m_VPoints.push_back(PtiIn);
99
100 else if (m_VPoints.back() != &PtiIn)
101 m_VPoints.push_back(PtiIn);
102}
103
104// void CA2DIShape::SetPoints(const vector<CGeom2DIPoint>* VNewPoints)
105// {
106// m_VPoints = *VNewPoints;
107// }
108
109// int CA2DIShape::nLookUp(CGeom2DIPoint* Pti)
110// {
111// auto it = find(m_VPoints.begin(), m_VPoints.end(), *Pti);
112// if (it != m_VPoints.end())
113// return it - m_VPoints.begin();
114// else
115// return -1;
116// }
Contains CA2DIShape definitions.
int nGetSize(void) const
Returns the number of integer point in the vector which represents this 2D shape.
Definition 2di_shape.cpp:70
vector< CGeom2DIPoint > m_VPoints
The integer points which comprise the integer-coordinate 2D shape.
Definition 2di_shape.h:39
virtual ~CA2DIShape(void)
Destructor.
Definition 2di_shape.cpp:34
void Resize(const int)
Resizes the vector which represents this 2D shape.
Definition 2di_shape.cpp:64
CGeom2DIPoint & Back(void)
Returns the last integer point from the vector which represents this 2D shape.
Definition 2di_shape.cpp:46
void Clear(void)
Clears the vector which represents this 2D shape.
Definition 2di_shape.cpp:58
CA2DIShape(void)
Constructor, no parameters.
Definition 2di_shape.cpp:29
void AppendIfNotAlready(int const, int const)
Appends a new integer point to the vector which represents this 2D shape, but only if the point is no...
Definition 2di_shape.cpp:93
void Append(CGeom2DIPoint const *)
Appends a new integer point to the vector which represents this 2D shape.
Definition 2di_shape.cpp:81
CGeom2DIPoint & operator[](int const)
Returns one integer point from the vector which represents this 2D shape.
Definition 2di_shape.cpp:39
vector< CGeom2DIPoint > * pPtiVGetPoints(void)
Returns the address of the vector which represents this 2D shape.
Definition 2di_shape.cpp:52
Geometry class used to represent 2D point objects with integer coordinates.
Definition 2di_point.h:29