/// <summary> /// /// </summary> /// <param name="node1"></param> /// <param name="node2"></param> /// <returns> /// A list of elements directly connecting both the nodes. /// If node1 is equal to node2 (i.e. they are the same nodes), then all the elements connected to that node will be returned. /// </returns> public IList <IFiniteElement> GetAllElementsDirectlyConnecting(IFiniteElementNode node1, IFiniteElementNode node2) { Guard.AgainstNullArgument(node1, "node1"); Guard.AgainstNullArgument(node2, "node2"); IList <IFiniteElement> connectingElements; int currentValidHashForCache = this.GetHashCode(); ElementRepository.NodeTuple keyForCache = new ElementRepository.NodeTuple(node1, node2); return(this.cacheConnectingElements.GetOrCreateAndSave(keyForCache, currentValidHashForCache, () => { IList <IFiniteElement> elementsConnectedToNode1 = this.GetAllElementsConnectedTo(node1); if (node1.Equals(node2)) { connectingElements = elementsConnectedToNode1; } else { IList <IFiniteElement> elementsConnectedToNode2 = this.GetAllElementsConnectedTo(node2); connectingElements = elementsConnectedToNode1.Intersect(elementsConnectedToNode2).ToList(); } return connectingElements; })); }
/// <summary> /// Order of nodes is ignored /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(ElementRepository.NodeTuple other) { return((object.Equals(this.n1, other.n1) && object.Equals(this.n2, other.n2)) || (object.Equals(this.n1, other.n2) && object.Equals(this.n2, other.n1))); }