| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #ifndef IMAGEREADERWRITER_H |
|---|
| 14 | #define IMAGEREADERWRITER_H |
|---|
| 15 | |
|---|
| 16 | #include <osgDB/ReadFile> |
|---|
| 17 | #include <osgDB/WriteFile> |
|---|
| 18 | #include <osgDB/ImageOptions> |
|---|
| 19 | |
|---|
| 20 | #include <OpenThreads/ScopedLock> |
|---|
| 21 | #include <OpenThreads/ReentrantMutex> |
|---|
| 22 | |
|---|
| 23 | #include "PhotoArchive.h" |
|---|
| 24 | |
|---|
| 25 | #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex) |
|---|
| 26 | |
|---|
| 27 | class ImageReaderWriter : public osgDB::ReaderWriter |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | |
|---|
| 31 | ImageReaderWriter(); |
|---|
| 32 | |
|---|
| 33 | virtual const char* className() const { return "ImageReader"; } |
|---|
| 34 | |
|---|
| 35 | void addPhotoArchive(PhotoArchive* archive) { _photoArchiveList.push_back(archive); } |
|---|
| 36 | |
|---|
| 37 | std::string insertReference(const std::string& fileName, unsigned int res, float width, float height, bool backPage) |
|---|
| 38 | { |
|---|
| 39 | SERIALIZER(); |
|---|
| 40 | return const_cast<ImageReaderWriter*>(this)->local_insertReference(fileName, res, width, height, backPage); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | virtual ReadResult readNode(const std::string& fileName, const Options* options) const |
|---|
| 44 | { |
|---|
| 45 | SERIALIZER(); |
|---|
| 46 | return const_cast<ImageReaderWriter*>(this)->local_readNode(fileName, options); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | protected: |
|---|
| 51 | |
|---|
| 52 | std::string local_insertReference(const std::string& fileName, unsigned int res, float width, float height, bool backPage); |
|---|
| 53 | |
|---|
| 54 | ReadResult local_readNode(const std::string& fileName, const Options*); |
|---|
| 55 | |
|---|
| 56 | mutable OpenThreads::ReentrantMutex _serializerMutex; |
|---|
| 57 | |
|---|
| 58 | struct DataReference |
|---|
| 59 | { |
|---|
| 60 | DataReference(); |
|---|
| 61 | DataReference(const std::string& fileName, unsigned int res, float width, float height,bool backPage); |
|---|
| 62 | DataReference(const DataReference& rhs); |
|---|
| 63 | |
|---|
| 64 | std::string _fileName; |
|---|
| 65 | unsigned int _resolutionX; |
|---|
| 66 | unsigned int _resolutionY; |
|---|
| 67 | osg::Vec3 _center; |
|---|
| 68 | osg::Vec3 _maximumWidth; |
|---|
| 69 | osg::Vec3 _maximumHeight; |
|---|
| 70 | unsigned int _numPointsAcross; |
|---|
| 71 | unsigned int _numPointsUp; |
|---|
| 72 | bool _backPage; |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | osg::Image* readImage_Archive(DataReference& dr, float& s,float& t); |
|---|
| 76 | |
|---|
| 77 | osg::Image* readImage_DynamicSampling(DataReference& dr, float& s,float& t); |
|---|
| 78 | |
|---|
| 79 | typedef std::map< std::string,DataReference > DataReferenceMap; |
|---|
| 80 | typedef std::vector< osg::ref_ptr<PhotoArchive> > PhotoArchiveList; |
|---|
| 81 | |
|---|
| 82 | DataReferenceMap _dataReferences; |
|---|
| 83 | PhotoArchiveList _photoArchiveList; |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | #endif |
|---|