1 /* 2 =============================================================================== 3 4 FILE: lasinterval.hpp 5 6 CONTENTS: 7 8 Used by lasindex to manage intervals of consecutive LiDAR points that are 9 read sequentially. 10 11 PROGRAMMERS: 12 13 martin.isenburg@rapidlasso.com - http://rapidlasso.com 14 15 COPYRIGHT: 16 17 (c) 2007-2015, martin isenburg, rapidlasso - fast tools to catch reality 18 19 This is free software; you can redistribute and/or modify it under the 20 terms of the GNU Lesser General Licence as published by the Free Software 21 Foundation. See the LICENSE.txt file for more information. 22 23 This software is distributed WITHOUT ANY WARRANTY and without even the 24 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 26 CHANGE HISTORY: 27 28 20 October 2018 -- fixed rare bug in merge_intervals() when verbose is TRUE 29 29 April 2011 -- created after cable outage during the royal wedding (-: 30 31 =============================================================================== 32 */ 33 #ifndef LAS_INTERVAL_HPP 34 #define LAS_INTERVAL_HPP 35 36 #include "mydefs.hpp" 37 38 class ByteStreamIn; 39 class ByteStreamOut; 40 41 class LASintervalCell 42 { 43 public: 44 U32 start; 45 U32 end; 46 LASintervalCell* next; 47 LASintervalCell(); 48 LASintervalCell(const U32 p_index); 49 LASintervalCell(const LASintervalCell* cell); 50 }; 51 52 class LASintervalStartCell : public LASintervalCell 53 { 54 public: 55 U32 full; 56 U32 total; 57 LASintervalCell* last; 58 LASintervalStartCell(); 59 LASintervalStartCell(const U32 p_index); 60 BOOL add(const U32 p_index, const U32 threshold=1000); 61 }; 62 63 class LASinterval 64 { 65 public: 66 LASinterval(const U32 threshold=1000); 67 ~LASinterval(); 68 69 // add points and create cells with intervals 70 BOOL add(const U32 p_index, const I32 c_index); 71 72 // get total number of cells 73 U32 get_number_cells() const; 74 75 // get total number of intervals 76 U32 get_number_intervals() const; 77 78 // merge cells (and their intervals) into one cell 79 BOOL merge_cells(const U32 num_indices, const I32* indices, const I32 new_index); 80 81 // merge adjacent intervals with small gaps in cells to reduce total interval number to maximum 82 void merge_intervals(U32 maximum, const BOOL verbose=TRUE); 83 84 // read from file or write to file 85 BOOL read(ByteStreamIn* stream); 86 BOOL write(ByteStreamOut* stream) const; 87 88 // get one cell after the other 89 void get_cells(); 90 BOOL has_cells(); 91 92 // get a particular cell 93 BOOL get_cell(const I32 c_index); 94 95 // add cell's intervals to those that will be merged 96 BOOL add_current_cell_to_merge_cell_set(); 97 BOOL add_cell_to_merge_cell_set(const I32 c_index, const BOOL erase=FALSE); 98 BOOL merge(const BOOL erase=FALSE); 99 void clear_merge_cell_set(); 100 BOOL get_merged_cell(); 101 102 // iterate intervals of current cell (or over merged intervals) 103 BOOL has_intervals(); 104 105 I32 index; 106 U32 start; 107 U32 end; 108 U32 full; 109 U32 total; 110 111 private: 112 void* cells; 113 void* cells_to_merge; 114 U32 threshold; 115 U32 number_intervals; 116 I32 last_index; 117 LASintervalStartCell* last_cell; 118 LASintervalCell* current_cell; 119 LASintervalStartCell* merged_cells; 120 BOOL merged_cells_temporary; 121 }; 122 123 #endif 124