53 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
56 int nNextProfile = -1;
65 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
67 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize - 1; nCoastPoint++)
69 if (!
m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
78 int const nThisProfile = pThisProfile->
nGetCoastID();
86 bool bNextProfileIsOK =
false;
106 if (!bNextProfileIsOK)
113 pNextProfile = pNextNextProfile;
116 }
while (!bNextProfileIsOK);
121 int const nNextProfileCoastPoint = pNextProfile->
nGetCoastPoint();
124 int const nDist = (nNextProfileCoastPoint - nCoastPoint) / 2;
127 int const nNodePoint = nCoastPoint + nDist;
128 m_VCoast[nCoast].SetPolygonNode(nNodePoint, ++nNode);
141 bool bMeetsAtAPoint =
false;
160 bMeetsAtAPoint =
true;
161 int nTmpThisProfileEnd;
162 int nTmpNextProfileEnd;
167 if (nTmpThisProfileEnd == -1)
169 LogStream <<
m_ulIter <<
": " <<
ERR <<
"profile " << nNextProfile <<
" should be coincident with profile " << nThisProfile <<
" but was not found" << endl;
174 nThisProfileEnd =
tMin(nThisProfileEnd, nTmpThisProfileEnd);
175 nNextProfileEnd =
tMin(nNextProfileEnd, nTmpNextProfileEnd);
181 vector<CGeom2DPoint> PtVBoundary;
184 for (
int i = nThisProfileEnd; i >= 0; i--)
187 PtVBoundary.push_back(PtThis);
191 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
194 PtVBoundary.push_back(PtThis);
198 for (
int i = 0; i <= nNextProfileEnd; i++)
201 PtVBoundary.push_back(PtThis);
206 PtVBoundary.push_back(PtThis);
221 bool bStartCoast =
false;
222 bool bEndCoast =
false;
231 CGeomCoastPolygon* pPolygon =
m_VCoast[nCoast].pPolyCreatePolygon(nThisProfile, nPolygon, nNodePoint, &PtiNode, &PtiAntiNode, nThisProfile, nNextProfile, &PtVBoundary, nThisProfileEnd + 1, nNextProfileEnd + 1, bStartCoast, bEndCoast);
252 assert(nPolygon <
m_VCoast[nCoast].nGetNumPolygons());
255 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
264 for (
int i = 0; i < nCellsInProfile; i++)
273 for (
int i = 0; i < nCellsInProfile; i++)
293 nCoastPoint = nNextProfileCoastPoint - 1;
312 int const nXStart = pPt1->
nGetX();
313 int const nYStart = pPt1->
nGetY();
316 int const nXEnd = pPt2->
nGetX();
317 int const nYEnd = pPt2->
nGetY();
320 if ((nXStart == nXEnd) && (nYStart == nYEnd))
324 double dXInc = nXEnd - nXStart;
325 double dYInc = nYEnd - nYStart;
335 for (
int m = 0; m <=
nRound(dLength); m++)
345 assert(nPoly <
m_VCoast[0].nGetNumPolygons());
348 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPoly);
424 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
427 int const nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
429 for (
int nPoly = 0; nPoly < nPolygons; nPoly++)
431 int nCellsInPolygon = 0;
432 double dTotDepth = 0;
433 double dStoredUnconsFine = 0;
434 double dStoredUnconsSand = 0;
435 double dStoredUnconsCoarse = 0;
436 double dStoredConsFine = 0;
437 double dStoredConsSand = 0;
438 double dStoredConsCoarse = 0;
439 double dSedimentInputFine = 0;
440 double dSedimentInputSand = 0;
441 double dSedimentInputCoarse = 0;
449 stack<CGeom2DIPoint> PtiStack;
504 PtiStack.push(PtiStart);
509 while (!PtiStack.empty())
514 int nX = Pti.
nGetX();
515 int const nY = Pti.
nGetY();
522 bool bSpanAbove =
false;
523 bool bSpanBelow =
false;
530 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPolyID);
542 int const nThisLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
548 dStoredUnconsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineDepth();
549 dStoredUnconsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandDepth();
550 dStoredUnconsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseDepth();
552 dStoredConsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetFineDepth();
553 dStoredConsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetSandDepth();
554 dStoredConsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetCoarseDepth();
560 dSedimentInputFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineSedimentInputDepth();
561 dSedimentInputSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandSedimentInputDepth();
562 dSedimentInputCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseSedimentInputDepth();
674 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
676 int const nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
697 for (
int nn = 0; nn < nNumPolygons; nn++)
700 int const nThisPolygon = pThisPolygon->
nGetCoastID();
702 vector<int> nVUpCoastAdjacentPolygon;
703 vector<int> nVDownCoastAdjacentPolygon;
705 vector<double> dVUpCoastBoundaryShare;
706 vector<double> dVDownCoastBoundaryShare;
712 nVDownCoastAdjacentPolygon.push_back(
INT_NODATA);
713 dVDownCoastBoundaryShare.push_back(1);
726 double dDownCoastTotBoundaryLen = 0;
730 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
745 int nNumValidCoinc = 0;
747 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
762 int nAdj = nThisPolygon + nNumValidCoinc;
765 if (nAdj >= nNumPolygons)
773 nVDownCoastAdjacentPolygon.push_back(nAdj);
775 dDownCoastTotBoundaryLen += dDistBetween;
776 dVDownCoastBoundaryShare.push_back(dDistBetween);
780 for (
unsigned int n = 0; n < dVDownCoastBoundaryShare.size(); n++)
785 nVDownCoastAdjacentPolygon.pop_back();
786 dVDownCoastBoundaryShare.pop_back();
790 dVDownCoastBoundaryShare[n] /= dDownCoastTotBoundaryLen;
802 nVUpCoastAdjacentPolygon.push_back(
INT_NODATA);
803 dVUpCoastBoundaryShare.push_back(1);
816 double dUpCoastTotBoundaryLen = 0;
820 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
826 if (PtStart == PtEnd)
840 int nNumValidCoinc = 0;
842 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
857 int nAdj = nThisPolygon - nNumValidCoinc;
868 nVUpCoastAdjacentPolygon.push_back(nAdj);
870 dUpCoastTotBoundaryLen += dDistBetween;
871 dVUpCoastBoundaryShare.push_back(dDistBetween);
875 for (
unsigned int n = 0; n < dVUpCoastBoundaryShare.size(); n++)
880 nVUpCoastAdjacentPolygon.pop_back();
881 dVUpCoastBoundaryShare.pop_back();
885 dVUpCoastBoundaryShare[n] /= dUpCoastTotBoundaryLen;
897 pThisPolygon->
SetLength(dPolygonSeawardLen);
990 bool bOddNodes =
false;
992 int const nPolyCorners =
static_cast<int>(pPtPoints->size());
993 int j = nPolyCorners - 1;
995 double const dX = pPtStart->
dGetX();
996 double const dY = pPtStart->
dGetY();
998 for (
int i = 0; i < nPolyCorners; i++)
1000 double const dCorneriX = pPtPoints->at(i).dGetX();
1001 double const dCorneriY = pPtPoints->at(i).dGetY();
1002 double const dCornerjX = pPtPoints->at(j).dGetX();
1003 double const dCornerjY = pPtPoints->at(j).dGetY();
1005 if ((dCorneriY < dY && dCornerjY >= dY) || (dCornerjY < dY && dCorneriY >= dY))
1007 if (dCorneriX + (dY - dCorneriY) / (dCornerjY - dCorneriY) * (dCornerjX - dCorneriX) < dX)
1009 bOddNodes = !bOddNodes;
1024 int const nPolySize =
static_cast<int>(pPtPoints->size());
1031 vector<CGeom2DPoint> nVTestPoints;
1033 for (
int n = 0; n < 3; n++)
1035 int nIndex = n + nStartPoint + nOffSet;
1037 if (nIndex > nPolySize - 1)
1038 nIndex -= nPolySize;
1044 nVTestPoints.push_back(pPtPoints->at(nIndex));
1051 if (nOffSet >= (nPolySize + 3))
1055 PtStart =
PtAverage(&nVTestPoints[0], &nVTestPoints[2]);
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.
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
vector< CRWCoast > m_VCoast
The coastline objects.
vector< CGeomCoastPolygon * > m_pVCoastPolygon
Pointers to coast polygon objects, in down-coast sequence TODO 044 Will need to use global polygon ID...
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 *)
double m_dStartIterSuspFineInPolygons
Depth (m) of fine suspended sediment at the start of the simulation (only cells in polygons)
void KeepWithinValidGrid(int &, int &) const
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
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.