VR-Forces Developer's Guide
 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 override {
64  return "TXP Reader/Writer";
65  }
66 
67  virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const override
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 
79 protected:
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 }
100 
101 #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
Definition: featureContext.h:36
Gets some informations for a given tile.
Definition: TXPArchive.h:111
virtual ReadResult readNode(const std::string &file, const osgDB::ReaderWriter::Options *options) const override
Definition: readerWriterTXP.h:67
std::map< int, osg::ref_ptr< TXPArchive > > _archives
Definition: readerWriterTXP.h:95
virtual const char * className() const override
Definition: readerWriterTXP.h:63
OpenThreads::ReentrantMutex _serializerMutex
Definition: readerWriterTXP.h:93
Definition: TXPArchive.h:121
static int _archiveId
Definition: readerWriterTXP.h:96

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)