romgrk-2d-geometry
Version:
Javascript library for 2d geometry
55 lines • 1.93 kB
TypeScript
import { Box } from '../classes/Box';
import type { Point } from '../classes/Point';
import { IntervalTree } from '../data_structures/interval-tree';
type AnyShape = {
box: Box;
};
/**
* Class representing a planar set - a generic container with ability to keep and retrieve shapes and
* perform spatial queries. Planar set is an extension of Set container, so it supports
* Set properties and methods
*/
export declare class PlanarSet extends Set {
index: IntervalTree;
/**
* Create new instance of PlanarSet
* @param shapes - array or set of geometric objects to store in planar set
* Each object should have a <b>box</b> property
*/
constructor(shapes?: AnyShape[]);
/**
* Add new shape to planar set and to its spatial index.<br/>
* If shape already exist, it will not be added again.
* This happens with no error, it is possible to use <i>size</i> property to check if
* a shape was actually added.<br/>
* Method returns planar set object updated and may be chained
* @param shape - shape to be added, should have valid <i>box</i> property
*/
add(shape: AnyShape): this;
/**
* Delete shape from planar set. Returns true if shape was actually deleted, false otherwise
* @param shape - shape to be deleted
*/
delete(shape: AnyShape): boolean;
/**
* Clear planar set
*/
clear(): void;
/**
* 2d range search in planar set.<br/>
* Returns array of all shapes in planar set which bounding box is intersected with query box
* @param box - query box
*/
search(box: Box): any[];
/**
* Point location test. Returns array of shapes which contains given point
* @param point - query point
*/
hit(point: Point): any[];
/**
* Returns svg string to draw all shapes in planar set
*/
svg(): string;
}
export {};
//# sourceMappingURL=planar_set.d.ts.map