Observation
|
00001 /* HiRISE Image Line 00002 00003 PIRL CVS ID: Image_Line.hh,v 1.37 2020/02/14 01:17:18 schaller Exp 00004 00005 Copyright (C) 2004-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_Image_Line_ 00020 #define _HiRISE_Image_Line_ 00021 00022 // UA::HiRISE 00023 #include "Data_Component.hh" 00024 #include "LUT.hh" 00025 00026 #if defined (INCLUDE_PVL) 00027 // idaeim::PVL 00028 #include "PVL.hh" 00029 #endif 00030 00031 #include <iostream> 00032 #include <string> 00033 00034 namespace UA 00035 { 00036 namespace HiRISE 00037 { 00038 // Forward references. 00039 class Line_Cache; 00040 00041 /******************************************************************************* 00042 Image_Line 00043 */ 00110 class Image_Line 00111 : public Data_Component 00112 { 00113 public: 00114 /*============================================================================== 00115 Constants: 00116 */ 00118 static const char* const 00119 ID; 00120 00122 static const char* const 00123 NAME; 00124 00135 enum Elements 00136 { 00137 // Line header Elements: 00138 Sync, 00139 Channel, 00140 Line_Number, 00141 00142 // Pixel Elements: 00143 Buffer_Pixels, 00144 Image_Pixels, 00145 Black_Pixels, 00146 Virtual_Pixels, 00147 00148 // The total number of Elements: 00149 Total_Elements 00150 }; 00151 00153 static const char* 00154 NAMES[]; 00155 00157 static const unsigned int 00158 LINE_HEADER_BYTES; 00160 static const unsigned int 00161 BUFFER_PIXELS_COUNT; 00163 static const unsigned int 00164 BLACK_PIXELS_COUNT; 00166 static const unsigned int 00167 MAX_VIRTUAL_PIXELS_COUNT; 00168 00175 static const unsigned int 00176 MAX_PIXELS_PER_LINE; 00177 00187 static const unsigned int 00188 DEFAULT_CALIBRATION_LINES; 00189 00191 static const Index 00192 MAX_COMPONENT_BYTES; 00193 00200 static const Index 00201 OFFSETS_TEMPLATE[]; 00202 00224 static const Index 00225 ARRAY_COUNTS_TEMPLATE[][2]; 00226 00235 static const u_int_32 00236 SYNC; 00237 00242 static const u_int_8 00243 SYNC_3; 00244 00249 static const u_int_8 00250 SYNC_2; 00251 00256 static const u_int_8 00257 SYNC_1_BIT_MASK; 00258 00261 static const u_int_8 00262 CHANNEL_BIT_MASK; 00263 00271 static const u_int_32 00272 LINE_NUMBER_MASK; 00273 00281 enum Sync_Type 00282 { 00283 No_Sync_Type, 00284 Line_Header_Sync_Type, 00285 FELICS_Sync_Type 00286 }; 00287 00289 static const char* 00290 Sync_Type_Names[]; 00291 00293 static const unsigned int 00294 DEFAULT_WIDTH; 00295 00296 /*============================================================================== 00297 Class (static) data: 00298 */ 00308 static unsigned int 00309 Calibration_Lines; 00310 00311 /*============================================================================== 00312 Constructors 00313 */ 00320 Image_Line (); 00321 00344 Image_Line 00345 ( 00346 unsigned int bytes_per_pixel, 00347 unsigned int total_pixels, 00348 unsigned int total_lines = 0, 00349 unsigned int channel_number = CCD_UNKNOWN, 00350 std::istream* stream = NULL 00351 ); 00352 00363 Image_Line (const Image_Line& component, bool duplicate = true); 00364 00374 Image_Line& operator= (const Image_Line& component); 00375 00381 virtual ~Image_Line (); 00382 00383 /*============================================================================== 00384 Accessors 00385 */ 00386 /* Identification: 00387 */ 00394 std::string id () const; 00395 00401 const char* name () const; 00402 00403 /*------------------------------------------------------------------------------ 00404 Line header 00405 */ 00415 u_int_32 sync () const; 00416 00426 Image_Line& sync (u_int_32 value); 00427 00435 u_int_32 channel () const; 00436 00445 Image_Line& channel (u_int_32 channel_number); 00446 00454 u_int_32 expected_channel () const 00455 {return Channel_Number;} 00456 00466 Image_Line& expected_channel (u_int_32 channel_number) 00467 {Channel_Number = channel_number; return *this;} 00468 00473 u_int_32 line_number () const; 00474 00480 Image_Line& line_number (u_int_32 line); 00481 00486 bool bad_line () const; 00487 00493 Image_Line& bad_line (bool state); 00494 00503 std::string bad_line_description () const; 00504 00505 /*------------------------------------------------------------------------------ 00506 Pixels 00507 */ 00521 Pixel_type pixel (Index index) const; 00522 00532 Pixel_type operator[] (Index index) const; 00533 00547 void pixel (Index index, Pixel_type value); 00548 00558 Pixel_type buffer_pixel (Index index) const; 00559 00571 void buffer_pixel (Index index, Pixel_type value); 00572 00582 Pixel_type image_pixel (Index index) const; 00583 00595 void image_pixel (Index index, Pixel_type value); 00596 00606 Pixel_type black_pixel (Index index) const; 00607 00619 void black_pixel (Index index, Pixel_type value); 00620 00630 Pixel_type virtual_pixel (Index index) const; 00631 00643 void virtual_pixel (Index index, Pixel_type value); 00644 00645 /*------------------------------------------------------------------------------ 00646 Structure 00647 */ 00658 unsigned int pixel_count () const 00659 {return Pixels_per_Line;} 00660 00678 Image_Line& pixel_count (unsigned int total_pixels); 00679 00684 unsigned int pixel_bytes () const; 00685 00696 Image_Line& pixel_bytes (unsigned int bytes_per_pixel); 00697 00704 unsigned int total_lines () const 00705 {return Total_Lines;} 00706 00721 Image_Line& total_lines (unsigned int lines); 00722 00727 static unsigned int calibration_lines () 00728 {return Calibration_Lines;} 00729 00747 static void calibration_lines (unsigned int lines); 00748 00782 void mirror (); 00783 00805 Image_Line& lookup (const LUT& lut); 00806 00826 Image_Line& pukool (Pixel_type *table); 00827 00828 /*============================================================================== 00829 Cache 00830 */ 00837 std::istream& source () const; 00838 00848 Image_Line& source (std::istream& stream); 00849 00874 bool next (); 00875 00887 unsigned int count () const; 00888 00904 unsigned long long bytes_read () const; 00905 00917 unsigned long long source_bytes () const; 00918 00924 bool compressed_data () const; 00925 00933 unsigned long long compressed_bytes () const; 00934 00942 unsigned long long decompressed_bytes () const; 00943 00954 Line_Cache* cache () 00955 {return Data_Cache;} 00956 00972 bool synchronization_lost (); 00973 00974 /*============================================================================== 00975 Printing 00976 */ 00990 std::ostream& print 00991 (std::ostream& stream = std::cout, bool verbose = false) const; 00992 00998 unsigned int width () const 00999 {return Width;} 01000 01009 Image_Line& width (unsigned int groups) 01010 {Width = groups; return *this;} 01011 01012 #if defined (INCLUDE_PVL) 01013 /*============================================================================== 01014 PVL 01015 */ 01024 idaeim::PVL::Aggregate* PVL () const; 01025 01048 idaeim::PVL::Aggregate* PVL_description () const; 01049 01050 #endif // defined (INCLUDE_PVL) 01051 01052 /*============================================================================== 01053 Validation 01054 */ 01062 bool is_valid () const; 01063 01064 /*============================================================================== 01065 Functions 01066 */ 01075 static bool is_sync (void* data_at); 01076 01094 static Sync_Type next_sync (std::istream& stream); 01095 01096 protected: 01097 /*============================================================================== 01098 Data 01099 */ 01101 unsigned int 01102 Pixels_per_Line; 01103 01105 unsigned int 01106 Bytes_per_Pixel; 01107 01109 unsigned int 01110 Total_Lines; 01111 01113 unsigned int 01114 Channel_Number; 01115 01117 Line_Cache 01118 *Data_Cache; 01119 01120 /*.............................................................................. 01121 List formatting 01122 */ 01124 unsigned int 01125 Width; 01126 01127 }; // class Image_Line 01128 01129 } // namespace HiRISE 01130 } // namespace UA 01131 #endif