/// <summary> /// Set the child for this Node /// </summary> /// <param name="matID">Material ID of the parentNode</param> /// <param name="childNode">ChildNode to be added</param> public bool SetChild(ushort matID, ChildNode childNode) { if (childNode == null) { throw new Exception("Childnode was null in SetChild method"); } if (!m_ElementParentNodeDictionary.ContainsKey(matID)) //the first time a HP is being added to this MatID { var tempElementparentNode = new ElementParentNode(); tempElementparentNode.ChildNodeDictionary.Add(childNode.Handle, childNode); m_ElementParentNodeDictionary.Add(matID, tempElementparentNode); } else { //this means there is already a HP added, let's see if it's not the same one again if (!m_ElementParentNodeDictionary[matID].ChildNodeDictionary.ContainsKey(childNode.Handle)) { m_ElementParentNodeDictionary[matID].ChildNodeDictionary.Add(childNode.Handle, childNode); } else { return(false); } } return(true); }
/// <summary> /// Sets boundingBox for the given ID /// </summary> /// <param name="matID">Material ID linked with this BB</param> public void SetBoundingBox(ushort matID, BoundingBox bb) { if (!m_ElementParentNodeDictionary.ContainsKey(matID)) //the key does not exists yet //this means the node doesn't have a HP added { var tempElementparentNode = new ElementParentNode { BoundingBox = bb }; m_ElementParentNodeDictionary.Add(matID, tempElementparentNode); } else { m_ElementParentNodeDictionary[matID].BoundingBox = bb; } }
/// <summary> /// Sets the sub-node's placeholder value /// </summary> /// <param name="matID"></param> public void SetPlaceHolderID(ushort matID) { if (!m_ElementParentNodeDictionary.ContainsKey(matID)) { //Create placeholder parentNode var tempElementParentNode = new ElementParentNode() { Placeholder = true }; m_ElementParentNodeDictionary.Add(matID, tempElementParentNode); //Create empty element node with empty bitArray for selection var tempElementNode = new ElementNode() { MaterialIDFaceBitArray = new BitArray(0), MaterialIDFaceIBitArraySelection = m_Global.BitArray.Create(0) }; m_ElementNodeDictionary.Add(matID, tempElementNode); } else { throw new Exception("We shouldn't set an already existing node to PlaceHolder. (MasterNode.cs)"); } }