imagedatadisk.h 3.25 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
#ifndef IMAGEDATADISK_H__
#define IMAGEDATADISK_H__
schultezub's avatar
schultezub committed
3
4

#include "tgt/vector.h"
schultezub's avatar
schultezub committed
5
6
7
8
9
10
#include "core/datastructures/imagedata.h"

#include "core/tools/endianhelper.h"
#include "core/tools/typetraits.h"
#include "core/tools/weaklytypedpointer.h"

schultezub's avatar
schultezub committed
11
12
13
14
15
16
17
18
#include <fstream>
#include <string>

namespace TUMVis {

    /**
     * Subclass of ImageData offering access to image data stored in binary form on the local harddisk.
     * 
schultezub's avatar
schultezub committed
19
     * \todo    Number of channels
schultezub's avatar
schultezub committed
20
21
22
23
24
25
26
27
28
     */
    class ImageDataDisk : public ImageData {
    public:
        /**
         * Creates a new ImageData disk representation.
         *
         * \param url               Path to file with raw data
         * \param dimensionality    Dimensionality of data
         * \param size              Size of this image (number of elements per dimension)
schultezub's avatar
schultezub committed
29
         * \param type              Base type of data
schultezub's avatar
schultezub committed
30
31
32
33
34
35
         * \param offset            Offset of first data element in file (in bytes)
         * \param endianness        Endianess of data
         * \param stride            Number of _elemments_ _between_ adjacent elements for each dimension (\see ImageDataDisk::_stride).
         */
        ImageDataDisk(
            const std::string& url,
36
            size_t dimensionality,
schultezub's avatar
schultezub committed
37
            const tgt::svec3& size,
38
39
            WeaklyTypedPointer::BaseType type,
            size_t numChannels,
schultezub's avatar
schultezub committed
40
41
            size_t offset = 0,
            EndianHelper::Endianness endianness = EndianHelper::LITTLE_ENDIAN,
schultezub's avatar
schultezub committed
42
            const tgt::svec3& stride = tgt::svec3::zero
schultezub's avatar
schultezub committed
43
44
45
46
47
            );

        /**
         * Destructor
         */
schultezub's avatar
schultezub committed
48
49
50
51
52
53
        virtual ~ImageDataDisk();


        /**
         * \see AbstractData::clone()
         **/
schultezub's avatar
schultezub committed
54
        virtual ImageDataDisk* clone() const;
schultezub's avatar
schultezub committed
55
56
57
58

        /**
         * \see ImageData::getSubImage
         */
schultezub's avatar
schultezub committed
59
        virtual ImageDataDisk* getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const;
schultezub's avatar
schultezub committed
60
61
62
63
64
65


        /**
         * Downloads the whole image data to local memory.
         * \return  Pointer to the image data in the local memory.
         */
schultezub's avatar
schultezub committed
66
        WeaklyTypedPointer getImageData() const;
schultezub's avatar
schultezub committed
67
68
69
70
71
72
73
74
75
76
77

    private:
        /**
         * Calculates the canonical stride for the given image size.
         * \param size  Image size (number of elements per dimension).
         * \return      (0, size.x, size.x * size.y)
         */
        tgt::svec3 getCanonicStride(const tgt::svec3& size) const;

        std::string _url;                       ///< path to file with raw data
        size_t _offset;                         ///< offset of first data element in file (in bytes)
78
79
        WeaklyTypedPointer::BaseType _type;     ///< base type of data
        size_t _numChannels;                    ///< number of channels per element
schultezub's avatar
schultezub committed
80
81
82
83
84
85
86
87
88
        EndianHelper::Endianness _endianess;    ///< endianess of data
        
        /**
         * Number of _elemments_ _between_ adjacent elements for each dimension.
         * If the stride is 0 for a dimension, the elements are assumed to be tightly packed, hence for
         * the x-dimension 0, for the y-dimension _size.x and for the z-dimension (_size.x * _size.y).
         **/
        tgt::svec3 _stride;

schultezub's avatar
schultezub committed
89
        static const std::string loggerCat_;
schultezub's avatar
schultezub committed
90
91
92
93
    };

}

schultezub's avatar
schultezub committed
94
#endif // IMAGEDATADISK_H__