int pCyclicalCheck_int(int cRef, PatternElement.properties_i prop, int subshape = -1) { List <int> cRefs = new List <int> { cRef }; bool cyclical = false; int collisionIndex = -1; while ((cRef >= 0) && !cyclical) { cRef = pGetRef(cRef, prop, subshape); if (cRefs.IndexOf(cRef) == -1) { cRefs.Add(cRef); } else { cyclical = true; collisionIndex = cRef; } } return(collisionIndex); }
int pGetRef(int elementIndex, PatternElement.properties_i prop, int subshape = -1) { int tmp = pGetPatternElement(elementIndex).getInt(prop, subshape) - 1; /* Above, tmp == 0 means the world reference. We decrement the value by 1 to compensate. * * However, the active layer isn't in our list of reference layers. This causes trouble now because we need to detect and handle this. * Consider the active layer as '1', the list is then (world, 0, 2, 3, 4) as (0th, 1st, 2nd, 3rd, 4th members). * * Decrementing the index means we have : * -1 => world * 0 => 0 * 1 => 2 * 2 => 3 * 3 => 4 * * To compensate, if the reduced layer index is equal to, or more than the active index, we should increase the value by 1 to sort the look-up out. */ if (tmp >= elementIndex) { tmp++; } return(tmp); }
Int32 pGetReferenceValue(int refElement, PatternElement.properties_i prop, int subshapeindex) { return(commonVars.stitcher .getPatternElement(patternIndex: 0, refElement) .getInt(prop, subshapeindex)); }
void pSetReferenceValues(int index, int subshapeindex, ObservableCollection <string> uilist, PatternElement.properties_decimal targetValue, PatternElement.properties_i propertyIndex, PatternElement.properties_i subShapeIndex, DropDown cb, NumericStepper ns) { uilist.Clear(); uilist.Add("1"); decimal val = commonVars.stitcher.getPatternElement(patternIndex: 0, index).getDecimal(targetValue, subshapeindex); int refElement = commonVars.stitcher.getPatternElement(patternIndex: 0, index).getInt(propertyIndex, subshapeindex); bool refActive = (refElement != 0); if (refActive) { if (refElement <= index) { refElement--; } int refSubShapeCount = commonVars.stitcher.getPatternElement(patternIndex: 0, refElement).getSubShapeCount(); for (int i = 1; i < refSubShapeCount; i++) { uilist.Add((i + 1).ToString()); } int _subShapeRef = commonVars.stitcher.getPatternElement(patternIndex: 0, index).getInt(subShapeIndex, subshapeindex); // Safety check in case our reference element shifted under us. if (_subShapeRef >= refSubShapeCount) { _subShapeRef = 0; commonVars.stitcher.getPatternElement(patternIndex: 0, index).setInt(subShapeIndex, _subShapeRef, subshapeindex); } cb.SelectedIndex = _subShapeRef; val = pGetReferenceValue(refElement, targetValue, _subShapeRef); } else { cb.SelectedIndex = 0; } ns.Value = Convert.ToDouble(val); commonVars.stitcher.getPatternElement(patternIndex: 0, index).setDecimal(targetValue, val, subshapeindex); }
public bool cyclicalCheck(int cRef, PatternElement.properties_i prop, int subshape = -1) { return(pCyclicalCheck(cRef, prop, subshape)); }
bool pCyclicalCheck(int cRef, PatternElement.properties_i prop, int subshape = -1) { return(pCyclicalCheck_int(cRef, prop, subshape) != -1); }
public int getRef(int elementIndex, PatternElement.properties_i prop, int subshape = -1) { return(pGetRef(elementIndex, prop, subshape)); }