Exemplo n.º 1
0
        public bool TryMatch(WhichEndPoint WhichEnd, TriangleLine[] OtherLines)
        {
            bool gotMatch = false;

            // match the start of this line to the start or end of the other lines.
            if (WhichEnd == WhichEndPoint.Start)
            {
                foreach (var otherLine in OtherLines)
                {
                    if (this.StartLine != null)
                    {
                        gotMatch = true;
                        break;
                    }

                    if ((otherLine.StartLine == null) &&
                        (this.LineCoor.Start.Equals(otherLine.LineCoor.Start)))
                    {
                        otherLine.StartLine = this;
                        this.StartLine      = otherLine;
                        gotMatch            = true;
                    }

                    else if ((otherLine.EndLine == null) &&
                             (this.LineCoor.Start.Equals(otherLine.LineCoor.End)))
                    {
                        this.StartLine    = otherLine;
                        otherLine.EndLine = this;
                        gotMatch          = true;
                    }
                }
            }

            if (WhichEnd == WhichEndPoint.End)
            {
                foreach (var otherLine in OtherLines)
                {
                    if (this.EndLine != null)
                    {
                        gotMatch = true;
                        break;
                    }

                    if ((otherLine.StartLine == null) &&
                        (this.LineCoor.End.Equals(otherLine.LineCoor.Start)))
                    {
                        otherLine.EndLine = this;
                        this.StartLine    = otherLine;
                        gotMatch          = true;
                    }

                    else if ((otherLine.EndLine == null) &&
                             (this.LineCoor.End.Equals(otherLine.LineCoor.End)))
                    {
                        this.EndLine      = otherLine;
                        otherLine.EndLine = this;
                        gotMatch          = true;
                    }
                }
            }

            return(gotMatch);
        }
Exemplo n.º 2
0
        public bool TryMatch(TriangleLine TriLine, WhichEndPoint WhichEnd)
        {
            bool gotMatch = false;

            foreach (var otherLine in this)
            {
                if (gotMatch == true)
                {
                    break;
                }
                if (TriLine == otherLine)
                {
                    continue;
                }
                else if (WhichEnd == WhichEndPoint.Start)
                {
                    if (TriLine.StartLine != null)
                    {
                        gotMatch = true;
                        break;
                    }

                    if ((otherLine.StartLine == null) &&
                        (TriLine.LineCoor.Start.Equals(otherLine.LineCoor.Start)))
                    {
                        otherLine.StartLine = TriLine;
                        TriLine.StartLine   = otherLine;
                        gotMatch            = true;
                    }

                    else if ((otherLine.EndLine == null) &&
                             (TriLine.LineCoor.Start.Equals(otherLine.LineCoor.End)))
                    {
                        TriLine.StartLine = otherLine;
                        otherLine.EndLine = TriLine;
                        gotMatch          = true;
                    }
                }
                else if (WhichEnd == WhichEndPoint.End)
                {
                    if (TriLine.EndLine != null)
                    {
                        gotMatch = true;
                        break;
                    }

                    if ((otherLine.StartLine == null) &&
                        (TriLine.LineCoor.End.Equals(otherLine.LineCoor.Start)))
                    {
                        otherLine.StartLine = TriLine;
                        TriLine.EndLine     = otherLine;
                        gotMatch            = true;
                    }

                    else if ((otherLine.EndLine == null) &&
                             (TriLine.LineCoor.End.Equals(otherLine.LineCoor.End)))
                    {
                        TriLine.EndLine   = otherLine;
                        otherLine.EndLine = TriLine;
                        gotMatch          = true;
                    }
                }
            }
            return(gotMatch);
        }