SlideIO 2.9.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
svstiledscene.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
6#include "slideio/drivers/svs/svsscene.hpp"
7#include "slideio/imagetools/tifftools.hpp"
8#include "slideio/core/tools/tilecomposer.hpp"
9
10#if defined(_MSC_VER)
11#pragma warning( push )
12#pragma warning(disable: 4251)
13#endif
14
15namespace slideio
16{
17 class SLIDEIO_SVS_EXPORTS SVSTiledScene : public SVSScene, public Tiler
18 {
19 public:
20 // Constructs and initializes. A factory rather than a constructor call because
21 // initialize() reads the image description through a virtual method, and a
22 // virtual call made from a constructor does not reach a derived override.
23 static std::shared_ptr<SVSTiledScene> create(const std::string& filePath,
24 const std::string& driverId, const std::string& name,
25 const std::vector<slideio::TiffDirectory>& dirs);
26 static std::shared_ptr<SVSTiledScene> create(const std::string& filePath,
27 const std::string& driverId, libtiff::TIFF* hFile, const std::string& name,
28 const std::vector<slideio::TiffDirectory>& dirs);
29 int getNumChannels() const override;
30 cv::Rect getRect() const override;
31 void readResampledBlockChannelsEx(const cv::Rect& blockRect, const cv::Size& blockSize,
32 const std::vector<int>& channelIndices, int zSliceIndex, int tFrameIndex, cv::OutputArray output) override;
33 void readResampledLevelBlockChannelsEx(int level, const cv::Rect& levelRect,
34 const cv::Size& blockSize, const std::vector<int>& channelIndices,
35 int zSliceIndex, int tFrameIndex, cv::OutputArray output) override;
36 // Returns the index of the level serving a zoom, not the directory: the level index
37 // is what the level-addressed read path takes.
38 int findZoomLevelIndex(double zoom) const;
39 // Tiler methods
40 int getTileCount(void* userData) override;
41 bool getTileRect(int tileIndex, cv::Rect& tileRect, void* userData) override;
42 bool readTile(int tileIndex, const std::vector<int>& channelIndices, cv::OutputArray tileRaster,
43 void* userData) override;
44 protected:
45 // Protected rather than public: a caller constructing the scene directly, instead
46 // of through create(), would skip initialize() and silently get a scene with zero
47 // zoom levels and zero resolution. The factories are members, so they still reach
48 // these, and so does a derived class's own constructor.
49 SVSTiledScene(const std::string& filePath,
50 const std::string& driverId,
51 const std::string& name,
52 const std::vector<slideio::TiffDirectory>& dirs);
53 SVSTiledScene(const std::string& filePath,
54 const std::string& driverId,
55 libtiff::TIFF* hFile,
56 const std::string& name,
57 const std::vector<slideio::TiffDirectory>& dirs);
58 void initialize();
59 // Reads the format specific fields — resolution, magnification, raw metadata —
60 // out of the description of the base directory. Called by initialize().
61 virtual void processImageDescription();
62 void initializeBlock(const cv::Size& blockSize, const std::vector<int>& channelIndices, cv::OutputArray output) override;
63 std::vector<slideio::TiffDirectory> m_directories;
64 };
65}
66
67#if defined(_MSC_VER)
68#pragma warning( pop )
69#endif
Definition: exceptions.hpp:15