42 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
45 int nNextProfile = -1;
49 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
51 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize - 1; nCoastPoint++)
53 if (!
m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
70 bool bNextProfileIsOK =
false;
90 if (! bNextProfileIsOK)
97 pNextProfile = pNextNextProfile;
100 }
while (! bNextProfileIsOK);
105 int const nNextProfileCoastPoint = pNextProfile->
nGetCoastPoint();
108 int const nDist = (nNextProfileCoastPoint - nCoastPoint) / 2;
111 int const nNodePoint = nCoastPoint + nDist;
112 m_VCoast[nCoast].SetPolygonNode(nNodePoint, ++nNode);
120 bool bMeetsAtAPoint =
false;
139 bMeetsAtAPoint =
true;
140 int nTmpThisProfileEnd;
141 int nTmpNextProfileEnd;
146 if (nTmpThisProfileEnd == -1)
148 LogStream <<
m_ulIter <<
": " <<
ERR <<
"profile " << nNextProfile <<
" should be coincident with profile " << nThisProfile <<
" but was not found" << endl;
153 nThisProfileEnd =
tMin(nThisProfileEnd, nTmpThisProfileEnd);
154 nNextProfileEnd =
tMin(nNextProfileEnd, nTmpNextProfileEnd);
160 vector<CGeom2DPoint> PtVBoundary;
163 for (
int i = nThisProfileEnd; i >= 0; i--)
166 PtVBoundary.push_back(PtThis);
170 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
173 PtVBoundary.push_back(PtThis);
177 for (
int i = 0; i <= nNextProfileEnd; i++)
180 PtVBoundary.push_back(PtThis);
185 PtVBoundary.push_back(PtThis);
199 bool bStartCoast =
false;
200 bool bEndCoast =
false;
209 CGeomCoastPolygon* pPolygon =
m_VCoast[nCoast].pPolyCreateAndAppendPolygon(nPolygon, nNodePoint, &PtiNode, &PtiAntiNode, nThisProfile, nNextProfile, &PtVBoundary, nThisProfileEnd + 1, nNextProfileEnd + 1, bStartCoast, bEndCoast);
216 if (! bMeetsAtAPoint)
229 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
238 for (
int i = 0; i < nCellsInProfile; i++)
247 for (
int i = 0; i < nCellsInProfile; i++)
254 if (! bMeetsAtAPoint)
267 nCoastPoint = nNextProfileCoastPoint - 1;
284 int const nXStart = pPt1->
nGetX();
285 int const nYStart = pPt1->
nGetY();
288 int const nXEnd = pPt2->
nGetX();
289 int const nYEnd = pPt2->
nGetY();
292 if ((nXStart == nXEnd) && (nYStart == nYEnd))
296 double dXInc = nXEnd - nXStart;
297 double dYInc = nYEnd - nYStart;
307 for (
int m = 0; m <=
nRound(dLength); m++)
319 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPoly);
395 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
398 int const nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
400 for (
int nPoly = 0; nPoly < nPolygons; nPoly++)
402 int nCellsInPolygon = 0;
403 double dTotDepth = 0;
404 double dStoredUnconsFine = 0;
405 double dStoredUnconsSand = 0;
406 double dStoredUnconsCoarse = 0;
407 double dStoredConsFine = 0;
408 double dStoredConsSand = 0;
409 double dStoredConsCoarse = 0;
410 double dSedimentInputFine = 0;
411 double dSedimentInputSand = 0;
412 double dSedimentInputCoarse = 0;
420 stack<CGeom2DIPoint> PtiStack;
475 PtiStack.push(PtiStart);
480 while (! PtiStack.empty())
485 int nX = Pti.
nGetX();
486 int const nY = Pti.
nGetY();
493 bool bSpanAbove =
false;
494 bool bSpanBelow =
false;
501 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPolyID);
513 int const nThisLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
519 dStoredUnconsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineDepth();
520 dStoredUnconsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandDepth();
521 dStoredUnconsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseDepth();
523 dStoredConsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetFineDepth();
524 dStoredConsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetSandDepth();
525 dStoredConsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetCoarseDepth();
531 dSedimentInputFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineSedimentInputDepth();
532 dSedimentInputSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandSedimentInputDepth();
533 dSedimentInputCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseSedimentInputDepth();
645 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
647 int const nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
668 for (
int nn = 0; nn < nNumPolygons; nn++)
673 vector<int> nVUpCoastAdjacentPolygon;
674 vector<int> nVDownCoastAdjacentPolygon;
676 vector<double> dVUpCoastBoundaryShare;
677 vector<double> dVDownCoastBoundaryShare;
683 nVDownCoastAdjacentPolygon.push_back(
INT_NODATA);
684 dVDownCoastBoundaryShare.push_back(1);
696 double dDownCoastTotBoundaryLen = 0;
700 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
715 int nNumValidCoinc = 0;
717 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
732 int nAdj = nThisPolygon + nNumValidCoinc;
735 if (nAdj >= nNumPolygons)
743 nVDownCoastAdjacentPolygon.push_back(nAdj);
745 dDownCoastTotBoundaryLen += dDistBetween;
746 dVDownCoastBoundaryShare.push_back(dDistBetween);
750 for (
unsigned int n = 0; n < dVDownCoastBoundaryShare.size(); n++)
755 nVDownCoastAdjacentPolygon.pop_back();
756 dVDownCoastBoundaryShare.pop_back();
760 dVDownCoastBoundaryShare[n] /= dDownCoastTotBoundaryLen;
772 nVUpCoastAdjacentPolygon.push_back(
INT_NODATA);
773 dVUpCoastBoundaryShare.push_back(1);
786 double dUpCoastTotBoundaryLen = 0;
790 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
796 if (PtStart == PtEnd)
810 int nNumValidCoinc = 0;
812 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
827 int nAdj = nThisPolygon - nNumValidCoinc;
838 nVUpCoastAdjacentPolygon.push_back(nAdj);
840 dUpCoastTotBoundaryLen += dDistBetween;
841 dVUpCoastBoundaryShare.push_back(dDistBetween);
845 for (
unsigned int n = 0; n < dVUpCoastBoundaryShare.size(); n++)
850 nVUpCoastAdjacentPolygon.pop_back();
851 dVUpCoastBoundaryShare.pop_back();
855 dVUpCoastBoundaryShare[n] /= dUpCoastTotBoundaryLen;
867 pThisPolygon->
SetLength(dPolygonSeawardLen);
Contains CGeom2DPoint definitions.
Contains CGeom2DIPoint definitions.
Geometry class used to represent 2D point objects with integer coordinates.
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Geometry class used to represent 2D point objects with floating-point coordinates.
Geometry class used for coast polygon objects.
bool bIsCoastStartPolygon(void) const
Is this polygon the coast-start polygon?
int nGetNumPointsUsedDownCoastProfile(void) const
Return the number of points in the down-coast profile.
CGeom2DIPoint * pPtiGetAntiNode(void)
Get the anti-node (raster grid CRS) which is at other (seaward) end of the polygon from the node.
bool bIsCoastEndPolygon(void) const
Is this polygon the coast-end polygon?
void SetSedimentInputUnconsSand(double const)
Set the value of sand sediment on the polygon derived from sediment input events(s)
void SetPreExistingUnconsFine(double const)
Set the value of pre-existing unconsolidated fine sediment stored on this polygon.
void SetSedimentInputUnconsFine(double const)
Set the value of fine sediment on the polygon derived from sediment input events(s)
void SetPreExistingConsFine(double const)
Set the value of pre-existing consolidated fine sediment stored on this polygon.
void SetPreExistingUnconsSand(double const)
Set the value of pre-existing unconsolidated sand sediment stored on this polygon.
void SetSeawaterVolume(const double)
Set the volume of seawater in the coast polygon.
bool bUpCoastIsAlreadyPresent(int const)
Searches the list of up-coast adjacent polygons for a given polygon number.
int nGetNumPointsUsedUpCoastProfile(void) const
Return the number of points in the up-coast profile.
CGeom2DIPoint PtiGetFillStartPoint(void)
void SetSedimentInputUnconsCoarse(double const)
Set the value of coarse sediment on the polygon derived from sediment input events(s)
void SetDownCoastAdjacentPolygonBoundaryShares(vector< double > const *)
Sets the boundary shares for all down-coast adjacent polygons.
int nGetPolygonCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence of polygons.
int nGetUpCoastProfile(void) const
Return the number of the up-coast profile.
void SetLength(double const)
Sets the polygon's length.
void SetPreExistingConsCoarse(double const)
Set the value of pre-existing consolidated coarse sediment stored on this polygon.
void SetPreExistingUnconsCoarse(double const)
Set the value of pre-existing unconsolidated coarse sediment stored on this polygon.
void AppendVertex(CGeom2DIPoint const *)
Appends the point cordinates (grid CRS) for a polygon vertex.
void SetDownCoastAdjacentPolygons(vector< int > const *)
Sets all down-coast adjacent polygons.
void SetUpCoastAdjacentPolygonBoundaryShares(vector< double > const *)
Sets the boundary shares for all up-coast adjacent polygons.
void SetUpCoastAdjacentPolygons(vector< int > const *)
Sets all up-coast adjacent polygons.
void SetPreExistingConsSand(double const)
Set the value of pre-existing consolidated sand sediment stored on this polygon.
int nGetDownCoastProfile(void) const
Return the number of the down-coast profile.
bool bDownCoastIsAlreadyPresent(int const)
Searches the list of down-coast adjacent polygons for a given polygon number.
void SetNumCellsInPolygon(int const)
Set the number of cells in the polygon.
CGeom2DIPoint * pPtiGetNode(void)
Get the grid coordinates of the cell on which the node sits.
int nGetNumCoincidentProfilesInLineSegment(int const)
Returns the count of coincident profiles in a specified line segment, or -1 if the line segment does ...
bool bFindProfileInCoincidentProfiles(int const)
Returns true if the given profile number is one of the coincident profiles of the a specified line se...
int nGetCoincidentProfileForLineSegment(int const, int const) const
Returns the numbers of coincident profiles.
void GetMostCoastwardSharedLineSegment(int const, int &, int &)
Finds the number of the most coastward line segment for which the two profiles are coincident,...
Geometry class used to represent coast profile objects.
int nGetProfileID(void) const
Returns the profile's this-coast ID.
int nGetCoastPoint(void) const
Returns the coast point at which the profile starts.
CGeomProfile * pGetDownCoastAdjacentProfile(void) const
Returns the down-coast adjacent profile, returns NULL if there is no down-coast adjacent profile.
CGeom2DIPoint * pPtiGetCellInProfile(int const)
Returns a single cell (grid CRS) in the profile.
int nGetNumCellsInProfile(void) const
Returns the number of cells in the profile.
bool bProfileOK(void) const
Returns true if this is a problem-free profile, and is not a start-of-coast and is not an end-of-coas...
CGeom2DIPoint * pPtiGetEndPoint(void)
Returns a pointer to the location of the cell (grid CRS) on which the profile ends.
CGeom2DPoint * pPtGetPointInProfile(int const)
Returns a single point (external CRS) from the profile.
bool bOKIncStartAndEndOfCoast(void) const
Returns true if this is a problem-free profile (however it could be a start-of-coast or an end-of-coa...
int nGetProfileSize(void) const
Returns the number of external CRS points in the profile (only two, initally; and always just two for...
CGeom2DIPoint * pPtiGetStartPoint(void)
Returns a pointer to the location of the cell (grid CRS) on which the profile starts.
bool bStartOfCoast(void) const
Returns the switch to indicate whether this is a start-of-coast profile.
bool bEndOfCoast(void) const
Returns the switch to indicate whether this is an end-of-coast profile.
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
int m_nXGridSize
The size of the grid in the x direction.
CGeom2DIPoint PtiExtCRSToGridRound(CGeom2DPoint const *) const
Transforms a pointer to a CGeom2DPoint in the external CRS to the equivalent CGeom2DIPoint in the ras...
vector< CRWCoast > m_VCoast
The coastline objects.
int m_nYGridSize
The size of the grid in the y direction.
static double dGetDistanceBetween(CGeom2DPoint const *, CGeom2DPoint const *)
Returns the distance (in external CRS) between two points.
static CGeom2DPoint PtAverage(CGeom2DPoint const *, CGeom2DPoint const *)
Returns a point (external CRS) which is the average of (i.e. is midway between) two other external CR...
double m_dStartIterSuspFineInPolygons
Depth (m) of fine suspended sediment at the start of the simulation (only cells in polygons)
void KeepWithinValidGrid(int &, int &) const
Constrains the supplied point (in the grid CRS) to be a valid cell within the raster grid.
int nCreateAllPolygons(void)
Create polygons, and mark the polygon boundaries on the raster grid.
void RasterizePolygonJoiningLine(int const, CGeom2DIPoint const *, CGeom2DIPoint const *, int const)
Puts a polygon 'joining line' (the line which is the seaward boundary of the polygon,...
void MarkPolygonCells(void)
Marks cells of the raster grid that are within each coastal polygon. The cell-by-cell fill (aka 'floo...
bool bIsWithinValidGrid(int const, int const) const
Checks whether the supplied point (an x-y pair, in the grid CRS) is within the raster grid,...
unsigned long m_ulIter
The number of the current iteration (time step)
double m_dCellSide
Length of a cell side (in external CRS units)
int nDoPolygonSharedBoundaries(void)
For between-polygon potential sediment routing: find which are the adjacent polygons,...
This file contains global definitions for CoastalME.
int const NO_NONZERO_THICKNESS_LAYERS
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
int const RTN_ERR_BAD_MULTILINE
Contains CRWCoast definitions.
Contains CSimulation definitions.
int nRound(double const d)
Correctly rounds doubles, returns an int.