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 bool AddChild_NoUpdate(IMarkGeometry vector, Color bgColor, Color fgColor) { if (Geometry == null) { if (!ShapeIsRegion(vector)) { return(false); } Geometry = vector; Geometry.Fill = fgColor; return(true); } if (!GeometricArithmeticModule.IsWithin2D(vector, Geometry)) { return(false); } foreach (var child in Children) { if (child is MarkGeometryTree && GeometricArithmeticModule.IsWithin2D(vector, child)) { if (!(child as MarkGeometryTree).AddChild_NoUpdate(vector, fgColor, bgColor)) { vector.Fill = bgColor; Children.Add(vector); } return(true); } } if (ShapeIsRegion(vector)) { Children.Add(new MarkGeometryTree(vector, fgColor, bgColor)); } else { vector.Fill = bgColor; Children.Add(vector); } return(true); }