50 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
53 int nNextProfile = -1;
62 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
64 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize - 1; nCoastPoint++)
66 if (!
m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
83 bool bNextProfileIsOK =
false;
103 if (! bNextProfileIsOK)
110 pNextProfile = pNextNextProfile;
113 }
while (! bNextProfileIsOK);
121 int nDist = (nNextProfileCoastPoint - nCoastPoint) / 2;
124 int nNodePoint = nCoastPoint + nDist;
125 m_VCoast[nCoast].SetPolygonNode(nNodePoint, ++nNode);
138 bool bMeetsAtAPoint =
false;
157 bMeetsAtAPoint =
true;
158 int nTmpThisProfileEnd;
159 int nTmpNextProfileEnd;
164 if (nTmpThisProfileEnd == -1)
166 LogStream <<
m_ulIter <<
": " <<
ERR <<
"profile " << nNextProfile <<
" should be coincident with profile " << nThisProfile <<
" but was not found" << endl;
171 nThisProfileEnd =
tMin(nThisProfileEnd, nTmpThisProfileEnd);
172 nNextProfileEnd =
tMin(nNextProfileEnd, nTmpNextProfileEnd);
178 vector<CGeom2DPoint> PtVBoundary;
181 for (
int i = nThisProfileEnd; i >= 0; i--)
184 PtVBoundary.push_back(PtThis);
188 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
191 PtVBoundary.push_back(PtThis);
195 for (
int i = 0; i <= nNextProfileEnd; i++)
198 PtVBoundary.push_back(PtThis);
203 PtVBoundary.push_back(PtThis);
218 bool bStartCoast =
false;
219 bool bEndCoast =
false;
228 CGeomCoastPolygon* pPolygon =
m_VCoast[nCoast].pPolyCreatePolygon(nThisProfile, nPolygon, nNodePoint, &PtiNode, &PtiAntiNode, nThisProfile, nNextProfile, &PtVBoundary, nThisProfileEnd + 1, nNextProfileEnd + 1, bStartCoast, bEndCoast);
238 if (! bMeetsAtAPoint)
249 assert(nPolygon <
m_VCoast[nCoast].nGetNumPolygons());
252 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
261 for (
int i = 0; i < nCellsInProfile; i++)
270 for (
int i = 0; i < nCellsInProfile; i++)
277 if (! bMeetsAtAPoint)
289 nNextProfile = nThisProfile;
290 nCoastPoint = nNextProfileCoastPoint - 1;
309 int nXStart = pPt1->
nGetX();
310 int nYStart = pPt1->
nGetY();
313 int nXEnd = pPt2->
nGetX();
314 int nYEnd = pPt2->
nGetY();
317 if ((nXStart == nXEnd) && (nYStart == nYEnd))
321 double dXInc = nXEnd - nXStart;
322 double dYInc = nYEnd - nYStart;
332 for (
int m = 0; m <=
nRound(dLength); m++)
342 assert(nPoly <
m_VCoast[0].nGetNumPolygons());
345 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPoly);
421 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
424 int nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
426 for (
int nPoly = 0; nPoly < nPolygons; nPoly++)
428 int nCellsInPolygon = 0;
429 double dTotDepth = 0;
430 double dStoredUnconsFine = 0;
431 double dStoredUnconsSand = 0;
432 double dStoredUnconsCoarse = 0;
433 double dStoredConsFine = 0;
434 double dStoredConsSand = 0;
435 double dStoredConsCoarse = 0;
436 double dSedimentInputFine = 0;
437 double dSedimentInputSand = 0;
438 double dSedimentInputCoarse = 0;
446 stack<CGeom2DIPoint> PtiStack;
501 PtiStack.push(PtiStart);
506 while (! PtiStack.empty())
511 int nX = Pti.
nGetX();
512 int nY = Pti.
nGetY();
519 bool bSpanAbove =
false;
520 bool bSpanBelow =
false;
527 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPolyID);
539 int nThisLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
545 dStoredUnconsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineDepth();
546 dStoredUnconsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandDepth();
547 dStoredUnconsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseDepth();
549 dStoredConsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetFineDepth();
550 dStoredConsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetSandDepth();
551 dStoredConsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetCoarseDepth();
557 dSedimentInputFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineSedimentInputDepth();
558 dSedimentInputSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandSedimentInputDepth();
559 dSedimentInputCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseSedimentInputDepth();
671 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
673 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
694 for (
int nn = 0; nn < nNumPolygons; nn++)
699 vector<int> nVUpCoastAdjacentPolygon;
700 vector<int> nVDownCoastAdjacentPolygon;
702 vector<double> dVUpCoastBoundaryShare;
703 vector<double> dVDownCoastBoundaryShare;
709 nVDownCoastAdjacentPolygon.push_back(
INT_NODATA);
710 dVDownCoastBoundaryShare.push_back(1);
723 double dDownCoastTotBoundaryLen = 0;
727 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
742 int nNumValidCoinc = 0;
744 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
759 int nAdj = nThisPolygon + nNumValidCoinc;
762 if (nAdj >= nNumPolygons)
770 nVDownCoastAdjacentPolygon.push_back(nAdj);
772 dDownCoastTotBoundaryLen += dDistBetween;
773 dVDownCoastBoundaryShare.push_back(dDistBetween);
777 for (
unsigned int n = 0; n < dVDownCoastBoundaryShare.size(); n++)
782 nVDownCoastAdjacentPolygon.pop_back();
783 dVDownCoastBoundaryShare.pop_back();
787 dVDownCoastBoundaryShare[n] /= dDownCoastTotBoundaryLen;
799 nVUpCoastAdjacentPolygon.push_back(
INT_NODATA);
800 dVUpCoastBoundaryShare.push_back(1);
813 double dUpCoastTotBoundaryLen = 0;
817 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
823 if (PtStart == PtEnd)
837 int nNumValidCoinc = 0;
839 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
854 int nAdj = nThisPolygon - nNumValidCoinc;
865 nVUpCoastAdjacentPolygon.push_back(nAdj);
867 dUpCoastTotBoundaryLen += dDistBetween;
868 dVUpCoastBoundaryShare.push_back(dDistBetween);
872 for (
unsigned int n = 0; n < dVUpCoastBoundaryShare.size(); n++)
877 nVUpCoastAdjacentPolygon.pop_back();
878 dVUpCoastBoundaryShare.pop_back();
882 dVUpCoastBoundaryShare[n] /= dUpCoastTotBoundaryLen;
894 pThisPolygon->
SetLength(dPolygonSeawardLen);
987 bool bOddNodes =
false;
989 int nPolyCorners =
static_cast<int>(pPtPoints->size());
990 int j = nPolyCorners - 1;
992 double dX = pPtStart->
dGetX();
993 double dY = pPtStart->
dGetY();
995 for (
int i = 0; i < nPolyCorners; i++)
997 double dCorneriX = pPtPoints->at(i).dGetX();
998 double dCorneriY = pPtPoints->at(i).dGetY();
999 double dCornerjX = pPtPoints->at(j).dGetX();
1000 double dCornerjY = pPtPoints->at(j).dGetY();
1002 if ((dCorneriY < dY && dCornerjY >= dY) || (dCornerjY < dY && dCorneriY >= dY))
1004 if (dCorneriX + (dY - dCorneriY) / (dCornerjY - dCorneriY) * (dCornerjX - dCorneriX) < dX)
1006 bOddNodes = ! bOddNodes;
1021 int nPolySize =
static_cast<int>(pPtPoints->size());
1028 vector <CGeom2DPoint> nVTestPoints;
1030 for (
int n = 0; n < 3; n++)
1032 int nIndex = n + nStartPoint + nOffSet;
1034 if (nIndex > nPolySize - 1)
1035 nIndex -= nPolySize;
1041 nVTestPoints.push_back(pPtPoints->at(nIndex));
1048 if (nOffSet >= (nPolySize + 3))
1052 PtStart =
PtAverage(&nVTestPoints[0], &nVTestPoints[2]);
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.
double dGetY(void) const
Returns the CGeom2DPoint object's double Y coordinate.
double dGetX(void) const
Returns the CGeom2DPoint object's double X coordinate.
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 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.
int nGetCoastID(void) const
Get the coast ID, this is the same as the down-coast sequence of polygons.
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 nGetCoastPoint(void) const
Returns the coast point at which the profile starts.
CGeomProfile * pGetDownCoastAdjacentProfile(void) const
CGeom2DIPoint * pPtiGetCellInProfile(int const)
Returns a single cell 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 or an end-of-coast profil...
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 in 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 nGetCoastID(void) const
Returns the profile's coast ID.
int nGetProfileSize(void) const
Returns the number of points in the profile.
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.
vector< CGeomCoastPolygon * > m_pVCoastPolygon
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
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,...
static CGeom2DPoint PtFindPointInPolygon(vector< CGeom2DPoint > const *, int const)
Finds a point in a polygon: is guaranteed to succeed, as every strictly closed polygon has at least o...
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)
int m_nNumPolygonGlobal
Number of global (all coasts) polygons.
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,...
static bool bIsWithinPolygon(CGeom2DPoint const *, vector< CGeom2DPoint > const *)
Determines whether a point is within a polygon: however if the point is exactly on the edge of the po...
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)
Version of the above that returns an int.