![]() |
Observation
|
00001 /* HiRISE Gap Map 00002 00003 PIRL CVS ID: Gap_Map.hh,v 1.10 2020/02/25 00:16:17 schaller 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 /*============================================================================== 00073 Types: 00074 */ 00076 typedef u_int_32 Location; 00077 00079 typedef std::pair<Location, Location> Range; 00080 00082 typedef std::vector<Range> List; 00083 00084 /*============================================================================== 00085 Constants: 00086 */ 00088 static const char* const 00089 ID; 00090 00092 static const char* const 00093 NAME; 00094 00096 enum End_Point 00097 { 00098 RANGE_START, 00099 RANGE_END 00100 }; 00101 00103 static const char* const 00104 END_POINT_NAMES[]; 00105 00107 enum 00108 { 00109 INSIDE = -1, 00110 OUTSIDE = 0, 00111 OVERLAP = 1 00112 }; 00113 00118 static const unsigned int 00119 DEFAULT_SEQUENCE_THRESHOLD; 00120 00122 static const u_int_8 00123 GAP_BYTE_VALUE; 00124 00125 /*============================================================================== 00126 Constructors 00127 */ 00130 Gap_Map (); 00131 00142 Gap_Map (std::istream& stream, unsigned int count); 00143 00151 Gap_Map (const Gap_Map& map, bool data_duplicate = true); 00152 00157 Gap_Map& operator= (const Gap_Map& map); 00158 00159 /*============================================================================== 00160 Accessors 00161 */ 00168 virtual std::string id () const; 00169 00175 virtual const char* name () const; 00176 00185 virtual Location get (Index range, End_Point end_point) const; 00186 00196 Gap_Map::Range gap (Index range) const; 00197 00204 Gap_Map::List gaps () const; 00205 00210 unsigned int total_gaps () const 00211 {return count_of (0) >> 1;} 00212 00218 bool in_gap (const Location location) const; 00219 00235 int in_gap (const Location start, const Location end) const; 00236 00247 int in_gap (const Gap_Map::Range& range) const 00248 {return in_gap (range.first, range.second);} 00249 00250 /*============================================================================== 00251 Manipulators 00252 */ 00279 Gap_Map& set (const Location start, const Location end); 00280 00287 Gap_Map& set (const Gap_Map::Range& range) 00288 {return set (range.first, range.second);} 00289 00296 Gap_Map& set (const Gap_Map::List list); 00297 00318 Gap_Map& clear (const Location start, const Location end); 00319 00324 Gap_Map& clear () 00325 {return clear (0, (Location)-1);} 00326 00333 Gap_Map& clear (const Gap_Map::Range& range) 00334 {return clear (range.first, range.second);} 00335 00342 Gap_Map& clear (const Gap_Map::List list); 00343 00354 Gap_Map& shift (int_32 amount); 00355 00356 /*------------------------------------------------------------------------------ 00357 Direct range manipulation. 00358 */ 00359 protected: 00360 00372 virtual Data_Component& put 00373 (const Location location, Index range, End_Point end_point); 00374 00392 Gap_Map& insert_range (Index range, Location start, Location end); 00393 00406 Gap_Map& remove_range (Index first, Index last = (Index)-1); 00407 00408 /*============================================================================== 00409 Printing 00410 */ 00411 public: 00450 virtual std::ostream& print 00451 (std::ostream& stream = std::cout, bool verbose = false) const; 00452 00453 #if defined (INCLUDE_PVL) 00454 /*============================================================================== 00455 PVL 00456 */ 00465 virtual idaeim::PVL::Aggregate* PVL () const; 00466 00476 idaeim::PVL::Aggregate* PVL_description () const; 00477 00478 #endif // defined (INCLUDE_PVL) 00479 00480 /*============================================================================== 00481 Validation 00482 */ 00487 virtual bool is_valid () const; 00488 00489 /*============================================================================== 00490 Utility 00491 */ 00506 static Gap_Map::List gaps_in 00507 (void* start, void* end, unsigned int threshold = 0); 00508 00522 static unsigned int sequence_threshold (unsigned int threshold = 0); 00523 00535 static Gap_Map::Range& shift (Gap_Map::Range& range, int_32 amount); 00536 00544 static Gap_Map::List& shift (Gap_Map::List& list, int_32 amount); 00545 00546 /*------------------------------------------------------------------------------ 00547 Data 00548 */ 00549 private: 00550 00552 static unsigned int 00553 Sequence_Threshold; 00554 00556 u_int_32 00557 Map_Storage_Amount; 00558 00559 }; // class Gap_Map 00560 00561 /*============================================================================== 00562 Helper functions 00563 */ 00571 std::ostream& operator<< 00572 (std::ostream& stream, const Gap_Map& map); 00573 00574 00575 } // namespace HiRISE 00576 } // namespace UA 00577 #endif