using System; using System.Collections.Generic; // ======================================================================================================================= // Class name: // // Description: // // Copyright (c) 2008 Deltares // // Date ID Modification // 2008-04-09 Best Created // ======================================================================================================================= namespace Deltares.Stability.Calculation.Inner { public class TForbiddenLine { private string FForbiddenLineName = String.Empty; private List FXCoords = new List(); private List FZCoords = new List(); // ======================================================================================================================= // Date ID Modification // 2008-04-09 Best Created // ======================================================================================================================= //Constructor Create() public TForbiddenLine() {} public string ForbiddenLineName { get { return FForbiddenLineName; } set { FForbiddenLineName = value; } } public double[] XCoords { get { return FXCoords.ToArray(); } } public double[] ZCoords { get { return FZCoords.ToArray(); } } // ======================================================================================================================= // Date ID Modification // 2008-06-25 Best Created // ======================================================================================================================= public void Addpoint(double Ax, double Az) { FXCoords.Add(Ax); FZCoords.Add(Az); } // ======================================================================================================================= // Descritption // Find if a circel cuts a forbidden line. // // Date ID Modification // 2008-04-09 Best Created // ======================================================================================================================= public bool CircleIntersectsForbiddenLine(double AXmid, double AZMid, double ARadius, double LXCircelEntry, double LXCircelExit) { bool result; int LNLines; int Ns = 0; // aantal gevonden snijpunten double xs1 = 0; double xs2 = 0; double ys1 = 0; double ys2 = 0; // coordinaten van eventuele snijpunten double LxStart = 0; double LxEnd = 0; double LyStart = 0; double LyEnd = 0; // coordinaten van eventuele snijpunten bool LIntersectionFound; LIntersectionFound = false; LNLines = FXCoords.Count - 1; for (int i = 1; i <= LNLines; i ++) { LxStart = XCoords[i - 1]; LyStart = ZCoords[i - 1]; LxEnd = XCoords[i]; LyEnd = ZCoords[i]; MStabDatafunctions.Intersect_Circle_line(AXmid, AZMid, ARadius, LxStart, LxEnd, LyStart, LyEnd, ref Ns, ref xs1, ref ys1, ref xs2, ref ys2); if ((Ns > 0)) { if ((Ns == 1)) { if (((xs1 >= LXCircelEntry - 1.0E-5) && (xs1 <= LXCircelExit + 1.0E-5))) { LIntersectionFound = true; } } if ((Ns == 2)) { if (!LIntersectionFound) { if (((xs2 >= LXCircelEntry - 1.0E-5) && (xs2 <= LXCircelExit + 1.0E-5))) { LIntersectionFound = true; } } } } } // Due to accuracy the exact points between two sheets may not be found if (!LIntersectionFound) { for (int i = 1; i < FXCoords.Count; i ++) { if ((Math.Abs(MStabDatafunctions.Distance2D(XCoords[i], ZCoords[i], AXmid, AZMid) - ARadius) <= Constants.CEpsMin)) { LIntersectionFound = true; } } } result = LIntersectionFound; return result; } // ======================================================================================================================= // Date ID Modification // 2008-06-25 Best Created // ======================================================================================================================= public bool LineIntersectsForbiddenLine(double AXStart, double AZStart, double AXEnd, double AZEnd) { bool result = false; int LNLines = 0; int i = 0; double LxStart = 0; double LxEnd = 0; double LzStart = 0; double LzEnd = 0; // coordinaten van eventuele snijpunten double LXS = 0; double LZS = 0; bool LIntersectionFound = false; LIntersectionFound = false; LNLines = FXCoords.Count - 1; for (i = 1; i <= LNLines; i ++) { LxStart = XCoords[i - 1]; LzStart = ZCoords[i - 1]; LxEnd = XCoords[i]; LzEnd = ZCoords[i]; if (MStabDatafunctions.IntersectLines(AXStart, AZStart, AXEnd, AZEnd, LxStart, LzStart, LxEnd, LzEnd, ref LXS, ref LZS)) { LIntersectionFound = true; } } // Due to accuracy the exact points between two sheets may not be found if (!LIntersectionFound) { // the first and last point are not considdered for (i = 1; i < FXCoords.Count; i ++) { if ((XCoords[i] >= AXStart) && (XCoords[i] <= AXEnd)) { if ((Math.Abs(ZCoords[i] - AZStart) <= Constants.CEpsMin)) { LIntersectionFound = true; } } } } result = LIntersectionFound; return result; } } // end TForbiddenLine }