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
10
11/* ===============================================================================================================================
12 This file is part of CoastalME, the Coastal Modelling Environment.
13
14 CoastalME 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.
15
16 This 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.
17
18 You 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.
19===============================================================================================================================*/
20#include "2di_point.h"
21#include "2di_shape.h"
22
27
32
35{
36 // TODO 055 Maybe add a safety check?
37 return m_VPoints[n];
38}
39
42{
43 return m_VPoints.back();
44}
45
47vector<CGeom2DIPoint>* CA2DIShape::pPtiVGetPoints(void)
48{
49 return &m_VPoints;
50}
51
54{
55 m_VPoints.clear();
56}
57
59void CA2DIShape::Resize(const int nSize)
60{
61 m_VPoints.resize(nSize);
62}
63
65int CA2DIShape::nGetSize(void) const
66{
67 return static_cast<int>(m_VPoints.size());
68}
69
70// void CA2DIShape::InsertAtFront(int const nX, int const nY)
71// {
72// m_VPoints.insert(m_VPoints.begin(), CGeom2DIPoint(nX, nY));
73// }
74
77{
78 m_VPoints.push_back(*pPtiNew);
79}
80
82void CA2DIShape::Append(int const nX, int const nY)
83{
84 m_VPoints.push_back(CGeom2DIPoint(nX, nY));
85}
86
88void CA2DIShape::AppendIfNotPrevious(int const nX, int const nY)
89{
90 CGeom2DIPoint const PtiIn(nX, nY);
91
92 if (m_VPoints.empty())
93 m_VPoints.push_back(PtiIn);
94
95 else if (m_VPoints.back() != &PtiIn)
96 m_VPoints.push_back(PtiIn);
97}
98
101{
102 if (m_VPoints.empty())
103 m_VPoints.push_back(*pPtiIn);
104
105 else if (m_VPoints.back() != pPtiIn)
106 m_VPoints.push_back(*pPtiIn);
107}
108
109// void CA2DIShape::SetPoints(const vector<CGeom2DIPoint>* VNewPoints)
110// {
111// m_VPoints = *VNewPoints;
112// }
113
114// int CA2DIShape::nLookUp(CGeom2DIPoint* Pti)
115// {
116// auto it = find(m_VPoints.begin(), m_VPoints.end(), *Pti);
117// if (it != m_VPoints.end())
118// return it - m_VPoints.begin();
119// else
120// return -1;
121// }
Contains CGeom2DIPoint definitions.
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:65
void AppendIfNotPrevious(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:88
vector< CGeom2DIPoint > m_VPoints
The integer points which comprise the integer-coordinate 2D shape.
Definition 2di_shape.h:34
virtual ~CA2DIShape(void)
Destructor.
Definition 2di_shape.cpp:29
void Resize(const int)
Resizes the vector which represents this 2D shape.
Definition 2di_shape.cpp:59
CGeom2DIPoint & Back(void)
Returns the last integer point from the vector which represents this 2D shape.
Definition 2di_shape.cpp:41
void Clear(void)
Clears the vector which represents this 2D shape.
Definition 2di_shape.cpp:53
CA2DIShape(void)
Constructor, no parameters.
Definition 2di_shape.cpp:24
void Append(CGeom2DIPoint const *)
Appends a new integer point to the vector which represents this 2D shape.
Definition 2di_shape.cpp:76
CGeom2DIPoint & operator[](int const)
Returns one integer point from the vector which represents this 2D shape.
Definition 2di_shape.cpp:34
vector< CGeom2DIPoint > * pPtiVGetPoints(void)
Returns the address of the vector which represents this 2D shape.
Definition 2di_shape.cpp:47
Geometry class used to represent 2D point objects with integer coordinates.
Definition 2di_point.h:25