47 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
50 int nNextProfile = -1;
59 int const nCoastSize =
m_VCoast[nCoast].nGetCoastlineSize();
61 for (
int nCoastPoint = 0; nCoastPoint < nCoastSize - 1; nCoastPoint++)
63 if (!
m_VCoast[nCoast].bIsProfileAtCoastPoint(nCoastPoint))
80 bool bNextProfileIsOK =
false;
100 if (! bNextProfileIsOK)
107 pNextProfile = pNextNextProfile;
110 }
while (! bNextProfileIsOK);
115 int const nNextProfileCoastPoint = pNextProfile->
nGetCoastPoint();
118 int const nDist = (nNextProfileCoastPoint - nCoastPoint) / 2;
121 int const nNodePoint = nCoastPoint + nDist;
122 m_VCoast[nCoast].SetPolygonNode(nNodePoint, ++nNode);
135 bool bMeetsAtAPoint =
false;
154 bMeetsAtAPoint =
true;
155 int nTmpThisProfileEnd;
156 int nTmpNextProfileEnd;
161 if (nTmpThisProfileEnd == -1)
163 LogStream <<
m_ulIter <<
": " <<
ERR <<
"profile " << nNextProfile <<
" should be coincident with profile " << nThisProfile <<
" but was not found" << endl;
168 nThisProfileEnd =
tMin(nThisProfileEnd, nTmpThisProfileEnd);
169 nNextProfileEnd =
tMin(nNextProfileEnd, nTmpNextProfileEnd);
175 vector<CGeom2DPoint> PtVBoundary;
178 for (
int i = nThisProfileEnd; i >= 0; i--)
181 PtVBoundary.push_back(PtThis);
185 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
188 PtVBoundary.push_back(PtThis);
192 for (
int i = 0; i <= nNextProfileEnd; i++)
195 PtVBoundary.push_back(PtThis);
200 PtVBoundary.push_back(PtThis);
215 bool bStartCoast =
false;
216 bool bEndCoast =
false;
225 CGeomCoastPolygon* pPolygon =
m_VCoast[nCoast].pPolyCreatePolygon(nPolygon, nNodePoint, &PtiNode, &PtiAntiNode, nThisProfile, nNextProfile, &PtVBoundary, nThisProfileEnd + 1, nNextProfileEnd + 1, bStartCoast, bEndCoast);
235 if (! bMeetsAtAPoint)
248 for (
int i = nCoastPoint; i <= nNextProfileCoastPoint; i++)
257 for (
int i = 0; i < nCellsInProfile; i++)
266 for (
int i = 0; i < nCellsInProfile; i++)
273 if (! bMeetsAtAPoint)
286 nCoastPoint = nNextProfileCoastPoint - 1;
305 int const nXStart = pPt1->
nGetX();
306 int const nYStart = pPt1->
nGetY();
309 int const nXEnd = pPt2->
nGetX();
310 int const nYEnd = pPt2->
nGetY();
313 if ((nXStart == nXEnd) && (nYStart == nYEnd))
317 double dXInc = nXEnd - nXStart;
318 double dYInc = nYEnd - nYStart;
328 for (
int m = 0; m <=
nRound(dLength); m++)
340 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPoly);
416 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
419 int const nPolygons =
m_VCoast[nCoast].nGetNumPolygons();
421 for (
int nPoly = 0; nPoly < nPolygons; nPoly++)
423 int nCellsInPolygon = 0;
424 double dTotDepth = 0;
425 double dStoredUnconsFine = 0;
426 double dStoredUnconsSand = 0;
427 double dStoredUnconsCoarse = 0;
428 double dStoredConsFine = 0;
429 double dStoredConsSand = 0;
430 double dStoredConsCoarse = 0;
431 double dSedimentInputFine = 0;
432 double dSedimentInputSand = 0;
433 double dSedimentInputCoarse = 0;
441 stack<CGeom2DIPoint> PtiStack;
496 PtiStack.push(PtiStart);
501 while (! PtiStack.empty())
506 int nX = Pti.
nGetX();
507 int const nY = Pti.
nGetY();
514 bool bSpanAbove =
false;
515 bool bSpanBelow =
false;
522 m_pRasterGrid->m_Cell[nX][nY].SetCoastAndPolygonID(nCoast, nPolyID);
534 int const nThisLayer =
m_pRasterGrid->m_Cell[nX][nY].nGetTopNonZeroLayerAboveBasement();
540 dStoredUnconsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineDepth();
541 dStoredUnconsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandDepth();
542 dStoredUnconsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseDepth();
544 dStoredConsFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetFineDepth();
545 dStoredConsSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetSandDepth();
546 dStoredConsCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetConsolidatedSediment()->dGetCoarseDepth();
552 dSedimentInputFine +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetFineSedimentInputDepth();
553 dSedimentInputSand +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetSandSedimentInputDepth();
554 dSedimentInputCoarse +=
m_pRasterGrid->m_Cell[nX][nY].pGetLayerAboveBasement(nThisLayer)->pGetUnconsolidatedSediment()->dGetCoarseSedimentInputDepth();
666 for (
int nCoast = 0; nCoast < static_cast<int>(
m_VCoast.size()); nCoast++)
668 int const nNumPolygons =
m_VCoast[nCoast].nGetNumPolygons();
689 for (
int nn = 0; nn < nNumPolygons; nn++)
694 vector<int> nVUpCoastAdjacentPolygon;
695 vector<int> nVDownCoastAdjacentPolygon;
697 vector<double> dVUpCoastBoundaryShare;
698 vector<double> dVDownCoastBoundaryShare;
704 nVDownCoastAdjacentPolygon.push_back(
INT_NODATA);
705 dVDownCoastBoundaryShare.push_back(1);
717 double dDownCoastTotBoundaryLen = 0;
721 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
736 int nNumValidCoinc = 0;
738 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
753 int nAdj = nThisPolygon + nNumValidCoinc;
756 if (nAdj >= nNumPolygons)
764 nVDownCoastAdjacentPolygon.push_back(nAdj);
766 dDownCoastTotBoundaryLen += dDistBetween;
767 dVDownCoastBoundaryShare.push_back(dDistBetween);
771 for (
unsigned int n = 0; n < dVDownCoastBoundaryShare.size(); n++)
776 nVDownCoastAdjacentPolygon.pop_back();
777 dVDownCoastBoundaryShare.pop_back();
781 dVDownCoastBoundaryShare[n] /= dDownCoastTotBoundaryLen;
793 nVUpCoastAdjacentPolygon.push_back(
INT_NODATA);
794 dVUpCoastBoundaryShare.push_back(1);
807 double dUpCoastTotBoundaryLen = 0;
811 for (
int nPoint = 0; nPoint < nPointsInProfile - 1; nPoint++)
817 if (PtStart == PtEnd)
831 int nNumValidCoinc = 0;
833 for (
int nCoinc = 0; nCoinc < nNumCoinc; nCoinc++)
848 int nAdj = nThisPolygon - nNumValidCoinc;
859 nVUpCoastAdjacentPolygon.push_back(nAdj);
861 dUpCoastTotBoundaryLen += dDistBetween;
862 dVUpCoastBoundaryShare.push_back(dDistBetween);
866 for (
unsigned int n = 0; n < dVUpCoastBoundaryShare.size(); n++)
871 nVUpCoastAdjacentPolygon.pop_back();
872 dVUpCoastBoundaryShare.pop_back();
876 dVUpCoastBoundaryShare[n] /= dUpCoastTotBoundaryLen;
888 pThisPolygon->
SetLength(dPolygonSeawardLen);
981 bool bOddNodes =
false;
983 int const nPolyCorners =
static_cast<int>(pPtPoints->size());
984 int j = nPolyCorners - 1;
986 double const dX = pPtStart->
dGetX();
987 double const dY = pPtStart->
dGetY();
989 for (
int i = 0; i < nPolyCorners; i++)
991 double const dCorneriX = pPtPoints->at(i).dGetX();
992 double const dCorneriY = pPtPoints->at(i).dGetY();
993 double const dCornerjX = pPtPoints->at(j).dGetX();
994 double const dCornerjY = pPtPoints->at(j).dGetY();
996 if ((dCorneriY < dY && dCornerjY >= dY) || (dCornerjY < dY && dCorneriY >= dY))
998 if (dCorneriX + (dY - dCorneriY) / (dCornerjY - dCorneriY) * (dCornerjX - dCorneriX) < dX)
1000 bOddNodes = ! bOddNodes;
1015 int const nPolySize =
static_cast<int>(pPtPoints->size());
1022 vector<CGeom2DPoint> nVTestPoints;
1024 for (
int n = 0; n < 3; n++)
1026 int nIndex = n + nStartPoint + nOffSet;
1028 if (nIndex > nPolySize - 1)
1029 nIndex -= nPolySize;
1035 nVTestPoints.push_back(pPtPoints->at(nIndex));
1042 if (nOffSet >= (nPolySize + 3))
1046 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 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
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...
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
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.