private void ContourStrands(List <StrandNode> contouredStrandNodeList, List <Strand> strands) { Debug.Assert(contouredStrandNodeList.Count == strands.Count); List <uint> tempList = new List <uint>(); int[] contour; for (int strandIndex = 0; strandIndex < _strands.Count; strandIndex++) { ContouredStrandNode contouredStrandNode = contouredStrandNodeList[strandIndex] as ContouredStrandNode; if (contouredStrandNode != null && contouredStrandNode.strandDensity > 1 && contouredStrandNode.strandDensity <= 7) { int density = contouredStrandNode.strandDensity; contour = K.Contour(density, contouredStrandNode.strandContour, contouredStrandNode.strandAxis); _strands[strandIndex].Values.Sort(); tempList.Clear(); for (int j = 0; j < density; j++) { tempList.Add(_strands[strandIndex].Values[contour[j] - 1]); } for (int j = 0; j < density; j++) { _strands[strandIndex].Values[j] = tempList[j]; } } } }
public override List <StrandNode> StrandNodeList() { DensityInputKrystal dKrystal = this.DensityInputKrystal; PointsInputKrystal pKrystal = this.PointsInputKrystal; AxisInputKrystal aKrystal = this.AxisInputKrystal; ContourInputKrystal cKrystal = this.ContourInputKrystal; if (aKrystal == null || cKrystal == null) { string msg = "Error: Both the axis and contour inputs must be set."; throw new ApplicationException(msg); } if (dKrystal.Level < pKrystal.Level || (aKrystal != null && dKrystal.Level < aKrystal.Level) || (cKrystal != null && dKrystal.Level < cKrystal.Level)) { string msg = "Error: The level of the density input krystal must be\n" + "greater than or equal to the level of all the other input krystals."; throw new ApplicationException(msg); } int[] alignedInputPointValues = pKrystal.AlignedValues(dKrystal); int[] alignedInputAxisValues = { }; if (aKrystal != null) { alignedInputAxisValues = aKrystal.AlignedValues(dKrystal); } int[] alignedInputContourValues = { }; if (cKrystal != null) { alignedInputContourValues = cKrystal.AlignedValues(dKrystal); } if (dKrystal.NumValues != alignedInputPointValues.Length || (aKrystal != null && dKrystal.NumValues != alignedInputAxisValues.Length) || (cKrystal != null && dKrystal.NumValues != alignedInputContourValues.Length)) { string msg = "Error: All the input krystals must belong to the same density family.\n"; throw new ApplicationException(msg); } List <LeveledValue> leveledValues = new List <LeveledValue>(); foreach (LeveledValue leveledValue in dKrystal.LeveledValues) { leveledValues.Add(leveledValue); } // construct the list of StrandNodes List <StrandNode> strandNodeList = new List <StrandNode>(); int momentIndex = 0; foreach (LeveledValue leveledValue in leveledValues) { int level = leveledValue.level; int mVal = leveledValue.value; if (mVal == 0 || alignedInputPointValues[momentIndex] == 0 || alignedInputAxisValues[momentIndex] == 0 || alignedInputContourValues[momentIndex] == 0) { string msg = "Error: An input krystal contained a value of zero."; throw new ApplicationException(msg); } ContouredStrandNode csn = new ContouredStrandNode(momentIndex + 1, level, mVal, alignedInputPointValues[momentIndex], alignedInputAxisValues[momentIndex], alignedInputContourValues[momentIndex]); strandNodeList.Add(csn); momentIndex++; } return(strandNodeList); }