// ****************************************************************** private Limit <T> FindLimits(T pt, ParallelLoopState state, Limit <T> limit) { double x = _xGet(pt); double y = _yGet(pt); // Top if (y.LargerOrEqualWithTol(_yGet(limit.Q2Top))) { if (y.EqualsWithTol(_yGet(limit.Q2Top))) // Special { if (y.EqualsWithTol(_yGet(limit.Q1Top))) { if (x.SmallerWithTol(_xGet(limit.Q2Top))) { limit.Q2Top = _pointConstructor(x, _yGet(limit.Q2Top)); } else if (x.LargerWithTol(_xGet(limit.Q1Top))) { limit.Q1Top = _pointConstructor(x, _yGet(limit.Q1Top)); } } else { if (x.SmallerWithTol(_xGet(limit.Q2Top))) { limit.Q1Top = _pointConstructor(_xGet(limit.Q2Top), _yGet(limit.Q2Top)); limit.Q2Top = _pointConstructor(x, _yGet(limit.Q2Top)); } else if (x.LargerWithTol(_xGet(limit.Q1Top))) { limit.Q1Top = _pointConstructor(x, y); } } } else { limit.Q2Top = _pointConstructor(x, y); } } // Bottom if (y.SmallerOrEqualWithTol(_yGet(limit.Q3Bottom))) { if (y.EqualsWithTol(_yGet(limit.Q3Bottom))) // Special { if (y.EqualsWithTol(_yGet(limit.Q4Bottom))) { if (x.SmallerWithTol(_xGet(limit.Q3Bottom))) { limit.Q3Bottom = _pointConstructor(x, _yGet(limit.Q3Bottom)); } else if (x.LargerWithTol(_xGet(limit.Q4Bottom))) { limit.Q4Bottom = _pointConstructor(x, _yGet(limit.Q4Bottom)); } } else { if (x.SmallerWithTol(_xGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(_xGet(limit.Q3Bottom), _yGet(limit.Q3Bottom)); limit.Q3Bottom = _pointConstructor(x, _yGet(limit.Q3Bottom)); } else if (x.LargerWithTol(_xGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(x, y); } } } else { limit.Q3Bottom = _pointConstructor(x, y); } } // Right if (x.LargerOrEqualWithTol(_xGet(limit.Q4Right))) { if (x.EqualsWithTol(_xGet(limit.Q4Right))) // Special { if (x.EqualsWithTol(_xGet(limit.Q1Right))) { if (y.SmallerWithTol(_yGet(limit.Q4Right))) { limit.Q4Right = _pointConstructor(_xGet(limit.Q4Right), y); } else if (y.LargerWithTol(_yGet(limit.Q1Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q1Right), y); } } else { if (y.SmallerWithTol(_yGet(limit.Q4Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q4Right), _yGet(limit.Q4Right)); limit.Q4Right = _pointConstructor(_xGet(limit.Q4Right), y); } else if (y.LargerWithTol(_yGet(limit.Q1Right))) { limit.Q1Right = _pointConstructor(x, y); } } } else { limit.Q4Right = _pointConstructor(x, y); } } // Left if (x.SmallerOrEqualWithTol(_xGet(limit.Q3Left))) { if (x.EqualsWithTol(_xGet(limit.Q3Left))) // Special { if (x.EqualsWithTol(_xGet(limit.Q2Left))) { if (y.SmallerWithTol(_yGet(limit.Q3Left))) { limit.Q3Left = _pointConstructor(_xGet(limit.Q3Left), y); } else if (y.LargerWithTol(_yGet(limit.Q2Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q2Left), y); } } else { if (y.SmallerWithTol(_yGet(limit.Q3Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q3Left), _yGet(limit.Q3Left)); limit.Q3Left = _pointConstructor(_xGet(limit.Q3Left), y); } else if (y.LargerWithTol(_yGet(limit.Q2Left))) { limit.Q2Left = _pointConstructor(x, y); } } } else { limit.Q3Left = _pointConstructor(x, y); } } if (!_xGet(limit.Q2Left).EqualsWithTol(_xGet(limit.Q3Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q3Left), _yGet(limit.Q3Left)); } if (!_xGet(limit.Q1Right).EqualsWithTol(_xGet(limit.Q4Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q4Right), _yGet(limit.Q4Right)); } if (!_yGet(limit.Q1Top).EqualsWithTol(_yGet(limit.Q2Top))) { limit.Q1Top = _pointConstructor(_xGet(limit.Q2Top), _yGet(limit.Q2Top)); } if (!_yGet(limit.Q4Bottom).EqualsWithTol(_yGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(_xGet(limit.Q3Bottom), _yGet(limit.Q3Bottom)); } return(limit); }
private void AggregateLimits(Limit <T> limit) { lock (_findLimitFinalLock) { if (_xGet(limit.Q1Right).LargerOrEqualWithTol(_xGet(_limit.Q1Right))) { if (_xGet(limit.Q1Right).EqualsWithTol(_xGet(_limit.Q1Right))) { if (_yGet(limit.Q1Right).LargerWithTol(_yGet(_limit.Q1Right))) { _limit.Q1Right = limit.Q1Right; } } else { _limit.Q1Right = limit.Q1Right; } } if (_xGet(limit.Q4Right).LargerWithTol(_xGet(_limit.Q4Right))) { if (_xGet(limit.Q4Right).EqualsWithTol(_xGet(_limit.Q4Right))) { if (_yGet(limit.Q4Right).SmallerWithTol(_yGet(_limit.Q4Right))) { _limit.Q4Right = limit.Q4Right; } } else { _limit.Q4Right = limit.Q4Right; } } if (_xGet(limit.Q2Left).SmallerWithTol(_xGet(_limit.Q2Left))) { if (_xGet(limit.Q2Left).EqualsWithTol(_xGet(_limit.Q2Left))) { if (_yGet(limit.Q2Left).LargerWithTol(_yGet(_limit.Q2Left))) { _limit.Q2Left = limit.Q2Left; } } else { _limit.Q2Left = limit.Q2Left; } } if (_xGet(limit.Q3Left).SmallerWithTol(_xGet(_limit.Q3Left))) { if (_xGet(limit.Q3Left).EqualsWithTol(_xGet(_limit.Q3Left))) { if (_yGet(limit.Q3Left).LargerWithTol(_yGet(_limit.Q3Left))) { _limit.Q3Left = limit.Q3Left; } } else { _limit.Q3Left = limit.Q3Left; } } if (_yGet(limit.Q1Top).LargerWithTol(_yGet(_limit.Q1Top))) { if (_yGet(limit.Q1Top).EqualsWithTol(_yGet(_limit.Q1Top))) { if (_xGet(limit.Q1Top).LargerWithTol(_xGet(_limit.Q1Top))) { _limit.Q1Top = limit.Q1Top; } } else { _limit.Q1Top = limit.Q1Top; } } if (_yGet(limit.Q2Top).LargerWithTol(_yGet(_limit.Q2Top))) { if (_yGet(limit.Q2Top).EqualsWithTol(_yGet(_limit.Q2Top))) { if (_xGet(limit.Q2Top).SmallerWithTol(_xGet(_limit.Q2Top))) { _limit.Q2Top = limit.Q2Top; } } else { _limit.Q2Top = limit.Q2Top; } } if (_yGet(limit.Q3Bottom).SmallerWithTol(_yGet(_limit.Q3Bottom))) { if (_yGet(limit.Q3Bottom).EqualsWithTol(_yGet(_limit.Q3Bottom))) { if (_xGet(limit.Q3Bottom).SmallerWithTol(_xGet(_limit.Q3Bottom))) { _limit.Q3Bottom = limit.Q3Bottom; } } else { _limit.Q3Bottom = limit.Q3Bottom; } } if (_yGet(limit.Q4Bottom).SmallerWithTol(_yGet(_limit.Q4Bottom))) { if (_yGet(limit.Q4Bottom).EqualsWithTol(_yGet(_limit.Q4Bottom))) { if (_xGet(limit.Q4Bottom).LargerWithTol(_xGet(_limit.Q4Bottom))) { _limit.Q4Bottom = limit.Q4Bottom; } } else { _limit.Q4Bottom = limit.Q4Bottom; } } } }
// ****************************************************************** private Limit <T> FindLimits(IEnumerable <IEnumerable <T> > listOfListOfPoint, int start, int offset, Limit <T> limit) { foreach (var listOfPoint in listOfListOfPoint) { var count = listOfPoint.Count(); for (int index = start; index < count; index += offset) { T pt = listOfPoint.ElementAt(index); double x = _xGet(pt); double y = _yGet(pt); // Top if (y.LargerOrEqualWithTol(_yGet(limit.Q2Top))) { if (y.EqualsWithTol(_yGet(limit.Q2Top))) // Special { if (y.EqualsWithTol(_yGet(limit.Q1Top))) { if (x.SmallerWithTol(_xGet(limit.Q2Top))) { limit.Q2Top = _pointConstructor(x, _yGet(limit.Q2Top)); } else if (x.LargerWithTol(_xGet(limit.Q1Top))) { limit.Q1Top = _pointConstructor(x, _yGet(limit.Q1Top)); } } else { if (x.SmallerWithTol(_xGet(limit.Q2Top))) { limit.Q1Top = _pointConstructor(_xGet(limit.Q2Top), _yGet(limit.Q2Top)); limit.Q2Top = _pointConstructor(x, _yGet(limit.Q2Top)); } else if (x.LargerWithTol(_xGet(limit.Q1Top))) { limit.Q1Top = _pointConstructor(x, y); } } } else { limit.Q2Top = _pointConstructor(x, y); } } // Bottom if (y.SmallerOrEqualWithTol(_yGet(limit.Q3Bottom))) { if (y.EqualsWithTol(_yGet(limit.Q3Bottom))) // Special { if (y.EqualsWithTol(_yGet(limit.Q4Bottom))) { if (x.SmallerWithTol(_xGet(limit.Q3Bottom))) { limit.Q3Bottom = _pointConstructor(x, _yGet(limit.Q3Bottom)); } else if (x.LargerWithTol(_xGet(limit.Q4Bottom))) { limit.Q4Bottom = _pointConstructor(x, _yGet(limit.Q4Bottom)); } } else { if (x.SmallerWithTol(_xGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(_xGet(limit.Q3Bottom), _yGet(limit.Q3Bottom)); limit.Q3Bottom = _pointConstructor(x, _yGet(limit.Q3Bottom)); } else if (x.LargerWithTol(_xGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(x, y); } } } else { limit.Q3Bottom = _pointConstructor(x, y); } } // Right if (x.LargerOrEqualWithTol(_xGet(limit.Q4Right))) { if (x.EqualsWithTol(_xGet(limit.Q4Right))) // Special { if (x.EqualsWithTol(_xGet(limit.Q1Right))) { if (y.SmallerWithTol(_yGet(limit.Q4Right))) { limit.Q4Right = _pointConstructor(_xGet(limit.Q4Right), y); } else if (y.LargerWithTol(_yGet(limit.Q1Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q1Right), y); } } else { if (y.SmallerWithTol(_yGet(limit.Q4Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q4Right), _yGet(limit.Q4Right)); limit.Q4Right = _pointConstructor(_xGet(limit.Q4Right), y); } else if (y.LargerWithTol(_yGet(limit.Q1Right))) { limit.Q1Right = _pointConstructor(x, y); } } } else { limit.Q4Right = _pointConstructor(x, y); } } // Left if (x.SmallerOrEqualWithTol(_xGet(limit.Q3Left))) { if (x.EqualsWithTol(_xGet(limit.Q3Left))) // Special { if (x.EqualsWithTol(_xGet(limit.Q2Left))) { if (y.SmallerWithTol(_yGet(limit.Q3Left))) { limit.Q3Left = _pointConstructor(_xGet(limit.Q3Left), y); } else if (y.LargerWithTol(_yGet(limit.Q2Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q2Left), y); } } else { if (y.SmallerWithTol(_yGet(limit.Q3Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q3Left), _yGet(limit.Q3Left)); limit.Q3Left = _pointConstructor(_xGet(limit.Q3Left), y); } else if (y.LargerWithTol(_yGet(limit.Q2Left))) { limit.Q2Left = _pointConstructor(x, y); } } } else { limit.Q3Left = _pointConstructor(x, y); } } if (!_xGet(limit.Q2Left).EqualsWithTol(_xGet(limit.Q3Left))) { limit.Q2Left = _pointConstructor(_xGet(limit.Q3Left), _yGet(limit.Q3Left)); } if (!_xGet(limit.Q1Right).EqualsWithTol(_xGet(limit.Q4Right))) { limit.Q1Right = _pointConstructor(_xGet(limit.Q4Right), _yGet(limit.Q4Right)); } if (!_yGet(limit.Q1Top).EqualsWithTol(_yGet(limit.Q2Top))) { limit.Q1Top = _pointConstructor(_xGet(limit.Q2Top), _yGet(limit.Q2Top)); } if (!_yGet(limit.Q4Bottom).EqualsWithTol(_yGet(limit.Q3Bottom))) { limit.Q4Bottom = _pointConstructor(_xGet(limit.Q3Bottom), _yGet(limit.Q3Bottom)); } } } return(limit); }