コード例 #1
0
        private bool IsGaussCodeCorrect()
        {
            /*
             * 1- 0 is not allowed, because 0 = -0
             * 2- Every cross has to appear twice, positive and negative
             * 3- There is no knot with 2 crossings TODO
             *      -1,2,1,-2 NO
             *      1,-1,-2,2 OK
             */

            bool notContainsZero = !GaussCode.Contains(0);
            bool everyCrossTwice = GaussCode.TrueForAll(c1 => gaussCode.Exists(c2 => c1 == -c2));

            return(notContainsZero && everyCrossTwice);
        }
コード例 #2
0
        private void RemapGaussCode()
        {
            //remap gauss code to keep consistency with names
            MovableCircularList <int> kGauss = new MovableCircularList <int>(GaussCode);
            int        indexCross            = 1;
            List <int> avoidPosition         = new List <int>();

            for (int i = 0; i < kGauss.Count; i++)
            {
                if (!avoidPosition.Contains(i))
                {
                    int index = GaussCode.IndexOf(-GaussCode[i]);
                    int sign  = GaussCode[i] < 0 ? -1 : 1;
                    kGauss[i]     = sign * indexCross;
                    kGauss[index] = -kGauss[i];
                    avoidPosition.Add(index);
                    avoidPosition.Add(i);
                    indexCross++;
                }
            }
            GaussCode = kGauss;
        }