root/OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.h @ 13041

Revision 13041, 3.6 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/***************************************************************************
2 * December 2003
3 *
4 * This TerraPage loader was re-written in a fashion to use PagedLOD
5 * to manage paging entirely, also includes a version of Terrex's smart mesh
6 * adapted to work with PagedLOD. The essential code by Boris Bralo is still present,
7 * slight modified.
8 * nick at terrex dot com
9 *
10 * Ported to PagedLOD technology by Trajce Nikolov (Nick) & Robert Osfield
11 *****************************************************************************/
12
13/***************************************************************************
14 * OpenSceneGraph loader for Terrapage format database
15 * by Boris Bralo 2002
16 *
17 * based on/modifed  sgl (Scene Graph Library) loader by Bryan Walsh
18 *
19 * This loader is based on/modified from Terrain Experts Performer Loader,
20 * and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net
21 *
22 * That loader is redistributed under the terms listed on Terrain Experts
23 * website (www.terrex.com/www/pages/technology/technologypage.htm)
24 *
25 * "TerraPage is provided as an Open Source format for use by anyone...
26 * We supply the TerraPage C++ source code free of charge.  Anyone
27 * can use it and redistribute it as needed (including our competitors).
28 * We do, however, ask that you keep the TERREX copyrights intact."
29 *
30 * Copyright Terrain Experts Inc. 1999.
31 * All Rights Reserved.
32 *
33 *****************************************************************************/
34#ifndef __READERWRITER_TXP_H_
35#define __READERWRITER_TXP_H_
36
37#include "trpage_sys.h"
38
39#include <osg/Object>
40#include <osg/Node>
41#include <osgDB/Registry>
42#include <osgDB/FileNameUtils>
43#include <osg/Referenced>
44#include <map>
45
46#include <OpenThreads/ScopedLock>
47#include <OpenThreads/ReentrantMutex>
48
49#include "TXPArchive.h"
50
51namespace txp
52{
53class ReaderWriterTXP : public osgDB::ReaderWriter
54{
55public:
56
57    ReaderWriterTXP()
58    {
59        supportsExtension("txp","Terrapage txp format");
60    }
61
62    virtual const char* className() const
63    {
64        return "TXP Reader/Writer";
65    }
66
67    virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
68    {
69        if( !acceptsExtension(osgDB::getFileExtension(file) ))
70            return ReadResult::FILE_NOT_HANDLED;
71
72        OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
73
74        return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options);
75    }
76
77    bool removeArchive( int id );
78
79protected:
80
81
82    ReadResult local_readNode(const std::string& file, const osgDB::ReaderWriter::Options* options);
83
84    std::string getArchiveName(const std::string& dir);
85    osg::ref_ptr< TXPArchive > createArchive(int id, const std::string& dir);
86    osg::ref_ptr< TXPArchive > getArchive(int id, const std::string&);
87
88    osg::Node* getTileContent(const TXPArchive::TileInfo &info, int x, int y, int lod, TXPArchive* archive,  std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
89    osg::Node* getTileContent(const TXPArchive::TileInfo &info, const TXPArchive::TileLocationInfo& loc, TXPArchive* archive,  std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
90    void createChildrenLocationString(const std::vector<TXPArchive::TileLocationInfo>& locs, std::string& locString) const;
91    bool extractChildrenLocations(const std::string& name, int parentLod, std::vector<TXPArchive::TileLocationInfo>& locs, int nbChild) const;
92
93    mutable OpenThreads::ReentrantMutex               _serializerMutex;
94
95    std::map< int,osg::ref_ptr<TXPArchive> >    _archives;
96    static int                                  _archiveId;
97};
98
99} // namespace
100
101#endif // __READERWRITER_TXP_H_
Note: See TracBrowser for help on using the browser.