public void AddElement(IElement pElement) { if (pElement == null) { return; } if (m_nDepth > 0) { if (pElement.TestContain(m_fTLMinX, m_fTLMaxX, m_fTLMinZ, m_fTLMaxZ)) { if (m_pTopLeft == null) { m_pTopLeft = m_pTree.CreateTreeNode(); m_pTopLeft.Init(m_fTLMinX, m_fTLMaxX, m_fTLMinZ, m_fTLMaxZ, m_nDepth - 1, this, m_pTree); } m_pTopLeft.AddElement(pElement); return; } else if (pElement.TestContain(m_fTRMinX, m_fTRMaxX, m_fTRMinZ, m_fTRMaxZ)) { if (m_pTopRight == null) { m_pTopRight = m_pTree.CreateTreeNode(); m_pTopRight.Init(m_fTRMinX, m_fTRMaxX, m_fTRMinZ, m_fTRMaxZ, m_nDepth - 1, this, m_pTree); } m_pTopRight.AddElement(pElement); return; } else if (pElement.TestContain(m_fBLMinX, m_fBLMaxX, m_fBLMinZ, m_fBLMaxZ)) { if (m_pBottomLeft == null) { m_pBottomLeft = m_pTree.CreateTreeNode(); m_pBottomLeft.Init(m_fBLMinX, m_fBLMaxX, m_fBLMinZ, m_fBLMaxZ, m_nDepth - 1, this, m_pTree); } m_pBottomLeft.AddElement(pElement); return; } else if (pElement.TestContain(m_fBRMinX, m_fBRMaxX, m_fBRMinZ, m_fBRMaxZ)) { if (m_pBottomRight == null) { m_pBottomRight = m_pTree.CreateTreeNode(); m_pBottomRight.Init(m_fBRMinX, m_fBRMaxX, m_fBRMinZ, m_fBRMaxZ, m_nDepth - 1, this, m_pTree); } m_pBottomRight.AddElement(pElement); return; } } m_lstElement.Add(pElement); }
public void AddElement(IElement pElement) { if (pElement == null) { return; } if (pElement.TestContain(m_pRoot.m_fMinX, m_pRoot.m_fMaxX, m_pRoot.m_fMinZ, m_pRoot.m_fMaxZ)) { m_pRoot.AddElement(pElement); } else { m_lstElement.Add(pElement); } }