lasquadtree.hpp
Go to the documentation of this file.
1 /*
2 ===============================================================================
3 
4  FILE: lasquadtree.hpp
5 
6  CONTENTS:
7 
8  An efficient quadtree that can be used for spatial indexing, for tiling,
9  for sorting into space-filling curve order, and for injecting spatial
10  finalization tags to be used in memory-efficienct streaming algorithms.
11 
12  PROGRAMMERS:
13 
14  martin.isenburg@gmail.com
15 
16  COPYRIGHT:
17 
18  (c) 2009-11, Martin Isenburg, LASSO - tools to catch reality
19 
20  This is free software; you can redistribute and/or modify it under the
21  terms of the GNU Lesser General Licence as published by the Free Software
22  Foundation. See the COPYING file for more information.
23 
24  This software is distributed WITHOUT ANY WARRANTY and without even the
25  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 
27  CHANGE HISTORY:
28 
29  11 May 2011 -- moved into LASlib so that LASreader supports spatial indexing
30  19 January 2011 -- created after mara met with silke to talk about africa
31 
32 ===============================================================================
33 */
34 #ifndef LAS_QUADTREE_HPP
35 #define LAS_QUADTREE_HPP
36 
37 #include "lasspatial.hpp"
38 
39 class LASquadtree : public LASspatial
40 {
41 public:
42  LASquadtree();
43  ~LASquadtree();
44 
45  // read from file or write to file
46  BOOL read(ByteStreamIn* stream);
47  BOOL write(ByteStreamOut* stream) const;
48 
49  // create or finalize the cell (in the spatial hierarchy)
50  BOOL manage_cell(const U32 cell_index, const BOOL finalize=FALSE);
51 
52  // map points to cells
53  BOOL inside(const F64 x, const F64 y) const;
54  U32 get_cell_index(const F64 x, const F64 y) const;
55 
56  // map cells to coarser cells
57  BOOL coarsen(const I32 cell_index, I32* coarser_cell_index, U32* num_cell_indices, I32** cell_indices) const;
58 
59  // describe cells
60  void get_cell_bounding_box(const I32 cell_index, F32* min, F32* max) const;
61  void get_cell_bounding_box(const F64 x, const F64 y, F32* min, F32* max) const;
62 
63  // decribe spatial extend
64  F64 get_min_x() const { return min_x; };
65  F64 get_min_y() const { return min_y; };
66  F64 get_max_x() const { return max_x; };
67  F64 get_max_y() const { return max_y; };
68 
69  // query spatial intersections
70  U32 intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y);
71  U32 intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size);
72  U32 intersect_circle(const F64 center_x, const F64 center_y, const F64 radius);
73 
74  // iterate over cells
78 
79  // for LASquadtree
80  BOOL setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, F32 cell_size = 1000.0f);
82 
83  // additional index queries
84  U32 get_level_index(const F64 x, const F64 y, U32 level) const;
85  U32 get_level_index(const F64 x, const F64 y) const;
86  U32 get_level_index(const F64 x, const F64 y, U32 level, F32* min, F32* max) const;
87  U32 get_level_index(const F64 x, const F64 y, F32* min, F32* max) const;
88  U32 get_cell_index(const F64 x, const F64 y, U32 level) const;
89 
90  // additional bounding box queries
91  void get_cell_bounding_box(const F64 x, const F64 y, U32 level, F32* min, F32* max) const;
92  void get_cell_bounding_box(U32 level_index, U32 level, F32* min, F32* max) const;
93  void get_cell_bounding_box(U32 level_index, F32* min, F32* max) const;
94 
95  // index conversions
96  U32 get_level(U32 cell_index) const;
97 
98  U32 get_level_index(U32 cell_index, U32 level) const;
99  U32 get_level_index(U32 cell_index) const;
100 
101  U32 get_cell_index(U32 level_index, U32 level) const;
102  U32 get_cell_index(U32 level_index) const;
103 
104  // convenience functions
105  U32 get_max_level_index(U32 level) const;
106  U32 get_max_level_index() const;
107 
108  U32 get_max_cell_index(U32 level) const;
109  U32 get_max_cell_index() const;
110 
111  U32* raster_occupancy(BOOL(*does_cell_exist)(I32), U32 level) const;
112  U32* raster_occupancy(BOOL(*does_cell_exist)(I32)) const;
113 
122 
123  // spatial queries
124  U32 intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, U32 level);
125  U32 intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size, U32 level);
126  U32 intersect_circle(const F64 center_x, const F64 center_y, const F64 radius, U32 level);
127 
128 private:
135 
136  void intersect_rectangle_with_cells(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
137  void intersect_rectangle_with_cells_adaptive(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
138  void intersect_tile_with_cells(const F32 ll_x, const F32 ll_y, const F32 ur_x, const F32 ur_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
139  void intersect_tile_with_cells_adaptive(const F32 ll_x, const F32 ll_y, const F32 ur_x, const F32 ur_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
140  void intersect_circle_with_cells(const F64 center_x, const F64 center_y, const F64 radius, const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
141  void intersect_circle_with_cells_adaptive(const F64 center_x, const F64 center_y, const F64 radius, const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index);
142  BOOL intersect_circle_with_rectangle(const F64 center_x, const F64 center_y, const F64 radius, const F32 r_min_x, const F32 r_max_x, const F32 r_min_y, const F32 r_max_y);
143  void raster_occupancy(BOOL(*does_cell_exist)(I32), U32* data, U32 min_x, U32 min_y, U32 level_index, U32 level, U32 stop_level) const;
146 };
147 
148 #endif
void get_cell_bounding_box(const I32 cell_index, F32 *min, F32 *max) const
U32 get_level(U32 cell_index) const
int BOOL
Definition: mydefs.hpp:57
F64 get_max_x() const
Definition: lasquadtree.hpp:66
BOOL get_intersected_cells()
#define FALSE
Definition: mydefs.hpp:133
U32 get_max_level_index() const
U32 intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y)
void * current_cells
float F32
Definition: mydefs.hpp:51
void intersect_rectangle_with_cells(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
BOOL subtiling_setup(F32 min_x, F32 max_x, F32 min_y, F32 max_y, U32 sub_level, U32 sub_level_index, U32 levels)
F64 get_min_y() const
Definition: lasquadtree.hpp:65
unsigned int U32
Definition: mydefs.hpp:39
void intersect_circle_with_cells(const F64 center_x, const F64 center_y, const F64 radius, const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
BOOL inside(const F64 x, const F64 y) const
BOOL manage_cell(const U32 cell_index, const BOOL finalize=FALSE)
U32 intersect_circle(const F64 center_x, const F64 center_y, const F64 radius)
U32 get_max_cell_index() const
F64 get_min_x() const
Definition: lasquadtree.hpp:64
U32 get_level_index(const F64 x, const F64 y, U32 level) const
BOOL get_all_cells()
BOOL setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, F32 cell_size=1000.0f)
BOOL read(ByteStreamIn *stream)
F64 get_max_y() const
Definition: lasquadtree.hpp:67
BOOL has_more_cells()
BOOL coarsen(const I32 cell_index, I32 *coarser_cell_index, U32 *num_cell_indices, I32 **cell_indices) const
BOOL write(ByteStreamOut *stream) const
U32 intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size)
U32 coarser_indices[4]
BOOL intersect_circle_with_rectangle(const F64 center_x, const F64 center_y, const F64 radius, const F32 r_min_x, const F32 r_max_x, const F32 r_min_y, const F32 r_max_y)
U32 get_cell_index(const F64 x, const F64 y) const
int I32
Definition: mydefs.hpp:35
U32 level_offset[24]
void intersect_rectangle_with_cells_adaptive(const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
void intersect_tile_with_cells(const F32 ll_x, const F32 ll_y, const F32 ur_x, const F32 ur_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
U32 * raster_occupancy(BOOL(*does_cell_exist)(I32), U32 level) const
void intersect_tile_with_cells_adaptive(const F32 ll_x, const F32 ll_y, const F32 ur_x, const F32 ur_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
void intersect_circle_with_cells_adaptive(const F64 center_x, const F64 center_y, const F64 radius, const F64 r_min_x, const F64 r_min_y, const F64 r_max_x, const F64 r_max_y, const F32 cell_min_x, const F32 cell_max_x, const F32 cell_min_y, const F32 cell_max_y, U32 level, U32 level_index)
double F64
Definition: mydefs.hpp:52


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:07