Exemplo n.º 1
0
        /// <summary>
        /// Reverse the order of the vertices. Only operates on the outer boundary
        /// </summary>
        public void Reverse()
        {
            // This is used in the process of combining triangles and therefore will work only with the face without holes
            List <int> revIdxOuter = IndexOuterBoundary.ToList();

            revIdxOuter.Reverse();
            OuterAndInnerBoundaries.Clear();
            BoundaryLinesDict.Clear();
            SetupEdges(revIdxOuter, 0);
        }
Exemplo n.º 2
0
        void SetupEdges(IList <int> vertxIndices, int idxOffset)
        {
            int boundLinesDictOffset = 0;

            if (BoundaryLinesDict == null)
            {
                IEqualityComparer <IndexSegment> segCompare = new SegmentComparer(false /*compareBothDirections*/);
                BoundaryLinesDict = new Dictionary <IndexSegment, int>(segCompare);
            }
            else
            {
                boundLinesDictOffset = BoundaryLinesDict.Count();
            }

            int prevIdx   = 0;
            int idx       = 0;
            int vertCount = vertxIndices.Count;

            foreach (int vIdx in vertxIndices)
            {
                IndexSegment segm = null;
                if (idx > 0)
                {
                    segm = new IndexSegment(prevIdx, vIdx);
                    OuterAndInnerBoundaries.Add(idx - 1 + idxOffset, segm);
                    BoundaryLinesDict.Add(segm, (idx - 1 + boundLinesDictOffset)); // boundaryLinesDict is a dictionary for the combined outer and inner boundaries, the values should be sequential
                }
                if (idx == vertCount - 1)                                          // The last index. Close the loop by connecing it to the first index
                {
                    segm = new IndexSegment(vIdx, vertxIndices[0]);
                    OuterAndInnerBoundaries.Add((idx + idxOffset), segm);
                    BoundaryLinesDict.Add(segm, (idx + boundLinesDictOffset));  // boundaryLinesDict is a dictionary for the combined outer and inner boundaries, the values should be sequential
                }
                prevIdx = vIdx;
                idx++;
            }
        }