1 / 102

1.04k likes | 1.31k Views

Data Structures for 3D Searching. partly based on: chapter 12 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner ) Slides by Marc van Kreveld. Data structures. Data structures for representation geometry (coordinates) topology (connectivity)

Download Presentation
## Data Structures for 3D Searching

**An Image/Link below is provided (as is) to download presentation**
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

**Data Structures for 3D Searching**partly based on: chapter 12 in Fundamentals of Computer Graphics, 3rd ed. (Shirley & Marschner) Slides by Marc van Kreveld**Data structures**• Data structures for representation • geometry (coordinates) • topology (connectivity) • attributes (anything else like material, …) • Data structures for searching • use the geometry to reduce the number objects that need be tested from all of them to some small subset • windowing queries, ray tracing, nearest neighbors 2**Data structures for searching**• Several steps in the algorithms we have seen until now can be sped up using data structures for efficient searching • Find the k nearest neighbors to each point(straightforward in O(n2) time; linear time per point) • Find the support of a plane tried in RANSAC (straightforward in O(n) time) • Test whether a mesh-changing operator causes self-intersections of the manifold (straightforward in O(n) time) • Also: for ray tracing, windowing 3**Data structures for searching**• Grid structure • Quadtree and Octree • Bounding Volume Hierarchy, R-tree • Kd-tree • BSP tree (Binary Space Partition) 4**Simple grid structure**• Also: cubical grid, cubic partitioning • Tile the space with equal-size cubes and store each object with every cube it intersects • The 3D grid is a 3D array of lists; list elements are pointers to the objects • Small grid cells: much storage overhead, but good for query time • Big grid cells: little storage overhead, worse query time 5**Simple grid structure**ray tracing query 7**Simple grid structure**k nearest neighbors query 8**Simple grid structure**RANSAC line support computation 9**Simple grid structure**windowing query 10**Simple grid structure**• A hierarchical version of a grid may give more efficient querying: one emptiness test at a higher level square may makeseveral tests at lower levelsquares unnecessary 11**Quadtrees and Octrees**• Tree version of the (hierarchical) square/cube grid • Storage requirements better than grid when large parts of the grid contain no objects • In a quadtree • the root corresponds to a bounding square • children correspond to four subsquares : NW, NE, SW, SE • nodes with 0 or 1 objects in their square are leaves • In an octree • the root corresponds to a bounding cube • children correspond to eight subcubes • nodes with 0 or 1 objects in their cube are leaves 12**Quadtrees and Octrees**NW NE NW NE SW SE root leaf leaf leaf storing one object SW SE 13**Quadtrees and Octrees**NW NE NW NE SW SE root leaf leaf leaf storing one object SW SE 14**Quadtrees and Octrees**NW NE This ray tracing query visits 10 nodes in the quadtree (12 squares in the original grid) SW SE 15**Quadtrees and Octrees**• Other queries are performed in the straightforward way • windowing query: easy • RANSAC support of line: determine all cells intersected by the strip, and test points in those cells only for inclusion in the strip, right normal, and therefore support • k nearest neighbors: explore cells further and further away from the query point until we know for sure that we have the k nearest neighbors explore all cells that intersect the circle centered at the query point and through the k-th closest point 16**Octree**18**Quadtrees and Octrees**• Often a quadtree or octree is not made deeper than a desired level of precision • E.g., given an object of 1 x 1 x 1 meters stored in a triangle mesh, store the triangles in an octree up to a cell size of 4 x 4 x 4 millimeters • Leaves that contain more than one object store them in a list (it is assumed that there would only be O(1) of them at this detail level) • Also possible: split a square/cube until at most some constant c objects or points intersect a cell 19**Bounding Volume Hierarchies**• Tree structure where internal nodes store bounding shapes of all objects in the subtree • If a query object intersects the bounding shape, it may intersect some object in that subtree, otherwise certainly not • Bounding shapes can be spheres, axis-parallel bounding boxes, or arbitrarily oriented bounding boxes; axis-parallel BB is most common 20**Bounding Volume Hierarchies**• In graphics usually binary trees • For huge data sets where the data must be on disk, usually higher-degree trees: R-tree 21**R-trees**• 2-dimensional version of the B-tree: B-tree of maximum degree 8; degree between 3 and 8 Internal nodes with k children have k – 1 split values 22**R-trees**• Can store: • a set of polygons (regions of a subdivision) • a set of polygonal lines (or boundaries) • a set of points • a mix of the above • Stored objects may overlap 23**R-trees**• Originally by Guttman, 1984 • Dozens of variations and optimizations since • Suitable for windowing, point location, intersection queries, and ray tracing • Heuristic structure, no order bounds ( O(..) ) • Example of a bounding volume hierarchy 24**Every internal node contains entries (rectangle, pointer to**child node) All leaves contain entries (rectangle, pointer to object) in database or file Rectangles are minimal axis-parallel bounding rectangles The root has 2 and M entries All other nodes have at least m and at most M entries All leaves have the same depth m > 1 and M > 2m(e.g. m = 200; M = 1000) R-trees 25**R-trees**• M is chosen so that a full node still (just) fits in a single block of disk memory • m is chosen depending on a trade-off in search time and update time • larger m: faster queries, slower updates • smaller m: slower queries, faster updates 26**Grouping of objects**Windowing query: the fewer rectangles intersected, the fewer subtrees to descend into 28**Grouping of objects**• Objects close together in same leaves small rectangles queries descend in only few subtrees • Group the child nodes under a parent node such that small rectangles arise 29**Heuristics for fast queries**• Small area of rectangles • Small perimeter of rectangles • Little overlap among rectangles • Well-filled nodes (tree less deep fewer disk accesses on each search path) 30**Searching in an R-tree**• Q is query object (point, window, object); we search for intersections with stored objects • For each rectangle R in the current node,if Q and R intersect, • search recursively in the subtree under the pointer at R (at an internal node) • get the object corresponding to R and test for intersection with R (at a leaf) 39**Nearest neighbor queries**• An R-tree can be used for nearest neighbor queries • The idea is to perform a DFS, maintain the closest object so far and use the distance for pruning pruned closest object so far queried 40**1**4 2 3 5 41**Inserting in an R-tree**• Determine minimal bounding rectangle of new object • When not yet at a leaf (choose subtree): • determine rectangle whose area increment after insertion of R is smallest • increase this rectangle if necessary and insert R • At a leaf: • if there is space, insert, otherwise Split Node 42**Split Node**• Divide the M+1 rectangles into two groups, each with at least m and at most M rectangles • Make a node for each group, with the rectangles and corresponding subtrees as entries • Hang the two new nodes under the parent node in the place of the overfull node; determine the new bounding rectangles (if the root was overfull, make a new root with two child nodes) • If the parent has M+1 children, repeat Split Node with this parent 48**Split Node, example**new bounding rectangles 49**Strategies for Split Node**• Determine R1 and R2 with largest bounding rectangle: the seeds for sets S1 and S2 • While |S1| , |S2| < M – m and not all rectangles distributed: • Take not yet distributed rectangle Rj, add tothe setwhose bounding rectangle increases least Linear R-tree of Guttman, 1984 50

More Related