|
|
Observation
|
00001 /* HiRISE Gap Map 00002 00003 PIRL CVS ID: Gap_Map.hh,v 1.11 2026/07/22 01:33:18 guym Exp 00004 00005 Copyright (C) 2005-2020 Arizona Board of Regents on behalf of the Lunar and 00006 Planetary Laboratory at the University of Arizona. 00007 00008 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 00009 this file except in compliance with the License. You may obtain a copy of the 00010 License at 00011 00012 http://www.apache.org/licenses/LICENSE-2.0 00013 00014 Unless required by applicable law or agreed to in writing, software distributed 00015 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 CONDITIONS OF ANY KIND, either express or implied. See the License for the 00017 specific language governing permissions and limitations under the License. 00018 */ 00019 #ifndef _HIRISE_GAP_MAP_ 00020 #define _HIRISE_GAP_MAP_ 00021 00022 #include "Data_Component.hh" 00023 00024 #if defined (INCLUDE_PVL) 00025 // idaeim::PVL 00026 #include "PVL.hh" 00027 #endif 00028 00029 #include <iosfwd> 00030 #include <string> 00031 #include <vector> 00032 #include <utility> 00033 00034 namespace UA 00035 { 00036 namespace HiRISE 00037 { 00038 /******************************************************************************* 00039 Gap_Map 00040 */ 00068 class Gap_Map 00069 : public Data_Component 00070 { 00071 public: 00072 using Data_Component::get; 00073 using Data_Component::put; 00074 /*============================================================================== 00075 Types: 00076 */ 00078 typedef u_int_32 Location; 00079 00081 typedef std::pair<Location, Location> Range; 00082 00084 typedef std::vector<Range> List; 00085 00086 /*============================================================================== 00087 Constants: 00088 */ 00090 static const char* const 00091 ID; 00092 00094 static const char* const 00095 NAME; 00096 00098 enum End_Point 00099 { 00100 RANGE_START, 00101 RANGE_END 00102 }; 00103 00105 static const char* const 00106 END_POINT_NAMES[]; 00107 00109 enum 00110 { 00111 INSIDE = -1, 00112 OUTSIDE = 0, 00113 OVERLAP = 1 00114 }; 00115 00120 static const unsigned int 00121 DEFAULT_SEQUENCE_THRESHOLD; 00122 00124 static const u_int_8 00125 GAP_BYTE_VALUE; 00126 00127 /*============================================================================== 00128 Constructors 00129 */ 00132 Gap_Map (); 00133 00144 Gap_Map (std::istream& stream, unsigned int count); 00145 00153 Gap_Map (const Gap_Map& map, bool data_duplicate = true); 00154 00159 Gap_Map& operator= (const Gap_Map& map); 00160 00161 /*============================================================================== 00162 Accessors 00163 */ 00170 virtual std::string id () const; 00171 00177 virtual const char* name () const; 00178 00187 virtual Location get (Index range, End_Point end_point) const; 00188 00198 Gap_Map::Range gap (Index range) const; 00199 00206 Gap_Map::List gaps () const; 00207 00212 unsigned int total_gaps () const 00213 {return count_of (0) >> 1;} 00214 00220 bool in_gap (const Location location) const; 00221 00237 int in_gap (const Location start, const Location end) const; 00238 00249 int in_gap (const Gap_Map::Range& range) const 00250 {return in_gap (range.first, range.second);} 00251 00252 /*============================================================================== 00253 Manipulators 00254 */ 00281 Gap_Map& set (const Location start, const Location end); 00282 00289 Gap_Map& set (const Gap_Map::Range& range) 00290 {return set (range.first, range.second);} 00291 00298 Gap_Map& set (const Gap_Map::List list); 00299 00320 Gap_Map& clear (const Location start, const Location end); 00321 00326 Gap_Map& clear () 00327 {return clear (0, (Location)-1);} 00328 00335 Gap_Map& clear (const Gap_Map::Range& range) 00336 {return clear (range.first, range.second);} 00337 00344 Gap_Map& clear (const Gap_Map::List list); 00345 00356 Gap_Map& shift (int_32 amount); 00357 00358 /*------------------------------------------------------------------------------ 00359 Direct range manipulation. 00360 */ 00361 protected: 00362 00374 virtual Data_Component& put 00375 (const Location location, Index range, End_Point end_point); 00376 00394 Gap_Map& insert_range (Index range, Location start, Location end); 00395 00408 Gap_Map& remove_range (Index first, Index last = (Index)-1); 00409 00410 /*============================================================================== 00411 Printing 00412 */ 00413 public: 00452 virtual std::ostream& print 00453 (std::ostream& stream = std::cout, bool verbose = false) const; 00454 00455 #if defined (INCLUDE_PVL) 00456 /*============================================================================== 00457 PVL 00458 */ 00467 virtual idaeim::PVL::Aggregate* PVL () const; 00468 00478 idaeim::PVL::Aggregate* PVL_description () const; 00479 00480 #endif // defined (INCLUDE_PVL) 00481 00482 /*============================================================================== 00483 Validation 00484 */ 00489 virtual bool is_valid () const; 00490 00491 /*============================================================================== 00492 Utility 00493 */ 00508 static Gap_Map::List gaps_in 00509 (void* start, void* end, unsigned int threshold = 0); 00510 00524 static unsigned int sequence_threshold (unsigned int threshold = 0); 00525 00537 static Gap_Map::Range& shift (Gap_Map::Range& range, int_32 amount); 00538 00546 static Gap_Map::List& shift (Gap_Map::List& list, int_32 amount); 00547 00548 /*------------------------------------------------------------------------------ 00549 Data 00550 */ 00551 private: 00552 00554 static unsigned int 00555 Sequence_Threshold; 00556 00558 u_int_32 00559 Map_Storage_Amount; 00560 00561 }; // class Gap_Map 00562 00563 /*============================================================================== 00564 Helper functions 00565 */ 00573 std::ostream& operator<< 00574 (std::ostream& stream, const Gap_Map& map); 00575 00576 00577 } // namespace HiRISE 00578 } // namespace UA 00579 #endif
1.7.2