UNPKG

js-subpcd

Version:

🌟 High-performance JavaScript/TypeScript QuadTree point cloud filtering and processing library. Published on npm as js-subpcd with PCL.js compatible API for spatial filtering, subsampling, and nearest neighbor search.

91 lines (90 loc) • 2.13 kB
/** * Simple QuadTree implementation for Node.js fallback * Used when WebAssembly is not available or for smaller datasets */ export interface QuadTreeBoundary { x: number; y: number; width: number; height: number; } export interface QuadTreePoint { x: number; y: number; z?: number; index?: number; [key: string]: any; } /** * Simple QuadTree implementation */ export declare class SimpleQuadTree { boundary: QuadTreeBoundary; capacity: number; maxDepth: number; depth: number; points: QuadTreePoint[]; divided: boolean; northeast: SimpleQuadTree | null; northwest: SimpleQuadTree | null; southeast: SimpleQuadTree | null; southwest: SimpleQuadTree | null; constructor(boundary: QuadTreeBoundary, capacity?: number, maxDepth?: number, depth?: number); /** * Insert a point into the quadtree */ insert(point: QuadTreePoint): boolean; /** * Check if a point is within the boundary */ private contains; /** * Subdivide the quadtree into four quadrants */ private subdivide; /** * Query points within a rectangular range */ query(range: QuadTreeBoundary, found?: QuadTreePoint[]): QuadTreePoint[]; /** * Check if the range intersects with the boundary */ private intersects; /** * Check if a point is within the range */ private inRange; /** * Get all points in the quadtree */ getAllPoints(found?: QuadTreePoint[]): QuadTreePoint[]; /** * Clear all points from the quadtree */ clear(): void; /** * Get the total number of points */ size(): number; /** * Get statistics about the quadtree */ getStatistics(): { totalPoints: number; depth: number; nodes: number; leafNodes: number; }; /** * Get the maximum depth of the quadtree */ private getMaxDepth; /** * Get the total number of nodes */ private getNodeCount; /** * Get the number of leaf nodes */ private getLeafNodeCount; }