/// <summary> /// Store the given OrganizedPoint in an organized (spatially hashed) manner. /// </summary> /// <param name="op">The OrganizedPoint to store.</param> public void StoreAndOrganizePoint(OrganizedPoint op) { int sX = (int)((op.Position.X - op.Position.X % LineCurveTool.SectionSizeDouble) / LineCurveTool.SectionSizeDouble); int sY = (int)((op.Position.Y - op.Position.Y % LineCurveTool.SectionSizeDouble) / LineCurveTool.SectionSizeDouble); Dictionary <int, List <OrganizedPoint> > xSection; List <OrganizedPoint> ySection; //Ensure that the xSection for this particular point exists. if (!collection.TryGetValue(sX, out xSection)) { //This particular X section does not exist yet; create it. xSection = new Dictionary <int, List <OrganizedPoint> >(); collection.Add(sX, xSection); } //Ensure that the ySection (which is contained within the respective xSection) for this particular point exists. if (!xSection.TryGetValue(sY, out ySection)) { //This particular Y section does not exist yet; create it. ySection = new List <OrganizedPoint>(); xSection.Add(sY, ySection); } //Now that both the corresponding xSection and ySection for this particular point exist, add the point to the list. ySection.Add(op); }
/// <summary> /// Store the given OrganizedPoint in an organized (spatially hashed) manner. /// </summary> /// <param name="op">The OrganizedPoint to store.</param> public void StoreAndOrganizePoint(OrganizedPoint op) { int sX = (int)((op.Position.X - op.Position.X % SectionSize) / SectionSize); int sY = (int)((op.Position.Y - op.Position.Y % SectionSize) / SectionSize); Dictionary<int, List<OrganizedPoint>> xSection; List<OrganizedPoint> ySection; //Ensure that the xSection for this particular point exists. if (!collection.TryGetValue(sX, out xSection)) { //This particular X section does not exist yet; create it. xSection = new Dictionary<int, List<OrganizedPoint>>(); collection.Add(sX, xSection); } //Ensure that the ySection (which is contained within the respective xSection) for this particular point exists. if (!xSection.TryGetValue(sY, out ySection)) { //This particular Y section does not exist yet; create it. ySection = new List<OrganizedPoint>(); xSection.Add(sY, ySection); } //Now that both the corresponding xSection and ySection for this particular point exist, add the point to the list. ySection.Add(op); }