VR-Forces 4.1.1 Class Documentation
ReaderWriterTXP.h
Go to the documentation of this file.
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 
40 
41 #include <osg/Object>
42 #include <osg/Node>
43 #include <osgDB/Registry>
44 #include <osgDB/FileNameUtils>
45 #include <osg/Referenced>
46 #include <map>
48 
49 #include <OpenThreads/ScopedLock>
50 #include <OpenThreads/ReentrantMutex>
51 
52 #include "TXPArchive.h"
53 
54 namespace txp
55 {
56 class DT_DLL_osgdb_vrftxt ReaderWriterTXP : public osgDB::ReaderWriter
57 {
58 public:
59 
61  {
62  supportsExtension("txp","Terrapage txp format");
63  }
64 
65  virtual const char* className() const
66  {
67  return "TXP Reader/Writer";
68  }
69 
70  virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
71  {
72  if( !acceptsExtension(osgDB::getFileExtension(file) ))
73  return ReadResult::FILE_NOT_HANDLED;
74 
75  OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
76 
77  return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options);
78  }
79 
80  bool removeArchive( int id );
81 
82 protected:
83 
84 
85  ReadResult local_readNode(const std::string& file, const osgDB::ReaderWriter::Options* options);
86 
87  std::string getArchiveName(const std::string& dir);
88  osg::ref_ptr< TXPArchive > createArchive(int id, const std::string& dir);
89  osg::ref_ptr< TXPArchive > getArchive(int id, const std::string&);
90 
91  osg::Node* getTileContent(const TXPArchive::TileInfo &info, int x, int y, int lod, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
92  osg::Node* getTileContent(const TXPArchive::TileInfo &info, const TXPArchive::TileLocationInfo& loc, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
93  void createChildrenLocationString(const std::vector<TXPArchive::TileLocationInfo>& locs, std::string& locString) const;
94  bool extractChildrenLocations(const std::string& name, int parentLod, std::vector<TXPArchive::TileLocationInfo>& locs, int nbChild) const;
95 
96  mutable OpenThreads::ReentrantMutex _serializerMutex;
97 
98  std::map< int,osg::ref_ptr<TXPArchive> > _archives;
99  static int _archiveId;
100 };
101 
102 }
103 
104 #endif

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)