Revit.SDK.Samples.CurtainWallGrid.CS.GridDrawing.GetConjointSegment C# (CSharp) Method

GetConjointSegment() private method

get all the segments which is connected to the end point of the segment and is in the same line as the segment for example: 2 grid line has one junction, so there'll be 4 segments connecting to this junction 2 U segments and 2 V segments, delete the 2 U segments first, then delete one of the V segment, the other V segment will be marked as the "ConjointSegment" and will be deleted automatically. this method is used to pick the "the other V segment" out
private GetConjointSegment ( System point, bool isUSegment, SegmentLine2D &removeSegLine ) : void
point System /// the junction of several segments ///
isUSegment bool /// the U/V status of the segment ///
removeSegLine SegmentLine2D /// the result segment line to be removed ///
return void
        private void GetConjointSegment(System.Drawing.Point point, bool isUSegment,
           ref SegmentLine2D removeSegLine)
        {
            int uIndex = -1;
             List<int> uSegIndexes = new List<int>();
             // get which U grid line contains the point
             uIndex = GetOutlineIndex(m_uLinePathList, point);

             int vIndex = -1;
             List<int> vSegIndexes = new List<int>();
             // get which V grid line contains the point
             vIndex = GetOutlineIndex(m_vLinePathList, point);

             if (-1 != uIndex)
             {
            // get the grid line containing the point and its segments
            List<SegmentLine2D> segList = m_uGridLines2D[uIndex].Segments;
            // get which segments of the grid line contains the point
            uSegIndexes = GetOutlineIndexes(segList, point);
             }

             if (-1 != vIndex)
             {
            // get the grid line containing the point and its segments
            List<SegmentLine2D> segList = m_vGridLines2D[vIndex].Segments;
            // get which segments of the grid line contains the point
            vSegIndexes = GetOutlineIndexes(segList, point);
             }

             if ((0 == uSegIndexes.Count && 1 == vSegIndexes.Count))
             {
            // the source segment is an V segment, and the result segment is a V segment too.
            // they're connected and in one line, so the result V segment should be removed,
            // according to the UI rule
            if (false == isUSegment)
            {
               removeSegLine = m_vGridLines2D[vIndex].Segments[vSegIndexes[0]];
               return;
            }
             }
             else if (1 == uSegIndexes.Count && 0 == vSegIndexes.Count)
             {
            // the source segment is an U segment, and the result segment is a U segment too.
            // they're connected and in one line, so the result U segment should be removed,
            // according to the UI rule
            if (true == isUSegment)
            {
               removeSegLine = m_uGridLines2D[uIndex].Segments[uSegIndexes[0]];
               return;
            }
             }
        }