Exemplo n.º 1
0
        private void AddValue(List <int> alignedValues, InputKrystal acKrystal, int acStrandIndex, int acValueIndex)
        {
            Debug.Assert(acStrandIndex < acKrystal.Strands.Count);
            Debug.Assert(acValueIndex < acKrystal.Strands[acStrandIndex].Values.Count);

            alignedValues.Add((int)(acKrystal.Strands[acStrandIndex].Values[acValueIndex]));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns an array containing one value from this krystal per value in the master krystal.
        /// The master krystal may have the same or more levels than this krystal, but must have the same form
        /// as this krystal at this krystal's level.
        /// The master krystal may not have less levels than this krystal. If it has MORE levels, values
        /// from this krystal are repeated.
        /// </summary>
        /// <param name="masterKrystal"></param>
        public int[] AlignedValues(InputKrystal masterKrystal)
        {
            List <int> alignedValues = new List <int>();
            int        mValueIndex   = 0;
            int        mStrandIndex  = 0;
            uint       masterLevel   = 1;
            int        strandIndex   = 0;
            int        valueIndex    = 0;

            while (strandIndex < _strands.Count)
            {
                uint valueLevel = _strands[strandIndex].Level;
                valueIndex = 0;

                while (valueIndex < _strands[strandIndex].Values.Count &&
                       mStrandIndex < masterKrystal.Strands.Count &&
                       mValueIndex < masterKrystal.Strands[mStrandIndex].Values.Count)
                {
                    alignedValues.Add((int)_strands[strandIndex].Values[valueIndex]);

                    mValueIndex++;
                    if (mValueIndex == masterKrystal.Strands[mStrandIndex].Values.Count)
                    {
                        mValueIndex = 0;
                        mStrandIndex++;
                        if (mStrandIndex < masterKrystal.Strands.Count)
                        {
                            masterLevel = masterKrystal.Strands[mStrandIndex].Level;
                        }
                    }
                    else
                    {
                        masterLevel = masterKrystal.Level + 1;
                    }

                    valueLevel = this._level + 1;

                    if (valueLevel == masterLevel || (mValueIndex == 0 && valueLevel > masterLevel))
                    {
                        valueIndex++;
                    }
                }
                strandIndex++;
            }
            return(alignedValues.ToArray());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a list of values from the InputKrystal (axis or contour) aligned to the outerSuperStrands.
        /// The returned List has as many values as there are strands in the source file at permutationLevel and below.
        /// The permutationLevel must be less than or equal to the level of the source krystal, and greater than the
        /// level of the InputKrystal.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="krystal"></param>
        /// <returns></returns>
        private List <int> GetSourceAlignedValues(PermutationSourceInputKrystal source, uint permutationLevel, InputKrystal acKrystal)
        {
            Debug.Assert(permutationLevel <= source.Level && permutationLevel > acKrystal.Level);
            List <int> alignedValues = new List <int>();
            int        acStrandIndex = 0;
            int        acValueIndex  = 0;
            int        acValueLevel  = (int)acKrystal.Level + 1;

            foreach (Strand strand in source.Strands)
            {
                if (permutationLevel == 1)
                {
                    AddValue(alignedValues, acKrystal, acStrandIndex, acValueIndex);
                    break;
                }
                else if (strand.Level <= permutationLevel)
                {
                    if (strand.Level == 1)
                    {
                        acStrandIndex = 0;
                        acValueIndex  = 0;
                    }
                    else if (strand.Level == acValueLevel)
                    {
                        acValueIndex++;
                    }
                    else if (strand.Level < acValueLevel)
                    {
                        acStrandIndex++;
                        acValueIndex = 0;
                    }
                    AddValue(alignedValues, acKrystal, acStrandIndex, acValueIndex);
                }
                // else if(strand.Level > permutationLevel) do nothing
            }
            return(alignedValues);
        }