50 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
53 int nNextProfile = -1;
62 int nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
63 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize-1; nCoastPoint++)
65 if (!
m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
82 bool bNextProfileIsOK =
false;
100 if (! bNextProfileIsOK)
107 pNextProfile = pNextNextProfile;
110 }
while (! bNextProfileIsOK);
118 int nDist = (nNextProfileCoastPoint - nCoastPoint) / 2;
121 int nNodePoint = nCoastPoint + nDist;
122 m_VCoast[nCoast].SetPolygonNode(nNodePoint, ++nNode);
135 bool bMeetsAtAPoint =
false;
154 bMeetsAtAPoint =
true;
155 int nTmpThisProfileEnd;
156 int nTmpNextProfileEnd;
160 if (nTmpThisProfileEnd == -1)
162 LogStream <<
m_ulIter <<
": " <<
ERR <<
"profile " << nNextProfile <<
" should be coincident with profile " << nThisProfile <<
" but was not found" << endl;
167 nThisProfileEnd =
tMin(nThisProfileEnd, nTmpThisProfileEnd);
168 nNextProfileEnd =
tMin(nNextProfileEnd, nTmpNextProfileEnd);
174 vector<CGeom2DPoint> PtVBoundary;
177 for (
int i = nThisProfileEnd; i >= 0; i--)
180 PtVBoundary.push_back(PtThis);
184 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
187 PtVBoundary.push_back(PtThis);
191 for (
int i = 0; i <= nNextProfileEnd; i++)
194 PtVBoundary.push_back(PtThis);
199 PtVBoundary.push_back(PtThis);
212 bool bStartCoast =
false;
213 bool bEndCoast =
false;
220 CGeomCoastPolygon* pPolygon =
m_VCoast[nCoast].pPolyCreatePolygon(nThisProfile, nPolygon, nNodePoint, &PtiNode, &PtiAntiNode, nThisProfile, nNextProfile, &PtVBoundary, nThisProfileEnd+1, nNextProfileEnd+1, bStartCoast, bEndCoast);
229 if (! bMeetsAtAPoint)
240 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
248 for (
int i = 0; i < nCellsInProfile; i++)
256 for (
int i = 0; i < nCellsInProfile; i++)
263 if (! bMeetsAtAPoint)
274 nNextProfile = nThisProfile;
275 nCoastPoint = nNextProfileCoastPoint-1;
452 int nXStart = pPt1->
nGetX();
453 int nYStart = pPt1->
nGetY();
456 int nXEnd = pPt2->
nGetX();
457 int nYEnd = pPt2->
nGetY();
460 if ((nXStart == nXEnd) && (nYStart == nYEnd))
464 double dXInc = nXEnd - nXStart;
465 double dYInc = nYEnd - nYStart;
475 for (
int m = 0; m <=
nRound(dLength); m++)
561 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
564 int nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
565 for (
int nPoly = 0; nPoly < nPolygons; nPoly++)
567 int nCellsInPolygon = 0;
568 double dTotDepth = 0;
569 double dStoredUnconsFine = 0;
570 double dStoredUnconsSand = 0;
571 double dStoredUnconsCoarse = 0;
572 double dStoredConsFine = 0;
573 double dStoredConsSand = 0;
574 double dStoredConsCoarse = 0;
575 double dSedimentInputFine = 0;
576 double dSedimentInputSand = 0;
577 double dSedimentInputCoarse = 0;
585 stack<CGeom2DIPoint> PtiStack;
640 PtiStack.push(PtiStart);
645 while (! PtiStack.empty())
650 int nX = Pti.
nGetX();
651 int nY = Pti.
nGetY();
659 bool bSpanAbove =
false;
660 bool bSpanBelow =
false;
678 int nThisLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
684 dStoredUnconsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineDepth();
685 dStoredUnconsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandDepth();
686 dStoredUnconsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseDepth();
688 dStoredConsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetFineDepth();
689 dStoredConsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetSandDepth();
690 dStoredConsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetCoarseDepth();
696 dSedimentInputFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineSedimentInputDepth();
697 dSedimentInputSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandSedimentInputDepth();
698 dSedimentInputCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseSedimentInputDepth();
808 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
810 int nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
831 for (
int nn = 0; nn < nNumPolygons; nn++)
836 vector<int> nVUpCoastAdjacentPolygon;
837 vector<int> nVDownCoastAdjacentPolygon;
839 vector<double> dVUpCoastBoundaryShare;
840 vector<double> dVDownCoastBoundaryShare;
846 nVDownCoastAdjacentPolygon.push_back(
INT_NODATA);
847 dVDownCoastBoundaryShare.push_back(1);
859 double dDownCoastTotBoundaryLen = 0;
863 for (
int nPoint = 0; nPoint < nPointsInProfile-1; nPoint++)
873 int nNumValidCoinc = 0;
875 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
890 int nAdj = nThisPolygon + nNumValidCoinc;
893 if (nAdj >= nNumPolygons)
896 nVDownCoastAdjacentPolygon.push_back(nAdj);
898 dDownCoastTotBoundaryLen += dDistBetween;
899 dVDownCoastBoundaryShare.push_back(dDistBetween);
903 for (
unsigned int n = 0; n < dVDownCoastBoundaryShare.size(); n++)
905 dVDownCoastBoundaryShare[n] /= dDownCoastTotBoundaryLen;
920 nVUpCoastAdjacentPolygon.push_back(
INT_NODATA);
921 dVUpCoastBoundaryShare.push_back(1);
933 double dUpCoastTotBoundaryLen = 0;
937 for (
int nPoint = 0; nPoint < nPointsInProfile-1; nPoint++)
943 if (PtStart == PtEnd)
952 int nNumValidCoinc = 0;
954 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
969 int nAdj = nThisPolygon - nNumValidCoinc;
975 nVUpCoastAdjacentPolygon.push_back(nAdj);
977 dUpCoastTotBoundaryLen += dDistBetween;
978 dVUpCoastBoundaryShare.push_back(dDistBetween);
982 for (
unsigned int n = 0; n < dVUpCoastBoundaryShare.size(); n++)
984 dVUpCoastBoundaryShare[n] /= dUpCoastTotBoundaryLen;
999 pThisPolygon->
SetLength(dPolygonSeawardLen);
1092 bool bOddNodes =
false;
1094 int nPolyCorners =
static_cast<int>(pPtPoints->size());
1095 int j = nPolyCorners-1;
1097 double dX = pPtStart->
dGetX();
1098 double dY = pPtStart->
dGetY();
1100 for (
int i = 0; i < nPolyCorners; i++)
1102 double dCorneriX = pPtPoints->at(i).dGetX();
1103 double dCorneriY = pPtPoints->at(i).dGetY();
1104 double dCornerjX = pPtPoints->at(j).dGetX();
1105 double dCornerjY = pPtPoints->at(j).dGetY();
1107 if ((dCorneriY < dY && dCornerjY >= dY) || (dCornerjY < dY && dCorneriY >= dY))
1109 if (dCorneriX + (dY - dCorneriY) / (dCornerjY - dCorneriY) * (dCornerjX - dCorneriX) < dX)
1111 bOddNodes = ! bOddNodes;
1126 int nPolySize =
static_cast<int>(pPtPoints->size());
1133 vector <CGeom2DPoint> nVTestPoints;
1134 for (
int n = 0; n < 3; n++)
1136 int nIndex = n + nStartPoint + nOffSet;
1137 if (nIndex > nPolySize-1)
1138 nIndex -= nPolySize;
1144 nVTestPoints.push_back(pPtPoints->at(nIndex));
1151 if (nOffSet >= (nPolySize + 3))
1155 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.
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.
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.
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.
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)
int nCreateAllPolygons(void)
Create polygons, and mark the polygon boundaries on the raster grid.
void KeepWithinValidGrid(int, int, int &, int &) const
Given two points in the grid CRS (the points assumed not to be coincident), this routine modifies the...
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 RasterizePolygonJoiningLine(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 flood fill code used here is...
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...
vector< CGeomCoastPolygon * > m_pVCoastPolygon
Pointers to coast polygon objects, in down-coast sequence TODO 044 Will need to use global polygon ID...
This file contains global definitions for CoastalME.
int const NO_NONZERO_THICKNESS_LAYERS
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.