SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
vsifile.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include <memory>
6#include <string>
7#include <vector>
8#include <boost/json.hpp>
9#include "vsitools.hpp"
10#include "slideio/drivers/vsi/vsi_api_def.hpp"
11#include "slideio/imagetools/tifftools.hpp"
12#include "slideio/drivers/vsi/volume.hpp"
13#include "slideio/drivers/vsi/taginfo.hpp"
14
15#if defined(_MSC_VER)
16#pragma warning( push )
17#pragma warning(disable: 4251)
18#endif
19
20
21namespace slideio
22{
23 namespace vsi
24 {
25 class VSIStream;
26 class EtsFile;
27
28 class SLIDEIO_VSI_EXPORTS VSIFile
29 {
30 public:
31 VSIFile(const std::string& filePath);
32 std::shared_ptr<vsi::EtsFile> getEtsFile(int index) const {
33 return m_etsFiles[index];
34 }
35 int getNumEtsFiles() const {
36 return static_cast<int>(m_etsFiles.size());
37 }
38 std::string getRawMetadata() const;
39 void assignAuxVolumes();
40
41 int getNumTiffDirectories() const {
42 return static_cast<int>(m_directories.size());
43 }
44 const TiffDirectory& getTiffDirectory(int index) {
45 return m_directories[index];
46 }
47 int getNumVolumes() const {
48 return static_cast<int>(m_volumes.size());
49 }
50 std::shared_ptr<Volume> getVolume(int index) const {
51 return m_volumes[index];
52 }
53 bool hasMetadata() const {
54 return !m_metadata.empty();
55 }
56 bool expectExternalFiles() const {
57 return m_expectExternalFiles;
58 }
59 bool hasExternalFiles() const {
60 return !m_etsFiles.empty();
61 }
62 void getVolumeMetadataItems(std::list<const TagInfo*>& volumes) const;
63 static void getImageFrameMetadataItems(const TagInfo* volume, std::list<const TagInfo*>& frames);
64
65 private:
66 void read();
67 void checkExternalFilePresence();
68 static StackType getVolumeStackType(const TagInfo* volume);
69 void extractVolumesFromMetadata();
70 bool readVolumeHeader(vsi::VSIStream& vsi, vsi::VolumeHeader& volumeHeader);
71 bool readMetadata(VSIStream& vsiStream, std::list<TagInfo>& path);
72 void serializeMetadata(const TagInfo& tagInfo, boost::json::object& jsonObj) const;
73 void readVolumeInfo();
74 void readExternalFiles();
75 void readExtendedType(vsi::VSIStream& vsi, TagInfo& tag, std::list<TagInfo>& path);
76 private:
77 std::vector<std::shared_ptr<vsi::EtsFile>> m_etsFiles;
78 bool m_expectExternalFiles = false;
79 int m_numChannels = 0;
80 int m_numSlices = 0;
81 std::string m_filePath;
82 TagInfo m_metadata;
83 std::vector<TiffDirectory> m_directories;
84 std::vector<std::shared_ptr<Volume>> m_volumes;
85 };
86 }
87}
88
Definition: exceptions.hpp:12