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