Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Checks if a tubing is straight or two-directional.
- /// </summary>
- /// <returns>True if the connector is straight.</returns>
- private bool IsConnectorStraight(IItem item)
- {
- var children = item.Children;
- var flanges = children.Where(i => i.GetType() == typeof(Flange));
- var elbows = children.Where(i => i.GetType() == typeof(Elbow)).Count();
- return !(AllElementsParallel(flanges) && elbows > 0);
- }
- /// <summary>
- /// Compares an IEnumerable of items and their orientation / direction.
- /// </summary>
- /// <param name="items">The items to compare.</param>
- /// <returns>True if all the elements are parallel.</returns>
- private bool AllElementsParallel(IEnumerable<IItem> items)
- {
- var distinctOrientations = items
- .ToList()
- .GroupBy(i => i.Orientation)
- .Select(g => g.First())
- .ToList();
- return distinctOrientations.Count > 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement