public bool Insert(MarkGeometryLine line) { if ( !( GeometricArithmeticModule.IsWithin2D(line.StartPoint, Boundary.Extents) && GeometricArithmeticModule.IsWithin2D(line.EndPoint, Boundary.Extents) ) ) { return(false); } // ensure quads exist if (!ChildrenExists) { var radius = 0.5 * SubSize; NorthWest = new ContourQuadTree( Boundary.Extents.MinX + radius, // west Boundary.Extents.MaxY - radius, // north SubSize ); NorthEast = new ContourQuadTree( Boundary.Extents.MaxX - radius, // east Boundary.Extents.MaxY - radius, // north SubSize ); SouthWest = new ContourQuadTree( Boundary.Extents.MinX + radius, // west Boundary.Extents.MinY + radius, // south SubSize ); SouthEast = new ContourQuadTree( Boundary.Extents.MaxX - radius, // east Boundary.Extents.MinY + radius, // south SubSize ); ChildrenExists = true; } if ( (line.Length <= MinSize) || !( NorthWest.Insert(line) || NorthEast.Insert(line) || SouthWest.Insert(line) || SouthEast.Insert(line) ) ) { Segments.Add(line); } return(true); }
public void Insert(Point pt) { if (!_rectangle.Contains(pt)) { return; } if (ptList.Count < CAPACITY) { ptList.Add(pt); } else { if (!divided) { SubDivide(); } NorthEast.Insert(pt); SouthEast.Insert(pt); SouthWest.Insert(pt); NorthWest.Insert(pt); } }