GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsImageLongLong.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsImageLongLong.cpp - Long long integer FITS image class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GFitsImageLongLong.cpp
23 * @brief Long long integer FITS image class implementation
24 * @author Juergen Knoedlseder
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GException.hpp"
32#include "GFitsCfitsio.hpp"
34
35/* __ Method name definitions ____________________________________________ */
36
37/* __ Macros _____________________________________________________________ */
38#define G_BITPIX 64 //!< Defines the number of bits per pixel
39
40/* __ Coding definitions _________________________________________________ */
41
42/* __ Debug definitions __________________________________________________ */
43
44
45
46/*==========================================================================
47 = =
48 = Constructors/destructors =
49 = =
50 ==========================================================================*/
51
52/***********************************************************************//**
53 * @brief Void constructor
54 ***************************************************************************/
56{
57 // Initialise class members
59
60 // Return
61 return;
62}
63
64
65/***********************************************************************//**
66 * @brief 1D image constructor
67 *
68 * @param[in] nx Number of pixels.
69 * @param[in] pixels Optional pointer to image pixel array
70 *
71 * Construct 1D instance by specifying the number of pixels in the image.
72 ***************************************************************************/
73GFitsImageLongLong::GFitsImageLongLong(const int& nx, const long long* pixels) :
75{
76 // Initialise class members
78
79 // Construct data
81
82 // Return
83 return;
84}
85
86
87/***********************************************************************//**
88 * @brief 2D image constructor
89 *
90 * @param[in] nx Number of pixels in first dimension.
91 * @param[in] ny Number of pixels in second dimension.
92 * @param[in] pixels Optional pointer to image pixel array
93 *
94 * Construct 2D image by specifying the number of pixels in each dimension.
95 ***************************************************************************/
96GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny,
97 const long long* pixels) :
98 GFitsImage(G_BITPIX, nx, ny)
99{
100 // Initialise class members
101 init_members();
102
103 // Construct data
105
106 // Return
107 return;
108}
109
110
111/***********************************************************************//**
112 * @brief 3D image constructor
113 *
114 * @param[in] nx Number of pixels in first dimension.
115 * @param[in] ny Number of pixels in second dimension.
116 * @param[in] nz Number of pixels in third dimension.
117 * @param[in] pixels Optional pointer to image pixel array
118 *
119 * Construct 3D image by specifying the number of pixels in each dimension.
120 ***************************************************************************/
121GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny,
122 const int& nz,
123 const long long* pixels) :
124 GFitsImage(G_BITPIX, nx, ny, nz)
125{
126 // Initialise class members
127 init_members();
128
129 // Construct data
131
132 // Return
133 return;
134}
135
136
137/***********************************************************************//**
138 * @brief 4D image constructor
139 *
140 * @param[in] nx Number of pixels in first dimension.
141 * @param[in] ny Number of pixels in second dimension.
142 * @param[in] nz Number of pixels in third dimension.
143 * @param[in] nt Number of pixels in forth dimension.
144 * @param[in] pixels Optional pointer to image pixel array
145 *
146 * Construct 4D image by specifying the number of pixels in each dimension.
147 ***************************************************************************/
148GFitsImageLongLong::GFitsImageLongLong(const int& nx, const int& ny,
149 const int& nz, const int& nt,
150 const long long* pixels) :
151 GFitsImage(G_BITPIX, nx, ny, nz, nt)
152{
153 // Initialise class members
154 init_members();
155
156 // Construct data
158
159 // Return
160 return;
161}
162
163
164/***********************************************************************//**
165 * @brief Pixel array constructor
166 *
167 * @param[in] naxes Vector of number of pixels in each dimension.
168 * @param[in] pixels Optional pointer to image pixel array
169 *
170 * Construct instance of GFitsImageLongLong by specifying the image dimension and
171 * the number of pixels in each dimension.
172 ***************************************************************************/
173GFitsImageLongLong::GFitsImageLongLong(const std::vector<int>& naxes,
174 const long long* pixels) :
175 GFitsImage(G_BITPIX, naxes)
176{
177 // Initialise class members
178 init_members();
179
180 // Construct data
182
183 // Return
184 return;
185}
186
187
188/***********************************************************************//**
189 * @brief Type conversion constructor
190 *
191 * @param[in] image FITS image.
192 *
193 * This constructor performs the conversion of any image type into a long
194 * long integer image.
195 ***************************************************************************/
197 GFitsImage(image)
198{
199 // Initialise class members
200 init_members();
201
202 // Copy pixels
203 if (m_num_pixels > 0) {
204 m_pixels = new long long[m_num_pixels];
205 for (int i = 0; i < m_num_pixels; ++i) {
206 m_pixels[i] = (long long)image.pixel(i);
207 }
208 }
209
210 // Set number of bits per pixel
212
213 // Update header card
214 card("BITPIX").value(G_BITPIX);
215
216 // Return
217 return;
218}
219
220
221/***********************************************************************//**
222 * @brief Copy constructor
223 *
224 * @param[in] image FITS image.
225 ***************************************************************************/
227 GFitsImage(image)
228{
229 // Initialise class members
230 init_members();
231
232 // Copy members
233 copy_members(image);
234
235 // Return
236 return;
237}
238
239
240/***********************************************************************//**
241 * @brief Destructor
242 ***************************************************************************/
244{
245 // Free members
246 free_members();
247
248 // Return
249 return;
250}
251
252
253/*==========================================================================
254 = =
255 = Operators =
256 = =
257 ==========================================================================*/
258
259/***********************************************************************//**
260 * @brief Assignment operator
261 *
262 * @param[in] image FITS image.
263 ***************************************************************************/
265{
266 // Execute only if object is not identical
267 if (this != &image) {
268
269 // Copy base class members
270 this->GFitsImage::operator=(image);
271
272 // Free members
273 free_members();
274
275 // Initialise private members
276 init_members();
277
278 // Copy members
279 copy_members(image);
280
281 } // endif: object was not identical
282
283 // Return this object
284 return *this;
285}
286
287
288/***********************************************************************//**
289 * @brief Image pixel access operator
290 *
291 * @param[in] ix Pixel index (starting from 0).
292 *
293 * Provides access to an image pixel. No range checking is performed.
294 * Use the at(ix) method if range checking is required.
295 ***************************************************************************/
296long long& GFitsImageLongLong::operator()(const int& ix)
297{
298 // Load data
299 load_data();
300
301 // Return image pixel
302 return m_pixels[ix];
303}
304
305
306/***********************************************************************//**
307 * @brief 2D image pixel access operator
308 *
309 * @param[in] ix Pixel index in first dimension (starting from 0).
310 * @param[in] iy Pixel index in second dimension (starting from 0).
311 *
312 * Provides access to a pixel of a 2D image. No range checking or image
313 * dimension verification is performed. Use the at(ix,iy) method if range
314 * checking and image dimension verification is required.
315 ***************************************************************************/
316long long& GFitsImageLongLong::operator()(const int& ix, const int& iy)
317{
318 // Load data
319 load_data();
320
321 // Calculate pixel offset
322 int offset = ix + iy * m_naxes[0];
323
324 // Return image pixel
325 return m_pixels[offset];
326}
327
328
329/***********************************************************************//**
330 * @brief 3D image pixel access operator
331 *
332 * @param[in] ix Pixel index in first dimension (starting from 0).
333 * @param[in] iy Pixel index in second dimension (starting from 0).
334 * @param[in] iz Pixel index in third dimension (starting from 0).
335 *
336 * Provides access to a pixel of a 3D image. No range checking or image
337 * dimension verification is performed. Use the at(ix,iy) method if range
338 * checking and image dimension verification is required.
339 ***************************************************************************/
340long long& GFitsImageLongLong::operator()(const int& ix, const int& iy,
341 const int& iz)
342{
343 // Load data
344 load_data();
345
346 // Calculate pixel offset
347 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
348
349 // Return image pixel
350 return m_pixels[offset];
351}
352
353
354/***********************************************************************//**
355 * @brief 4D image pixel access operator
356 *
357 * @param[in] ix Pixel index in first dimension (starting from 0).
358 * @param[in] iy Pixel index in second dimension (starting from 0).
359 * @param[in] iz Pixel index in third dimension (starting from 0).
360 * @param[in] it Pixel index in forth dimension (starting from 0).
361 *
362 * Provides access to a pixel of a 4D image. No range checking or image
363 * dimension verification is performed. Use the at(ix,iy) method if range
364 * checking and image dimension verification is required.
365 ***************************************************************************/
366long long& GFitsImageLongLong::operator()(const int& ix, const int& iy,
367 const int& iz, const int& it)
368{
369 // Load data
370 load_data();
371
372 // Calculate pixel offset
373 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
374
375 // Return image pixel
376 return m_pixels[offset];
377}
378
379
380/***********************************************************************//**
381 * @brief Image pixel access operator (const variant)
382 *
383 * @param[in] ix Pixel index (starting from 0).
384 *
385 * Provides access to an image pixel. No range checking is performed.
386 * Use the at(ix) method if range checking is required.
387 ***************************************************************************/
388const long long& GFitsImageLongLong::operator()(const int& ix) const
389{
390 // Load data
391 load_data();
392
393 // Return image pixel
394 return m_pixels[ix];
395}
396
397
398/***********************************************************************//**
399 * @brief 2D image pixel access operator (const variant)
400 *
401 * @param[in] ix Pixel index in first dimension (starting from 0).
402 * @param[in] iy Pixel index in second dimension (starting from 0).
403 *
404 * Provides access to a pixel of a 2D image. No range checking or image
405 * dimension verification is performed. Use the at(ix,iy) method if range
406 * checking and image dimension verification is required.
407 ***************************************************************************/
408const long long& GFitsImageLongLong::operator()(const int& ix, const int& iy) const
409{
410 // Load data
411 load_data();
412
413 // Calculate pixel offset
414 int offset = ix + iy * m_naxes[0];
415
416 // Return image pixel
417 return m_pixels[offset];
418}
419
420
421/***********************************************************************//**
422 * @brief 3D image pixel access operator (const variant)
423 *
424 * @param[in] ix Pixel index in first dimension (starting from 0).
425 * @param[in] iy Pixel index in second dimension (starting from 0).
426 * @param[in] iz Pixel index in third dimension (starting from 0).
427 *
428 * Provides access to a pixel of a 3D image. No range checking or image
429 * dimension verification is performed. Use the at(ix,iy) method if range
430 * checking and image dimension verification is required.
431 ***************************************************************************/
432const long long& GFitsImageLongLong::operator()(const int& ix, const int& iy,
433 const int& iz) const
434{
435 // Load data
436 load_data();
437
438 // Calculate pixel offset
439 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
440
441 // Return image pixel
442 return m_pixels[offset];
443}
444
445
446/***********************************************************************//**
447 * @brief 4D image pixel access operator (const variant)
448 *
449 * @param[in] ix Pixel index in first dimension (starting from 0).
450 * @param[in] iy Pixel index in second dimension (starting from 0).
451 * @param[in] iz Pixel index in third dimension (starting from 0).
452 * @param[in] it Pixel index in forth dimension (starting from 0).
453 *
454 * Provides access to a pixel of a 4D image. No range checking or image
455 * dimension verification is performed. Use the at(ix,iy) method if range
456 * checking and image dimension verification is required.
457 ***************************************************************************/
458const long long& GFitsImageLongLong::operator()(const int& ix, const int& iy,
459 const int& iz, const int& it) const
460{
461 // Load data
462 load_data();
463
464 // Calculate pixel offset
465 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
466
467 // Return image pixel
468 return m_pixels[offset];
469}
470
471
472/*==========================================================================
473 = =
474 = Public methods =
475 = =
476 ==========================================================================*/
477
478/***********************************************************************//**
479 * @brief Clear instance
480 *
481 * This method properly resets the object to an initial state.
482 ***************************************************************************/
484{
485 // Free class members (base and derived classes, derived class first)
486 free_members();
489
490 // Initialise members
493 init_members();
494
495 // Return
496 return;
497}
498
499
500/***********************************************************************//**
501 * @brief Clone FITS image
502 *
503 * Cloning provides a copy of the FITS file. Cloning is used to allocate
504 * derived classes into a base class pointer.
505 ***************************************************************************/
507{
508 // Clone this image
509 return new GFitsImageLongLong(*this);
510}
511
512
513/***********************************************************************//**
514 * @brief Image pixel access operator
515 *
516 * @param[in] ix Pixel index (starting from 0).
517 *
518 * Provides access to a pixel of an image including range checking. Note that
519 * this method does not necessarily restrict do 1D images but generally
520 * applies to all image dimensions.
521 ***************************************************************************/
522long long& GFitsImageLongLong::at(const int& ix)
523{
524 // Load data
525 load_data();
526
527 // Return image pixel
528 return (m_pixels[offset(ix)]);
529}
530
531
532/***********************************************************************//**
533 * @brief 2D image pixel access operator
534 *
535 * @param[in] ix Pixel index in first dimension (starting from 0).
536 * @param[in] iy Pixel index in second dimension (starting from 0).
537 *
538 * Provides access to a pixel of an image including range checking.
539 ***************************************************************************/
540long long& GFitsImageLongLong::at(const int& ix, const int& iy)
541{
542 // Load data
543 load_data();
544
545 // Return image pixel
546 return (m_pixels[offset(ix,iy)]);
547}
548
549
550/***********************************************************************//**
551 * @brief 3D image pixel access operator
552 *
553 * @param[in] ix Pixel index in first dimension (starting from 0).
554 * @param[in] iy Pixel index in second dimension (starting from 0).
555 * @param[in] iz Pixel index in third dimension (starting from 0).
556 *
557 * Provides access to a pixel of an image including range checking.
558 ***************************************************************************/
559long long& GFitsImageLongLong::at(const int& ix, const int& iy, const int& iz)
560{
561 // Load data
562 load_data();
563
564 // Return image pixel
565 return (m_pixels[offset(ix,iy,iz)]);
566}
567
568
569/***********************************************************************//**
570 * @brief 4D image pixel access operator
571 *
572 * @param[in] ix Pixel index in first dimension (starting from 0).
573 * @param[in] iy Pixel index in second dimension (starting from 0).
574 * @param[in] iz Pixel index in third dimension (starting from 0).
575 * @param[in] it Pixel index in forth dimension (starting from 0).
576 *
577 * Provides access to a pixel of an image including range checking.
578 ***************************************************************************/
579long long& GFitsImageLongLong::at(const int& ix, const int& iy, const int& iz,
580 const int& it)
581{
582 // Load data
583 load_data();
584
585 // Return image pixel
586 return (m_pixels[offset(ix,iy,iz,it)]);
587}
588
589
590/***********************************************************************//**
591 * @brief Image pixel access operator (const variant)
592 *
593 * @param[in] ix Pixel index (starting from 0).
594 *
595 * Provides access to a pixel of an image including range checking.
596 ***************************************************************************/
597const long long& GFitsImageLongLong::at(const int& ix) const
598{
599 // Load data
600 load_data();
601
602 // Return image pixel
603 return (m_pixels[offset(ix)]);
604}
605
606
607/***********************************************************************//**
608 * @brief 2D image pixel access operator (const variant)
609 *
610 * @param[in] ix Pixel index in first dimension (starting from 0).
611 * @param[in] iy Pixel index in second dimension (starting from 0).
612 *
613 * Provides access to a pixel of an image including range checking.
614 ***************************************************************************/
615const long long& GFitsImageLongLong::at(const int& ix, const int& iy) const
616{
617 // Load data
618 load_data();
619
620 // Return image pixel
621 return (m_pixels[offset(ix,iy)]);
622}
623
624
625/***********************************************************************//**
626 * @brief 3D image pixel access operator (const variant)
627 *
628 * @param[in] ix Pixel index in first dimension (starting from 0).
629 * @param[in] iy Pixel index in second dimension (starting from 0).
630 * @param[in] iz Pixel index in third dimension (starting from 0).
631 *
632 * Provides access to a pixel of an image including range checking.
633 ***************************************************************************/
634const long long& GFitsImageLongLong::at(const int& ix, const int& iy,
635 const int& iz) const
636{
637 // Load data
638 load_data();
639
640 // Return image pixel
641 return (m_pixels[offset(ix,iy,iz)]);
642}
643
644
645/***********************************************************************//**
646 * @brief 4D image pixel access operator (const variant)
647 *
648 * @param[in] ix Pixel index in first dimension (starting from 0).
649 * @param[in] iy Pixel index in second dimension (starting from 0).
650 * @param[in] iz Pixel index in third dimension (starting from 0).
651 * @param[in] it Pixel index in forth dimension (starting from 0).
652 *
653 * Provides access to a pixel of an image including range checking.
654 ***************************************************************************/
655const long long& GFitsImageLongLong::at(const int& ix, const int& iy,
656 const int& iz, const int& it) const
657{
658 // Load data
659 load_data();
660
661 // Return image pixel
662 return (m_pixels[offset(ix,iy,iz,it)]);
663}
664
665
666/***********************************************************************//**
667 * @brief Return value of image pixel
668 *
669 * @param[in] ix Pixel index (starting from 0).
670 *
671 * Returns the value of an image pixel as double precision floating point
672 * value. This method performs range checking.
673 ***************************************************************************/
674double GFitsImageLongLong::pixel(const int& ix) const
675{
676 // Return pixel value
677 return (double(this->at(ix)));
678}
679
680
681/***********************************************************************//**
682 * @brief Return value of image pixel (2D version)
683 *
684 * @param[in] ix Pixel index in first dimension (starting from 0).
685 * @param[in] iy Pixel index in second dimension (starting from 0).
686 *
687 * Returns the value of an image pixel as double precision floating point
688 * value. This method performs range checking.
689 ***************************************************************************/
690double GFitsImageLongLong::pixel(const int& ix, const int& iy) const
691{
692 // Return pixel value
693 return (double(this->at(ix,iy)));
694}
695
696
697/***********************************************************************//**
698 * @brief Return value of image pixel (3D version)
699 *
700 * @param[in] ix Pixel index in first dimension (starting from 0).
701 * @param[in] iy Pixel index in second dimension (starting from 0).
702 * @param[in] iz Pixel index in third dimension (starting from 0).
703 *
704 * Returns the value of an image pixel as double precision floating point
705 * value. This method performs range checking.
706 ***************************************************************************/
707double GFitsImageLongLong::pixel(const int& ix, const int& iy, const int& iz) const
708{
709 // Return pixel value
710 return (double(this->at(ix,iy,iz)));
711}
712
713
714/***********************************************************************//**
715 * @brief Return value of image pixel (4D version)
716 *
717 * @param[in] ix Pixel index in first dimension (starting from 0).
718 * @param[in] iy Pixel index in second dimension (starting from 0).
719 * @param[in] iz Pixel index in third dimension (starting from 0).
720 * @param[in] it Pixel index in forth dimension (starting from 0).
721 *
722 * Returns the value of an image pixel as double precision floating point
723 * value. This method performs range checking.
724 ***************************************************************************/
725double GFitsImageLongLong::pixel(const int& ix, const int& iy, const int& iz,
726 const int& it) const
727{
728 // Return pixel value
729 return (double(this->at(ix,iy,iz,it)));
730}
731
732
733/***********************************************************************//**
734 * @brief Return pointer to image pixel
735 ***************************************************************************/
737{
738 // Load data
739 load_data();
740
741 // Return
742 return m_pixels;
743}
744
745
746/***********************************************************************//**
747 * @brief Return image type
748 ***************************************************************************/
750{
751 // Return type
752 return __TLONGLONG;
753}
754
755
756/*==========================================================================
757 = =
758 = Private methods =
759 = =
760 ==========================================================================*/
761
762/***********************************************************************//**
763 * @brief Initialise class members
764 ***************************************************************************/
766{
767 // Initialise members
769 m_pixels = NULL;
770 m_nulval = NULL;
771
772 // Return
773 return;
774}
775
776
777/***********************************************************************//**
778 * @brief Copy class members
779 *
780 * @param image FITS image to copy
781 *
782 * Copy class members. If the pixel array is linked the pointer to the array
783 * is copied. Otherwise a copy of the image pixels will be created.
784 ***************************************************************************/
786{
787 // Fetch column data if not yet fetched. The casting circumvents the
788 // const correctness
789 bool not_loaded = (image.m_pixels == NULL);
790 if (not_loaded) {
791 const_cast<GFitsImageLongLong*>(&image)->fetch_data();
792 }
793
794 // Copy pixels
795 if (m_num_pixels > 0 && image.m_pixels != NULL) {
796 m_pixels = new long long[m_num_pixels];
797 for (int i = 0; i < m_num_pixels; ++i) {
798 m_pixels[i] = image.m_pixels[i];
799 }
800 }
801
802 // Copy NULL value
803 alloc_nulval(image.m_nulval);
804
805 // Small memory option: release column if it was fetch above
806 #if defined(G_SMALL_MEMORY)
807 if (not_loaded) {
808 const_cast<GFitsImageLongLong*>(&image)->release_data();
809 }
810 #endif
811
812 // Return
813 return;
814}
815
816
817/***********************************************************************//**
818 * @brief Delete class members
819 ***************************************************************************/
821{
822 // Free memory
823 if (m_pixels != NULL) delete [] m_pixels;
824 if (m_nulval != NULL) delete m_nulval;
825
826 // Mark memory as free
827 m_pixels = NULL;
828 m_nulval = NULL;
829
830 // Return
831 return;
832}
833
834
835/***********************************************************************//**
836 * @brief Allocate data
837 ***************************************************************************/
839{
840 // Release any existing data
841 release_data();
842
843 // Allocate new data
844 if (m_num_pixels > 0) {
845 m_pixels = new long long[m_num_pixels];
846 }
847
848 // Return
849 return;
850}
851
852
853/***********************************************************************//**
854 * @brief Initialise data
855 ***************************************************************************/
857{
858 // Initialise data if they exist
859 if (m_pixels != NULL) {
860 for (int i = 0; i < m_num_pixels; ++i) {
861 m_pixels[i] = 0;
862 }
863 }
864
865 // Return
866 return;
867}
868
869
870/***********************************************************************//**
871 * @brief Release data
872 ***************************************************************************/
874{
875 // Free any existing memory
876 if (m_pixels != NULL) delete [] m_pixels;
877
878 // Mark pointer as free
879 m_pixels = NULL;
880
881 // Return
882 return;
883}
884
885
886/***********************************************************************//**
887 * @brief Construct data from array
888 *
889 * @param[in] pixels Optional pointer to pixel array.
890 *
891 * Initialise pixel data from an optional pixel array. If the pointer is
892 * NULL the image is simply initialised. This method supports all
893 * constructors.
894 ***************************************************************************/
895void GFitsImageLongLong::construct_data(const long long* pixels)
896{
897 // If there are pixels then allocate array
898 if (m_num_pixels > 0) {
899
900 // Allocate data
901 alloc_data();
902
903 // If no pixel array has been specified then simply initialise data
904 if (pixels == NULL) {
905 init_data();
906 }
907
908 // ... otherwise copy pixels
909 else {
910 for (int i = 0; i < m_num_pixels; ++i) {
911 m_pixels[i] = pixels[i];
912 }
913 }
914
915 } // endif: there are pixels in image
916
917 // Return
918 return;
919}
920
921
922/***********************************************************************//**
923 * @brief Load data
924 *
925 * Load the image data if no pixels have been allocated.
926 ***************************************************************************/
928{
929 // If image pixels are not available then fetch them now.
930 if (m_pixels == NULL) {
931 const_cast<GFitsImageLongLong*>(this)->fetch_data();
932 }
933
934 // Return
935 return;
936}
937
938
939/***********************************************************************//**
940 * @brief Allocates nul value
941 *
942 * @param[in] value Nul value.
943 ***************************************************************************/
944void GFitsImageLongLong::alloc_nulval(const void* value)
945{
946 // Free any existing memory
947 if (m_nulval != NULL) delete m_nulval;
948
949 // Mark pointer as free
950 m_nulval = NULL;
951
952 // If we have valid value, allocate and set nul value
953 if (value != NULL) {
954 m_nulval = new long long;
955 *m_nulval = *((long long*)value);
956 }
957
958 // Return
959 return;
960}
Exception handler interface definition.
CFITSIO interface header.
#define __TLONGLONG
#define G_BITPIX
Defines the number of bits per pixel.
#define G_BITPIX
Defines the number of bits per pixel.
Long long integer FITS image class definition.
void free_members(void)
Delete class members.
Definition GFitsHDU.cpp:505
void init_members(void)
Initialise class members.
Definition GFitsHDU.cpp:462
GFitsHeaderCard & card(const int &cardno)
Return header card.
Definition GFitsHDU.hpp:259
void value(const std::string &value)
Set string value of header card.
Long long integer FITS image class.
long long * m_nulval
NULL value.
long long & operator()(const int &ix)
Image pixel access operator.
long long * m_pixels
Pixels.
void alloc_data(void)
Allocate data.
void alloc_nulval(const void *value)
Allocates nul value.
void construct_data(const long long *pixels)
Construct data from array.
void free_members(void)
Delete class members.
int type(void) const
Return image type.
long long & at(const int &ix)
Image pixel access operator.
void clear(void)
Clear instance.
virtual ~GFitsImageLongLong(void)
Destructor.
void init_members(void)
Initialise class members.
GFitsImageLongLong(void)
Void constructor.
double pixel(const int &ix) const
Return value of image pixel.
void load_data(void) const
Load data.
GFitsImageLongLong * clone(void) const
Clone FITS image.
void copy_members(const GFitsImageLongLong &image)
Copy class members.
GFitsImageLongLong & operator=(const GFitsImageLongLong &image)
Assignment operator.
void * pixels(void)
Return pointer to image pixel.
void release_data(void)
Release data.
void init_data(void)
Initialise data.
Abstract FITS image base class.
virtual double pixel(const int &ix) const =0
int offset(const int &ix) const
Return pixel offset.
void free_members(void)
Delete class members.
void fetch_data(void)
Fetch image pixels.
long * m_naxes
Number of pixels in each dimension.
int m_bitpix
Number of Bits/pixel.
int m_num_pixels
Number of image pixels.
GFitsImage & operator=(const GFitsImage &image)
Assignment operator.
void init_members(void)
Initialise class members.