VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
39 #include <osg/Object>
40 #include <osg/Node>
41 #include <osgDB/Registry>
42 #include <osgDB/FileNameUtils>
43 #include <osg/Referenced>
44 #include <map>
46 
47 #include <OpenThreads/ScopedLock>
48 #include <OpenThreads/ReentrantMutex>
49 
50 #include "TXPArchive.h"
51 
52 namespace txp
53 {
54 class DT_DLL_osgdb_vrftxp ReaderWriterTXP : public osgDB::ReaderWriter
55 {
56 public:
57 
59  {
60  supportsExtension("txp","Terrapage txp format");
61  }
62 
63  virtual const char* className() const
64  {
65  return "TXP Reader/Writer";
66  }
67 
68  virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
69  {
70  if( !acceptsExtension(osgDB::getFileExtension(file) ))
71  return ReadResult::FILE_NOT_HANDLED;
72 
73  OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
74 
75  return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options);
76  }
77 
78  bool removeArchive( int id );
79 
80 protected:
81 
82 
83  ReadResult local_readNode(const std::string& file, const osgDB::ReaderWriter::Options* options);
84 
85  std::string getArchiveName(const std::string& dir);
86  osg::ref_ptr< TXPArchive > createArchive(int id, const std::string& dir);
87  osg::ref_ptr< TXPArchive > getArchive(int id, const std::string&);
88 
89  osg::Node* getTileContent(const TXPArchive::TileInfo &info, int x, int y, int lod, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
90  osg::Node* getTileContent(const TXPArchive::TileInfo &info, const TXPArchive::TileLocationInfo& loc, TXPArchive* archive, std::vector<TXPArchive::TileLocationInfo>& childrenLoc);
91  void createChildrenLocationString(const std::vector<TXPArchive::TileLocationInfo>& locs, std::string& locString) const;
92  bool extractChildrenLocations(const std::string& name, int parentLod, std::vector<TXPArchive::TileLocationInfo>& locs, int nbChild) const;
93 
94  mutable OpenThreads::ReentrantMutex _serializerMutex;
95 
96  std::map< int,osg::ref_ptr<TXPArchive> > _archives;
97  static int _archiveId;
98 };
99 
100 }
101 
102 #endif
Definition: TXPArchive.h:65
ReaderWriterTXP()
Definition: readerWriterTXP.h:58
Definition: readerWriterTXP.h:54
#define DT_DLL_osgdb_vrftxp
Contains DLL export macros.
Definition: osgdb_vrftxpDefines.h:25
virtual ReadResult readNode(const std::string &file, const osgDB::ReaderWriter::Options *options) const
Definition: readerWriterTXP.h:68
Definition: featureContext.h:37
Gets some informations for a given tile.
Definition: TXPArchive.h:111
std::map< int, osg::ref_ptr< TXPArchive > > _archives
Definition: readerWriterTXP.h:96
virtual const char * className() const
Definition: readerWriterTXP.h:63
OpenThreads::ReentrantMutex _serializerMutex
Definition: readerWriterTXP.h:94
Definition: TXPArchive.h:121
static int _archiveId
Definition: readerWriterTXP.h:97

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)